Begin to codegen bytecode instructions
This commit is contained in:
34
bytecode_codegen.cpp
Normal file
34
bytecode_codegen.cpp
Normal 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: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user