diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/algebra/data.spad.pamphlet | 8 | ||||
-rw-r--r-- | src/interp/g-opt.boot | 2 | ||||
-rw-r--r-- | src/interp/g-util.boot | 32 |
4 files changed, 37 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 55a45813..953e5257 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-07-21 Gabriel Dos Reis <gdr@cse.tamu.edu> + + * algebra/data.spad.pamphlet (Byte) [~]: Tidy. + (SystemNonNegativeInteger) [~]: Likewise. + * interp/g-util.boot: Better expansion of byte operations. + 2010-07-19 Gabriel Dos Reis <gdr@cs.tamu.edu> * interp/g-opt.boot ($VMsideEffectFreeOperators): Include diff --git a/src/algebra/data.spad.pamphlet b/src/algebra/data.spad.pamphlet index 39576863..06a73cf8 100644 --- a/src/algebra/data.spad.pamphlet +++ b/src/algebra/data.spad.pamphlet @@ -43,7 +43,7 @@ Byte(): Public == Private where import %bge: (%,%) -> Boolean from Foreign Builtin import %bitand: (%,%) -> % from Foreign Builtin import %bitior: (%,%) -> % from Foreign Builtin - import %bitnot: % -> % from Foreign Builtin + import %bcompl: % -> % from Foreign Builtin byte(x: NonNegativeInteger): % == per x sample = 0$Foreign(Builtin) @@ -64,7 +64,7 @@ Byte(): Public == Private where bitior(x,y) == %bitior(x,y) x /\ y == bitand(x,y) x \/ y == bitior(x,y) - ~ x == %bitnot x + ~ x == %bcompl x @ @@ -200,13 +200,13 @@ SystemNonNegativeInteger(N: PositiveInteger): Public == Private where import %bitnot: % -> % from Foreign Builtin min == per 0 - max == per((shift(1,N)-1)::NonNegativeInteger) + max == per((shift(1,N)-1) : NonNegativeInteger) sample == min bitand(x,y) == %bitand(x,y) bitior(x,y) == %bitior(x,y) x /\ y == bitand(x,y) x \/ y == bitior(x,y) - ~ x == %bitnot x + ~ x == per((shift(1,N) + rep %bitnot x) : NonNegativeInteger) @ diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot index 4d598b05..b9705f6b 100644 --- a/src/interp/g-opt.boot +++ b/src/interp/g-opt.boot @@ -473,7 +473,7 @@ $VMsideEffectFreeOperators == MINUSP GREATERP ZEROP ODDP FLOAT_-RADIX FLOAT FLOAT_-SIGN FLOAT_-DIGITS CGREATERP GGREATERP CHAR BOOLE GET BVEC_-GREATER %false %true %and %or %not %peq %ieq %ilt %ile %igt %ige %head %tail %integer? - %beq %blt %ble %bgt %bge %bitand %bitior %bitnot + %beq %blt %ble %bgt %bge %bitand %bitior %bitnot %bcompl %imul %iadd %isub %igcd %ilcm %ipow %imin %imax %ieven? %iodd? %iinc %feq %flt %fle %fgt %fge %fmul %fadd %fsub %fexp %fmin %fmax %float? %fpow %fdiv %fneg %i2f %fminval %fmaxval %fbase %fprec %ftrunc diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot index df6628f9..012a9ccc 100644 --- a/src/interp/g-util.boot +++ b/src/interp/g-util.boot @@ -230,6 +230,20 @@ expandPeq ['%peq,x,y] == expandBefore? ['%before?,x,y] == ['GGREATERP,expandToVMForm y,expandToVMForm x] +-- Byte operations +expandBle ['%ble,x,y] == + expandToVMForm ['%not,['%blt,y,x]] + +expandBgt ['%bgt,x,y] == + expandToVMForm ['%blt,y,x] + +expandBge ['%bge,x,y] == + expandToVMForm ['%not,['%blt,x,y]] + +expandBcompl ['%bcompl,x] == + integer? x => 255 - x + ['_+,256,['LOGNOT,expandToVMForm x]] + -- Integer operations expandIneg ['%ineg,x] == x := expandToVMForm x @@ -237,12 +251,16 @@ expandIneg ['%ineg,x] == ['_-,x] expandIlt ['%ilt,x,y] == - integer? x and x = 0 => ['PLUSP,expandToVMForm y] - integer? y and y = 0 => ['MINUSP,expandToVMForm x] + integer? x and x = 0 => + integer? y => y > 0 + ['PLUSP,expandToVMForm y] + integer? y and y = 0 => + integer? x => x < 0 + ['MINUSP,expandToVMForm x] ['_<,expandToVMForm x,expandToVMForm y] expandIgt ['%igt,x,y] == - expandFlt ['%ilt,y,x] + expandIlt ['%ilt,y,x] expandBitand ['%bitand,x,y] == ['BOOLE,'BOOLE_-AND,expandToVMForm x,expandToVMForm y] @@ -331,9 +349,6 @@ for x in [ -- byte operations ['%beq, :'byteEqual], ['%blt, :'byteLessThan], - ['%ble, :'byteLessEqual], - ['%bgt, :'byteGreaterThan], - ['%bge, :'byteGreaterEqual], -- unary integer operations. ['%iabs, :'ABS], @@ -417,6 +432,11 @@ for x in [ ['%loop, :function expandLoop], ['%return, :function expandReturn], + ['%ble, :function expandBle], + ['%bgt, :function expandBgt], + ['%bge, :function expandBge], + ['%bcompl, :function expandBcompl], + ['%igt, :function expandIgt], ['%ilt, :function expandIlt], ['%ineg, :function expandIneg], |