Allow multiple variable declarations with a single type
This commit is contained in:
52
boot/ast.cc
52
boot/ast.cc
@ -300,8 +300,7 @@ namespace boot
|
||||
return this;
|
||||
}
|
||||
|
||||
array_type::array_type(const struct position position, top_type *base,
|
||||
const std::uint32_t size)
|
||||
array_type::array_type(const struct position position, std::shared_ptr<top_type> base, const std::uint32_t size)
|
||||
: top_type(position), m_base(base), size(size)
|
||||
{
|
||||
}
|
||||
@ -321,12 +320,7 @@ namespace boot
|
||||
return this;
|
||||
}
|
||||
|
||||
array_type::~array_type()
|
||||
{
|
||||
delete m_base;
|
||||
}
|
||||
|
||||
pointer_type::pointer_type(const struct position position, top_type *base)
|
||||
pointer_type::pointer_type(const struct position position, std::shared_ptr<top_type> base)
|
||||
: top_type(position), m_base(base)
|
||||
{
|
||||
}
|
||||
@ -346,24 +340,11 @@ namespace boot
|
||||
return this;
|
||||
}
|
||||
|
||||
pointer_type::~pointer_type()
|
||||
{
|
||||
delete m_base;
|
||||
}
|
||||
|
||||
composite_type::composite_type(const struct position position, fields_t&& fields)
|
||||
: top_type(position), fields(std::move(fields))
|
||||
{
|
||||
}
|
||||
|
||||
composite_type::~composite_type()
|
||||
{
|
||||
for (auto& field_declaration : fields)
|
||||
{
|
||||
delete field_declaration.second;
|
||||
}
|
||||
}
|
||||
|
||||
record_type::record_type(const struct position position, fields_t&& fields)
|
||||
: composite_type(position, std::move(fields))
|
||||
{
|
||||
@ -395,16 +376,11 @@ namespace boot
|
||||
}
|
||||
|
||||
variable_declaration::variable_declaration(const struct position position, const std::string& identifier,
|
||||
const bool exported, top_type *type)
|
||||
std::shared_ptr<top_type> type, const bool exported)
|
||||
: definition(position, identifier, exported), m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
variable_declaration::~variable_declaration()
|
||||
{
|
||||
delete m_type;
|
||||
}
|
||||
|
||||
void variable_declaration::accept(parser_visitor *visitor)
|
||||
{
|
||||
visitor->visit(this);
|
||||
@ -442,7 +418,7 @@ namespace boot
|
||||
}
|
||||
|
||||
procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, top_type *return_type)
|
||||
const bool exported, std::shared_ptr<top_type> return_type)
|
||||
: definition(position, identifier, exported), m_return_type(return_type)
|
||||
{
|
||||
}
|
||||
@ -463,7 +439,7 @@ namespace boot
|
||||
return this;
|
||||
}
|
||||
|
||||
top_type *procedure_definition::return_type()
|
||||
std::shared_ptr<top_type> procedure_definition::return_type()
|
||||
{
|
||||
return m_return_type;
|
||||
}
|
||||
@ -481,7 +457,7 @@ namespace boot
|
||||
}
|
||||
|
||||
type_definition::type_definition(const struct position position, const std::string& identifier,
|
||||
const bool exported, top_type *body)
|
||||
const bool exported, std::shared_ptr<top_type> body)
|
||||
: definition(position, identifier, exported), m_body(body)
|
||||
{
|
||||
}
|
||||
@ -496,11 +472,6 @@ namespace boot
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
type_definition::~type_definition()
|
||||
{
|
||||
delete m_body;
|
||||
}
|
||||
|
||||
block::block(const struct position position)
|
||||
: node(position)
|
||||
{
|
||||
@ -772,7 +743,8 @@ namespace boot
|
||||
}
|
||||
}
|
||||
|
||||
cast_expression::cast_expression(const struct position position, top_type *target, expression *value)
|
||||
cast_expression::cast_expression(const struct position position,
|
||||
std::shared_ptr<top_type> target, expression *value)
|
||||
: expression(position), m_target(target), m_value(value)
|
||||
{
|
||||
}
|
||||
@ -794,11 +766,10 @@ namespace boot
|
||||
|
||||
cast_expression::~cast_expression()
|
||||
{
|
||||
delete m_target;
|
||||
delete m_value;
|
||||
}
|
||||
|
||||
type_expression::type_expression(const struct position position, top_type *body)
|
||||
type_expression::type_expression(const struct position position, std::shared_ptr<top_type> body)
|
||||
: expression(position), m_body(body)
|
||||
{
|
||||
}
|
||||
@ -813,11 +784,6 @@ namespace boot
|
||||
return *m_body;
|
||||
}
|
||||
|
||||
type_expression::~type_expression()
|
||||
{
|
||||
delete m_body;
|
||||
}
|
||||
|
||||
call_statement::call_statement(const struct position position, call_expression *body)
|
||||
: statement(position), m_body(body)
|
||||
{
|
||||
|
Reference in New Issue
Block a user