|
|
@ -104,8 +104,7 @@ public: |
|
|
|
StructDefinition(Location const& _location, |
|
|
|
ptr<ASTString> const& _name, |
|
|
|
vecptr<VariableDeclaration> const& _members) |
|
|
|
: Declaration(_location, _name), m_members(_members) |
|
|
|
{} |
|
|
|
: Declaration(_location, _name), m_members(_members) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
|
|
|
|
private: |
|
|
@ -119,8 +118,7 @@ class ParameterList : public ASTNode |
|
|
|
{ |
|
|
|
public: |
|
|
|
ParameterList(Location const& _location, vecptr<VariableDeclaration> const& _parameters) |
|
|
|
: ASTNode(_location), m_parameters(_parameters) |
|
|
|
{} |
|
|
|
: ASTNode(_location), m_parameters(_parameters) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
|
|
|
|
vecptr<VariableDeclaration> const& getParameters() { return m_parameters; } |
|
|
@ -138,8 +136,7 @@ public: |
|
|
|
ptr<Block> const& _body) |
|
|
|
: Declaration(_location, _name), m_isPublic(_isPublic), m_parameters(_parameters), |
|
|
|
m_isDeclaredConst(_isDeclaredConst), m_returnParameters(_returnParameters), |
|
|
|
m_body(_body) |
|
|
|
{} |
|
|
|
m_body(_body) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
|
|
|
|
bool isPublic() const { return m_isPublic; } |
|
|
@ -159,11 +156,9 @@ private: |
|
|
|
class VariableDeclaration: public Declaration |
|
|
|
{ |
|
|
|
public: |
|
|
|
VariableDeclaration(Location const& _location, |
|
|
|
ptr<TypeName> const& _type, |
|
|
|
VariableDeclaration(Location const& _location, ptr<TypeName> const& _type, |
|
|
|
ptr<ASTString> const& _name) |
|
|
|
: Declaration(_location, _name), m_typeName(_type) |
|
|
|
{} |
|
|
|
: Declaration(_location, _name), m_typeName(_type) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
|
|
|
|
bool isTypeGivenExplicitly() const { return m_typeName.get() != nullptr; } |
|
|
@ -196,8 +191,7 @@ class ElementaryTypeName : public TypeName |
|
|
|
{ |
|
|
|
public: |
|
|
|
explicit ElementaryTypeName(Location const& _location, Token::Value _type) |
|
|
|
: TypeName(_location), m_type(_type) |
|
|
|
{} |
|
|
|
: TypeName(_location), m_type(_type) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> toType() override { return Type::fromElementaryTypeName(m_type); } |
|
|
|
|
|
|
@ -210,8 +204,7 @@ class UserDefinedTypeName : public TypeName |
|
|
|
{ |
|
|
|
public: |
|
|
|
UserDefinedTypeName(Location const& _location, ptr<ASTString> const& _name) |
|
|
|
: TypeName(_location), m_name(_name) |
|
|
|
{} |
|
|
|
: TypeName(_location), m_name(_name) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> toType() override { return Type::fromUserDefinedTypeName(*this); } |
|
|
|
|
|
|
@ -229,8 +222,7 @@ class Mapping : public TypeName |
|
|
|
public: |
|
|
|
Mapping(Location const& _location, ptr<ElementaryTypeName> const& _keyType, |
|
|
|
ptr<TypeName> const& _valueType) |
|
|
|
: TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) |
|
|
|
{} |
|
|
|
: TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> toType() override { return Type::fromMapping(*this); } |
|
|
|
private: |
|
|
@ -263,8 +255,7 @@ class Block : public Statement |
|
|
|
{ |
|
|
|
public: |
|
|
|
Block(Location const& _location, vecptr<Statement> const& _statements) |
|
|
|
: Statement(_location), m_statements(_statements) |
|
|
|
{} |
|
|
|
: Statement(_location), m_statements(_statements) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
|
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
@ -278,8 +269,7 @@ public: |
|
|
|
IfStatement(Location const& _location, ptr<Expression> const& _condition, |
|
|
|
ptr<Statement> const& _trueBody, ptr<Statement> const& _falseBody) |
|
|
|
: Statement(_location), m_condition(_condition), |
|
|
|
m_trueBody(_trueBody), m_falseBody(_falseBody) |
|
|
|
{} |
|
|
|
m_trueBody(_trueBody), m_falseBody(_falseBody) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
private: |
|
|
@ -300,8 +290,7 @@ class WhileStatement : public BreakableStatement |
|
|
|
public: |
|
|
|
WhileStatement(Location const& _location, ptr<Expression> const& _condition, |
|
|
|
ptr<Statement> const& _body) |
|
|
|
: BreakableStatement(_location), m_condition(_condition), m_body(_body) |
|
|
|
{} |
|
|
|
: BreakableStatement(_location), m_condition(_condition), m_body(_body) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
private: |
|
|
@ -329,8 +318,7 @@ class Return : public Statement |
|
|
|
{ |
|
|
|
public: |
|
|
|
Return(Location const& _location, ptr<Expression> _expression) |
|
|
|
: Statement(_location), m_expression(_expression) |
|
|
|
{} |
|
|
|
: Statement(_location), m_expression(_expression) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
@ -346,8 +334,7 @@ class VariableDefinition : public Statement |
|
|
|
public: |
|
|
|
VariableDefinition(Location const& _location, ptr<VariableDeclaration> _variable, |
|
|
|
ptr<Expression> _value) |
|
|
|
: Statement(_location), m_variable(_variable), m_value(_value) |
|
|
|
{} |
|
|
|
: Statement(_location), m_variable(_variable), m_value(_value) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
@ -376,8 +363,7 @@ public: |
|
|
|
Assignment(Location const& _location, ptr<Expression> const& _leftHandSide, |
|
|
|
Token::Value _assignmentOperator, ptr<Expression> const& _rightHandSide) |
|
|
|
: Expression(_location), m_leftHandSide(_leftHandSide), |
|
|
|
m_assigmentOperator(_assignmentOperator), m_rightHandSide(_rightHandSide) |
|
|
|
{} |
|
|
|
m_assigmentOperator(_assignmentOperator), m_rightHandSide(_rightHandSide) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
@ -394,8 +380,7 @@ public: |
|
|
|
UnaryOperation(Location const& _location, Token::Value _operator, |
|
|
|
ptr<Expression> const& _subExpression, bool _isPrefix) |
|
|
|
: Expression(_location), m_operator(_operator), |
|
|
|
m_subExpression(_subExpression), m_isPrefix(_isPrefix) |
|
|
|
{} |
|
|
|
m_subExpression(_subExpression), m_isPrefix(_isPrefix) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
@ -412,8 +397,7 @@ class BinaryOperation : public Expression |
|
|
|
public: |
|
|
|
BinaryOperation(Location const& _location, ptr<Expression> const& _left, |
|
|
|
Token::Value _operator, ptr<Expression> const& _right) |
|
|
|
: Expression(_location), m_left(_left), m_operator(_operator), m_right(_right) |
|
|
|
{} |
|
|
|
: Expression(_location), m_left(_left), m_operator(_operator), m_right(_right) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
@ -432,8 +416,7 @@ class FunctionCall : public Expression |
|
|
|
public: |
|
|
|
FunctionCall(Location const& _location, ptr<Expression> const& _expression, |
|
|
|
vecptr<Expression> const& _arguments) |
|
|
|
: Expression(_location), m_expression(_expression), m_arguments(_arguments) |
|
|
|
{} |
|
|
|
: Expression(_location), m_expression(_expression), m_arguments(_arguments) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
private: |
|
|
@ -446,8 +429,7 @@ class MemberAccess : public Expression |
|
|
|
public: |
|
|
|
MemberAccess(Location const& _location, ptr<Expression> _expression, |
|
|
|
ptr<ASTString> const& _memberName) |
|
|
|
: Expression(_location), m_expression(_expression), m_memberName(_memberName) |
|
|
|
{} |
|
|
|
: Expression(_location), m_expression(_expression), m_memberName(_memberName) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
const ASTString& getMemberName() const { return *m_memberName; } |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
@ -461,8 +443,7 @@ class IndexAccess : public Expression |
|
|
|
public: |
|
|
|
IndexAccess(Location const& _location, ptr<Expression> const& _base, |
|
|
|
ptr<Expression> const& _index) |
|
|
|
: Expression(_location), m_base(_base), m_index(_index) |
|
|
|
{} |
|
|
|
: Expression(_location), m_base(_base), m_index(_index) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
private: |
|
|
@ -511,8 +492,7 @@ class Literal : public PrimaryExpression |
|
|
|
{ |
|
|
|
public: |
|
|
|
Literal(Location const& _location, Token::Value _token, ptr<ASTString> const& _value) |
|
|
|
: PrimaryExpression(_location), m_token(_token), m_value(_value) |
|
|
|
{} |
|
|
|
: PrimaryExpression(_location), m_token(_token), m_value(_value) {} |
|
|
|
virtual void accept(ASTVisitor& _visitor) override; |
|
|
|
virtual ptr<Type> checkTypeRequirements() override; |
|
|
|
|
|
|
|