diff options
Diffstat (limited to 'rod')
-rwxr-xr-x | rod/astalgo.nim | 8 | ||||
-rwxr-xr-x | rod/ccgstmts.nim | 6 | ||||
-rwxr-xr-x | rod/cgen.nim | 21 | ||||
-rwxr-xr-x | rod/passaux.nim | 7 |
4 files changed, 25 insertions, 17 deletions
diff --git a/rod/astalgo.nim b/rod/astalgo.nim index 1b4572b2b..f3e573d84 100755 --- a/rod/astalgo.nim +++ b/rod/astalgo.nim @@ -284,7 +284,8 @@ proc symToYamlAux(n: PSym, marker: var TIntSet, indent: int, flagsToStr(n.options), toRope("position"), toRope(n.position)]) -proc typeToYamlAux(n: PType, marker: var TIntSet, indent: int, maxRecDepth: int): PRope = +proc typeToYamlAux(n: PType, marker: var TIntSet, indent: int, + maxRecDepth: int): PRope = if n == nil: result = toRope("null") elif intSetContainsOrIncl(marker, n.id): @@ -417,7 +418,10 @@ proc debugTree(n: PNode, indent: int, maxRecDepth: int): PRope = appf(result, "$n$1}", [spaces(indent)]) proc debug(n: PSym) = - writeln(stdout, ropeToStr(ropef("$1_$2", [toRope(n.name.s), toRope(n.id)]))) + #writeln(stdout, ropeToStr(symToYaml(n, 0, 1))) + writeln(stdout, ropeToStr(ropef("$1_$2: $3, $4", [ + toRope(n.name.s), toRope(n.id), flagsToStr(n.flags), + flagsToStr(n.loc.flags)]))) proc debug(n: PType) = writeln(stdout, ropeToStr(debugType(n))) diff --git a/rod/ccgstmts.nim b/rod/ccgstmts.nim index 9171b5fb8..348615cce 100755 --- a/rod/ccgstmts.nim +++ b/rod/ccgstmts.nim @@ -715,10 +715,12 @@ proc genStmts(p: BProc, t: PNode) = of nkProcDef, nkMethodDef, nkConverterDef: if (t.sons[genericParamsPos] == nil): prc = t.sons[namePos].sym - if not (optDeadCodeElim in gGlobalOptions) and - not (sfDeadCodeElim in getModule(prc).flags) or + if (optDeadCodeElim notin gGlobalOptions and + sfDeadCodeElim notin getModule(prc).flags) or ({sfExportc, sfCompilerProc} * prc.flags == {sfExportc}) or + (sfExportc in prc.flags and lfExportLib in prc.loc.flags) or (prc.kind == skMethod): + # we have not only the header: if (t.sons[codePos] != nil) or (lfDynamicLib in prc.loc.flags): genProc(p.module, prc) else: internalError(t.info, "genStmts(" & $t.kind & ')') diff --git a/rod/cgen.nim b/rod/cgen.nim index dd1878465..b5cf04b58 100755 --- a/rod/cgen.nim +++ b/rod/cgen.nim @@ -399,7 +399,7 @@ proc loadDynamicLib(m: BModule, lib: PLib) = lib.generated = true var tmp = getGlobalTempName() assert(lib.name == nil) - lib.name = tmp # BUGFIX: useMagic has awful side-effects + lib.name = tmp # BUGFIX: cgsym has awful side-effects appf(m.s[cfsVars], "static void* $1;$n", [tmp]) if lib.path.kind in {nkStrLit..nkTripleStrLit}: var s: TStringSeq = @[] @@ -437,14 +437,14 @@ proc SymInDynamicLib(m: BModule, sym: PSym) = var lib = sym.annex var extname = sym.loc.r loadDynamicLib(m, lib) - discard cgsym(m, "nimGetProcAddr") + #discard cgsym(m, "nimGetProcAddr") if gCmd == cmdCompileToLLVM: incl(sym.loc.flags, lfIndirect) var tmp = mangleDynLibProc(sym) sym.loc.r = tmp # from now on we only need the internal name sym.typ.sym = nil # generate a new name inc(m.labels, 2) - appf(m.s[cfsDynLibInit], - "$1 = ($2) nimGetProcAddr($3, $4);$n", + appcg(m, m.s[cfsDynLibInit], + "$1 = ($2) #nimGetProcAddr($3, $4);$n", [tmp, getTypeDesc(m, sym.typ), lib.name, cstringLit(m, m.s[cfsDynLibInit], ropeToStr(extname))]) appff(m.s[cfsVars], "$2 $1;$n", @@ -458,7 +458,7 @@ proc cgsym(m: BModule, name: string): PRope = of skProc, skMethod, skConverter: genProc(m, sym) of skVar: genVarPrototype(m, sym) of skType: discard getTypeDesc(m, sym.typ) - else: InternalError("useMagic: " & name) + else: InternalError("cgsym: " & name) else: # we used to exclude the system module from this check, but for DLL # generation support this sloppyness leads to hard to detect bugs, so @@ -700,10 +700,10 @@ proc getFileHeader(cfilenoext: string): PRope = proc genMainProc(m: BModule) = const - CommonMainBody = " setStackBottom(dummy);$n" & " nim__datInit();$n" & + CommonMainBody = " #setStackBottom(dummy);$n" & " nim__datInit();$n" & " systemInit();$n" & "$1" & "$2" CommonMainBodyLLVM = " %MOC$3 = bitcast [8 x %NI]* %dummy to i8*$n" & - " call void @setStackBottom(i8* %MOC$3)$n" & + " call void @#setStackBottom(i8* %MOC$3)$n" & " call void @nim__datInit()$n" & " call void systemInit()$n" & "$1" & "$2" PosixNimMain = "int cmdCount;$n" & "char** cmdLine;$n" & "char** gEnv;$n" & @@ -744,7 +744,6 @@ proc genMainProc(m: BModule) = " i8* %lpvReserved) {$n" & " call void @NimMain()$n" & " ret i32 1$n" & "}$n" var nimMain, otherMain: TFormatStr - discard cgsym(m, "setStackBottom") if (platform.targetOS == osWindows) and (gGlobalOptions * {optGenGuiApp, optGenDynLib} != {}): if optGenGuiApp in gGlobalOptions: @@ -771,8 +770,10 @@ proc genMainProc(m: BModule) = otherMain = PosixCMain if gBreakpoints != nil: discard cgsym(m, "dbgRegisterBreakpoint") inc(m.labels) - appf(m.s[cfsProcs], nimMain, [gBreakpoints, mainModInit, toRope(m.labels)]) - if not (optNoMain in gGlobalOptions): appf(m.s[cfsProcs], otherMain, []) + appcg(m, m.s[cfsProcs], nimMain, [ + gBreakpoints, mainModInit, toRope(m.labels)]) + if not (optNoMain in gGlobalOptions): + appcg(m, m.s[cfsProcs], otherMain, []) proc getInitName(m: PSym): PRope = result = ropeff("$1Init", "@$1Init", [toRope(m.name.s)]) diff --git a/rod/passaux.nim b/rod/passaux.nim index 0fc5226d1..d687dba08 100755 --- a/rod/passaux.nim +++ b/rod/passaux.nim @@ -1,7 +1,7 @@ # # # The Nimrod Compiler -# (c) Copyright 2008 Andreas Rumpf +# (c) Copyright 2010 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -33,8 +33,9 @@ proc verbosePass(): TPass = proc cleanUp(c: PPassContext, n: PNode): PNode = var s: PSym - result = n # we cannot clean up if dead code elimination is activated - if (optDeadCodeElim in gGlobalOptions): return + result = n + # we cannot clean up if dead code elimination is activated + if optDeadCodeElim in gGlobalOptions: return case n.kind of nkStmtList: for i in countup(0, sonsLen(n) - 1): discard cleanup(c, n.sons[i]) |