Prepare before typing the untyped
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
|
||||
function Register_Index
|
||||
bc_emit_expr(Bc *b, Ast *ast){
|
||||
if(!ast) return REG_NULL;
|
||||
if(!ast) return -1;
|
||||
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){
|
||||
|
||||
// @todo pass type and figure out what to do with untyped ??
|
||||
CASE(VALUE, Atom){
|
||||
Register_Index dst = allocate_register(b);
|
||||
U64 value = bigint_as_unsigned(&node->big_int_val);
|
||||
emit_load_constant_s64(b, dst, value);
|
||||
switch(node->type->kind){
|
||||
CASE_UINT: emit_load_constant_u64(b, dst, bigint_as_unsigned(&node->big_int_val)); break;
|
||||
CASE_SINT: emit_load_constant_s64(b, dst, bigint_as_signed(&node->big_int_val)); break;
|
||||
CASE_FLOAT: emit_load_constant_f64(b, dst, node->f64_val); break;
|
||||
invalid_default_case;
|
||||
}
|
||||
|
||||
return dst;
|
||||
BREAK();
|
||||
}
|
||||
|
||||
CASE(BINARY, Binary){
|
||||
Register_Index left = bc_emit_expr(b, node->left);
|
||||
Register_Index right = bc_emit_expr(b, node->right);
|
||||
@@ -20,9 +28,10 @@ bc_emit_expr(Bc *b, Ast *ast){
|
||||
return left;
|
||||
BREAK();
|
||||
}
|
||||
|
||||
default:{}
|
||||
}
|
||||
return REG_NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
function void
|
||||
@@ -43,6 +52,7 @@ compile_to_bc(){
|
||||
emit_load_constant_address(b, address_index, node->bytecode_data_position);
|
||||
emit_memory(b, BC_STORE_TO_MEMORY64, address_index, expression_index);
|
||||
release_register(b, expression_index);
|
||||
release_register(b, address_index);
|
||||
}
|
||||
BREAK();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user