Use colon instead of as to cast
This commit is contained in:
110
boot/ast.cc
110
boot/ast.cc
@ -61,7 +61,7 @@ namespace boot
|
||||
expression->value().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(size_of_expression *expression)
|
||||
void empty_visitor::visit(type_expression *expression)
|
||||
{
|
||||
expression->body().accept(this);
|
||||
}
|
||||
@ -152,21 +152,21 @@ namespace boot
|
||||
expression->operand().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(basic_type_expression *)
|
||||
void empty_visitor::visit(basic_type *)
|
||||
{
|
||||
}
|
||||
|
||||
void empty_visitor::visit(array_type_expression *expression)
|
||||
void empty_visitor::visit(array_type *expression)
|
||||
{
|
||||
expression->base().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(pointer_type_expression *expression)
|
||||
void empty_visitor::visit(pointer_type *expression)
|
||||
{
|
||||
expression->base().accept(this);
|
||||
}
|
||||
|
||||
void empty_visitor::visit(record_type_expression *expression)
|
||||
void empty_visitor::visit(record_type *expression)
|
||||
{
|
||||
for (auto& field : expression->fields)
|
||||
{
|
||||
@ -174,7 +174,7 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
void empty_visitor::visit(union_type_expression *expression)
|
||||
void empty_visitor::visit(union_type *expression)
|
||||
{
|
||||
for (auto& field : expression->fields)
|
||||
{
|
||||
@ -250,115 +250,113 @@ namespace boot
|
||||
{
|
||||
}
|
||||
|
||||
type_expression::type_expression(const struct position position)
|
||||
top_type::top_type(const struct position position)
|
||||
: node(position)
|
||||
{
|
||||
}
|
||||
|
||||
basic_type_expression *type_expression::is_basic()
|
||||
basic_type *top_type::is_basic()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
array_type_expression *type_expression::is_array()
|
||||
array_type *top_type::is_array()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
record_type_expression *type_expression::is_record()
|
||||
record_type *top_type::is_record()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
union_type_expression *type_expression::is_union()
|
||||
union_type *top_type::is_union()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pointer_type_expression *type_expression::is_pointer()
|
||||
pointer_type *top_type::is_pointer()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
basic_type_expression::basic_type_expression(
|
||||
const struct position position, const std::string& name)
|
||||
: type_expression(position), m_name(name)
|
||||
basic_type::basic_type(const struct position position, const std::string& name)
|
||||
: top_type(position), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
void basic_type_expression::accept(parser_visitor *visitor)
|
||||
void basic_type::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
const std::string& basic_type_expression::base_name()
|
||||
const std::string& basic_type::base_name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
basic_type_expression *basic_type_expression::is_basic()
|
||||
basic_type *basic_type::is_basic()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
array_type_expression::array_type_expression(const struct position position, type_expression *base,
|
||||
array_type::array_type(const struct position position, top_type *base,
|
||||
const std::uint32_t size)
|
||||
: type_expression(position), m_base(base), size(size)
|
||||
: top_type(position), m_base(base), size(size)
|
||||
{
|
||||
}
|
||||
|
||||
void array_type_expression::accept(parser_visitor *visitor)
|
||||
void array_type::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& array_type_expression::base()
|
||||
top_type& array_type::base()
|
||||
{
|
||||
return *m_base;
|
||||
}
|
||||
|
||||
array_type_expression *array_type_expression::is_array()
|
||||
array_type*array_type::is_array()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
array_type_expression::~array_type_expression()
|
||||
array_type::~array_type()
|
||||
{
|
||||
delete m_base;
|
||||
}
|
||||
|
||||
pointer_type_expression::pointer_type_expression(const struct position position, type_expression *base)
|
||||
: type_expression(position), m_base(base)
|
||||
pointer_type::pointer_type(const struct position position, top_type *base)
|
||||
: top_type(position), m_base(base)
|
||||
{
|
||||
}
|
||||
|
||||
void pointer_type_expression::accept(parser_visitor *visitor)
|
||||
void pointer_type::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& pointer_type_expression::base()
|
||||
top_type& pointer_type::base()
|
||||
{
|
||||
return *m_base;
|
||||
}
|
||||
|
||||
pointer_type_expression *pointer_type_expression::is_pointer()
|
||||
pointer_type *pointer_type::is_pointer()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
pointer_type_expression::~pointer_type_expression()
|
||||
pointer_type::~pointer_type()
|
||||
{
|
||||
delete m_base;
|
||||
}
|
||||
|
||||
composite_type_expression::composite_type_expression(const struct position position,
|
||||
fields_t&& fields)
|
||||
: type_expression(position), fields(std::move(fields))
|
||||
composite_type::composite_type(const struct position position, fields_t&& fields)
|
||||
: top_type(position), fields(std::move(fields))
|
||||
{
|
||||
}
|
||||
|
||||
composite_type_expression::~composite_type_expression()
|
||||
composite_type::~composite_type()
|
||||
{
|
||||
for (auto& field_declaration : fields)
|
||||
{
|
||||
@ -366,40 +364,38 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
record_type_expression::record_type_expression(const struct position position,
|
||||
fields_t&& fields)
|
||||
: composite_type_expression(position, std::move(fields))
|
||||
record_type::record_type(const struct position position, fields_t&& fields)
|
||||
: composite_type(position, std::move(fields))
|
||||
{
|
||||
}
|
||||
|
||||
void record_type_expression::accept(parser_visitor *visitor)
|
||||
void record_type::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
record_type_expression *record_type_expression::is_record()
|
||||
record_type *record_type::is_record()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
union_type_expression::union_type_expression(const struct position position,
|
||||
fields_t&& fields)
|
||||
: composite_type_expression(position, std::move(fields))
|
||||
union_type::union_type(const struct position position, fields_t&& fields)
|
||||
: composite_type(position, std::move(fields))
|
||||
{
|
||||
}
|
||||
|
||||
union_type_expression *union_type_expression::is_union()
|
||||
union_type *union_type::is_union()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
void union_type_expression::accept(parser_visitor *visitor)
|
||||
void union_type::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
variable_declaration::variable_declaration(const struct position position, const std::string& identifier,
|
||||
const bool exported, type_expression *type)
|
||||
const bool exported, top_type *type)
|
||||
: definition(position, identifier, exported), m_type(type)
|
||||
{
|
||||
}
|
||||
@ -414,7 +410,7 @@ namespace boot
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& variable_declaration::type()
|
||||
top_type& variable_declaration::variable_type()
|
||||
{
|
||||
return *m_type;
|
||||
}
|
||||
@ -446,7 +442,7 @@ namespace boot
|
||||
}
|
||||
|
||||
procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, type_expression *return_type)
|
||||
const bool exported, top_type *return_type)
|
||||
: definition(position, identifier, exported), m_return_type(return_type)
|
||||
{
|
||||
}
|
||||
@ -467,7 +463,7 @@ namespace boot
|
||||
return this;
|
||||
}
|
||||
|
||||
type_expression *procedure_definition::return_type()
|
||||
top_type *procedure_definition::return_type()
|
||||
{
|
||||
return m_return_type;
|
||||
}
|
||||
@ -485,7 +481,7 @@ namespace boot
|
||||
}
|
||||
|
||||
type_definition::type_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, type_expression *body)
|
||||
const bool exported, top_type *body)
|
||||
: definition(position, identifier, exported), m_body(body)
|
||||
{
|
||||
}
|
||||
@ -495,7 +491,7 @@ namespace boot
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& type_definition::body()
|
||||
top_type& type_definition::body()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
@ -776,7 +772,7 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
cast_expression::cast_expression(const struct position position, type_expression *target, expression *value)
|
||||
cast_expression::cast_expression(const struct position position, top_type *target, expression *value)
|
||||
: expression(position), m_target(target), m_value(value)
|
||||
{
|
||||
}
|
||||
@ -786,7 +782,7 @@ namespace boot
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& cast_expression::target()
|
||||
top_type& cast_expression::target()
|
||||
{
|
||||
return *m_target;
|
||||
}
|
||||
@ -802,22 +798,22 @@ namespace boot
|
||||
delete m_value;
|
||||
}
|
||||
|
||||
size_of_expression::size_of_expression(const struct position position, type_expression *body)
|
||||
type_expression::type_expression(const struct position position, top_type *body)
|
||||
: expression(position), m_body(body)
|
||||
{
|
||||
}
|
||||
|
||||
void size_of_expression::accept(parser_visitor *visitor)
|
||||
void type_expression::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
}
|
||||
|
||||
type_expression& size_of_expression::body()
|
||||
top_type& type_expression::body()
|
||||
{
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
size_of_expression::~size_of_expression()
|
||||
type_expression::~type_expression()
|
||||
{
|
||||
delete m_body;
|
||||
}
|
||||
@ -1014,6 +1010,8 @@ namespace boot
|
||||
return "and";
|
||||
case binary_operator::disjunction:
|
||||
return "or";
|
||||
case binary_operator::exclusive_disjunction:
|
||||
return "xor";
|
||||
}
|
||||
__builtin_unreachable();
|
||||
};
|
||||
|
Reference in New Issue
Block a user