From 9c95831901031017f1911e61260ef2fb136b451b Mon Sep 17 00:00:00 2001 From: metagn Date: Fri, 29 Nov 2024 22:10:46 +0300 Subject: [PATCH] fix forward type issue, now "compiles" hello world but output c is broken --- compiler/ccgtypes.nim | 1 + compiler/cgen.nim | 3 +-- compiler/condsyms.nim | 2 ++ lib/system.nim | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index a2522d49fbc7b..1cc86e316015f 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -926,6 +926,7 @@ proc getTypeDescAux(m: BModule; origTyp: PType, check: var IntSet; kind: TypeDes let name = getTypeForward(m, et, hashType(et, m.config)) result = wrapStar(name) m.typeCache[sig] = result + pushType(m, et) of tySequence: if optSeqDestructors in m.config.globalOptions: result = wrapStar(getTypeDescWeak(m, et, check, kind)) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 9dc94b0b4df4d..0a88c38284cfb 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1655,10 +1655,9 @@ proc getSomeInitName(m: BModule, suffix: string): Rope = proc getInitName(m: BModule): Rope = if sfMainModule in m.module.flags: # generate constant name for main module, for "easy" debugging. - result = rope(m.config.nimMainPrefix) & rope"NimMainModule" + result = cSymbol(rope(m.config.nimMainPrefix) & rope"NimMainModule") else: result = getSomeInitName(m, "Init000") - result = cSymbol(result) proc getDatInitName(m: BModule): Rope = getSomeInitName(m, "DatInit000") proc getHcrInitName(m: BModule): Rope = getSomeInitName(m, "HcrInit000") diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index f9db67d4bb562..700ee88ca8b9d 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -173,3 +173,5 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimHasXorSet") defineSymbol("nimHasLegacyNoStrictDefs") + when defined(nimCompileToNifc): + defineSymbol("nifc") diff --git a/lib/system.nim b/lib/system.nim index b2cf92ffb7572..a213a168396ff 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1720,11 +1720,16 @@ when not defined(nimscript): when not declared(sysFatal): include "system/fatal" +when defined(nifc): + {.pragma: tframe, compilerproc.} +else: + {.pragma: tframe, importc, nodecl.} + type PFrame* = ptr TFrame ## Represents a runtime frame of the call stack; ## part of the debugger API. # keep in sync with nimbase.h `struct TFrame_` - TFrame* {.importc, nodecl, final.} = object ## The frame itself. + TFrame* {.tframe, final.} = object ## The frame itself. prev*: PFrame ## Previous frame; used for chaining the call stack. procname*: cstring ## Name of the proc that is currently executing. line*: int ## Line number of the proc that is currently executing.