From 3c67e7208a8d68d44d3830133d90c3c122dc1347 Mon Sep 17 00:00:00 2001 From: Drahflow Date: Wed, 27 Nov 2019 00:17:43 +0100 Subject: Correctly handle non-trivial const add --- elymas/lib/sys/opt.ey | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey index af99e42..ce51615 100644 --- a/elymas/lib/sys/opt.ey +++ b/elymas/lib/sys/opt.ey @@ -337,10 +337,26 @@ /ge /jngeRel8 comparisonOperator ==:INLINEBLOCKGE /gt /jngRel8 comparisonOperator ==:INLINEBLOCKGT + { ==t + t 0 lt { # unboxed integer + 1 + } { + t ::rawObject sys .typed .type 0 eq + } ? * + } /isConstInt deffd + + { ==t + t 0 lt { # unboxed integer + t 9223372036854775807 band + } { + t ::rawObject + } ? * + } /getConstInt deffd + { ==e [ 0 e * STATICTYPED eq { 4 e * sys .typed .type 0 eq }' andif - 0 e * PUSH eq { 1 e * sys .typed .type 0 eq }' andif # FIXME: this is wrong! PUSH holds _address_ of integer, if at all + 0 e * PUSH eq { 1 e * isConstInt }' andif 0 e * STRINGSTAR eq ] any } /holdsInt deffd @@ -654,9 +670,11 @@ [ { 1 last * |add ::rawAddress eq { 0 secondLast * PUSH eq }' andif - { 1 secondLast * 128 lt }' andif + { 1 secondLast * isConstInt }' andif + { 1 secondLast * getConstInt 128 lt }' andif + { 1 secondLast * getConstInt 0 ge }' andif }' { - 1 secondLast * ==value + 1 secondLast * getConstInt ==value [ NATIVENOSCOPE [ /rdx :popqReg 63 /rdx :btrqImm8Reg -- cgit v1.2.3