1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

LibJS: Integrate labels into the Interpreter

The interpreter now considers a statement or block's label when
considering whether or not to break. All statements can be labelled.
This commit is contained in:
Matthew Olsson 2020-05-28 13:36:59 -07:00 committed by Andreas Kling
parent 03615a7872
commit d52ea37717
6 changed files with 87 additions and 21 deletions

View file

@ -25,9 +25,13 @@ function bar() {
}
function foo() {
label:
for (var i = 0; i < 4; i++) {
break // semicolon inserted here
continue // semicolon inserted here
break label // semicolon inserted here
continue label // semicolon inserted here
}
var j // semicolon inserted here
@ -39,8 +43,25 @@ function foo() {
1;
var curly/* semicolon inserted here */}
function baz() {
let counter = 0;
let outer;
outer:
for (let i = 0; i < 5; ++i) {
for (let j = 0; j < 5; ++j) {
continue // semicolon inserted here
outer // semicolon inserted here
}
counter++;
}
return counter;
}
try {
assert(foo() === undefined);
assert(baz() === 5);
console.log("PASS");
} catch (e) {