diff options
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/cgen.nim | 19 | ||||
-rw-r--r-- | compiler/cgendata.nim | 2 | ||||
-rwxr-xr-x | compiler/main.nim | 2 | ||||
-rw-r--r-- | compiler/service.nim | 1 |
4 files changed, 21 insertions, 3 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 2c58eecec..57dd85d9c 100755 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -552,10 +552,19 @@ proc SymInDynamicLib(m: BModule, sym: PSym) = initLocExpr(m.initProc, n[i], a) params.app(rdLoc(a)) params.app(", ") - appcg(m, m.initProc.s(cpsStmts), - "\t$1 = ($2) ($3$4));$n", + let load = ropef("\t$1 = ($2) ($3$4));$n", [tmp, getTypeDesc(m, sym.typ), params, cstringLit(m, m.s[cfsDynLibInit], ropeToStr(extname))]) + var last = lastSon(n) + if last.kind == nkHiddenStdConv: last = last.sons[1] + InternalAssert(last.kind == nkStrLit) + let idx = last.strVal + if idx.len == 0: + app(m.initProc.s(cpsStmts), load) + elif idx.len == 1 and idx[0] in {'0'..'9'}: + app(m.extensionLoaders[idx[0]], load) + else: + InternalError(sym.info, "wrong index: " & idx) else: appcg(m, m.s[cfsDynLibInit], "\t$1 = ($2) #nimGetProcAddr($3, $4);$n", @@ -972,6 +981,12 @@ proc genInitCode(m: BModule) = # that would lead to a *nesting* of merge sections which the merger does # not support. So we add it to another special section: ``cfsInitProc`` app(m.s[cfsInitProc], prc) + + for i, el in pairs(m.extensionLoaders): + if el != nil: + let ex = ropef("N_NIMCALL(void, nimLoadProcs$1)(void) {$2}$N$N", + (i.ord - '0'.ord).toRope, el) + app(m.s[cfsInitProc], ex) proc genModule(m: BModule, cfilenoext: string): PRope = result = getFileHeader(cfilenoext) diff --git a/compiler/cgendata.nim b/compiler/cgendata.nim index d0d0eece8..d0cc07097 100644 --- a/compiler/cgendata.nim +++ b/compiler/cgendata.nim @@ -111,6 +111,8 @@ type typeNodes*, nimTypes*: int # used for type info generation typeNodesName*, nimTypesName*: PRope # used for type info generation labels*: natural # for generating unique module-scope names + extensionLoaders*: array['0'..'9', PRope] # special procs for the + # OpenGL wrapper var mainModProcs*, mainModInit*, mainDatInit*: PRope # parts of the main module diff --git a/compiler/main.nim b/compiler/main.nim index dec393c50..26b3c9c4c 100755 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -300,7 +300,7 @@ proc MainCommand = #registerPass(rodwrite.rodwritePass()) discard CompileModule(options.libpath / "system", {sfSystemModule}) service.serve(proc () = - let projectFile = gProjectFull + let projectFile = mainCommandArg() discard CompileModule(projectFile, {sfMainModule}) ) else: rawMessage(errInvalidCommandX, command) diff --git a/compiler/service.nim b/compiler/service.nim index 23a9bda66..b1741b7bd 100644 --- a/compiler/service.nim +++ b/compiler/service.nim @@ -62,6 +62,7 @@ proc serve*(action: proc (){.nimcall.}) = server.bindAddr(port, getConfigVar("server.address")) var inp = "".TaintedString server.listen() + new(stdoutSocket) while true: accept(server, stdoutSocket) discard stdoutSocket.recvLine(inp) |