-static bool ast_value_codegen(ast_value *self, ast_function *func, bool lvalue, ir_value **out);
-ast_value* ast_value_new(lex_ctx_t ctx, const char *name, int t)
-{
- ast_instantiate(ast_value, ctx, ast_value_delete);
- ast_expression_init((ast_expression*)self,
- (ast_expression_codegen*)&ast_value_codegen);
- self->expression.node.keep = true; /* keep */
-
- self->name = name ? util_strdup(name) : NULL;
- self->expression.vtype = t;
- self->expression.next = NULL;
- self->isfield = false;
- self->cvq = CV_NONE;
- self->hasvalue = false;
- self->isimm = false;
- self->inexact = false;
- self->uses = 0;
- memset(&self->constval, 0, sizeof(self->constval));
-
- self->ir_v = NULL;
- self->ir_values = NULL;
- self->ir_value_count = 0;
-
- self->setter = NULL;
- self->getter = NULL;
- self->desc = NULL;
-
- self->argcounter = NULL;
- self->intrinsic = false;
-
- return self;
-}
-
-void ast_value_delete(ast_value* self)
-{
- if (self->name)
- mem_d((void*)self->name);
- if (self->argcounter)
- mem_d((void*)self->argcounter);
- if (self->hasvalue) {
- switch (self->expression.vtype)
- {
- case TYPE_STRING:
- mem_d((void*)self->constval.vstring);
- break;
- case TYPE_FUNCTION:
- /* unlink us from the function node */
- self->constval.vfunc->vtype = NULL;
- break;
- /* NOTE: delete function? currently collected in
- * the parser structure
- */
- default:
- break;
- }
- }
- if (self->ir_values)
- mem_d(self->ir_values);
-
- if (self->desc)
- mem_d(self->desc);
-
- // initlist imples an array which implies .next in the expression exists.
- if (self->initlist.size() && self->expression.next->vtype == TYPE_STRING) {
- for (auto &it : self->initlist)
- if (it.vstring)
- mem_d(it.vstring);
- }
-
- ast_expression_delete((ast_expression*)self);
- mem_d(self);
-}
-
-void ast_value_params_add(ast_value *self, ast_value *p)
-{
- self->expression.params.push_back(p);
-}
-
-bool ast_value_set_name(ast_value *self, const char *name)