SILGen: Gen VarDecls as locals for toplevel code.

If the TranslationUnit being silgenned is a Main or Repl unit, generate globals like locals. Generating toplevel functions as closures still needs to be done.

Swift SVN r3340
This commit is contained in:
Joe Groff
2012-12-04 00:04:38 +00:00
parent 683ef3548b
commit 7b5e8c84cb
7 changed files with 58 additions and 34 deletions

View File

@@ -51,7 +51,8 @@ private:
// Intentionally marked private so that we need to use 'constructSIL()'
// to construct a SILModule.
SILModule(ASTContext &Context) : Context(Context), toplevel(nullptr) {}
SILModule(ASTContext &Context, bool hasTopLevel);
public:
~SILModule();
@@ -62,12 +63,12 @@ public:
ASTContext &getContext() const { return Context; }
/// Returns true if this module has top-level code.
bool hasToplevelFunction() const {
bool hasTopLevelFunction() const {
return toplevel != nullptr;
}
/// Returns the Function containing top-level code for the module.
Function *getToplevelFunction() const {
Function *getTopLevelFunction() const {
assert(toplevel && "no toplevel");
return toplevel;
}