Change error printing to use colors, enable colors on windows cmd, print bytecode instruction line

This commit is contained in:
Krzosa Karol
2022-06-22 18:14:43 +02:00
parent cd48253e3e
commit a36747bc9c
4 changed files with 128 additions and 84 deletions

View File

@@ -10,9 +10,9 @@ bc_emit_expr(Bc *b, Ast *ast){
CASE(VALUE, Atom){
Register_Index dst = allocate_register(b);
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;
CASE_UINT: emit_load_constant_u64(b, node->pos, dst, bigint_as_unsigned(&node->big_int_val)); break;
CASE_SINT: emit_load_constant_s64(b, node->pos, dst, bigint_as_signed(&node->big_int_val)); break;
CASE_FLOAT: emit_load_constant_f64(b, node->pos, dst, node->f64_val); break;
invalid_default_case;
}
@@ -23,7 +23,7 @@ bc_emit_expr(Bc *b, Ast *ast){
CASE(BINARY, Binary){
Register_Index left = bc_emit_expr(b, node->left);
Register_Index right = bc_emit_expr(b, node->right);
emit_arithmetic(b, BC_ADD_S64, left, right, left);
emit_arithmetic(b, node->pos, BC_ADD_S64, left, right, left);
release_register(b, right);
return left;
BREAK();
@@ -42,6 +42,7 @@ compile_to_bc(){
switch(ast->kind){
CASE(LAMBDA, Decl){
unused(node);
// node->bytecode_data_position = emit_lambda();
BREAK();
}
@@ -51,8 +52,8 @@ compile_to_bc(){
if(node->expr){
Register_Index expression_index = bc_emit_expr(b, node->expr);
Register_Index address_index = allocate_register(b);
emit_load_constant_address(b, address_index, node->bytecode_data_position);
emit_memory(b, BC_STORE_TO_MEMORY64, address_index, expression_index);
emit_load_constant_address(b, node->pos, address_index, node->bytecode_data_position);
emit_memory(b, node->pos, BC_STORE_TO_MEMORY64, address_index, expression_index);
release_register(b, expression_index);
release_register(b, address_index);
}