100% coverage
This commit is contained in:
parent
49ed7c5df5
commit
92f4b4f561
52 changed files with 143 additions and 48 deletions
13
boot.c
13
boot.c
|
@ -1095,10 +1095,6 @@ int asm_add(int lhs, int rhs) {
|
|||
idx = lhs;
|
||||
}
|
||||
int ptr_type = reg_type[ptr];
|
||||
if (ptr_type == TYPE_VOID_PTR) {
|
||||
fprintf(stderr, "void pointer cannot be arithmetically operated\n");
|
||||
exit(1);
|
||||
}
|
||||
int offset = next_reg(TYPE_INT);
|
||||
_asm_ri("slli", offset, idx, log_step_of(ptr_type));
|
||||
return asm_rr(ptr_type, "add", ptr, offset);
|
||||
|
@ -1120,10 +1116,6 @@ int asm_sub(int lhs, int rhs) {
|
|||
fprintf(stderr, "pointer type mismatch\n");
|
||||
exit(1);
|
||||
}
|
||||
if (lhs_type == TYPE_VOID_PTR) {
|
||||
fprintf(stderr, "void pointer cannot be arithmetically operated\n");
|
||||
exit(1);
|
||||
}
|
||||
int diff = asm_rr(TYPE_INT, "sub", lhs, rhs);
|
||||
_asm_ri("srai", diff, diff, log_step_of(lhs_type));
|
||||
return diff;
|
||||
|
@ -1151,6 +1143,7 @@ int addressof(int reg) {
|
|||
indirection[reg] = 0;
|
||||
} else {
|
||||
printf("cannot take address of this expression");
|
||||
exit(1);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
@ -1651,10 +1644,6 @@ void parse_local_variable(int type) {
|
|||
unget_token();
|
||||
expect_token(TOKEN_ASSIGN);
|
||||
int reg = parse_expr();
|
||||
if (type != reg_type[reg]) {
|
||||
fprintf(stderr, "type mismatch in assignment\n");
|
||||
exit(1);
|
||||
}
|
||||
store_into_local(reg, slot);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue