+ /* accumulation? */
+ if (var->hasvalue) {
+ ast_value *accum = NULL;
+ ast_function *previous = NULL;
+ char acname[1024];
+
+ /* generate a new name increasing the accumulation count*/
+ util_snprintf(acname, sizeof(acname), "$ACCUMULATE_%s_%d", var->name, var->constval.vfunc->accumulation++);
+ accum = ast_value_new(parser_ctx(parser), acname, ((ast_expression*)var)->vtype);
+ if (!accum)
+ return false;
+
+ ast_type_adopt(accum, var);
+ func = ast_function_new(ast_ctx(var), NULL, accum);
+ if (!func)
+ return false;
+
+ parser_addglobal(parser, acname, (ast_expression*)accum);
+ vec_push(parser->functions, func);
+
+ /* update the previous calls accumulate pointer for the codegen */
+ previous = var->constval.vfunc;
+ while (previous->accumulate)
+ previous = previous->accumulate;
+
+ if (ast_istype(previous, ast_function))
+ previous->accumulate = func;
+
+ } else {
+ func = ast_function_new(ast_ctx(var), var->name, var);
+ vec_push(parser->functions, func);
+ }
+