src/compiler/CompileContext.cpp
changeset 258 241d082d6d89
parent 256 3c184218462d
child 260 05de34f712fe
     1.1 --- a/src/compiler/CompileContext.cpp	Sun Jan 06 13:56:56 2013 -0800
     1.2 +++ b/src/compiler/CompileContext.cpp	Sat Jan 12 16:13:46 2013 -0800
     1.3 @@ -271,7 +271,7 @@
     1.4  CompileContext::compile()
     1.5  {
     1.6      // Phase 1. Parse all modules we're importing. This process may load new
     1.7 -    // modules off disk, and add them to the parse queue.
     1.8 +    // modules off disk and add them to the parse queue.
     1.9      while (!unparsed_.empty()) {
    1.10          TranslationUnit *unit = unparsed_.popCopy();
    1.11  
    1.12 @@ -289,6 +289,9 @@
    1.13          if (unit->failed())
    1.14              continue;
    1.15  
    1.16 +        // Mark the module as currently in translation.
    1.17 +        unit->module()->setTranslationUnit(unit);
    1.18 +
    1.19          PopulateNamesAndTypes(zone_, *this, unit);
    1.20      }
    1.21  
    1.22 @@ -298,15 +301,12 @@
    1.23          if (unit->failed())
    1.24              continue;
    1.25  
    1.26 -        BindNamesAndTypes(zone_, *this, unit);
    1.27 -    }
    1.28 +        BindGlobals(zone_, *this, unit);
    1.29  
    1.30 -    // Phase 4. Assign types to every public name in the module.
    1.31 -    for (size_t i = 0; i < units_.length(); i++) {
    1.32 -        TranslationUnit *unit = units_[i];
    1.33          if (unit->failed())
    1.34              continue;
    1.35  
    1.36 +        BindNamesAndTypes(zone_, *this, unit);
    1.37      }
    1.38  
    1.39      // Intermediate phase. Decide which modules we should not perform
    1.40 @@ -328,6 +328,10 @@
    1.41      // Phase 5. Run modules.
    1.42      for (size_t i = 0; i < units_.length(); i++) {
    1.43          TranslationUnit *unit = units_[i];
    1.44 +
    1.45 +        // Mark the unit as no longer being translated.
    1.46 +        unit->module()->setTranslationUnit(NULL);
    1.47 +
    1.48          if (unit->failed())
    1.49              break;
    1.50