RValue, LValue concept working, Assigning to numbers is now illegal!
This commit is contained in:
@@ -14,7 +14,7 @@ if_stmt :: (cond: int): type
|
||||
|
||||
|
||||
for_stmt :: ()
|
||||
for i := 0, i + 10, i
|
||||
for i := 0, i + 10, i+=1
|
||||
pass
|
||||
|
||||
add_10 :: (size: int): int
|
||||
|
||||
4
main.cpp
4
main.cpp
@@ -93,12 +93,12 @@ int main(){
|
||||
printf("%s", result.str);
|
||||
result = compile_file("enums.kl"_s);
|
||||
printf("%s", result.str);
|
||||
result = compile_file("lambdas.kl"_s);
|
||||
printf("%s", result.str);
|
||||
result = compile_file("order1.kl"_s);
|
||||
printf("%s", result.str);
|
||||
result = compile_file("order2.kl"_s);
|
||||
printf("%s", result.str);
|
||||
result = compile_file("lambdas.kl"_s);
|
||||
printf("%s", result.str);
|
||||
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ test_assignments :: ()
|
||||
i >>= 2
|
||||
i <<= 2
|
||||
|
||||
i + 4 = 32
|
||||
8 = 32
|
||||
j: *int
|
||||
*j = 1
|
||||
/* invalid
|
||||
8 = 32
|
||||
i + 4 = 32
|
||||
i += "String"
|
||||
|
||||
*/
|
||||
|
||||
@@ -73,9 +73,8 @@ resolve_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
sym_insert(sym);
|
||||
}
|
||||
else if(token_is_assign(node->op)){
|
||||
// @todo: assign value to constant
|
||||
// @todo: lvalue concept, passing down syms to change (constants)
|
||||
Operand left = resolve_expr(node->left);
|
||||
if(!left.is_lvalue) parsing_error(node->pos, "Assigning to rvalue");
|
||||
Operand right = resolve_expr(node->right);
|
||||
if(left.type != right.type) parsing_error(node->pos, "Different types");
|
||||
}
|
||||
@@ -89,7 +88,6 @@ resolve_stmt(Ast *ast, Ast_Resolved_Type *ret){
|
||||
}
|
||||
|
||||
CASE(FOR, For){
|
||||
// @todo: I think we need to bring back the Ast_Init, it was not an expression
|
||||
resolve_expr(node->init, ret);
|
||||
Operand cond = resolve_expr(node->cond); // @todo: typechecking
|
||||
resolve_expr(node->iter, ret);
|
||||
|
||||
Reference in New Issue
Block a user