summary refs log tree commit diff stats
path: root/compiler/semdata.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-14 00:59:07 +0200
committerAraq <rumpf_a@web.de>2013-05-14 00:59:07 +0200
commit635ad3b336bfcf89c3bb611156fd68f3cc953c30 (patch)
tree66decee75e670e5e30ff9bf15b05806348f63ae7 /compiler/semdata.nim
parent9b9a18094732ec88157a11d3845d626b8970bfb9 (diff)
parentd3cf8121b7dddcea867328382113acfed845cf69 (diff)
downloadNim-635ad3b336bfcf89c3bb611156fd68f3cc953c30.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'compiler/semdata.nim')
-rw-r--r--compiler/semdata.nim14
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/semdata.nim b/compiler/semdata.nim
index afce365f9..4c94d0812 100644
--- a/compiler/semdata.nim
+++ b/compiler/semdata.nim
@@ -44,10 +44,13 @@ type
     efLValue, efWantIterator, efInTypeof, efWantStmt, efDetermineType,
     efAllowDestructor
   TExprFlags* = set[TExprFlag]
-    
+
   PContext* = ref TContext
   TContext* = object of TPassContext # a context represents a module
     module*: PSym              # the module sym belonging to the context
+    currentScope*: PScope      # current scope
+    importTable*: PScope       # scope for all imported symbols
+    topLevelScope*: PScope     # scope for all top-level symbols
     p*: PProcCon               # procedure context
     friendModule*: PSym        # current friend module; may access private data;
                                # this is used so that generic instantiations
@@ -55,7 +58,6 @@ type
     InstCounter*: int          # to prevent endless instantiations
    
     threadEntries*: TSymSeq    # list of thread entries to check
-    tab*: TSymTab              # each module has its own symbol table
     AmbiguousSymbols*: TIntSet # ids of all ambiguous symbols (cannot
                                # store this info in the syms themselves!)
     InGenericContext*: int     # > 0 if we are in a generic type
@@ -82,8 +84,7 @@ type
                                # naming it multiple times
     generics*: seq[TInstantiationPair] # pending list of instantiated generics to compile
     lastGenericIdx*: int      # used for the generics stack
-    
-
+   
 proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
   result.genericSym = s
   result.inst = inst
@@ -103,6 +104,10 @@ proc makeVarType*(c: PContext, baseType: PType): PType
 proc newTypeS*(kind: TTypeKind, c: PContext): PType
 proc fillTypeS*(dest: PType, kind: TTypeKind, c: PContext)
 
+proc scopeDepth*(c: PContext): int {.inline.} =
+  result = if c.currentScope != nil: c.currentScope.depthLevel
+           else: 0
+
 # owner handling:
 proc getCurrOwner*(): PSym
 proc PushOwner*(owner: PSym)
@@ -151,7 +156,6 @@ proc newOptionEntry(): POptionEntry =
 
 proc newContext(module: PSym): PContext =
   new(result)
-  InitSymTab(result.tab)
   result.AmbiguousSymbols = initIntset()
   initLinkedList(result.optionStack)
   initLinkedList(result.libs)