From 3579e495bee4f009e9ab47551bf62e6bee78f63a Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Mon, 12 Nov 2012 22:24:11 +0100 Subject: [PATCH] code to instantiate field-array accessors --- parser.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/parser.c b/parser.c index 49bb107..07052f9 100644 --- a/parser.c +++ b/parser.c @@ -3599,6 +3599,35 @@ bool parser_finish(const char *output) } } } + for (i = 0; i < parser->fields_count; ++i) { + ast_value *asvalue; + asvalue = (ast_value*)(parser->fields[i].var->expression.next); + + if (!ast_istype((ast_expression*)asvalue, ast_value)) + continue; + if (asvalue->expression.vtype != TYPE_ARRAY) + continue; + if (asvalue->setter) { + if (!ast_global_codegen(asvalue->setter, ir, false) || + !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); + ir_builder_delete(ir); + return false; + } + } + if (asvalue->getter) { + if (!ast_global_codegen(asvalue->getter, ir, 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); + ir_builder_delete(ir); + return false; + } + } + } for (i = 0; i < parser->functions_count; ++i) { if (!ast_function_codegen(parser->functions[i], ir)) { printf("failed to generate function %s\n", parser->functions[i]->name); -- 2.39.2