VM: support importc var, ptr/pointer types, cast int <=> ptr/pointer (#12877)

* VM: allow certain hardcoded special var variables at CT
* VM: allow all importc var, cast[int](ptr)
* fix tests tests/vm/tstaticprintseq.nim, tests/cpp/t8241.nim
* VM: == works for ptr/pointer nodes
* bugfix: ==, cast now also works for pointer, not just ptr
* VM supports cast PtrLikeKinds <=> PtrLikeKinds / int
* improve cname handling
* fixup + bug fix
* VM: support cast from ref to int
* address comment: opcLdGlobalDeref => opcLdGlobalDerefFFI
* defensive check against typ == nil
This commit is contained in:
Timothee Cour 2020-01-05 00:11:29 -08:00 • committed by Andreas Rumpf
commit 13c08f3ab4
7 changed files with 199 additions and 35 deletions

View file

@ -63,6 +63,8 @@ type
opcCastIntToFloat64, # int and float must be of the same byte size
opcCastFloatToInt32, # int and float must be of the same byte size
opcCastFloatToInt64, # int and float must be of the same byte size
opcCastPtrToInt,
opcCastIntToPtr,
opcFastAsgnComplex,
opcNodeToReg,
@ -169,6 +171,8 @@ type
opcAsgnConst, # dest = copy(constants[Bx])
opcLdGlobal, # dest = globals[Bx]
opcLdGlobalAddr, # dest = addr(globals[Bx])
opcLdGlobalDerefFFI, # dest = globals[Bx][]
opcLdGlobalAddrDerefFFI, # globals[Bx][] = ...
opcLdImmInt, # dest = immediate value
opcNBindSym, opcNDynBindSym,