mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-29 10:02:14 +00:00
Implement for-of statement (#205)
* merging for-of and for-in statement * remove unnecessary bytecodes Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
0d2d0bdaf2
commit
8850b0103f
9 changed files with 332 additions and 138 deletions
|
|
@ -1066,6 +1066,32 @@ Value ByteCodeInterpreter::interpret(ExecutionState& state, ByteCodeBlock* byteC
|
|||
NEXT_INSTRUCTION();
|
||||
}
|
||||
|
||||
DEFINE_OPCODE(GetIterator)
|
||||
:
|
||||
{
|
||||
GetIterator* code = (GetIterator*)programCounter;
|
||||
Value obj = registerFile[code->m_objectRegisterIndex];
|
||||
registerFile[code->m_registerIndex] = getIterator(state, obj);
|
||||
ADD_PROGRAM_COUNTER(GetIterator);
|
||||
NEXT_INSTRUCTION();
|
||||
}
|
||||
|
||||
DEFINE_OPCODE(IteratorStep)
|
||||
:
|
||||
{
|
||||
IteratorStep* code = (IteratorStep*)programCounter;
|
||||
Value iterator = registerFile[code->m_iterRegisterIndex];
|
||||
Value nextResult = iteratorStep(state, iterator);
|
||||
|
||||
if (nextResult.isFalse()) {
|
||||
programCounter = jumpTo(codeBuffer, code->m_forOfEndPosition);
|
||||
} else {
|
||||
registerFile[code->m_registerIndex] = iteratorValue(state, nextResult);
|
||||
ADD_PROGRAM_COUNTER(IteratorStep);
|
||||
}
|
||||
NEXT_INSTRUCTION();
|
||||
}
|
||||
|
||||
DEFINE_OPCODE(LoadRegexp)
|
||||
:
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue