mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 10:27:36 +00:00
LibJS: Parse object expressions
This commit is contained in:
parent
c64b5e73f5
commit
bc002f807a
7 changed files with 48 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue