ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field)
{
- const ast_expression *outtype;
-
- ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
-
if (field->expression.vtype != TYPE_FIELD) {
asterror(ctx, "ast_entfield_new with expression not of type field");
- mem_d(self);
return NULL;
}
+ return ast_entfield_new_force(ctx, entity, field, field->expression.next);
+}
+
+ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype)
+{
+ ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
- outtype = field->expression.next;
if (!outtype) {
mem_d(self);
/* Error: field has no type... */
ast_expression *field;
};
ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field);
+ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype);
void ast_entfield_delete(ast_entfield*);
bool ast_entfield_codegen(ast_entfield*, ast_function*, bool lvalue, ir_value**);
if (!subscript)
return NULL;
- entfield = ast_entfield_new(ctx, (ast_expression*)entity, (ast_expression*)subscript);
+ entfield = ast_entfield_new_force(ctx,
+ (ast_expression*)entity,
+ (ast_expression*)subscript,
+ (ast_expression*)subscript);
if (!entfield) {
ast_delete(subscript);
return NULL;
!ast_function_codegen(asvalue->setter->constval.vfunc, ir) ||
!ir_function_finalize(asvalue->setter->constval.vfunc->ir_func))
{
- printf("failed to generate setter for %s\n", parser->globals[i].name);
+ printf("failed to generate setter for %s\n", parser->fields[i].name);
ir_builder_delete(ir);
return false;
}
!ast_function_codegen(asvalue->getter->constval.vfunc, ir) ||
!ir_function_finalize(asvalue->getter->constval.vfunc->ir_func))
{
- printf("failed to generate getter for %s\n", parser->globals[i].name);
+ printf("failed to generate getter for %s\n", parser->fields[i].name);
ir_builder_delete(ir);
return false;
}