mem_d(self);
}
+ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field)
+{
+ ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
+ ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_entfield_codegen);
+
+ self->entity = entity;
+ self->field = field;
+
+ return self;
+}
+
+void ast_entfield_delete(ast_entfield *self)
+{
+ ast_unref(self->entity);
+ ast_unref(self->field);
+ mem_d(self);
+}
+
ast_store* ast_store_new(lex_ctx ctx, int op,
ast_value *dest, ast_expression *source)
{
{
return false;
}
+
+bool ast_entfield_codegen(ast_entfield *self, ast_function *func, ir_value **out)
+{
+ return false;
+}
typedef struct ast_block_s ast_block;
typedef struct ast_binary_s ast_binary;
typedef struct ast_store_s ast_store;
+typedef struct ast_entfield_s ast_entfield;
/* Node interface with common components
*/
*/
bool ast_binary_codegen(ast_binary*, ast_function*, ir_value**);
+/* Entity-field
+ *
+ * This must do 2 things:
+ * -) Provide a way to fetch an entity field value. (Rvalue)
+ * -) Provide a pointer to an entity field. (Lvalue)
+ * The problem:
+ * In original QC, there's only a STORE via pointer, but
+ * no LOAD via pointer.
+ * So we must know beforehand if we are going to read or assign
+ * the field.
+ * For this we will have to extend the codegen() functions with
+ * a flag saying whether or not we need an L or an R-value.
+ */
+struct ast_entfield_s
+{
+ ast_expression_common expression;
+ /* The entity can come from an expression of course. */
+ ast_expression *entity;
+ /* As can the field, it just must result in a value of TYPE_FIELD */
+ ast_expression *field;
+};
+ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field);
+void ast_entfield_delete(ast_entfield*);
+
+bool ast_entfield_codegen(ast_entfield*, ast_function*, ir_value**);
+
/* Store
*
* Stores left<-right and returns left.