117 |
else |
else |
118 |
return 1; |
return 1; |
119 |
} |
} |
120 |
|
|
121 |
|
case STMT_SYNC: { |
122 |
|
#if DEBUG_SCRIPTVM_CORE |
123 |
|
_printIndents(depth); |
124 |
|
printf("-> STMT_SYNC\n"); |
125 |
|
#endif |
126 |
|
SyncBlock* syncStmt = (SyncBlock*) statement; |
127 |
|
if (syncStmt->statements()) |
128 |
|
return _requiredMaxStackSizeFor( syncStmt->statements() ) + 1; |
129 |
|
else |
130 |
|
return 1; |
131 |
|
} |
132 |
} |
} |
133 |
|
|
134 |
return 1; // actually just to avoid compiler warning |
return 1; // actually just to avoid compiler warning |
368 |
ctx->instructionsCount = 0; |
ctx->instructionsCount = 0; |
369 |
StmtFlags_t flags = STMT_SUCCESS; |
StmtFlags_t flags = STMT_SUCCESS; |
370 |
int instructionsCounter = 0; |
int instructionsCounter = 0; |
371 |
|
int synced = m_autoSuspend ? 0 : 1; |
372 |
|
|
373 |
int& frameIdx = ctx->stackFrame; |
int& frameIdx = ctx->stackFrame; |
374 |
if (frameIdx < 0) { // start condition ... |
if (frameIdx < 0) { // start condition ... |
445 |
ctx->pushStack( |
ctx->pushStack( |
446 |
whileStmt->statements() |
whileStmt->statements() |
447 |
); |
); |
448 |
if (flags == STMT_SUCCESS && m_autoSuspend && |
if (flags == STMT_SUCCESS && !synced && |
449 |
instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT) |
instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT) |
450 |
{ |
{ |
451 |
flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED); |
flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED); |
454 |
} else ctx->popStack(); |
} else ctx->popStack(); |
455 |
break; |
break; |
456 |
} |
} |
457 |
|
|
458 |
|
case STMT_SYNC: { |
459 |
|
#if DEBUG_SCRIPTVM_CORE |
460 |
|
_printIndents(frameIdx); |
461 |
|
printf("-> STMT_SYNC\n"); |
462 |
|
#endif |
463 |
|
SyncBlock* syncStmt = (SyncBlock*) frame.statement; |
464 |
|
if (!frame.subindex++ && syncStmt->statements()) { |
465 |
|
++synced; |
466 |
|
ctx->pushStack( |
467 |
|
syncStmt->statements() |
468 |
|
); |
469 |
|
} else { |
470 |
|
ctx->popStack(); |
471 |
|
--synced; |
472 |
|
} |
473 |
|
break; |
474 |
|
} |
475 |
} |
} |
476 |
|
|
477 |
if (flags == STMT_SUCCESS && m_autoSuspend && |
if (flags == STMT_SUCCESS && !synced && |
478 |
instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD) |
instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD) |
479 |
{ |
{ |
480 |
flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED); |
flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED); |