all repos — min @ 4aaafe8d8a41c766be7b00c0369a1d3524be81c2

A small but practical concatenative programming language.

code cleanup + added 'bitnot`, `bitor` and `bitxor`
drkameleon yaniszaf@gmail.com
Thu, 21 Jan 2021 13:49:52 +0100
commit

4aaafe8d8a41c766be7b00c0369a1d3524be81c2

parent

2cb51fc988eaca98156fe6f1fc6755a30c8ce074

1 files changed, 23 insertions(+), 3 deletions(-)

jump to
M minpkg/lib/min_binary.nimminpkg/lib/min_binary.nim

@@ -7,12 +7,32 @@

proc binary_module*(i: In)= let def = i.define() - + def.symbol("bitand") do (i: In): let vals = i.expect("int","int") let b = vals[0] let a = vals[1] - i.push newVal(a.intVal mod b.intVal) + i.push newVal(a.intVal and b.intVal) + + def.symbol("bitnot") do (i: In): + let vals = i.expect("int") + let a = vals[0] + + i.push newVal(not a.intVal) - def.finalize("binary") + def.symbol("bitor") do (i: In): + let vals = i.expect("int","int") + let b = vals[0] + let a = vals[1] + + i.push newVal(a.intVal or b.intVal) + + def.symbol("bitxor") do (i: In): + let vals = i.expect("int","int") + let b = vals[0] + let a = vals[1] + + i.push newVal(a.intVal xor b.intVal) + + def.finalize("binary")