|
@@ -157,13 +157,29 @@ static void sPreIncrement(Script* sc) {
|
|
} else if(o->type == OT_FLOAT) {
|
|
} else if(o->type == OT_FLOAT) {
|
|
o->data.floatValue++;
|
|
o->data.floatValue++;
|
|
} else {
|
|
} else {
|
|
- sError(sc, "object is not a number on line %d", sc->line);
|
|
|
|
|
|
+ sError(sc, "variable is not a number on line %d", sc->line);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
sPush(sc, o);
|
|
sPush(sc, o);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void sPostIncrement(Script* sc) {
|
|
|
|
+ int value = 0;
|
|
|
|
+ if(sReadInt(sc, &value)) {
|
|
|
|
+ Object* o = sc->stack + value + sc->stackVarIndex;
|
|
|
|
+ if(o->type == OT_INT) {
|
|
|
|
+ sPush(sc, o);
|
|
|
|
+ o->data.intValue++;
|
|
|
|
+ } else if(o->type == OT_FLOAT) {
|
|
|
|
+ sPush(sc, o);
|
|
|
|
+ o->data.floatValue++;
|
|
|
|
+ } else {
|
|
|
|
+ sError(sc, "variable is not a number on line %d", sc->line);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
static void sPushCodeInt(Script* sc) {
|
|
static void sPushCodeInt(Script* sc) {
|
|
int value = 0;
|
|
int value = 0;
|
|
if(sReadInt(sc, &value)) {
|
|
if(sReadInt(sc, &value)) {
|
|
@@ -406,6 +422,7 @@ static void sConsumeInstruction(Script* sc) {
|
|
case OP_SET: sSet(sc); break;
|
|
case OP_SET: sSet(sc); break;
|
|
case OP_GET: sGet(sc); break;
|
|
case OP_GET: sGet(sc); break;
|
|
case OP_PRE_INCREMENT: sPreIncrement(sc); break;
|
|
case OP_PRE_INCREMENT: sPreIncrement(sc); break;
|
|
|
|
+ case OP_POST_INCREMENT: sPostIncrement(sc); break;
|
|
case OP_ADD: sNumberBinary(sc, sIntAdd, sFloatAdd); break;
|
|
case OP_ADD: sNumberBinary(sc, sIntAdd, sFloatAdd); break;
|
|
case OP_SUB: sNumberBinary(sc, sIntSub, sFloatSub); break;
|
|
case OP_SUB: sNumberBinary(sc, sIntSub, sFloatSub); break;
|
|
case OP_MUL: sNumberBinary(sc, sIntMul, sFloatMul); break;
|
|
case OP_MUL: sNumberBinary(sc, sIntMul, sFloatMul); break;
|
|
@@ -508,6 +525,7 @@ void sPrintCode(Script* sc) {
|
|
case OP_SET: sPrintInt(sc, "Set"); break;
|
|
case OP_SET: sPrintInt(sc, "Set"); break;
|
|
case OP_GET: sPrintInt(sc, "Get"); break;
|
|
case OP_GET: sPrintInt(sc, "Get"); break;
|
|
case OP_PRE_INCREMENT: sPrintInt(sc, "Pre Increment"); break;
|
|
case OP_PRE_INCREMENT: sPrintInt(sc, "Pre Increment"); break;
|
|
|
|
+ case OP_POST_INCREMENT: sPrintInt(sc, "Post Increment"); break;
|
|
case OP_ADD: puts("Add"); break;
|
|
case OP_ADD: puts("Add"); break;
|
|
case OP_SUB: puts("Sub"); break;
|
|
case OP_SUB: puts("Sub"); break;
|
|
case OP_MUL: puts("Mul"); break;
|
|
case OP_MUL: puts("Mul"); break;
|