Remove libc dependency for the generated code

This commit is contained in:
2024-05-23 01:13:16 +02:00
parent 189b2e6054
commit 8ea09ff3b4
14 changed files with 362 additions and 417 deletions

View File

@ -165,7 +165,7 @@ namespace elna::source
this->current.emplace_back(quadruple_operator::start);
program->body().accept(this);
this->current.emplace_back(quadruple_operator::stop);
code["main"] = std::move(this->current);
code["_start"] = std::move(this->current);
}
void intermediate_code_generator::visit(call_statement *statement)

View File

@ -44,7 +44,7 @@ namespace elna::source
void name_analysis_visitor::visit(program *program)
{
class procedure_type main_type{ std::vector<std::shared_ptr<const class type>>(), this->pointer_size };
this->table->enter("main", std::make_shared<procedure_info>(main_type, this->table));
this->table->enter("_start", std::make_shared<procedure_info>(main_type, this->table));
empty_visitor::visit(program);
}
@ -105,7 +105,7 @@ namespace elna::source
this->argument_offset = 0;
empty_visitor::visit(program);
std::dynamic_pointer_cast<procedure_info>(table->lookup("main"))->local_stack_size =
std::dynamic_pointer_cast<procedure_info>(table->lookup("_start"))->local_stack_size =
std::abs(this->local_offset);
}