Struct field access. Damn, I coded for like 30 minutes and then it just worked on the first try
This commit is contained in:
19
ccodegen.cpp
19
ccodegen.cpp
@@ -100,11 +100,20 @@ gen_expr(Ast_Expr *ast){
|
||||
}
|
||||
|
||||
CASE(BINARY, Binary){
|
||||
gen("(");
|
||||
gen_expr(node->left);
|
||||
gen("%s", token_kind_string(node->op).str);
|
||||
gen_expr(node->right);
|
||||
gen(")");
|
||||
if(node->op == TK_Dot){
|
||||
Sym *sym = resolved_get(node->left);
|
||||
gen_expr(node->left);
|
||||
if(sym->type->kind == TYPE_POINTER) gen("->");
|
||||
else gen(".");
|
||||
gen_expr(node->right);
|
||||
}
|
||||
else{
|
||||
gen("(");
|
||||
gen_expr(node->left);
|
||||
gen("%s", token_kind_string(node->op).str);
|
||||
gen_expr(node->right);
|
||||
gen(")");
|
||||
}
|
||||
BREAK();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user