mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 11:24:08 +00:00
@@ -1142,7 +1142,8 @@ proc isNoReturn(m: BModule; s: PSym): bool {.inline.} =
|
||||
proc genProcAux*(m: BModule, prc: PSym) =
|
||||
var p = newProc(prc, m)
|
||||
var header = newRopeAppender()
|
||||
if m.config.backend == backendCpp and sfCppMember * prc.flags != {}:
|
||||
let isCppMember = m.config.backend == backendCpp and sfCppMember * prc.flags != {}
|
||||
if isCppMember:
|
||||
genMemberProcHeader(m, prc, header)
|
||||
else:
|
||||
genProcHeader(m, prc, header)
|
||||
@@ -1205,10 +1206,10 @@ proc genProcAux*(m: BModule, prc: PSym) =
|
||||
var generatedProc: Rope = ""
|
||||
generatedProc.genCLineDir prc.info, m.config
|
||||
if isNoReturn(p.module, prc):
|
||||
if hasDeclspec in extccomp.CC[p.config.cCompiler].props:
|
||||
if hasDeclspec in extccomp.CC[p.config.cCompiler].props and not isCppMember:
|
||||
header = "__declspec(noreturn) " & header
|
||||
if sfPure in prc.flags:
|
||||
if hasDeclspec in extccomp.CC[p.config.cCompiler].props:
|
||||
if hasDeclspec in extccomp.CC[p.config.cCompiler].props and not isCppMember:
|
||||
header = "__declspec(naked) " & header
|
||||
generatedProc.add ropecg(p.module, "$1 {$n$2$3$4}$N$N",
|
||||
[header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)])
|
||||
|
||||
@@ -79,3 +79,40 @@ type Doo = object
|
||||
proc naiveMember(x: Doo): int {. virtual .} = 2
|
||||
discard naiveMember(Doo())
|
||||
|
||||
#asmnostackframe works with virtual
|
||||
{.emit:"""/*TYPESECTION*/
|
||||
template<typename T>
|
||||
struct Box {
|
||||
T* first;
|
||||
|
||||
Box(int x){
|
||||
first = new T(x);
|
||||
};
|
||||
};
|
||||
struct Inner {
|
||||
int val;
|
||||
//Coo() = default;
|
||||
Inner(int x){
|
||||
val = x;
|
||||
};
|
||||
};
|
||||
struct Base {
|
||||
virtual Box<Inner> test() = 0;
|
||||
};
|
||||
""".}
|
||||
|
||||
type
|
||||
Inner {.importcpp.} = object
|
||||
Base {.importcpp, inheritable.} = object
|
||||
Child = object of Base
|
||||
Box[T] {.importcpp, inheritable.} = object
|
||||
first: T
|
||||
|
||||
proc makeBox[T](x:int32): Box[T] {.importcpp:"Box<'0>(@)", constructor.}
|
||||
|
||||
proc test(self: Child): Box[Inner] {.virtual, asmnostackframe.} =
|
||||
let res {.exportc.} = makeBox[Inner](100)
|
||||
{.emit:"return res;".}
|
||||
|
||||
|
||||
discard Child().test()
|
||||
Reference in New Issue
Block a user