Begin to codegen bytecode instructions

This commit is contained in:
Krzosa Karol
2022-06-21 15:49:39 +02:00
parent 6ed17a3c1c
commit 2c3a8dc764
6 changed files with 59 additions and 6 deletions

34
bytecode_codegen.cpp Normal file
View File

@@ -0,0 +1,34 @@
function void
bc_emit_expr(Bc *b, Ast *ast){
if(!ast) return;
if(!is_flag_set(ast->flags, AST_EXPR))
compiler_error(ast->pos, "Internal compiler error: Trying to emit expression but it doesn't have appropriate flag");
switch(ast->kind){
CASE(BINARY, Binary){
BREAK();
}
default:{}
}
}
function void
compile_to_bc(){
Bc bc = create_bytecode_interp();
Bc *b = &bc;
For_Named(pctx->ordered_decls, ast){
switch(ast->kind){
CASE(LAMBDA, Decl){
unused(node);
BREAK();
}
CASE(VAR, Decl){
node->bytecode_data_position = exp_alloc(&b->memory, node->type->size, AF_ZeroMemory);
bc_emit_assign(b, node);
BREAK();
}
default: {}
}
}
}