Beispiel #1
0
    int check_func(ast::Func* func) {
        assert(func != nullptr);

        for (auto it = func->arguments.begin(); it != func->arguments.end(); ++it) {
            declare_variable(*it);
        }
        // Allocate memory on stack for local variables
        for (auto it = func->local_variables.begin(); it != func->local_variables.end(); ++it) {
            declare_variable(*it);
        }
        this->current_function = func;
        check_body(func->body);

        // TODO: check for return value?
        auto return_ = std::make_shared<ast::Return>();
        return_->value =
            std::make_shared<ast::Constant>(default_value_for(func->return_value));
        func->body.push_back(return_);
        this->current_function = nullptr;
        variables.clear();
        return EXIT_SUCCESS;
    }
Beispiel #2
0
void clearRelocatableSymsMap() {
    relocatable_syms.clear();
}