Working on arrays

This commit is contained in:
Krzosa Karol
2022-06-07 21:19:06 +02:00
parent c3e071b3bb
commit b65a5f78bf
6 changed files with 48 additions and 11 deletions

View File

@@ -133,7 +133,8 @@ gen_expr(Ast_Expr *ast){
else gen(".");
gen_expr(node->right);
}
else if(node->op == TK_ColonAssign){ // @todo: I think this needs to be a stmt
else if(node->op == TK_ColonAssign){
Sym *sym = resolved_get(node);
Ast_Atom *atom = (Ast_Atom *)node->left;
assert(is_atom(atom));
@@ -210,6 +211,8 @@ gen_expr(Ast_Expr *ast){
gen("(");
auto name_for_printf = (Ast_Atom *)node->name;
For(node->exprs){
// @special_case @todo in the future this should be replaced
// with []Any
if(intern_printf == name_for_printf->intern_val && &it == node->exprs.data){
Ast_Atom *atom = (Ast_Atom *)it->item;
assert(atom->kind == AST_VALUE);
@@ -231,7 +234,8 @@ gen_expr(Ast_Expr *ast){
function void
gen_line(Ast *node){
genln("#line %d", node->pos->line+1);
if(emit_line_directives)
genln("#line %d", node->pos->line+1);
}
function void
@@ -254,7 +258,8 @@ gen_ast(Ast *ast){
switch(ast->kind){
CASE(PACKAGE, Package){
genln("#line 0 \"%s\"", node->name.str);
if(emit_line_directives)
genln("#line 0 \"%s\"", node->name.str);
For(node->ordered) {
gen_line(it);
genln("");
@@ -290,6 +295,8 @@ gen_ast(Ast *ast){
gen_simple_decl(sym->type, {});
gen("){}");
gen("}");
} else { // Default zero
gen(" = {}");
}
gen(";");
BREAK();