diff options
author | 0xtechnobabble <0xtechnobabble@protonmail.com> | 2020-03-21 02:29:00 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-21 10:08:58 +0100 |
commit | bc002f807a122bcd91498f87b970671a2d38bbb8 (patch) | |
tree | f7ddcffa5176469821647dde1d2f33f2238a4330 /Libraries/LibJS/AST.cpp | |
parent | c64b5e73f5d78b887c9e9358bccc1524858dbc6f (diff) | |
download | serenity-bc002f807a122bcd91498f87b970671a2d38bbb8.zip |
LibJS: Parse object expressions
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r-- | Libraries/LibJS/AST.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 2a077f8133..95cb322e74 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -623,6 +623,11 @@ void VariableDeclaration::dump(int indent) const void ObjectExpression::dump(int indent) const { ASTNode::dump(indent); + for (String property_key : m_properties.keys()) { + print_indent(indent + 1); + printf("%s: ", property_key.characters()); + m_properties.get(property_key).value()->dump(0); + } } void ExpressionStatement::dump(int indent) const @@ -633,7 +638,12 @@ void ExpressionStatement::dump(int indent) const Value ObjectExpression::execute(Interpreter& interpreter) const { - return interpreter.heap().allocate<Object>(); + auto object = interpreter.heap().allocate<Object>(); + for (String property_key : m_properties.keys()) { + object->put(property_key, m_properties.get(property_key).value()->execute(interpreter)); + } + + return object; } void MemberExpression::dump(int indent) const |