return true;
}
-bool ast_global_codegen(ast_value *self, ir_builder *ir)
+bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
{
ir_value *v = NULL;
if (self->isconst && self->expression.vtype == TYPE_FUNCTION)
return true;
}
- if (self->expression.vtype == TYPE_FIELD) {
+ if (isfield && self->expression.vtype == TYPE_FIELD) {
v = ir_builder_create_field(ir, self->name, self->expression.next->expression.vtype);
if (!v)
return false;
bool ast_value_codegen(ast_value*, ast_function*, bool lvalue, ir_value**);
bool ast_local_codegen(ast_value *self, ir_function *func, bool isparam);
-bool ast_global_codegen(ast_value *self, ir_builder *ir);
+bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield);
bool GMQCC_WARN ast_value_params_add(ast_value*, ast_value*);
field = (ast_value*)parser->fields[i].var;
isconst = field->isconst;
field->isconst = false;
- if (!ast_global_codegen((ast_value*)field, ir)) {
+ if (!ast_global_codegen((ast_value*)field, ir, true)) {
printf("failed to generate field %s\n", field->name);
ir_builder_delete(ir);
return false;
"unused global: `%s`", asvalue->name);
}
}
- if (!ast_global_codegen(asvalue, ir)) {
+ if (!ast_global_codegen(asvalue, ir, false)) {
printf("failed to generate global %s\n", parser->globals[i].name);
ir_builder_delete(ir);
return false;
}
}
for (i = 0; i < parser->imm_float_count; ++i) {
- if (!ast_global_codegen(parser->imm_float[i], ir)) {
+ if (!ast_global_codegen(parser->imm_float[i], ir, false)) {
printf("failed to generate global %s\n", parser->imm_float[i]->name);
ir_builder_delete(ir);
return false;
}
}
for (i = 0; i < parser->imm_string_count; ++i) {
- if (!ast_global_codegen(parser->imm_string[i], ir)) {
+ if (!ast_global_codegen(parser->imm_string[i], ir, false)) {
printf("failed to generate global %s\n", parser->imm_string[i]->name);
ir_builder_delete(ir);
return false;
}
}
for (i = 0; i < parser->imm_vector_count; ++i) {
- if (!ast_global_codegen(parser->imm_vector[i], ir)) {
+ if (!ast_global_codegen(parser->imm_vector[i], ir, false)) {
printf("failed to generate global %s\n", parser->imm_vector[i]->name);
ir_builder_delete(ir);
return false;