Add isInstanceOf for generic procs to the macros module (#9730)
This commit is contained in:
parent
1cc8b7814d
commit
086676782a
8 changed files with 46 additions and 3 deletions
|
|
@ -656,7 +656,8 @@ type
|
|||
mNHint, mNWarning, mNError,
|
||||
mInstantiationInfo, mGetTypeInfo,
|
||||
mNimvm, mIntDefine, mStrDefine, mRunnableExamples,
|
||||
mException, mBuiltinType, mSymOwner, mUncheckedArray, mGetImplTransf
|
||||
mException, mBuiltinType, mSymOwner, mUncheckedArray, mGetImplTransf,
|
||||
mSymIsInstantiationOf
|
||||
|
||||
# things that we can evaluate safely at compile time, even if not asked for it:
|
||||
const
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ proc initDefines*(symbols: StringTableRef) =
|
|||
defineSymbol("nimUncheckedArrayTyp")
|
||||
defineSymbol("nimHasTypeof")
|
||||
defineSymbol("nimErrorProcCanHaveBody")
|
||||
|
||||
defineSymbol("nimHasInstantiationOfInMacro")
|
||||
defineSymbol("nimHasNilSeqs")
|
||||
for f in low(Feature)..high(Feature):
|
||||
defineSymbol("nimHas" & $f)
|
||||
|
|
|
|||
|
|
@ -960,6 +960,17 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
|||
regs[ra].node.flags.incl nfIsRef
|
||||
else:
|
||||
stackTrace(c, tos, pc, "node is not a symbol")
|
||||
of opcSymIsInstantiationOf:
|
||||
decodeBC(rkInt)
|
||||
let a = regs[rb].node
|
||||
let b = regs[rc].node
|
||||
if a.kind == nkSym and a.sym.kind in skProcKinds and
|
||||
b.kind == nkSym and b.sym.kind in skProcKinds:
|
||||
regs[ra].intVal =
|
||||
if sfFromGeneric in a.sym.flags and a.sym.owner == b.sym: 1
|
||||
else: 0
|
||||
else:
|
||||
stackTrace(c, tos, pc, "node is not a proc symbol")
|
||||
of opcEcho:
|
||||
let rb = instr.regB
|
||||
if rb == 1:
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@ type
|
|||
opcTypeTrait,
|
||||
opcMarshalLoad, opcMarshalStore,
|
||||
opcToNarrowInt,
|
||||
opcSymOwner
|
||||
opcSymOwner,
|
||||
opcSymIsInstantiationOf
|
||||
|
||||
TBlock* = object
|
||||
label*: PSym
|
||||
|
|
|
|||
|
|
@ -1148,6 +1148,7 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
|||
of mGetImpl: genUnaryABC(c, n, dest, opcGetImpl)
|
||||
of mGetImplTransf: genUnaryABC(c, n, dest, opcGetImplTransf)
|
||||
of mSymOwner: genUnaryABC(c, n, dest, opcSymOwner)
|
||||
of mSymIsInstantiationOf: genBinaryABC(c, n, dest, opcSymIsInstantiationOf)
|
||||
of mNChild: genBinaryABC(c, n, dest, opcNChild)
|
||||
of mNSetChild: genVoidABC(c, n, dest, opcNSetChild)
|
||||
of mNDel: genVoidABC(c, n, dest, opcNDel)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue