2020-03-07 18:42:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/NonnullOwnPtrVector.h>
|
2020-03-08 05:55:44 +00:00
|
|
|
#include <AK/OwnPtr.h>
|
2020-03-07 18:42:11 +00:00
|
|
|
#include <AK/String.h>
|
2020-03-12 11:22:13 +00:00
|
|
|
#include <AK/Vector.h>
|
2020-03-07 18:42:11 +00:00
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
#include <LibJS/Value.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class ASTNode {
|
|
|
|
public:
|
|
|
|
virtual ~ASTNode() {}
|
|
|
|
virtual const char* class_name() const = 0;
|
|
|
|
virtual Value execute(Interpreter&) const = 0;
|
|
|
|
virtual void dump(int indent) const;
|
2020-03-09 20:13:55 +00:00
|
|
|
virtual bool is_identifier() const { return false; }
|
2020-03-07 18:42:11 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ASTNode() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class Statement : public ASTNode {
|
|
|
|
};
|
|
|
|
|
|
|
|
class ErrorStatement final : public Statement {
|
|
|
|
public:
|
|
|
|
Value execute(Interpreter&) const { return js_undefined(); }
|
|
|
|
const char* class_name() const override { return "ErrorStatement"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class ExpressionStatement final : public Statement {
|
|
|
|
public:
|
|
|
|
ExpressionStatement(NonnullOwnPtr<Expression> expression)
|
|
|
|
: m_expression(move(expression))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Value execute(Interpreter&) const override;
|
|
|
|
const char* class_name() const override { return "ExpressionStatement"; }
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
NonnullOwnPtr<Expression> m_expression;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScopeNode : public Statement {
|
2020-03-07 18:42:11 +00:00
|
|
|
public:
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
T& append(Args&&... args)
|
|
|
|
{
|
|
|
|
auto child = make<T>(forward<Args>(args)...);
|
|
|
|
m_children.append(move(child));
|
|
|
|
return static_cast<T&>(m_children.last());
|
|
|
|
}
|
2020-03-11 18:27:43 +00:00
|
|
|
void append(NonnullOwnPtr<Statement> child)
|
|
|
|
{
|
|
|
|
m_children.append(move(child));
|
|
|
|
}
|
2020-03-07 18:42:11 +00:00
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
const NonnullOwnPtrVector<Statement>& children() const { return m_children; }
|
2020-03-07 18:42:11 +00:00
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ScopeNode() {}
|
|
|
|
|
|
|
|
private:
|
2020-03-11 18:27:43 +00:00
|
|
|
NonnullOwnPtrVector<Statement> m_children;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Program : public ScopeNode {
|
|
|
|
public:
|
|
|
|
Program() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "Program"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class BlockStatement : public ScopeNode {
|
|
|
|
public:
|
|
|
|
BlockStatement() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "BlockStatement"; }
|
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class FunctionDeclaration : public Statement {
|
2020-03-07 18:42:11 +00:00
|
|
|
public:
|
2020-03-12 11:22:13 +00:00
|
|
|
FunctionDeclaration(String name, NonnullOwnPtr<ScopeNode> body, Vector<String> parameters = {})
|
2020-03-07 18:42:11 +00:00
|
|
|
: m_name(move(name))
|
|
|
|
, m_body(move(body))
|
2020-03-12 11:22:13 +00:00
|
|
|
, m_parameters(move(parameters))
|
2020-03-07 18:42:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
String name() const { return m_name; }
|
|
|
|
const ScopeNode& body() const { return *m_body; }
|
2020-03-12 11:22:13 +00:00
|
|
|
const Vector<String>& parameters() const { return m_parameters; };
|
2020-03-07 18:42:11 +00:00
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "FunctionDeclaration"; }
|
|
|
|
|
|
|
|
String m_name;
|
|
|
|
NonnullOwnPtr<ScopeNode> m_body;
|
2020-03-12 11:22:13 +00:00
|
|
|
const Vector<String> m_parameters;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Expression : public ASTNode {
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class ErrorExpression final : public Expression {
|
|
|
|
public:
|
|
|
|
Value execute(Interpreter&) const { return js_undefined(); }
|
|
|
|
const char* class_name() const override { return "ErrorExpression"; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReturnStatement : public Statement {
|
2020-03-07 18:42:11 +00:00
|
|
|
public:
|
2020-03-11 18:27:43 +00:00
|
|
|
explicit ReturnStatement(OwnPtr<Expression> argument)
|
2020-03-07 18:42:11 +00:00
|
|
|
: m_argument(move(argument))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
const Expression* argument() const { return m_argument; }
|
2020-03-07 18:42:11 +00:00
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "ReturnStatement"; }
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
OwnPtr<Expression> m_argument;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class IfStatement : public Statement {
|
2020-03-08 05:58:58 +00:00
|
|
|
public:
|
2020-03-09 13:37:08 +00:00
|
|
|
IfStatement(NonnullOwnPtr<Expression> predicate, NonnullOwnPtr<ScopeNode> consequent, NonnullOwnPtr<ScopeNode> alternate)
|
2020-03-08 05:58:58 +00:00
|
|
|
: m_predicate(move(predicate))
|
|
|
|
, m_consequent(move(consequent))
|
|
|
|
, m_alternate(move(alternate))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const Expression& predicate() const { return *m_predicate; }
|
|
|
|
const ScopeNode& consequent() const { return *m_consequent; }
|
|
|
|
const ScopeNode& alternate() const { return *m_alternate; }
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "IfStatement"; }
|
|
|
|
|
|
|
|
NonnullOwnPtr<Expression> m_predicate;
|
|
|
|
NonnullOwnPtr<ScopeNode> m_consequent;
|
|
|
|
NonnullOwnPtr<ScopeNode> m_alternate;
|
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class WhileStatement : public Statement {
|
2020-03-08 19:22:21 +00:00
|
|
|
public:
|
|
|
|
WhileStatement(NonnullOwnPtr<Expression> predicate, NonnullOwnPtr<ScopeNode> body)
|
|
|
|
: m_predicate(move(predicate))
|
|
|
|
, m_body(move(body))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const Expression& predicate() const { return *m_predicate; }
|
|
|
|
const ScopeNode& body() const { return *m_body; }
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "WhileStatement"; }
|
|
|
|
|
|
|
|
NonnullOwnPtr<Expression> m_predicate;
|
|
|
|
NonnullOwnPtr<ScopeNode> m_body;
|
|
|
|
};
|
|
|
|
|
2020-03-07 18:42:11 +00:00
|
|
|
enum class BinaryOp {
|
|
|
|
Plus,
|
|
|
|
Minus,
|
2020-03-12 12:04:52 +00:00
|
|
|
Asterisk,
|
|
|
|
Slash,
|
2020-03-08 05:53:02 +00:00
|
|
|
TypedEquals,
|
2020-03-08 21:27:18 +00:00
|
|
|
TypedInequals,
|
2020-03-10 10:35:05 +00:00
|
|
|
GreaterThan,
|
2020-03-12 12:07:08 +00:00
|
|
|
GreaterThanEquals,
|
2020-03-10 10:35:05 +00:00
|
|
|
LessThan,
|
2020-03-12 12:07:08 +00:00
|
|
|
LessThanEquals,
|
2020-03-10 10:35:05 +00:00
|
|
|
BitwiseAnd,
|
|
|
|
BitwiseOr,
|
|
|
|
BitwiseXor,
|
|
|
|
LeftShift,
|
|
|
|
RightShift,
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BinaryExpression : public Expression {
|
|
|
|
public:
|
2020-03-10 10:48:49 +00:00
|
|
|
BinaryExpression(BinaryOp op, NonnullOwnPtr<Expression> lhs, NonnullOwnPtr<Expression> rhs)
|
2020-03-07 18:42:11 +00:00
|
|
|
: m_op(op)
|
|
|
|
, m_lhs(move(lhs))
|
|
|
|
, m_rhs(move(rhs))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "BinaryExpression"; }
|
|
|
|
|
|
|
|
BinaryOp m_op;
|
2020-03-10 10:48:49 +00:00
|
|
|
NonnullOwnPtr<Expression> m_lhs;
|
|
|
|
NonnullOwnPtr<Expression> m_rhs;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
2020-03-08 05:55:44 +00:00
|
|
|
enum class LogicalOp {
|
|
|
|
And,
|
|
|
|
Or,
|
|
|
|
};
|
|
|
|
|
|
|
|
class LogicalExpression : public Expression {
|
|
|
|
public:
|
|
|
|
LogicalExpression(LogicalOp op, NonnullOwnPtr<Expression> lhs, NonnullOwnPtr<Expression> rhs)
|
|
|
|
: m_op(op)
|
|
|
|
, m_lhs(move(lhs))
|
|
|
|
, m_rhs(move(rhs))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "LogicalExpression"; }
|
|
|
|
|
|
|
|
LogicalOp m_op;
|
|
|
|
NonnullOwnPtr<Expression> m_lhs;
|
2020-03-09 17:04:44 +00:00
|
|
|
NonnullOwnPtr<Expression> m_rhs;
|
2020-03-08 05:55:44 +00:00
|
|
|
};
|
|
|
|
|
2020-03-08 21:27:18 +00:00
|
|
|
enum class UnaryOp {
|
|
|
|
BitNot,
|
2020-03-09 17:04:44 +00:00
|
|
|
Not,
|
2020-03-08 21:27:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnaryExpression : public Expression {
|
|
|
|
public:
|
|
|
|
UnaryExpression(UnaryOp op, NonnullOwnPtr<Expression> lhs)
|
|
|
|
: m_op(op)
|
|
|
|
, m_lhs(move(lhs))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "UnaryExpression"; }
|
|
|
|
|
|
|
|
UnaryOp m_op;
|
|
|
|
NonnullOwnPtr<Expression> m_lhs;
|
|
|
|
};
|
|
|
|
|
2020-03-07 18:42:11 +00:00
|
|
|
class Literal : public Expression {
|
2020-03-12 11:19:11 +00:00
|
|
|
protected:
|
|
|
|
explicit Literal() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class BooleanLiteral final : public Literal {
|
|
|
|
public:
|
|
|
|
explicit BooleanLiteral(bool value)
|
|
|
|
: m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "BooleanLiteral"; }
|
|
|
|
|
|
|
|
bool m_value { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
class NumericLiteral final : public Literal {
|
2020-03-07 18:42:11 +00:00
|
|
|
public:
|
2020-03-12 11:19:11 +00:00
|
|
|
explicit NumericLiteral(double value)
|
|
|
|
: m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "NumericLiteral"; }
|
|
|
|
|
|
|
|
double m_value { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
class StringLiteral final : public Literal {
|
|
|
|
public:
|
|
|
|
explicit StringLiteral(String value)
|
2020-03-07 18:42:11 +00:00
|
|
|
: m_value(move(value))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-03-12 11:19:11 +00:00
|
|
|
virtual Value execute(Interpreter&) const override;
|
2020-03-07 18:42:11 +00:00
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
2020-03-12 11:19:11 +00:00
|
|
|
virtual const char* class_name() const override { return "StringLiteral"; }
|
2020-03-07 18:42:11 +00:00
|
|
|
|
2020-03-12 11:19:11 +00:00
|
|
|
String m_value;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
2020-03-10 10:48:49 +00:00
|
|
|
class Identifier final : public Expression {
|
2020-03-09 20:13:55 +00:00
|
|
|
public:
|
|
|
|
explicit Identifier(String string)
|
|
|
|
: m_string(move(string))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const String& string() const { return m_string; }
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
virtual bool is_identifier() const override { return true; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "Identifier"; }
|
|
|
|
|
|
|
|
String m_string;
|
|
|
|
};
|
|
|
|
|
2020-03-07 18:42:11 +00:00
|
|
|
class CallExpression : public Expression {
|
|
|
|
public:
|
2020-03-12 11:22:13 +00:00
|
|
|
explicit CallExpression(String name, NonnullOwnPtrVector<Expression> arguments = {})
|
2020-03-07 18:42:11 +00:00
|
|
|
: m_name(move(name))
|
2020-03-12 11:22:13 +00:00
|
|
|
, m_arguments(move(arguments))
|
2020-03-07 18:42:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
const String& name() const { return m_name; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "CallExpression"; }
|
|
|
|
|
|
|
|
String m_name;
|
2020-03-12 11:22:13 +00:00
|
|
|
const NonnullOwnPtrVector<Expression> m_arguments;
|
2020-03-07 18:42:11 +00:00
|
|
|
};
|
|
|
|
|
2020-03-09 20:13:55 +00:00
|
|
|
enum class AssignmentOp {
|
|
|
|
Assign,
|
2020-03-12 12:09:15 +00:00
|
|
|
PlusEquals,
|
|
|
|
MinusEquals,
|
|
|
|
AsteriskEquals,
|
|
|
|
SlashEquals,
|
2020-03-09 20:13:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AssignmentExpression : public Expression {
|
|
|
|
public:
|
2020-03-10 10:48:49 +00:00
|
|
|
AssignmentExpression(AssignmentOp op, NonnullOwnPtr<ASTNode> lhs, NonnullOwnPtr<Expression> rhs)
|
2020-03-09 20:13:55 +00:00
|
|
|
: m_op(op)
|
|
|
|
, m_lhs(move(lhs))
|
|
|
|
, m_rhs(move(rhs))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "AssignmentExpression"; }
|
|
|
|
|
|
|
|
AssignmentOp m_op;
|
|
|
|
NonnullOwnPtr<ASTNode> m_lhs;
|
2020-03-10 10:48:49 +00:00
|
|
|
NonnullOwnPtr<Expression> m_rhs;
|
2020-03-09 20:13:55 +00:00
|
|
|
};
|
|
|
|
|
2020-03-11 19:09:20 +00:00
|
|
|
enum class DeclarationType {
|
|
|
|
Var,
|
|
|
|
Let,
|
|
|
|
};
|
|
|
|
|
2020-03-11 18:27:43 +00:00
|
|
|
class VariableDeclaration : public Statement {
|
2020-03-09 20:13:55 +00:00
|
|
|
public:
|
2020-03-11 19:09:20 +00:00
|
|
|
VariableDeclaration(NonnullOwnPtr<Identifier> name, OwnPtr<Expression> initializer, DeclarationType declaration_type)
|
|
|
|
: m_declaration_type(declaration_type)
|
|
|
|
, m_name(move(name))
|
2020-03-09 20:13:55 +00:00
|
|
|
, m_initializer(move(initializer))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const Identifier& name() const { return *m_name; }
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "VariableDeclaration"; }
|
|
|
|
|
2020-03-11 19:09:20 +00:00
|
|
|
DeclarationType m_declaration_type;
|
2020-03-09 20:13:55 +00:00
|
|
|
NonnullOwnPtr<Identifier> m_name;
|
2020-03-10 10:48:49 +00:00
|
|
|
OwnPtr<Expression> m_initializer;
|
2020-03-09 20:13:55 +00:00
|
|
|
};
|
|
|
|
|
2020-03-09 20:28:31 +00:00
|
|
|
class ObjectExpression : public Expression {
|
|
|
|
public:
|
|
|
|
ObjectExpression() {}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "ObjectExpression"; }
|
|
|
|
};
|
|
|
|
|
2020-03-11 17:58:19 +00:00
|
|
|
class MemberExpression final : public Expression {
|
|
|
|
public:
|
|
|
|
MemberExpression(NonnullOwnPtr<Expression> object, NonnullOwnPtr<Expression> property)
|
|
|
|
: m_object(move(object))
|
|
|
|
, m_property(move(property))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Value execute(Interpreter&) const override;
|
|
|
|
virtual void dump(int indent) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "MemberExpression"; }
|
|
|
|
|
|
|
|
NonnullOwnPtr<Expression> m_object;
|
|
|
|
NonnullOwnPtr<Expression> m_property;
|
|
|
|
};
|
|
|
|
|
2020-03-07 18:42:11 +00:00
|
|
|
}
|