|
@@ -30,6 +30,7 @@ static int returnState = 0;
|
|
static int breaks[BREAK_BUFFER];
|
|
static int breaks[BREAK_BUFFER];
|
|
static int breakIndex = 0;
|
|
static int breakIndex = 0;
|
|
static int forWhileStack = 0;
|
|
static int forWhileStack = 0;
|
|
|
|
+static int continueAt = 0;
|
|
|
|
|
|
static void cError(const char* format, ...) {
|
|
static void cError(const char* format, ...) {
|
|
va_list args;
|
|
va_list args;
|
|
@@ -580,7 +581,10 @@ static void cWhile() {
|
|
int ifP = cReserveInt();
|
|
int ifP = cReserveInt();
|
|
int breakStart = breakIndex;
|
|
int breakStart = breakIndex;
|
|
forWhileStack++;
|
|
forWhileStack++;
|
|
|
|
+ int oldContinue = continueAt;
|
|
|
|
+ continueAt = start;
|
|
cConsumeBody();
|
|
cConsumeBody();
|
|
|
|
+ continueAt = oldContinue;
|
|
forWhileStack--;
|
|
forWhileStack--;
|
|
cAddOperation(OP_GOTO);
|
|
cAddOperation(OP_GOTO);
|
|
cAddInt(start);
|
|
cAddInt(start);
|
|
@@ -622,7 +626,10 @@ static void cFor() {
|
|
cSetInt(beginBody, code->length);
|
|
cSetInt(beginBody, code->length);
|
|
int breakStart = breakIndex;
|
|
int breakStart = breakIndex;
|
|
forWhileStack++;
|
|
forWhileStack++;
|
|
|
|
+ int oldContinue = continueAt;
|
|
|
|
+ continueAt = startPerLoop;
|
|
cConsumeBody();
|
|
cConsumeBody();
|
|
|
|
+ continueAt = oldContinue;
|
|
forWhileStack--;
|
|
forWhileStack--;
|
|
cAddOperation(OP_GOTO);
|
|
cAddOperation(OP_GOTO);
|
|
cAddInt(startPerLoop);
|
|
cAddInt(startPerLoop);
|
|
@@ -641,6 +648,15 @@ static void cBreak() {
|
|
cConsumeToken(T_SEMICOLON);
|
|
cConsumeToken(T_SEMICOLON);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void cContinue() {
|
|
|
|
+ if(forWhileStack == 0) {
|
|
|
|
+ cError("continue without for or while on line %d", line);
|
|
|
|
+ }
|
|
|
|
+ cAddOperation(OP_GOTO);
|
|
|
|
+ cAddInt(continueAt);
|
|
|
|
+ cConsumeToken(T_SEMICOLON);
|
|
|
|
+}
|
|
|
|
+
|
|
static void cLine(Token t) {
|
|
static void cLine(Token t) {
|
|
cAddOperation(OP_LINE);
|
|
cAddOperation(OP_LINE);
|
|
cAddInt16(line);
|
|
cAddInt16(line);
|
|
@@ -652,6 +668,7 @@ static void cLine(Token t) {
|
|
case T_WHILE: cWhile(); break;
|
|
case T_WHILE: cWhile(); break;
|
|
case T_FOR: cFor(); break;
|
|
case T_FOR: cFor(); break;
|
|
case T_BREAK: cBreak(); break;
|
|
case T_BREAK: cBreak(); break;
|
|
|
|
+ case T_CONTINUE: cContinue(); break;
|
|
default: cLineExpression(t); cConsumeToken(T_SEMICOLON);
|
|
default: cLineExpression(t); cConsumeToken(T_SEMICOLON);
|
|
}
|
|
}
|
|
}
|
|
}
|