|
@@ -193,6 +193,10 @@ static int sIntMul(int a, int b) {
|
|
|
return a * b;
|
|
|
}
|
|
|
|
|
|
+static int sIntDiv(int a, int b) {
|
|
|
+ return b / a;
|
|
|
+}
|
|
|
+
|
|
|
static float sFloatAdd(float a, float b) {
|
|
|
return a + b;
|
|
|
}
|
|
@@ -205,6 +209,10 @@ static float sFloatMul(float a, float b) {
|
|
|
return a * b;
|
|
|
}
|
|
|
|
|
|
+static float sFloatDiv(float a, float b) {
|
|
|
+ return b / a;
|
|
|
+}
|
|
|
+
|
|
|
static void sBoolBinary(Script* sc, bool (*fInt)(int, int), bool (*fFloat)(float, float)) {
|
|
|
Object o[2];
|
|
|
if(sPop(sc, o) || sPop(sc, o + 1)) {
|
|
@@ -339,6 +347,7 @@ static void sConsumeInstruction(Script* sc) {
|
|
|
case OP_ADD: sIntBinary(sc, sIntAdd, sFloatAdd); break;
|
|
|
case OP_SUB: sIntBinary(sc, sIntSub, sFloatSub); break;
|
|
|
case OP_MUL: sIntBinary(sc, sIntMul, sFloatMul); break;
|
|
|
+ case OP_DIV: sIntBinary(sc, sIntDiv, sFloatDiv); break;
|
|
|
case OP_LESS: sBoolBinary(sc, sIntLess, sFloatLess); break;
|
|
|
case OP_GREATER: sBoolBinary(sc, sIntGreater, sFloatGreater); break;
|
|
|
case OP_EQUAL: sEqual(sc); break;
|
|
@@ -434,6 +443,7 @@ void sPrintCode(Script* sc) {
|
|
|
case OP_ADD: puts("Add"); break;
|
|
|
case OP_SUB: puts("Sub"); break;
|
|
|
case OP_MUL: puts("Mul"); break;
|
|
|
+ case OP_DIV: puts("Div"); break;
|
|
|
case OP_LESS: puts("Less"); break;
|
|
|
case OP_GREATER: puts("Greater"); break;
|
|
|
case OP_EQUAL: puts("Equal"); break;
|