made more tests green

This commit is contained in:
Araq
2016-12-05 16:27:37 +01:00
parent ba38b83dd5
commit 80cbe61c6c
2 changed files with 17 additions and 3 deletions

View File

@@ -107,8 +107,10 @@ proc mangleName(m: BModule; s: PSym): Rope =
s.loc.r = result
proc typeName(typ: PType): Rope =
result = if typ.sym != nil: typ.sym.name.s.mangle.rope
else: ~"TY"
result = if typ.sym != nil and typ.kind in {tyObject, tyEnum}:
typ.sym.name.s.mangle.rope
else:
~"TY"
proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
let typ = if typ.kind == tyAlias: typ.lastSon else: typ
@@ -1078,6 +1080,14 @@ proc genTypeInfo(m: BModule, t: PType): Rope =
if result != nil:
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)]
m.typeInfoMarker[sig] = result
@@ -1091,6 +1101,8 @@ proc genTypeInfo(m: BModule, t: PType): Rope =
addf(m.s[cfsVars], "extern TNimType $1; /* $2 */$n",
[result, rope(typeToString(t))])
return "(&".rope & result & ")".rope
m.g.typeInfoMarker[sig] = result
case t.kind
of tyEmpty, tyVoid: result = rope"0"
of tyPointer, tyBool, tyChar, tyCString, tyString, tyInt..tyUInt64, tyVar:

View File

@@ -114,6 +114,7 @@ type
generatedHeader*: BModule
breakPointId*: int
breakpoints*: Rope # later the breakpoints are inserted into the main proc
typeInfoMarker*: TypeCache
TCGen = object of TPassContext # represents a C source file
s*: TCFileSections # sections of the C file
@@ -162,7 +163,8 @@ proc newProc*(prc: PSym, module: BModule): BProc =
result.nestedTryStmts = @[]
result.finallySafePoints = @[]
proc newModuleList*(): BModuleList = BModuleList(modules: @[])
proc newModuleList*(): BModuleList =
BModuleList(modules: @[], typeInfoMarker: initTable[SigHash, Rope]())
iterator cgenModules*(g: BModuleList): BModule =
for i in 0..high(g.modules):