Files
swift-mirror/include/swift/Subsystems.h
Eli Friedman f477cf588e Introduce the notion of the "main" module, i.e. the module which defines main(). Disallow top-level statements in modules other than the main module. Fix IRGen to generate a main() function in the main module, and implement top-level statements. Get rid of the main() mangling hack. Part of <rdar://problem/11185451>.
I haven't really carefully considered whether existing type-checking etc. is correct for the main module (I think the name-binding rules need to be a bit different?), but it seems to work well enough for the obvious cases.

This is enough to get the one-liner "println(10)" to print "10" in "swift -i" mode, although the path to swift.swift still needs to be explicitly provided with -I.



Swift SVN r1325
2012-04-05 00:35:28 +00:00

69 lines
2.4 KiB
C++

//===--- Subsystems.h - Swift Compiler Subsystem Entrypoints ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file declares the main entrypoints to the various subsystems.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SUBSYSTEMS_H
#define SWIFT_SUBSYSTEMS_H
namespace llvm {
class Module;
}
namespace swift {
class TranslationUnit;
class ASTContext;
class Component;
namespace irgen {
class Options;
}
/// verify - Check that the translation unit is well formed (i.e. following
/// the invariants of the AST, not that the code written by the user makes
/// sense), aborting and spewing errors if not.
void verify(TranslationUnit *TUnit);
/// parseTranslationUnit - Parse a single buffer as a translation unit
/// in the given component and return the decl.
TranslationUnit *parseTranslationUnit(unsigned BufferID, Component *Comp,
ASTContext &Ctx, bool IsMainModule);
/// performNameBinding - Once parsing is complete, this walks the AST to
/// resolve names and do other top-level validation.
void performNameBinding(TranslationUnit *TU);
/// performTypeChecking - Once parsing and namebinding are complete, this
/// walks the AST to resolve types and diagnose problems therein.
///
void performTypeChecking(TranslationUnit *TU);
/// performCaptureAnalysis - Analyse the AST and mark local declarations
/// and expressions which can capture them so they can be emitted more
/// efficiently.
void performCaptureAnalysis(TranslationUnit *TU);
/// performIRGeneration - Turn the given translation unit into
/// either LLVM IR or native code.
void performIRGeneration(TranslationUnit *TU, irgen::Options &Opts);
/// performIRGenerationIntoModule - Alternate entry point for IR generation
/// for users which need the resulting module in memory.
void performIRGenerationIntoModule(TranslationUnit *TU, irgen::Options &Opts,
llvm::Module &Module);
} // end namespace swift
#endif