diff options
Diffstat (limited to 'compiler/ast.nim')
-rwxr-xr-x | compiler/ast.nim | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 978b43b5e..d9ec70450 100755 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -371,7 +371,7 @@ type TMagic* = enum # symbols that require compiler magic: mNone, mDefined, mDefinedInScope, mLow, mHigh, mSizeOf, mTypeTrait, mIs, mOf, - mEcho, mShallowCopy, mSlurp, + mEcho, mShallowCopy, mSlurp, mStaticExec, mParseExprToAst, mParseStmtToAst, mExpandToAst, mUnaryLt, mSucc, mPred, mInc, mDec, mOrd, mNew, mNewFinalize, mNewSeq, mLengthOpenArray, @@ -542,6 +542,9 @@ type # for easy generation of proper error messages # for variant record fields the discriminant # expression + # for modules, it's a placeholder for compiler + # generated code that will be appended to the + # module after the sem pass (see appendToModule) options*: TOptions position*: int # used for many different things: # for enum fields its position; @@ -568,6 +571,9 @@ type # for record types a nkRecord node # for enum types a list of symbols # else: unused + destructor*: PSym # destructor. warning: nil here may not necessary + # mean that there is no destructor. + # see instantiateDestructor in types.nim owner*: PSym # the 'owner' of the type sym*: PSym # types have the sym associated with them # it is used for converting types to strings @@ -740,6 +746,16 @@ proc linkTo*(s: PSym, t: PType): PSym {.discardable.} = s.typ = t result = s +proc appendToModule*(m: PSym, n: PNode) = + ## The compiler will use this internally to add nodes that will be + ## appended to the module after the sem pass + if m.ast == nil: + m.ast = newNode(nkStmtList) + m.ast.sons = @[n] + else: + assert m.ast.kind == nkStmtList + m.ast.sons.add(n) + const # for all kind of hash tables: GrowthFactor* = 2 # must be power of 2, > 0 StartSize* = 8 # must be power of 2, > 0 |