src/compiler/SemanticAnalysis.cpp
changeset 258 241d082d6d89
parent 256 3c184218462d
child 259 99ab8b19f0b9
     1.1 --- a/src/compiler/SemanticAnalysis.cpp	Sun Jan 06 13:56:56 2013 -0800
     1.2 +++ b/src/compiler/SemanticAnalysis.cpp	Sat Jan 12 16:13:46 2013 -0800
     1.3 @@ -559,6 +559,23 @@
     1.4      return true;
     1.5  }
     1.6  
     1.7 +static unsigned
     1.8 +BindImplicitName(Module *from, ImplicitSymbol *sym)
     1.9 +{
    1.10 +    if (sym->bound())
    1.11 +        return sym->fieldIndex();
    1.12 +
    1.13 +    Module *module = Module::cast(from->getImportAt(sym->index()));
    1.14 +    StructMap *map = module->globals()->map();
    1.15 +
    1.16 +    unsigned fieldIndex;
    1.17 +    Descriptor *desc = map->type()->lookupField(sym->name(), &fieldIndex);
    1.18 +    assert(desc && desc->type() == sym->type());
    1.19 +
    1.20 +    sym->bind(fieldIndex);
    1.21 +    return fieldIndex;
    1.22 +}
    1.23 +
    1.24  void
    1.25  SemanticAnalysis::visitNameProxy(NameProxy *proxy)
    1.26  {
    1.27 @@ -572,6 +589,16 @@
    1.28          break;
    1.29        }
    1.30  
    1.31 +      case Symbol::kImplicit:
    1.32 +      {
    1.33 +        ImplicitSymbol *import = sym->toImplicit();
    1.34 +        unsigned fieldIndex = BindImplicitName(unit_->module(), import);
    1.35 +
    1.36 +        hir_ = new (pool_) HImport(proxy, zone_->types()->getImportable(), import->index());
    1.37 +        hir_ = new (pool_) HField(proxy, hir_, sym->type(), fieldIndex);
    1.38 +        break;
    1.39 +      }
    1.40 +
    1.41        case Symbol::kConstant:
    1.42        {
    1.43          ConstantSymbol *val = sym->toConstant();