if (code_defs_add(def) < 0)
return false;
return gen_global_function(self, global);
+ case TYPE_VARIANT:
+ /* assume biggest type */
+ global->code.globaladdr = code_globals_add(0);
+ code_globals_add(0);
+ code_globals_add(0);
+ return true;
default:
/* refuse to create 'void' type or any other fancy business. */
printf("Invalid type for global variable %s\n", global->name);
return false;
}
- code_write(filename);
- return false;
+ return code_write(filename);
}
/***********************************************************************
ir_value* ir_builder_get_global(ir_builder*, const char *fun);
ir_value* ir_builder_create_global(ir_builder*, const char *name, int vtype);
+bool ir_builder_generate(ir_builder *self, const char *filename);
+
void ir_builder_dump(ir_builder*, int (*oprintf)(const char*, ...));
/* This code assumes 32 bit floats while generating binary */
ENDWHILE();
ENDFUNCTION(main);
-
+
ir = ir_builder_new("ast_test");
assert(ir);
/* dump */
ir_builder_dump(ir, printf);
+ /* Now create a file */
+ if (!ir_builder_generate(ir, "test_ast.dat"))
+ printf("*** failed to generate code\n");
+
/* ir cleanup */
ir_builder_delete(ir);