diff options
author | Arne Döring <arne.doering@gmx.net> | 2019-11-07 14:40:44 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-11-07 14:40:44 +0100 |
commit | 94675c2378aed37a76899b4ab9cae9962e3d9542 (patch) | |
tree | 9d336de70d091be35ac27a11551507b58ca25bb5 /compiler/vm.nim | |
parent | 372b01711e2a4d3f0672f75aaa0895147b928cfc (diff) | |
download | Nim-94675c2378aed37a76899b4ab9cae9962e3d9542.tar.gz |
backtick and export marker handling in `eqIdent` (#12574)
Diffstat (limited to 'compiler/vm.nim')
-rw-r--r-- | compiler/vm.nim | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim index 4589d3a25..922208034 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1644,10 +1644,22 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of opcEqIdent: decodeBC(rkInt) # aliases for shorter and easier to understand code below - let aNode = regs[rb].node - let bNode = regs[rc].node - # these are cstring to prevent string copy, and cmpIgnoreStyle from - # takes cstring arguments + var aNode = regs[rb].node + var bNode = regs[rc].node + # Skipping both, `nkPostfix` and `nkAccQuoted` for both + # arguments. `nkPostfix` exists only to tag exported symbols + # and therefor it can be safely skipped. Nim has no postfix + # operator. `nkAccQuoted` is used to quote an identifier that + # wouldn't be allowed to use in an unquoted context. + if aNode.kind == nkPostfix: + aNode = aNode[1] + if aNode.kind == nkAccQuoted: + aNode = aNode[0] + if bNode.kind == nkPostfix: + bNode = bNode[1] + if bNode.kind == nkAccQuoted: + bNode = bNode[0] + # These vars are of type `cstring` to prevent unnecessary string copy. var aStrVal: cstring = nil var bStrVal: cstring = nil # extract strVal from argument ``a`` @@ -1674,7 +1686,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = bStrVal = bNode[0].sym.name.s.cstring else: discard - # set result regs[ra].intVal = if aStrVal != nil and bStrVal != nil: ord(idents.cmpIgnoreStyle(aStrVal, bStrVal, high(int)) == 0) |