Fix operations on string as openarray in VM. (#6257)

* fix openarray.len for string as openArray in VM.
* fix openarray[idx] for string as openArray in VM.
* fix openarray[idx]=val for string as openArray in VM.
* add tests for passing string as openArray in VM.
* fix issue with NimNode.len
NimNode.len was also returning len for string literals.
also fix logic bug in if/elif chain.
This commit is contained in:
Parashurama 2017-09-15 13:35:57 +02:00 • committed by Andreas Rumpf
commit 88a5e9d88c
5 changed files with 69 additions and 8 deletions

View file

@ -234,6 +234,9 @@ const
slotSomeTemp* = slotTempUnknown
relativeJumps* = {opcTJmp, opcFJmp, opcJmp, opcJmpBack}
# flag is used to signal opcSeqLen if node is NimNode.
const nimNodeFlag* = 16
template opcode*(x: TInstr): TOpcode = TOpcode(x.uint32 and 0xff'u32)
template regA*(x: TInstr): TRegister = TRegister(x.uint32 shr 8'u32 and 0xff'u32)
template regB*(x: TInstr): TRegister = TRegister(x.uint32 shr 16'u32 and 0xff'u32)