diff options
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/ast.nim | 3 | ||||
-rwxr-xr-x | compiler/cgen.nim | 15 | ||||
-rwxr-xr-x | compiler/pragmas.nim | 18 | ||||
-rwxr-xr-x | compiler/wordrecg.nim | 4 |
4 files changed, 23 insertions, 17 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 3fdf5f6e3..d80f2289e 100755 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -236,7 +236,8 @@ type const sfFakeConst* = sfDeadCodeElim # const cannot be put into a data section - sfDispatcher* = sfDeadCodeElim # copied method symbol is the dispatcher + sfDispatcher* = sfDeadCodeElim # copied method symbol is the dispatcher + sfNoInit* = sfMainModule # don't generate code to init the variable type TTypeKind* = enum # order is important! diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 2b75edeff..ca58e4b1c 100755 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -74,9 +74,9 @@ proc fillLoc(a: var TLoc, k: TLocKind, typ: PType, r: PRope, s: TStorageLoc) = a.s = s if a.r == nil: a.r = r -proc isSimpleConst(typ: PType): bool = - result = not (skipTypes(typ, abstractVar).kind in - {tyTuple, tyObject, tyArray, tyArrayConstr, tySet, tySequence}) +proc isSimpleConst(typ: PType): bool = + result = skipTypes(typ, abstractVar).kind notin + {tyTuple, tyObject, tyArray, tyArrayConstr, tySet, tySequence} proc useHeader(m: BModule, sym: PSym) = if lfHeader in sym.loc.Flags: @@ -263,10 +263,11 @@ proc zeroTemp(p: BProc, loc: TLoc) = appcg(p, cpsStmts, "#genericReset((void*)$1, $2);$n", [addrLoc(loc), genTypeInfo(p.module, loc.t)]) -proc initVariable(p: BProc, v: PSym) = - var b = containsGarbageCollectedRef(v.typ) - if b or v.ast == nil: - zeroVar(p, v.loc, b) +proc initVariable(p: BProc, v: PSym) = + if sfNoInit notin v.flags: + var b = containsGarbageCollectedRef(v.typ) + if b or v.ast == nil: + zeroVar(p, v.loc, b) proc initTemp(p: BProc, tmp: var TLoc) = if containsGarbageCollectedRef(tmp.t) or isInvalidReturnType(tmp.t): diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 6c3a7ba67..5eb6263e9 100755 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -32,12 +32,13 @@ const iteratorPragmas* = {FirstCallConv..LastCallConv, wNosideEffect, wSideEffect, wImportc, wExportc, wNodecl, wMagic, wDeprecated, wBorrow, wExtern, wImportcpp, wImportobjc, wError, wDiscardable} - stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangechecks, wBoundchecks, - wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, wLinedir, - wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError, wFatal, - wDefine, wUndef, wCompile, wLink, wLinkSys, wPure, wPush, wPop, wBreakpoint, - wCheckpoint, wPassL, wPassC, wDeadCodeElim, wDeprecated, wFloatChecks, - wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, wLinearScanEnd} + stmtPragmas* = {wChecks, wObjChecks, wFieldChecks, wRangechecks, + wBoundchecks, wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, + wLinedir, wStacktrace, wLinetrace, wOptimization, wHint, wWarning, wError, + wFatal, wDefine, wUndef, wCompile, wLink, wLinkSys, wPure, wPush, wPop, + wBreakpoint, wCheckpoint, wPassL, wPassC, wDeadCodeElim, wDeprecated, + wFloatChecks, wInfChecks, wNanChecks, wPragma, wEmit, wUnroll, + wLinearScanEnd} lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl, wNosideEffect, wSideEffect, wNoreturn, wDynLib, wHeader, wDeprecated, wExtern, wThread, wImportcpp, wImportobjc, wNoStackFrame} @@ -48,7 +49,7 @@ const wImportcpp, wImportobjc, wError} varPragmas* = {wImportc, wExportc, wVolatile, wRegister, wThreadVar, wNodecl, wMagic, wHeader, wDeprecated, wCompilerProc, wDynLib, wExtern, - wImportcpp, wImportobjc, wError} + wImportcpp, wImportobjc, wError, wNoInit} constPragmas* = {wImportc, wExportc, wHeader, wDeprecated, wMagic, wNodecl, wExtern, wImportcpp, wImportobjc, wError} procTypePragmas* = {FirstCallConv..LastCallConv, wVarargs, wNosideEffect, @@ -556,6 +557,9 @@ proc pragma(c: PContext, sym: PSym, n: PNode, validPragmas: TSpecialWords) = of wDiscardable: noVal(it) if sym != nil: incl(sym.flags, sfDiscardable) + of wNoInit: + noVal(it) + if sym != nil: incl(sym.flags, sfNoInit) of wChecks, wObjChecks, wFieldChecks, wRangechecks, wBoundchecks, wOverflowchecks, wNilchecks, wAssertions, wWarnings, wHints, wLinedir, wStacktrace, wLinetrace, wOptimization, wByRef, diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index 5f8a2b3fd..43b0f522c 100755 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -50,7 +50,7 @@ type wHints, wOptimization, wSpeed, wSize, wNone, wDeadCodeElim, wSafecode, wPragma, - wCompileTime, + wCompileTime, wNoInit, wPassc, wPassl, wBorrow, wDiscardable, wFieldChecks, wCheckPoint, wSubsChar, @@ -96,7 +96,7 @@ const "optimization", "speed", "size", "none", "deadcodeelim", "safecode", "pragma", - "compiletime", + "compiletime", "noinit", "passc", "passl", "borrow", "discardable", "fieldchecks", "checkpoint", "subschar", "acyclic", "shallow", "unroll", "linearscanend", |