eval: implemented logical binary operations

This commit is contained in:
2017-05-27 21:07:40 -04:00
parent fd60f3c91c
commit db19846539

View File

@@ -105,10 +105,10 @@ fn exec(instructions: Vec<i64>) -> i64 {
/* SUB */ 2 => binop(&mut stack, |x, y| x - y), /* SUB */ 2 => binop(&mut stack, |x, y| x - y),
/* MUL */ 3 => binop(&mut stack, |x, y| x * y), /* MUL */ 3 => binop(&mut stack, |x, y| x * y),
/* DIV */ 4 => binop(&mut stack, |x, y| x / y), /* DIV */ 4 => binop(&mut stack, |x, y| x / y),
/* MOD */ 5 => (), /* MOD */ 5 => binop(&mut stack, |x, y| x % y),
/* LT */ 6 => (), /* LT */ 6 => binop(&mut stack, |x, y| (x < y) as i64),
/* EQ */ 7 => (), /* EQ */ 7 => binop(&mut stack, |x, y| (x == y) as i64),
/* GT */ 8 => (), /* GT */ 8 => binop(&mut stack, |x, y| (x > y) as i64),
/* BR */ 9 => (), /* BR */ 9 => (),
/* BRT */ 10 => (), /* BRT */ 10 => (),
/* BRF */ 11 => (), /* BRF */ 11 => (),
@@ -120,8 +120,8 @@ fn exec(instructions: Vec<i64>) -> i64 {
/* PRN */ 17 => (), /* PRN */ 17 => (),
/* POP */ 18 => (), /* POP */ 18 => (),
/* HLT */ 19 => break, /* HLT */ 19 => break,
/* LEQ */ 20 => (), /* LEQ */ 20 => binop(&mut stack, |x, y| (x <= y) as i64),
/* GEQ */ 21 => (), /* GEQ */ 21 => binop(&mut stack, |x, y| (x >= y) as i64),
/* CAL */ 22 => (), /* CAL */ 22 => (),
/* RET */ 23 => (), /* RET */ 23 => (),
/* IPR */ 24 => (), /* IPR */ 24 => (),