This commit is contained in:
Alon Zakai 2014-09-22 18:08:06 -07:00
Родитель 412eaa4337
Коммит 5038e9c979
2 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -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;'

Просмотреть файл

@ -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]);