parent
673c5990c6
commit
7b19217798
4 changed files with 36 additions and 12 deletions
|
|
@ -110,14 +110,14 @@ proc iiTablePut*(t: var TIITable, key, val: int)
|
||||||
|
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
proc skipConvAndClosure*(n: PNode): PNode =
|
proc skipConvCastAndClosure*(n: PNode): PNode =
|
||||||
result = n
|
result = n
|
||||||
while true:
|
while true:
|
||||||
case result.kind
|
case result.kind
|
||||||
of nkObjUpConv, nkObjDownConv, nkChckRange, nkChckRangeF, nkChckRange64,
|
of nkObjUpConv, nkObjDownConv, nkChckRange, nkChckRangeF, nkChckRange64,
|
||||||
nkClosure:
|
nkClosure:
|
||||||
result = result[0]
|
result = result[0]
|
||||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv:
|
of nkHiddenStdConv, nkHiddenSubConv, nkConv, nkCast:
|
||||||
result = result[1]
|
result = result[1]
|
||||||
else: break
|
else: break
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -527,14 +527,24 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
|
||||||
if n[^1].kind == nkSym and n[^1].sym.kind notin {skProc, skFunc}:
|
if n[^1].kind == nkSym and n[^1].sym.kind notin {skProc, skFunc}:
|
||||||
localError(c.config, n.info, "finalizer must be a direct reference to a proc")
|
localError(c.config, n.info, "finalizer must be a direct reference to a proc")
|
||||||
elif optTinyRtti in c.config.globalOptions:
|
elif optTinyRtti in c.config.globalOptions:
|
||||||
let fin = if n[^1].kind in {nkLambda, nkDo}: n[^1][namePos].sym
|
let nfin = skipConvCastAndClosure(n[^1])
|
||||||
else: n[^1].sym
|
let fin = case nfin.kind
|
||||||
# check if we converted this finalizer into a destructor already:
|
of nkSym: nfin.sym
|
||||||
let t = whereToBindTypeHook(c, fin.typ[1].skipTypes(abstractInst+{tyRef}))
|
of nkLambda, nkDo: nfin[namePos].sym
|
||||||
if t != nil and t.attachedOps[attachedDestructor] != nil and t.attachedOps[attachedDestructor].owner == fin:
|
else:
|
||||||
discard "already turned this one into a finalizer"
|
localError(c.config, n.info, "finalizer must be a direct reference to a proc")
|
||||||
else:
|
nil
|
||||||
bindTypeHook(c, turnFinalizerIntoDestructor(c, fin, n.info), n, attachedDestructor)
|
if fin != nil:
|
||||||
|
if fin.kind notin {skProc, skFunc}:
|
||||||
|
# calling convention is checked in codegen
|
||||||
|
localError(c.config, n.info, "finalizer must be a direct reference to a proc")
|
||||||
|
|
||||||
|
# check if we converted this finalizer into a destructor already:
|
||||||
|
let t = whereToBindTypeHook(c, fin.typ[1].skipTypes(abstractInst+{tyRef}))
|
||||||
|
if t != nil and t.attachedOps[attachedDestructor] != nil and t.attachedOps[attachedDestructor].owner == fin:
|
||||||
|
discard "already turned this one into a finalizer"
|
||||||
|
else:
|
||||||
|
bindTypeHook(c, turnFinalizerIntoDestructor(c, fin, n.info), n, attachedDestructor)
|
||||||
result = n
|
result = n
|
||||||
of mDestroy:
|
of mDestroy:
|
||||||
result = n
|
result = n
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ proc procVarCheck(n: PNode; conf: ConfigRef) =
|
||||||
proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
|
proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
|
||||||
let n = n.skipConv
|
let n = n.skipConv
|
||||||
if paramType.isNil or paramType.kind != tyTypeDesc:
|
if paramType.isNil or paramType.kind != tyTypeDesc:
|
||||||
procVarCheck skipConvAndClosure(n), tracked.config
|
procVarCheck skipConvCastAndClosure(n), tracked.config
|
||||||
#elif n.kind in nkSymChoices:
|
#elif n.kind in nkSymChoices:
|
||||||
# echo "came here"
|
# echo "came here"
|
||||||
let paramType = paramType.skipTypesOrNil(abstractInst)
|
let paramType = paramType.skipTypesOrNil(abstractInst)
|
||||||
|
|
@ -556,7 +556,7 @@ proc isTrival(caller: PNode): bool {.inline.} =
|
||||||
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved, mSwap}
|
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved, mSwap}
|
||||||
|
|
||||||
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) =
|
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) =
|
||||||
let a = skipConvAndClosure(n)
|
let a = skipConvCastAndClosure(n)
|
||||||
let op = a.typ
|
let op = a.typ
|
||||||
# assume indirect calls are taken here:
|
# assume indirect calls are taken here:
|
||||||
if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and not isTrival(caller):
|
if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and not isTrival(caller):
|
||||||
|
|
|
||||||
|
|
@ -34,3 +34,17 @@ echo x
|
||||||
|
|
||||||
import std/os
|
import std/os
|
||||||
discard getFileInfo(".")
|
discard getFileInfo(".")
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Issue #15707
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
type
|
||||||
|
JVMObject = ref object
|
||||||
|
proc freeJVMObject(o: JVMObject) =
|
||||||
|
discard
|
||||||
|
proc fromJObject(T: typedesc[JVMObject]): T =
|
||||||
|
result.new(cast[proc(r: T) {.nimcall.}](freeJVMObject))
|
||||||
|
|
||||||
|
discard JVMObject.fromJObject()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue