Replace type expression with traits
This commit is contained in:
101
boot/ast.cc
101
boot/ast.cc
@ -44,30 +44,25 @@ namespace boot
|
||||
definition->body().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(call_expression *expression)
|
||||
void empty_visitor::visit(procedure_call *call)
|
||||
{
|
||||
for (struct expression *const argument : expression->arguments)
|
||||
for (expression *const argument : call->arguments)
|
||||
{
|
||||
argument->accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
void empty_visitor::visit(traits_expression *trait)
|
||||
{
|
||||
trait->type().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(cast_expression *expression)
|
||||
{
|
||||
expression->target().accept(this);
|
||||
expression->value().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(type_expression *expression)
|
||||
{
|
||||
expression->body().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(call_statement *statement)
|
||||
{
|
||||
statement->body().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(assign_statement *statement)
|
||||
{
|
||||
statement->rvalue().accept(this);
|
||||
@ -249,13 +244,11 @@ namespace boot
|
||||
return this->source_position;
|
||||
}
|
||||
|
||||
statement::statement(const struct position position)
|
||||
: node(position)
|
||||
statement::statement()
|
||||
{
|
||||
}
|
||||
|
||||
expression::expression(const struct position position)
|
||||
: node(position)
|
||||
expression::expression()
|
||||
{
|
||||
}
|
||||
|
||||
@ -539,13 +532,12 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
literal::literal(const struct position position)
|
||||
: expression(position)
|
||||
literal::literal()
|
||||
{
|
||||
}
|
||||
|
||||
defer_statement::defer_statement(const struct position position)
|
||||
: statement(position)
|
||||
: node(position)
|
||||
{
|
||||
}
|
||||
|
||||
@ -562,13 +554,12 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
designator_expression::designator_expression(const struct position position)
|
||||
: expression(position)
|
||||
designator_expression::designator_expression()
|
||||
{
|
||||
}
|
||||
|
||||
variable_expression::variable_expression(const struct position position, const std::string& name)
|
||||
: designator_expression(position), m_name(name)
|
||||
: node(position), name(name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -577,11 +568,6 @@ namespace boot
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& variable_expression::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
variable_expression *variable_expression::is_variable()
|
||||
{
|
||||
return this;
|
||||
@ -589,7 +575,7 @@ namespace boot
|
||||
|
||||
array_access_expression::array_access_expression(const struct position position,
|
||||
expression *base, expression *index)
|
||||
: designator_expression(position), m_base(base), m_index(index)
|
||||
: node(position), m_base(base), m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
@ -621,7 +607,7 @@ namespace boot
|
||||
|
||||
field_access_expression::field_access_expression(const struct position position,
|
||||
expression *base, const std::string& field)
|
||||
: designator_expression(position), m_base(base), m_field(field)
|
||||
: node(position), m_base(base), m_field(field)
|
||||
{
|
||||
}
|
||||
|
||||
@ -652,7 +638,7 @@ namespace boot
|
||||
|
||||
dereference_expression::dereference_expression(const struct position position,
|
||||
expression *base)
|
||||
: designator_expression(position), m_base(base)
|
||||
: node(position), m_base(base)
|
||||
{
|
||||
}
|
||||
|
||||
@ -678,7 +664,7 @@ namespace boot
|
||||
|
||||
binary_expression::binary_expression(const struct position position, expression *lhs,
|
||||
expression *rhs, const binary_operator operation)
|
||||
: expression(position), m_lhs(lhs), m_rhs(rhs), m_operator(operation)
|
||||
: node(position), m_lhs(lhs), m_rhs(rhs), m_operator(operation)
|
||||
{
|
||||
}
|
||||
|
||||
@ -710,7 +696,7 @@ namespace boot
|
||||
|
||||
unary_expression::unary_expression(const struct position position, expression *operand,
|
||||
const unary_operator operation)
|
||||
: expression(position), m_operand(std::move(operand)), m_operator(operation)
|
||||
: node(position), m_operand(std::move(operand)), m_operator(operation)
|
||||
{
|
||||
}
|
||||
|
||||
@ -734,22 +720,22 @@ namespace boot
|
||||
delete m_operand;
|
||||
}
|
||||
|
||||
call_expression::call_expression(const struct position position, designator_expression *callable)
|
||||
: expression(position), m_callable(callable)
|
||||
procedure_call::procedure_call(const struct position position, designator_expression *callable)
|
||||
: node(position), m_callable(callable)
|
||||
{
|
||||
}
|
||||
|
||||
void call_expression::accept(parser_visitor *visitor)
|
||||
void procedure_call::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
designator_expression& call_expression::callable()
|
||||
designator_expression& procedure_call::callable()
|
||||
{
|
||||
return *m_callable;
|
||||
}
|
||||
|
||||
call_expression::~call_expression()
|
||||
procedure_call::~procedure_call()
|
||||
{
|
||||
for (expression *const argument : arguments)
|
||||
{
|
||||
@ -760,7 +746,7 @@ namespace boot
|
||||
|
||||
cast_expression::cast_expression(const struct position position,
|
||||
std::shared_ptr<top_type> target, expression *value)
|
||||
: expression(position), m_target(target), m_value(value)
|
||||
: node(position), m_target(target), m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
@ -784,39 +770,20 @@ namespace boot
|
||||
delete m_value;
|
||||
}
|
||||
|
||||
type_expression::type_expression(const struct position position, std::shared_ptr<top_type> body)
|
||||
: expression(position), m_body(body)
|
||||
traits_expression::traits_expression(const struct position position,
|
||||
const std::string& name, std::shared_ptr<top_type> type)
|
||||
: node(position), m_type(type), name(name)
|
||||
{
|
||||
}
|
||||
|
||||
void type_expression::accept(parser_visitor *visitor)
|
||||
void traits_expression::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
top_type& type_expression::body()
|
||||
top_type& traits_expression::type()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
call_statement::call_statement(const struct position position, call_expression *body)
|
||||
: statement(position), m_body(body)
|
||||
{
|
||||
}
|
||||
|
||||
void call_statement::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
call_expression& call_statement::body()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
call_statement::~call_statement()
|
||||
{
|
||||
delete m_body;
|
||||
return *m_type;
|
||||
}
|
||||
|
||||
conditional_statements::conditional_statements(expression *prerequisite)
|
||||
@ -839,7 +806,7 @@ namespace boot
|
||||
}
|
||||
|
||||
return_statement::return_statement(const struct position position, expression *return_expression)
|
||||
: statement(position), m_return_expression(return_expression)
|
||||
: node(position), m_return_expression(return_expression)
|
||||
{
|
||||
}
|
||||
|
||||
@ -865,7 +832,7 @@ namespace boot
|
||||
|
||||
assign_statement::assign_statement(const struct position position, designator_expression *lvalue,
|
||||
expression *rvalue)
|
||||
: statement(position), m_lvalue(lvalue), m_rvalue(rvalue)
|
||||
: node(position), m_lvalue(lvalue), m_rvalue(rvalue)
|
||||
{
|
||||
}
|
||||
|
||||
@ -906,7 +873,7 @@ namespace boot
|
||||
|
||||
if_statement::if_statement(const struct position position, conditional_statements *body,
|
||||
std::vector<statement *> *alternative)
|
||||
: statement(position), m_body(body), m_alternative(alternative)
|
||||
: node(position), m_body(body), m_alternative(alternative)
|
||||
{
|
||||
}
|
||||
|
||||
@ -936,7 +903,7 @@ namespace boot
|
||||
}
|
||||
|
||||
while_statement::while_statement(const struct position position, conditional_statements *body)
|
||||
: statement(position), m_body(body)
|
||||
: node(position), m_body(body)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user