summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
author0xtechnobabble <0xtechnobabble@protonmail.com>2020-03-21 02:29:00 +0200
committerAndreas Kling <kling@serenityos.org>2020-03-21 10:08:58 +0100
commitbc002f807a122bcd91498f87b970671a2d38bbb8 (patch)
treef7ddcffa5176469821647dde1d2f33f2238a4330 /Libraries/LibJS/AST.cpp
parentc64b5e73f5d78b887c9e9358bccc1524858dbc6f (diff)
downloadserenity-bc002f807a122bcd91498f87b970671a2d38bbb8.zip
LibJS: Parse object expressions
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r--Libraries/LibJS/AST.cpp12
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