made more tests green
This commit is contained in:
parent
ba38b83dd5
commit
80cbe61c6c
2 changed files with 17 additions and 3 deletions
|
|
@ -107,8 +107,10 @@ proc mangleName(m: BModule; s: PSym): Rope =
|
||||||
s.loc.r = result
|
s.loc.r = result
|
||||||
|
|
||||||
proc typeName(typ: PType): Rope =
|
proc typeName(typ: PType): Rope =
|
||||||
result = if typ.sym != nil: typ.sym.name.s.mangle.rope
|
result = if typ.sym != nil and typ.kind in {tyObject, tyEnum}:
|
||||||
else: ~"TY"
|
typ.sym.name.s.mangle.rope
|
||||||
|
else:
|
||||||
|
~"TY"
|
||||||
|
|
||||||
proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
|
proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
|
||||||
let typ = if typ.kind == tyAlias: typ.lastSon else: typ
|
let typ = if typ.kind == tyAlias: typ.lastSon else: typ
|
||||||
|
|
@ -1078,6 +1080,14 @@ proc genTypeInfo(m: BModule, t: PType): Rope =
|
||||||
if result != nil:
|
if result != nil:
|
||||||
return "(&".rope & result & ")".rope
|
return "(&".rope & result & ")".rope
|
||||||
|
|
||||||
|
result = m.g.typeInfoMarker.getOrDefault(sig)
|
||||||
|
if result != nil:
|
||||||
|
discard cgsym(m, "TNimType")
|
||||||
|
discard cgsym(m, "TNimNode")
|
||||||
|
addf(m.s[cfsVars], "extern TNimType $1; /* $2 */$n",
|
||||||
|
[result, rope(typeToString(t))])
|
||||||
|
return "(&".rope & result & ")".rope
|
||||||
|
|
||||||
result = "NTI$1" % [rope($sig)]
|
result = "NTI$1" % [rope($sig)]
|
||||||
m.typeInfoMarker[sig] = result
|
m.typeInfoMarker[sig] = result
|
||||||
|
|
||||||
|
|
@ -1091,6 +1101,8 @@ proc genTypeInfo(m: BModule, t: PType): Rope =
|
||||||
addf(m.s[cfsVars], "extern TNimType $1; /* $2 */$n",
|
addf(m.s[cfsVars], "extern TNimType $1; /* $2 */$n",
|
||||||
[result, rope(typeToString(t))])
|
[result, rope(typeToString(t))])
|
||||||
return "(&".rope & result & ")".rope
|
return "(&".rope & result & ")".rope
|
||||||
|
|
||||||
|
m.g.typeInfoMarker[sig] = result
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyEmpty, tyVoid: result = rope"0"
|
of tyEmpty, tyVoid: result = rope"0"
|
||||||
of tyPointer, tyBool, tyChar, tyCString, tyString, tyInt..tyUInt64, tyVar:
|
of tyPointer, tyBool, tyChar, tyCString, tyString, tyInt..tyUInt64, tyVar:
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ type
|
||||||
generatedHeader*: BModule
|
generatedHeader*: BModule
|
||||||
breakPointId*: int
|
breakPointId*: int
|
||||||
breakpoints*: Rope # later the breakpoints are inserted into the main proc
|
breakpoints*: Rope # later the breakpoints are inserted into the main proc
|
||||||
|
typeInfoMarker*: TypeCache
|
||||||
|
|
||||||
TCGen = object of TPassContext # represents a C source file
|
TCGen = object of TPassContext # represents a C source file
|
||||||
s*: TCFileSections # sections of the C file
|
s*: TCFileSections # sections of the C file
|
||||||
|
|
@ -162,7 +163,8 @@ proc newProc*(prc: PSym, module: BModule): BProc =
|
||||||
result.nestedTryStmts = @[]
|
result.nestedTryStmts = @[]
|
||||||
result.finallySafePoints = @[]
|
result.finallySafePoints = @[]
|
||||||
|
|
||||||
proc newModuleList*(): BModuleList = BModuleList(modules: @[])
|
proc newModuleList*(): BModuleList =
|
||||||
|
BModuleList(modules: @[], typeInfoMarker: initTable[SigHash, Rope]())
|
||||||
|
|
||||||
iterator cgenModules*(g: BModuleList): BModule =
|
iterator cgenModules*(g: BModuleList): BModule =
|
||||||
for i in 0..high(g.modules):
|
for i in 0..high(g.modules):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue