+bool ast_generate_accessors(ast_value *asvalue, ir_builder *ir)
+{
+ 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))
+ {
+ compile_error(ast_ctx(asvalue), "internal error: failed to generate setter for `%s`", asvalue->name);
+ 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))
+ {
+ compile_error(ast_ctx(asvalue), "internal error: failed to generate getter for `%s`", asvalue->name);
+ return false;
+ }
+ }
+ return true;
+}
+