{
(void)func;
(void)lvalue;
+ if (self->expression.vtype == TYPE_NIL) {
+ *out = func->ir_func->owner->nil;
+ return true;
+ }
/* NOTE: This is the codegen for a variable used in an expression.
* It is not the codegen to generate the value. For this purpose,
* ast_local_codegen and ast_global_codegen are to be used before this
{
ir_value *v = NULL;
+ if (self->expression.vtype == TYPE_NIL) {
+ compile_error(ast_ctx(self), "internal error: trying to generate a variable of TYPE_NIL");
+ return false;
+ }
+
if (self->hasvalue && self->expression.vtype == TYPE_FUNCTION)
{
ir_function *func = ir_builder_create_function(ir, self->name, self->expression.next->expression.vtype);
bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
{
ir_value *v = NULL;
+
+ if (self->expression.vtype == TYPE_NIL) {
+ compile_error(ast_ctx(self), "internal error: trying to generate a variable of TYPE_NIL");
+ return false;
+ }
+
if (self->hasvalue && self->expression.vtype == TYPE_FUNCTION)
{
/* Do we allow local functions? I think not...
TYPE_UNION ,
TYPE_ARRAY ,
+ TYPE_NIL , /* it's its own type / untyped */
+
TYPE_COUNT
};
"variant",
"struct",
"union",
- "array"
+ "array",
+
+ "nil"
};
size_t type_sizeof_[TYPE_COUNT] = {
0, /* TYPE_STRUCT */
0, /* TYPE_UNION */
0, /* TYPE_ARRAY */
+ 0, /* TYPE_NIL */
};
uint16_t type_store_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
uint16_t field_store_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
uint16_t type_storep_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
uint16_t type_eq_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
uint16_t type_ne_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
uint16_t type_not_instr[TYPE_COUNT] = {
AINSTR_END, /* struct */
AINSTR_END, /* union */
AINSTR_END, /* array */
+ AINSTR_END, /* nil */
};
/* protos */
return NULL;
}
+ self->nil = ir_value_var("nil", store_value, TYPE_NIL);
+ self->nil->cvq = CV_CONST;
+
return self;
}
for (i = 0; i != vec_size(self->fields); ++i) {
ir_value_delete(self->fields[i]);
}
+ ir_value_delete(self->nil);
vec_free(self->fields);
vec_free(self->filenames);
vec_free(self->filestrings);
const char **filenames;
qcint *filestrings;
/* we cache the #IMMEDIATE string here */
- qcint str_immediate;
+ qcint str_immediate;
+ /* there should just be this one nil */
+ ir_value *nil;
} ir_builder;
ir_builder* ir_builder_new(const char *modulename);