diff options
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r-- | compiler/ast.nim | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 6e0cafd74..2a7d8a551 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -131,7 +131,7 @@ type nkFormalParams, # formal parameters nkOfInherit, # inherited from symbol - nkModule, # the syntax tree of a module + nkImportAs, # a 'as' b in an import statement nkProcDef, # a proc nkMethodDef, # a method nkConverterDef, # a converter @@ -231,7 +231,8 @@ type sfVolatile, # variable is volatile sfRegister, # variable should be placed in a register sfPure, # object is "pure" that means it has no type-information - + # enum is "pure", its values need qualified access + # variable is "pure"; it's an explicit "global" sfNoSideEffect, # proc has no side effects sfSideEffect, # proc may have side effects; cannot prove it has none sfMainModule, # module is the main module @@ -386,7 +387,7 @@ type tfNeedsInit, # type constains a "not nil" constraint somewhere or some # other type so that it requires inititalization tfHasShared, # type constains a "shared" constraint modifier somewhere - tfHasMeta, # type has "typedesc" or "expr" somewhere + tfHasMeta, # type has "typedesc" or "expr" somewhere; or uses '|' tfHasGCedMem, # type contains GC'ed memory TTypeFlags* = set[TTypeFlag] @@ -640,6 +641,11 @@ type # this is because in incremental compilation, when a module is about to # be replaced with a newer version, we must decrement the usage count # of all previously used generics. + # For 'import as' we copy the module symbol but shallowCopy the 'tab' + # and set the 'usedGenerics' to ... XXX gah! Better set module.name + # instead? But this doesn't work either. --> We need an skModuleAlias? + # No need, just leave it as skModule but set the owner accordingly and + # check for the owner when touching 'usedGenerics'. usedGenerics*: seq[PInstantiation] tab*: TStrTable # interface table for modules else: nil @@ -1105,7 +1111,7 @@ proc copyType(t: PType, owner: PSym, keepId: bool): PType = proc copySym(s: PSym, keepId: bool = false): PSym = result = newSym(s.kind, s.name, s.owner, s.info) - result.ast = nil # BUGFIX; was: s.ast which made problems + #result.ast = nil # BUGFIX; was: s.ast which made problems result.typ = s.typ if keepId: result.id = s.id @@ -1120,6 +1126,20 @@ proc copySym(s: PSym, keepId: bool = false): PSym = result.position = s.position result.loc = s.loc result.annex = s.annex # BUGFIX + +proc createModuleAlias*(s: PSym, newIdent: PIdent, info: TLineInfo): PSym = + result = newSym(s.kind, newIdent, s.owner, info) + # keep ID! + result.ast = s.ast + result.id = s.id + result.flags = s.flags + system.shallowCopy(result.tab, s.tab) + result.options = s.options + result.position = s.position + result.loc = s.loc + result.annex = s.annex + # XXX once usedGenerics is used, ensure module aliases keep working! + assert s.usedGenerics == nil proc newSym(symKind: TSymKind, Name: PIdent, owner: PSym, info: TLineInfo): PSym = @@ -1190,7 +1210,7 @@ proc newSons(father: PNode, length: int) = setlen(father.sons, length) proc propagateToOwner*(owner, elem: PType) = - const HaveTheirOwnEmpty = {tySequence, tySet} + const HaveTheirOwnEmpty = {tySequence, tySet} owner.flags = owner.flags + (elem.flags * {tfHasShared, tfHasMeta, tfHasGCedMem}) if tfNotNil in elem.flags: |