summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.h
AgeCommit message (Collapse)Author
2020-04-15LibJS: Support empty values in array expressionLinus Groh
2020-04-15LibJS: Implement void operatorLinus Groh
2020-04-13LibJS: Hoist variable declarations to the nearest relevant scopeAndreas Kling
"var" declarations are hoisted to the nearest function scope, while "let" and "const" are hoisted to the nearest block scope. This is done by the parser, which keeps two scope stacks, one stack for the current var scope and one for the current let/const scope. When the interpreter enters a scope, we walk all of the declarations and insert them into the variable environment. We don't support the temporal dead zone for let/const yet.
2020-04-13LibJS: Parse "this" as ThisExpressionStephan Unverwerth
2020-04-11LibJS: Make Function and CallFrame aware of their function nameLinus Groh
2020-04-08LibJS: rename JS::DeclarationType => JS::DeclarationKindEmanuele Torre
Many other parsers call it with this name. Also Type can be confusing in this context since the DeclarationType is not the type (number, string, etc.) of the variables that are being declared by the VariableDeclaration.
2020-04-07LibJS: Add SequenceExpression AST node (comma operator)Andreas Kling
This patch only adds the AST node, the parser doesn't create them yet.
2020-04-06LibJS: Add a PropertyName class that represents a string or a numberAndreas Kling
Now that we have two separate storages for Object properties depending on what kind of index they have, it's nice to have an abstraction that still allows us to say "here's a property name". We use PropertyName to always choose the optimal storage path directly while interpreting the AST. :^)
2020-04-05LibJS: Implement exponentiation (** operator)Linus Groh
2020-04-05LibJS: Rename BinaryOp::{Plus,Minus,Asterisk,Slash}Linus Groh
2020-04-05AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtrAndreas Kling
We were allowing this dangerous kind of thing: RefPtr<Base> base; RefPtr<Derived> derived = base; This patch changes the {Nonnull,}RefPtr constructors so this is no longer possible. To downcast one of these pointers, there is now static_ptr_cast<T>: RefPtr<Derived> derived = static_ptr_cast<Derived>(base); Fixing this exposed a ton of cowboy-downcasts in various places, which we're now forced to fix. :^)
2020-04-05LibJS: Add support for "continue" inside "for" statements :^)Andreas Kling
2020-04-04LibJS: Support VariableDeclaration with multiple declaratorsAndreas Kling
This patch adds support in the parser and interpreter for this: var a = 1, b = 2, c = a + b; VariableDeclaration is now a sequence of VariableDeclarators. :^)
2020-04-04LibJS: Add Declaration class to the ASTAndreas Kling
This is just here to make the AST class hierarchy more spec-like.
2020-04-04LibJS: Add support for do..while statementsAndreas Kling
2020-04-04LibJS: Rename WhileStatement::predicate() => body()Andreas Kling
This name matches other parsers.
2020-04-04LibJS: Add basic support for modulo (%) in binary expressionsAndreas Kling
2020-04-03LibJS: Implement ConditionalExpression (ternary "?:" operator)Andreas Kling
2020-04-03LibJS: Remove UndefinedLiteral, add undefined to global objectLinus Groh
There is no such thing as a "undefined literal" in JS - undefined is just a property on the global object with a value of undefined. This is pretty similar to NaN. var undefined = "foo"; is a perfectly fine AssignmentExpression :^)
2020-04-02LibJS: Implement unary plus / minusLinus Groh
2020-04-01LibJS: Reorganize computing of |this| for CallExpressionsAndreas Kling
This avoids executing the LHS of the object expression twice when doing a call on the result of an object expression.
2020-03-29LibJS: Implement basic execution of "switch" statementsAndreas Kling
The "break" keyword now unwinds to the nearest ScopeType::Breakable. There's no support for break labels yet, but we'll get there too.
2020-03-29LibJS: Lexer and parser support for "switch" statementsAndreas Kling
2020-03-28LibJS: Implement the "instanceof" operatorAndreas Kling
This operator walks the prototype chain of the RHS value and looks for a "prototype" property with the same value as the prototype of the LHS. This is pretty cool. :^)
2020-03-28LibJS: Implement basic support for the "new" keywordAndreas Kling
NewExpression mostly piggybacks on the existing CallExpression. The big difference is that "new" creates a new Object and passes it as |this| to the callee.
2020-03-24LibJS: Implement "throw"Andreas Kling
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.
2020-03-24LibJS: Parse "try", "catch" and "finally"Andreas Kling
This is the first step towards support exceptions. :^)
2020-03-23LibJS: Consume semicolon at the end of a statementAndreas Kling
A bunch of code was relying on this not happenind, in particular the parsing of "for" statements. Reorganized things so they work again.
2020-03-23LibJS: Implement "else" parsingAndreas Kling
We can now handle scripts with if/else in LibJS. Most of the changes are about fixing IfStatement to store the consequent and alternate node as Statements. Interpreter now also runs Statements, rather than running ScopeNodes.
2020-03-22LibJS: Use FlyString for identifiersAndreas Kling
This makes variable and property lookups a lot faster since comparing two FlyStrings is O(1).
2020-03-21LibJS: Parse "if" statementsAndreas Kling
This patch implements basic parsing of "if" statements. We don't yet support parsing "else", so I added a FIXME about that.
2020-03-21LibJS: Some optimizations for ObjectExpressionAndreas Kling
- move() the property map when constructing ObjectExpression instead of making a copy. - Use key+value iterators to traverse the property map in the execute() and dump() functions.
2020-03-21LibJS: Parse object expressions0xtechnobabble
2020-03-20LibJS: Parse computed MemberExpressionsAndreas Kling
MemberExpression comes in two flavors: computed: a[b] non-computed: a.b We can now parse both of the types. :^)
2020-03-20LibJS: Parse ArrayExpression and start implementing Array objectsAndreas Kling
Note that property lookup is not functional yet.
2020-03-19LibJS: Implement basic object property assignmentAndreas Kling
This is pretty naive, we just walk up the prototype chain and call any NativeProperty setter that we find. If we don't find one, we put/set the value as an own property of the object itself.
2020-03-19LibJS: Parse FunctionExpressionsAndreas Kling
FunctionExpression is mostly like FunctionDeclaration, except the name is optional. Share the parsing logic in parse_function_node<NodeType>. This allows us to do nice things like: document.addEventListener("DOMContentLoaded", function() { alert("Hello friends!"); });
2020-03-19LibJS: Add FunctionExpression AST nodeAndreas Kling
Most of the code is shared with FunctionDeclaration, so the shared bits are moved up into a common base called FunctionNode.
2020-03-19LibJS: Fix reference leak in ASTNode::append()Andreas Kling
Using make<T> like this would create an unadopted object whose refcount would never reach zero.
2020-03-18LibJS: Make the AST reference-countedAndreas Kling
This allows function objects to outlive the original parsed program without their ScopeNode disappearing.
2020-03-17LibJS: Implement typeof operatorConrad Pankoff
2020-03-16LibJS: Add "Heap" and "Runtime" subdirectoriesAndreas Kling
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16LibJS: Implement abstract equality and inequality0xtechnobabble
2020-03-16LibJS: Specify overridden functions with 'override'0xtechnobabble
2020-03-16LibJS: Implement null and undefined literals0xtechnobabble
2020-03-15LibJS: Add basic prototype supportAndreas Kling
Object will now traverse up the prototype chain when doing a get(). When a function is called on an object, that object will now also be the "this" value inside the function. This stuff is probably not very correct, but we will improve things as we go! :^)
2020-03-14LibJS/AST: Implement prefixed update expressions0xtechnobabble
2020-03-14LibJS: Rename BitNot -> BitwiseNot to match other bitwise operators0xtechnobabble
2020-03-14LibJS: Evaluate for statements in their own scope if necessary0xtechnobabble
We now evaluate for loops in their own scope if their init statement is a lexical declaration. Evaluating for loops in their own scope allow us to obtain expected behaviour, which means for example, that the block-scoped variables declared in a for statement will be limited to the scope of the for loop's body and statement and not to that of the current scope (i.e the one where the for statement was made)
2020-03-14LibJS: Add operator precedence parsingStephan Unverwerth
Obey precedence and associativity rules when parsing expressions with chained operators.