compilation cache: small fixes; methods still not working
This commit is contained in:
parent
bd1cb9e77b
commit
627d33da08
5 changed files with 30 additions and 22 deletions
|
|
@ -936,6 +936,11 @@ proc writeModule(m: BModule, pending: bool) =
|
||||||
var code = genModule(m, cfilenoext)
|
var code = genModule(m, cfilenoext)
|
||||||
writeRope(code, cfile)
|
writeRope(code, cfile)
|
||||||
addFileToCompile(cfilenoext)
|
addFileToCompile(cfilenoext)
|
||||||
|
elif not ExistsFile(toObjFile(cfilenoext)):
|
||||||
|
# Consider: first compilation compiles ``system.nim`` and produces
|
||||||
|
# ``system.c`` but then compilation fails due to an error. This means
|
||||||
|
# that ``system.o`` is missing, so we need to call the C compiler for it:
|
||||||
|
addFileToCompile(cfilenoext)
|
||||||
addFileToLink(cfilenoext)
|
addFileToLink(cfilenoext)
|
||||||
|
|
||||||
proc myClose(b: PPassContext, n: PNode): PNode =
|
proc myClose(b: PPassContext, n: PNode): PNode =
|
||||||
|
|
@ -953,7 +958,7 @@ proc myClose(b: PPassContext, n: PNode): PNode =
|
||||||
finishModule(m)
|
finishModule(m)
|
||||||
if sfMainModule in m.module.flags:
|
if sfMainModule in m.module.flags:
|
||||||
var disp = generateMethodDispatchers()
|
var disp = generateMethodDispatchers()
|
||||||
for i in 0..sonsLen(disp)-1: genProcAux(gNimDat, disp.sons[i].sym)
|
for i in 0..sonsLen(disp)-1: genProcAux(m, disp.sons[i].sym)
|
||||||
genMainProc(m)
|
genMainProc(m)
|
||||||
# we need to process the transitive closure because recursive module
|
# we need to process the transitive closure because recursive module
|
||||||
# deps are allowed (and the system module is processed in the wrong
|
# deps are allowed (and the system module is processed in the wrong
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ proc methodCall*(n: PNode): PNode =
|
||||||
for i in countup(1, sonsLen(result) - 1):
|
for i in countup(1, sonsLen(result) - 1):
|
||||||
result.sons[i] = genConv(result.sons[i], disp.typ.sons[i], true)
|
result.sons[i] = genConv(result.sons[i], disp.typ.sons[i], true)
|
||||||
|
|
||||||
var gMethods: seq[TSymSeq]
|
# save for incremental compilation:
|
||||||
|
var gMethods: seq[TSymSeq] = @[]
|
||||||
|
|
||||||
proc sameMethodBucket(a, b: PSym): bool =
|
proc sameMethodBucket(a, b: PSym): bool =
|
||||||
result = false
|
result = false
|
||||||
|
|
@ -66,14 +67,16 @@ proc sameMethodBucket(a, b: PSym): bool =
|
||||||
return
|
return
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
proc methodDef*(s: PSym) =
|
proc methodDef*(s: PSym, fromCache: bool) =
|
||||||
var L = len(gMethods)
|
var L = len(gMethods)
|
||||||
for i in countup(0, L - 1):
|
for i in countup(0, L - 1):
|
||||||
if sameMethodBucket(gMethods[i][0], s):
|
if sameMethodBucket(gMethods[i][0], s):
|
||||||
add(gMethods[i], s) # store a symbol to the dispatcher:
|
add(gMethods[i], s) # store a symbol to the dispatcher:
|
||||||
addSon(s.ast, lastSon(gMethods[i][0].ast))
|
addSon(s.ast, lastSon(gMethods[i][0].ast))
|
||||||
return
|
return
|
||||||
add(gMethods, @[s]) # create a new dispatcher:
|
add(gMethods, @[s])
|
||||||
|
# create a new dispatcher:
|
||||||
|
if not fromCache:
|
||||||
var disp = copySym(s)
|
var disp = copySym(s)
|
||||||
disp.typ = copyType(disp.typ, disp.typ.owner, false)
|
disp.typ = copyType(disp.typ, disp.typ.owner, false)
|
||||||
if disp.typ.callConv == ccInline: disp.typ.callConv = ccDefault
|
if disp.typ.callConv == ccInline: disp.typ.callConv = ccDefault
|
||||||
|
|
@ -177,4 +180,3 @@ proc generateMethodDispatchers*(): PNode =
|
||||||
sortBucket(gMethods[bucket], relevantCols)
|
sortBucket(gMethods[bucket], relevantCols)
|
||||||
addSon(result, newSymNode(genDispatcher(gMethods[bucket], relevantCols)))
|
addSon(result, newSymNode(genDispatcher(gMethods[bucket], relevantCols)))
|
||||||
|
|
||||||
gMethods = @[]
|
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ proc symStack(w: PRodWriter) =
|
||||||
#intSetIncl(debugWritten, s.id)
|
#intSetIncl(debugWritten, s.id)
|
||||||
encodeSym(w, s, w.data)
|
encodeSym(w, s, w.data)
|
||||||
add(w.data, rodNL)
|
add(w.data, rodNL)
|
||||||
if sfExported in s.flags:
|
if sfExported in s.flags and s.kind in ExportableSymKinds:
|
||||||
encodeStr(s.name.s, w.interf)
|
encodeStr(s.name.s, w.interf)
|
||||||
add(w.interf, ' ')
|
add(w.interf, ' ')
|
||||||
encodeVInt(s.id, w.interf)
|
encodeVInt(s.id, w.interf)
|
||||||
|
|
@ -386,7 +386,8 @@ proc rawAddInterfaceSym(w: PRodWriter, s: PSym) =
|
||||||
|
|
||||||
proc addInterfaceSym(w: PRodWriter, s: PSym) =
|
proc addInterfaceSym(w: PRodWriter, s: PSym) =
|
||||||
if w == nil: return
|
if w == nil: return
|
||||||
if {sfExported, sfCompilerProc} * s.flags != {}:
|
if s.kind in ExportableSymKinds and
|
||||||
|
{sfExported, sfCompilerProc} * s.flags != {}:
|
||||||
rawAddInterfaceSym(w, s)
|
rawAddInterfaceSym(w, s)
|
||||||
|
|
||||||
proc addStmt(w: PRodWriter, n: PNode) =
|
proc addStmt(w: PRodWriter, n: PNode) =
|
||||||
|
|
|
||||||
|
|
@ -676,7 +676,7 @@ proc transform(c: PTransf, n: PNode): PTransNode =
|
||||||
of nkProcDef, nkMethodDef, nkIteratorDef, nkMacroDef, nkConverterDef:
|
of nkProcDef, nkMethodDef, nkIteratorDef, nkMacroDef, nkConverterDef:
|
||||||
if n.sons[genericParamsPos].kind == nkEmpty:
|
if n.sons[genericParamsPos].kind == nkEmpty:
|
||||||
n.sons[codePos] = PNode(transform(c, n.sons[codePos]))
|
n.sons[codePos] = PNode(transform(c, n.sons[codePos]))
|
||||||
if n.kind == nkMethodDef: methodDef(n.sons[namePos].sym)
|
if n.kind == nkMethodDef: methodDef(n.sons[namePos].sym, false)
|
||||||
result = PTransNode(n)
|
result = PTransNode(n)
|
||||||
of nkContinueStmt:
|
of nkContinueStmt:
|
||||||
result = PTransNode(newNode(nkBreakStmt))
|
result = PTransNode(newNode(nkBreakStmt))
|
||||||
|
|
@ -742,7 +742,7 @@ proc openTransf(module: PSym, filename: string): PPassContext =
|
||||||
proc openTransfCached(module: PSym, filename: string,
|
proc openTransfCached(module: PSym, filename: string,
|
||||||
rd: PRodReader): PPassContext =
|
rd: PRodReader): PPassContext =
|
||||||
result = openTransf(module, filename)
|
result = openTransf(module, filename)
|
||||||
for m in items(rd.methods): methodDef(m)
|
for m in items(rd.methods): methodDef(m, true)
|
||||||
|
|
||||||
proc transfPass(): TPass =
|
proc transfPass(): TPass =
|
||||||
initPass(result)
|
initPass(result)
|
||||||
|
|
|
||||||
8
todo.txt
8
todo.txt
|
|
@ -18,16 +18,16 @@ incremental compilation
|
||||||
|
|
||||||
- adapt thread var implementation to care about the new merge operation
|
- adapt thread var implementation to care about the new merge operation
|
||||||
- write test cases: needs test script support
|
- write test cases: needs test script support
|
||||||
- test G, A, B example from the documentation
|
- fix method generation
|
||||||
- test thread var
|
- test thread var
|
||||||
- test method generation; could work, needs ROD support though
|
|
||||||
- test init sections
|
|
||||||
- test DLL interfacing!
|
- test DLL interfacing!
|
||||||
- hallo.rod is missing initial statements: feature or bug?
|
- stress test with whole compiler
|
||||||
|
|
||||||
- automate tests:
|
- automate tests:
|
||||||
- test basic recompilation scheme
|
- test basic recompilation scheme
|
||||||
- test type converters
|
- test type converters
|
||||||
|
- test G, A, B example from the documentation
|
||||||
|
- test init sections
|
||||||
|
|
||||||
- fix remaining bugs
|
- fix remaining bugs
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue