mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibJS: Replace the custom unwind mechanism with completions :^)
This includes: - Parsing proper LabelledStatements with try_parse_labelled_statement() - Removing LabelableStatement - Implementing the LoopEvaluation semantics via loop_evaluation() in each IterationStatement subclass; and IterationStatement evaluation via {For,ForIn,ForOf,ForAwaitOf,While,DoWhile}Statement::execute() - Updating ReturnStatement, BreakStatement and ContinueStatement to return the appropriate completion types - Basically reimplementing TryStatement and SwitchStatement according to the spec, using completions - Honoring result completion types in AsyncBlockStart and OrdinaryCallEvaluateBody - Removing any uses of the VM unwind mechanism - most importantly, VM::throw_exception() now exclusively sets an exception and no longer triggers any unwinding mechanism. However, we already did a good job updating all of LibWeb and userland applications to not use it, and the few remaining uses elsewhere don't rely on unwinding AFAICT.
This commit is contained in:
parent
eed764e1dd
commit
9d0d3affd4
16 changed files with 512 additions and 279 deletions
|
@ -1,4 +1,4 @@
|
|||
test("labeled plain scope", () => {
|
||||
test("labelled plain scope", () => {
|
||||
notused: test: alsonotused: {
|
||||
let o = 1;
|
||||
expect(o).toBe(1);
|
||||
|
@ -16,7 +16,7 @@ test("break on plain scope from inner scope", () => {
|
|||
}
|
||||
});
|
||||
|
||||
test("labeled for loop with break", () => {
|
||||
test("labelled for loop with break", () => {
|
||||
let counter = 0;
|
||||
notused: outer: alsonotused: for (a of [1, 2, 3]) {
|
||||
for (b of [4, 5, 6]) {
|
||||
|
@ -27,7 +27,7 @@ test("labeled for loop with break", () => {
|
|||
expect(counter).toBe(4);
|
||||
});
|
||||
|
||||
test("labeled for loop with continue", () => {
|
||||
test("labelled for loop with continue", () => {
|
||||
let counter = 0;
|
||||
notused: outer: alsonotused: for (a of [1, 2, 3]) {
|
||||
for (b of [4, 5, 6]) {
|
||||
|
@ -38,6 +38,32 @@ test("labeled for loop with continue", () => {
|
|||
expect(counter).toBe(6);
|
||||
});
|
||||
|
||||
test("continue label statement is not an iteration statement", () => {
|
||||
expect(() =>
|
||||
eval(`
|
||||
outer: outer2: {
|
||||
for (;;) {
|
||||
continue outer;
|
||||
}
|
||||
}`)
|
||||
).toThrowWithMessage(
|
||||
SyntaxError,
|
||||
"labelled continue statement cannot use non iterating statement (line: 4, column: 18)"
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
eval(`
|
||||
for (;;) {
|
||||
outer: outer2: {
|
||||
continue outer;
|
||||
}
|
||||
}`)
|
||||
).toThrowWithMessage(
|
||||
SyntaxError,
|
||||
"labelled continue statement cannot use non iterating statement (line: 4, column: 18)"
|
||||
);
|
||||
});
|
||||
|
||||
test("break on try catch statement", () => {
|
||||
let entered = false;
|
||||
label1: label2: label3: try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue