1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibJS: Implement "throw"

You can now throw an expression to the nearest catcher! :^)

To support throwing arbitrary values, I added an Exception class that
sits as a wrapper around whatever is thrown. In the future it will be
a logical place to store a call stack.
This commit is contained in:
Andreas Kling 2020-03-24 22:03:50 +01:00
parent db024a9cb1
commit faddf3a1db
13 changed files with 160 additions and 7 deletions

View file

@ -62,6 +62,7 @@ Lexer::Lexer(StringView source)
s_keywords.set("null", TokenType::NullLiteral);
s_keywords.set("undefined", TokenType::UndefinedLiteral);
s_keywords.set("return", TokenType::Return);
s_keywords.set("throw", TokenType::Throw);
s_keywords.set("true", TokenType::BoolLiteral);
s_keywords.set("try", TokenType::Try);
s_keywords.set("typeof", TokenType::Typeof);