File tree Expand file tree Collapse file tree 4 files changed +8
-9
lines changed Expand file tree Collapse file tree 4 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 856
856
loc* : TLoc
857
857
annex* : PLib # additional fields (seldom used, so we use a
858
858
# reference to another object to save space)
859
+ cname* : string # resolved C declaration name in importc decl, eg:
860
+ # {.importc: "foo".} => cname = foo
859
861
constraint* : PNode # additional constraints like 'lit|result'; also
860
862
# misused for the codegenDecl pragma in the hope
861
863
# it won't cause problems
Original file line number Diff line number Diff line change @@ -697,14 +697,10 @@ proc loadDynamicLib(m: BModule, lib: PLib) =
697
697
proc mangleDynLibProc(sym: PSym): Rope =
698
698
# we have to build this as a single rope in order not to trip the
699
699
# optimization in genInfixCall, see test tests/cpp/t8241.nim
700
- when not defined(windows) :
701
- # mysterious bug that only affects windows, causing SIGSEGV in
700
+ if sym.loc.r != nil :
701
+ # `return rope($sym.loc.r)` would cause on windows a SIGSEGV in
702
702
# stdlib_winleanDatInit000 () at generated_not_to_break_here
703
- if sym.loc.r != nil:
704
- if sym.loc.r.data.len > 0:
705
- return sym.loc.r
706
- else:
707
- return rope($sym.loc.r)
703
+ if sym.cname.len == 0: sym.cname = $sym.loc.r
708
704
if sfCompilerProc in sym.flags:
709
705
# NOTE: sym.loc.r is the external name!
710
706
result = rope(sym.name.s)
Original file line number Diff line number Diff line change 47
47
nkPtrLit = nkIntLit # hopefully we can get rid of this hack soon
48
48
49
49
proc importcSymbol*(conf: ConfigRef, sym: PSym): PNode =
50
- let name = $sym.loc.r
50
+ var name = $sym.cname
51
+ if name.len == 0: name = $sym.loc.r
51
52
# the AST does not support untyped pointers directly, so we use an nkIntLit
52
53
# that contains the address instead:
53
54
result = newNodeIT(nkPtrLit, sym.info, sym.typ)
Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ proc putIntoReg(dest: var TFullReg; n: PNode) =
281
281
if dest.kind == rkNode:
282
282
dest.node = n
283
283
return
284
- elif n.typ.kind == tyPtr:
284
+ elif n.typ != nil and n.typ .kind == tyPtr:
285
285
dest = TFullReg(kind: rkNode, node: n)
286
286
return
287
287
You can’t perform that action at this time.
0 commit comments