|
@@ -228,12 +228,12 @@ static void sPushCodeFloat(Script* sc) {
|
|
|
sPushFloat(sc, value);
|
|
|
}
|
|
|
|
|
|
-static void sNumberBinary(Script* sc, int (*fInt)(int, int), float (*fFloat)(float, float)) {
|
|
|
+static void sNumberBinary(Script* sc, int (*fInt)(Script*, int, int), float (*fFloat)(float, float)) {
|
|
|
Object o[2];
|
|
|
if(sPop(sc, o) || sPop(sc, o + 1)) {
|
|
|
return;
|
|
|
} else if(o[0].type == OT_INT && o[1].type == OT_INT) {
|
|
|
- sPushInt(sc, fInt(o[0].data.intValue, o[1].data.intValue));
|
|
|
+ sPushInt(sc, fInt(sc, o[0].data.intValue, o[1].data.intValue));
|
|
|
} else if(o[0].type == OT_FLOAT && o[1].type == OT_INT) {
|
|
|
sPushFloat(sc, fFloat(o[0].data.floatValue, o[1].data.intValue));
|
|
|
} else if(o[0].type == OT_INT && o[1].type == OT_FLOAT) {
|
|
@@ -245,30 +245,41 @@ static void sNumberBinary(Script* sc, int (*fInt)(int, int), float (*fFloat)(flo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void sIntBinary(Script* sc, int (*f)(int, int)) {
|
|
|
+static void sIntBinary(Script* sc, int (*f)(Script*, int, int)) {
|
|
|
Object o[2];
|
|
|
if(!sPop(sc, o) && !sPop(sc, o + 1) && sCheckType(sc, o, OT_INT) && sCheckType(sc, o + 1, OT_INT)) {
|
|
|
- sPushInt(sc, f(o[0].data.intValue, o[1].data.intValue));
|
|
|
+ sPushInt(sc, f(sc, o[0].data.intValue, o[1].data.intValue));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int sIntAdd(int a, int b) {
|
|
|
+static int sIntAdd(Script* sc, int a, int b) {
|
|
|
+ (void)sc;
|
|
|
return a + b;
|
|
|
}
|
|
|
|
|
|
-static int sIntSub(int a, int b) {
|
|
|
+static int sIntSub(Script* sc, int a, int b) {
|
|
|
+ (void)sc;
|
|
|
return b - a;
|
|
|
}
|
|
|
|
|
|
-static int sIntMul(int a, int b) {
|
|
|
+static int sIntMul(Script* sc, int a, int b) {
|
|
|
+ (void)sc;
|
|
|
return a * b;
|
|
|
}
|
|
|
|
|
|
-static int sIntDiv(int a, int b) {
|
|
|
+static int sIntDiv(Script* sc, int a, int b) {
|
|
|
+ if(a == 0) {
|
|
|
+ sError(sc, "division by 0 on line %d", sc->line);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
return b / a;
|
|
|
}
|
|
|
|
|
|
-static int sMod(int a, int b) {
|
|
|
+static int sMod(Script* sc, int a, int b) {
|
|
|
+ if(a == 0) {
|
|
|
+ sError(sc, "module of 0 on line %d", sc->line);
|
|
|
+ return b;
|
|
|
+ }
|
|
|
return b % a;
|
|
|
}
|
|
|
|