зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459845 - Part 1: Fix the comment for IfThenElseEmitter with cascading if-else. r=Yoric
This commit is contained in:
Родитель
0eaac17a4a
Коммит
766c2a0669
|
@ -1921,8 +1921,8 @@ class MOZ_STACK_CLASS TryEmitter
|
||||||
|
|
||||||
// Class for emitting bytecode for blocks like if-then-else.
|
// Class for emitting bytecode for blocks like if-then-else.
|
||||||
//
|
//
|
||||||
// This class can be used to emit single if-then-else block. Cascading
|
// This class can be used to emit single if-then-else block, or cascading
|
||||||
// elseif's need multiple instances of this class.
|
// else-if blocks.
|
||||||
//
|
//
|
||||||
// Usage: (check for the return value is omitted for simplicity)
|
// Usage: (check for the return value is omitted for simplicity)
|
||||||
//
|
//
|
||||||
|
@ -1942,6 +1942,23 @@ class MOZ_STACK_CLASS TryEmitter
|
||||||
// emit(else_block);
|
// emit(else_block);
|
||||||
// ifThenElse.emitEnd();
|
// ifThenElse.emitEnd();
|
||||||
//
|
//
|
||||||
|
// `if (c1) b1 else if (c2) b2 else if (c3) b3 else b4`
|
||||||
|
// IfThenElseEmitter ifThenElse(this);
|
||||||
|
// emit(c1);
|
||||||
|
// ifThenElse.emitIfElse();
|
||||||
|
// emit(b1);
|
||||||
|
// ifThenElse.emitElse();
|
||||||
|
// emit(c2);
|
||||||
|
// ifThenElse.emitIfElse();
|
||||||
|
// emit(b2);
|
||||||
|
// ifThenElse.emitElse();
|
||||||
|
// emit(c3);
|
||||||
|
// ifThenElse.emitIfElse();
|
||||||
|
// emit(b3);
|
||||||
|
// ifThenElse.emitElse();
|
||||||
|
// emit(b4);
|
||||||
|
// ifThenElse.emitEnd();
|
||||||
|
//
|
||||||
// `cond ? then_expr : else_expr`
|
// `cond ? then_expr : else_expr`
|
||||||
// IfThenElseEmitter condElse(this);
|
// IfThenElseEmitter condElse(this);
|
||||||
// emit(cond);
|
// emit(cond);
|
||||||
|
@ -1955,7 +1972,10 @@ class MOZ_STACK_CLASS IfThenElseEmitter
|
||||||
{
|
{
|
||||||
BytecodeEmitter* bce_;
|
BytecodeEmitter* bce_;
|
||||||
|
|
||||||
|
// Jump around the then clause, to the beginning of the else clause.
|
||||||
JumpList jumpAroundThen_;
|
JumpList jumpAroundThen_;
|
||||||
|
|
||||||
|
// Jump around the else clause, to the end of the entire branch.
|
||||||
JumpList jumpsAroundElse_;
|
JumpList jumpsAroundElse_;
|
||||||
|
|
||||||
// The stack depth before emitting the then block.
|
// The stack depth before emitting the then block.
|
||||||
|
@ -1972,17 +1992,21 @@ class MOZ_STACK_CLASS IfThenElseEmitter
|
||||||
|
|
||||||
// The state of this emitter.
|
// The state of this emitter.
|
||||||
//
|
//
|
||||||
// +-------+ emitIf +----+ emitEnd +-----+
|
// +-------+ emitCond +------+ emitElse +------+ emitEnd +-----+
|
||||||
// | Start |-+----------->| If |-------------------------+-------->| End |
|
// | Start |-+--------->| Cond |--------->| Else |---->+------->| End |
|
||||||
// +-------+ | +----+ | +-----+
|
// +-------+ | +------+ +------+ ^ +-----+
|
||||||
// | |
|
// | |
|
||||||
// | emitCond +------+ emitElse +------+ |
|
// v emitIf +----+ |
|
||||||
// +----------->| Cond |---+--------->| Else |-+
|
// +->+------->| If |-------------------------->+
|
||||||
// | +------+ | +------+
|
// ^ | +----+ ^
|
||||||
// | |
|
// | | |
|
||||||
// | emitIfElse +--------+ |
|
// | | |
|
||||||
// +----------->| IfElse |-+
|
// | | |
|
||||||
// +--------+
|
// | | emitIfElse +--------+ emitElse +------+ |
|
||||||
|
// | +----------->| IfElse |--------->| Else |-+
|
||||||
|
// | +--------+ +------+ |
|
||||||
|
// | |
|
||||||
|
// +--------------------------------------------+
|
||||||
enum State {
|
enum State {
|
||||||
// The initial state.
|
// The initial state.
|
||||||
Start,
|
Start,
|
||||||
|
@ -1996,7 +2020,7 @@ class MOZ_STACK_CLASS IfThenElseEmitter
|
||||||
// After calling emitIfElse.
|
// After calling emitIfElse.
|
||||||
IfElse,
|
IfElse,
|
||||||
|
|
||||||
// After calling Else.
|
// After calling emitElse.
|
||||||
Else,
|
Else,
|
||||||
|
|
||||||
// After calling emitEnd.
|
// After calling emitEnd.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче