#include "macro.hpp" namespace fkstd { void assert_static_fail(Compiler& compiler, std::shared_ptr node, std::shared_ptr program) { try { compiler.compile_prog(node->child(1), program); } catch(std::exception const&) { program->load_const(std::make_shared(TYPE_BOOL, true, node->loc())); return; } std::stringstream ss; ss << "assertion failed"; node->loc().error(LOG_ERROR, ss.str()); } void decl(Compiler& compiler, std::shared_ptr node, std::shared_ptr program) { static addr_t addr = 0; addr++; std::string ident = node->child(1)->repr(); auto rhs = node->child(2); compiler.compile_prog(rhs, program); compiler.sym()->declare_local(ident, addr, node->loc()); program->add(OP_STORE_LOCAL, addr); } void block(Compiler& compiler, std::shared_ptr node, std::shared_ptr program) { compiler.sym()->enter_scope(); for (size_t i=1; isize(); i++) { compiler.compile_prog(node->child(i), program); if (i != node->size() - 1) { program->add(OP_POP); } } compiler.sym()->leave_scope(); // std::cout << compiler.sym()->string() << std::endl; } }