Allow comparing all pointer types to nil
This commit is contained in:
49
boot/ast.cc
49
boot/ast.cc
@ -92,15 +92,15 @@ namespace boot
|
||||
|
||||
void empty_visitor::visit(block *block)
|
||||
{
|
||||
for (const auto constant : block->constants)
|
||||
for (constant_definition *const constant : block->constants)
|
||||
{
|
||||
constant->accept(this);
|
||||
}
|
||||
for (const auto variable : block->variables)
|
||||
for (variable_declaration *const variable : block->variables)
|
||||
{
|
||||
variable->accept(this);
|
||||
}
|
||||
for (const auto body_statement : block->body)
|
||||
for (statement *const body_statement : block->body)
|
||||
{
|
||||
body_statement->accept(this);
|
||||
}
|
||||
@ -108,11 +108,15 @@ namespace boot
|
||||
|
||||
void empty_visitor::visit(program *program)
|
||||
{
|
||||
for (auto definition : program->type_definitions)
|
||||
{
|
||||
definition->accept(this);
|
||||
}
|
||||
visit(reinterpret_cast<block *>(program));
|
||||
for (type_definition *const type : program->types)
|
||||
{
|
||||
type->accept(this);
|
||||
}
|
||||
for (procedure_definition *const procedure : program->procedures)
|
||||
{
|
||||
procedure->accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
void empty_visitor::visit(binary_expression *expression)
|
||||
@ -490,23 +494,22 @@ namespace boot
|
||||
|
||||
block::~block()
|
||||
{
|
||||
for (auto variable : this->variables)
|
||||
{
|
||||
delete variable;
|
||||
}
|
||||
for (auto constant : this->constants)
|
||||
{
|
||||
delete constant;
|
||||
}
|
||||
for (auto body_statement : this->body)
|
||||
for (statement *body_statement : this->body)
|
||||
{
|
||||
delete body_statement;
|
||||
}
|
||||
for (variable_declaration *variable : this->variables)
|
||||
{
|
||||
delete variable;
|
||||
}
|
||||
for (constant_definition *constant : this->constants)
|
||||
{
|
||||
delete constant;
|
||||
}
|
||||
}
|
||||
|
||||
program::program(const struct position position, std::vector<definition *>&& type_definitions)
|
||||
: block(position),
|
||||
type_definitions(std::move(type_definitions))
|
||||
program::program(const struct position position)
|
||||
: block(position)
|
||||
{
|
||||
}
|
||||
|
||||
@ -517,9 +520,13 @@ namespace boot
|
||||
|
||||
program::~program()
|
||||
{
|
||||
for (auto definition : type_definitions)
|
||||
for (procedure_definition *procedure : this->procedures)
|
||||
{
|
||||
delete definition;
|
||||
delete procedure;
|
||||
}
|
||||
for (type_definition *type : this->types)
|
||||
{
|
||||
delete type;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user