зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1253137 - Baldr: update br_table syntax to match ml-proto (r=sunfish)
MozReview-Commit-ID: FDassUgTtWL
This commit is contained in:
Родитель
1fb28161ef
Коммит
a9eaaf6743
|
@ -2623,47 +2623,25 @@ ParseStore(WasmParseContext& c, Expr expr)
|
|||
}
|
||||
|
||||
static WasmAstBranchTable*
|
||||
ParseBranchTable(WasmParseContext& c)
|
||||
ParseBranchTable(WasmParseContext& c, WasmToken brTable)
|
||||
{
|
||||
WasmAstExpr* index = ParseExpr(c);
|
||||
if (!index)
|
||||
return nullptr;
|
||||
|
||||
if (!c.ts.match(WasmToken::OpenParen, c.error))
|
||||
return nullptr;
|
||||
if (!c.ts.match(WasmToken::Table, c.error))
|
||||
return nullptr;
|
||||
|
||||
WasmRefVector table(c.lifo);
|
||||
|
||||
while (c.ts.getIf(WasmToken::OpenParen)) {
|
||||
if (!c.ts.match(WasmToken::Br, c.error))
|
||||
return nullptr;
|
||||
|
||||
WasmRef target;
|
||||
if (!c.ts.matchRef(&target, c.error))
|
||||
return nullptr;
|
||||
|
||||
WasmRef target;
|
||||
while (c.ts.getIfRef(&target)) {
|
||||
if (!table.append(target))
|
||||
return nullptr;
|
||||
|
||||
if (!c.ts.match(WasmToken::CloseParen, c.error))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!c.ts.match(WasmToken::CloseParen, c.error))
|
||||
if (table.empty()) {
|
||||
c.ts.generateError(brTable, c.error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!c.ts.match(WasmToken::OpenParen, c.error))
|
||||
return nullptr;
|
||||
if (!c.ts.match(WasmToken::Br, c.error))
|
||||
return nullptr;
|
||||
WasmRef def = table.popCopy();
|
||||
|
||||
WasmRef def;
|
||||
if (!c.ts.matchRef(&def, c.error))
|
||||
return nullptr;
|
||||
|
||||
if (!c.ts.match(WasmToken::CloseParen, c.error))
|
||||
WasmAstExpr* index = ParseExpr(c);
|
||||
if (!index)
|
||||
return nullptr;
|
||||
|
||||
return new(c.lifo) WasmAstBranchTable(*index, def, Move(table));
|
||||
|
@ -2686,7 +2664,7 @@ ParseExprInsideParens(WasmParseContext& c)
|
|||
case WasmToken::BrIf:
|
||||
return ParseBranch(c, Expr::BrIf);
|
||||
case WasmToken::BrTable:
|
||||
return ParseBranchTable(c);
|
||||
return ParseBranchTable(c, token);
|
||||
case WasmToken::Call:
|
||||
return ParseCall(c, Expr::Call);
|
||||
case WasmToken::CallImport:
|
||||
|
|
|
@ -353,15 +353,13 @@ assertEq(wasmEvalText(`(module (func (result i32) (local i32)
|
|||
// ----------------------------------------------------------------------------
|
||||
// br_table
|
||||
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (br_table (i32.const 0) (table) (br 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
|
||||
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (block (br_table (i32.const 0) (table (br 2)) (br 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
|
||||
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (block (br_table (f32.const 0) (table) (br 0)))))'), TypeError, mismatchError("f32", "i32"));
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (br_table 0 (i32.const 0))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (block (br_table 2 0 (i32.const 0)))))'), TypeError, DEPTH_OUT_OF_BOUNDS);
|
||||
assertErrorMessage(() => wasmEvalText('(module (func (block (br_table 0 (f32.const 0)))))'), TypeError, mismatchError("f32", "i32"));
|
||||
|
||||
assertEq(wasmEvalText(`(module (func (result i32) (param i32)
|
||||
(block $default
|
||||
(br_table (get_local 0) (table) (br $default))
|
||||
(br_table $default (get_local 0))
|
||||
(return (i32.const 0))
|
||||
)
|
||||
(return (i32.const 1))
|
||||
|
@ -369,7 +367,7 @@ assertEq(wasmEvalText(`(module (func (result i32) (param i32)
|
|||
|
||||
assertEq(wasmEvalText(`(module (func (result i32) (param i32)
|
||||
(block $default
|
||||
(br_table (return (i32.const 1)) (table) (br $default))
|
||||
(br_table $default (return (i32.const 1)))
|
||||
(return (i32.const 0))
|
||||
)
|
||||
(return (i32.const 2))
|
||||
|
@ -378,7 +376,7 @@ assertEq(wasmEvalText(`(module (func (result i32) (param i32)
|
|||
assertEq(wasmEvalText(`(module (func (result i32) (param i32)
|
||||
(block $outer
|
||||
(block $inner
|
||||
(br_table (get_local 0) (table) (br $inner))
|
||||
(br_table $inner (get_local 0))
|
||||
(return (i32.const 0))
|
||||
)
|
||||
(return (i32.const 1))
|
||||
|
@ -391,11 +389,7 @@ var f = wasmEvalText(`(module (func (result i32) (param i32)
|
|||
(block $1
|
||||
(block $2
|
||||
(block $default
|
||||
(br_table
|
||||
(get_local 0)
|
||||
(table (br $0) (br $1) (br $2))
|
||||
(br $default)
|
||||
)
|
||||
(br_table $0 $1 $2 $default (get_local 0))
|
||||
)
|
||||
(return (i32.const -1))
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче