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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,23 +111,14 @@
|
||||
%type <elna::boot::cast_expression *> cast_expression;
|
||||
%%
|
||||
program:
|
||||
type_part constant_part variable_part procedure_part BEGIN_BLOCK optional_statements END_BLOCK DOT
|
||||
constant_part type_part variable_part procedure_part BEGIN_BLOCK optional_statements END_BLOCK DOT
|
||||
{
|
||||
std::vector<elna::boot::definition *> definitions($1.size() + $4.size());
|
||||
std::vector<elna::boot::definition *>::iterator definition = definitions.begin();
|
||||
auto tree = new elna::boot::program(elna::boot::make_position(@5));
|
||||
|
||||
for (auto type : $1)
|
||||
{
|
||||
*definition++ = type;
|
||||
}
|
||||
for (auto procedure : $4)
|
||||
{
|
||||
*definition++ = procedure;
|
||||
}
|
||||
auto tree = new elna::boot::program(elna::boot::make_position(@5), std::move(definitions));
|
||||
|
||||
std::swap(tree->constants, $2);
|
||||
std::swap(tree->constants, $1);
|
||||
std::swap(tree->types , $2);
|
||||
std::swap(tree->variables, $3);
|
||||
std::swap(tree->procedures, $4);
|
||||
std::swap(tree->body, $6);
|
||||
|
||||
driver.tree.reset(tree);
|
||||
|
Reference in New Issue
Block a user