From 5038e9c9799d98ee941e20176cbf7408ba985eb8 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 22 Sep 2014 18:08:06 -0700 Subject: [PATCH] LNOT --- tools/emterpretify.py | 2 ++ tools/js-optimizer.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/emterpretify.py b/tools/emterpretify.py index 4a06c2c8f..8da81718d 100755 --- a/tools/emterpretify.py +++ b/tools/emterpretify.py @@ -30,6 +30,7 @@ OPCODES = { # l, lx, ly etc - one of 256 locals '9': 'SMOD', # [lx, ly, lz] lx = ly % lz (32-bit signed int) '10': 'UMOD', # [lx, ly, lz] lx = ly % lz (32-bit unsigned int) '12': 'NEG', # [lx, ly, 0] lx = -ly (int) + '13': 'LNOT', # [lx, ly, 0] ly = !ly (int) '18': 'EQ', # [lx, ly, lz] lx = ly == lz (32-bit int) '19': 'NE', # [lx, ly, lz] lx = ly != lz (32-bit int) '20': 'SLT', # [lx, ly, lz] lx = ly < lz (32-bit signed) @@ -107,6 +108,7 @@ CASES[ROPCODES['UDIV']] = get_access('lx') + ' = (' + get_coerced_access('ly', u CASES[ROPCODES['SMOD']] = get_access('lx') + ' = (' + get_coerced_access('ly') + ') % (' + get_coerced_access('lz') + ') | 0;' CASES[ROPCODES['UMOD']] = get_access('lx') + ' = (' + get_coerced_access('ly', unsigned=True) + ') % (' + get_coerced_access('lz', unsigned=True) + ') >>> 0;' CASES[ROPCODES['NEG']] = get_access('lx') + ' = -(' + get_coerced_access('ly') + ');' +CASES[ROPCODES['LNOT']] = get_access('lx') + ' = !(' + get_coerced_access('ly') + ');' CASES[ROPCODES['EQ']] = get_access('lx') + ' = (' + get_coerced_access('ly') + ') == (' + get_coerced_access('lz') + ') | 0;' CASES[ROPCODES['NE']] = get_access('lx') + ' = (' + get_coerced_access('ly') + ') != (' + get_coerced_access('lz') + ') | 0;' CASES[ROPCODES['SLT']] = get_access('lx') + ' = (' + get_coerced_access('ly') + ') < (' + get_coerced_access('lz') + ') | 0;' diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 58805008e..82188ed32 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1930,7 +1930,7 @@ function getCombinedSign(node1, node2, hint) { assert(sign1 != ASM_FLEXIBLE); return sign1; } - assert(sign1 === sign2); + assert(sign1 === sign2);//, JSON.stringify([node1, ' ', node2, sign1, sign2])); return sign1; } @@ -5835,6 +5835,7 @@ function emterpretify(ast) { var sign = detectSign(node[2]); return makeUnary(node, type, sign); } + case '!': return makeUnary(node, ASM_INT, ASM_SIGNED); default: throw 'ehh'; } throw 'todo'; @@ -6074,6 +6075,7 @@ function emterpretify(ast) { var opcode; switch(node[1]) { case '-': opcode = 'NEG'; break; + case '!': opcode = 'LNOT'; break; default: throw 'bad'; } var y = getReg(node[2]);