* of the form: (a, b, c) = x should not assign to c...
*/
(void)lvalue;
+ if (self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
/* output is NULL at first, we'll have each expression
* assign to out output, thus, a comma-operator represention
return false;
}
+ self->expression.outr = *out;
+
return true;
}
ast_expression_codegen *cgen;
ir_value *left, *right;
+ if (lvalue && self->expression.outl) {
+ *out = self->expression.outl;
+ return true;
+ }
+
+ if (!lvalue && self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
+
cgen = self->dest->expression.codegen;
/* lvalue! */
if (!(*cgen)((ast_expression*)(self->dest), func, true, &left))
return false;
+ self->expression.outl = left;
cgen = self->source->expression.codegen;
/* rvalue! */
if (!ir_block_create_store_op(func->curblock, self->op, left, right))
return false;
+ self->expression.outr = right;
/* Theoretically, an assinment returns its left side as an
* lvalue, if we don't need an lvalue though, we return
/* In the context of a binary operation, we can disregard
* the lvalue flag.
*/
- (void)lvalue;
+ (void)lvalue;
+ if (self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
cgen = self->left->expression.codegen;
/* lvalue! */
self->op, left, right);
if (!*out)
return false;
+ self->expression.outr = *out;
return true;
}
* the lvalue flag.
*/
(void)lvalue;
+ if (self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
cgen = self->operand->expression.codegen;
/* lvalue! */
self->op, operand);
if (!*out)
return false;
+ self->expression.outr = *out;
return true;
}
* the lvalue flag.
*/
(void)lvalue;
+ if (self->expression.outr) {
+ printf("internal error: ast_return cannot be reused, it bears no result!\n");
+ return false;
+ }
+ self->expression.outr = (ir_value*)1;
cgen = self->operand->expression.codegen;
/* lvalue! */
* value in a temp.
*/
+ if (lvalue && self->expression.outl) {
+ *out = self->expression.outl;
+ return true;
+ }
+
+ if (!lvalue && self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
+
cgen = self->entity->expression.codegen;
if (!(*cgen)((ast_expression*)(self->entity), func, false, &ent))
return false;
if (!*out)
return false;
+ if (lvalue)
+ self->expression.outl = *out;
+ else
+ self->expression.outr = *out;
+
/* Hm that should be it... */
return true;
}
ast_expression_codegen *cgen;
ir_value *vec;
+ /* in QC this is always an lvalue */
+ (void)lvalue;
+ if (self->expression.outl) {
+ *out = self->expression.outl;
+ return true;
+ }
+
cgen = self->owner->expression.codegen;
if (!(*cgen)((ast_expression*)(self->owner), func, true, &vec))
return false;
}
*out = ir_value_vector_member(vec, self->field);
+ self->expression.outl = *out;
return (*out != NULL);
}
(void)out;
(void)lvalue;
+ if (self->expression.outr) {
+ printf("internal error: ast_ifthen cannot be reused, it bears no result!\n");
+ return false;
+ }
+ self->expression.outr = (ir_value*)1;
+
/* generate the condition */
func->curblock = cond;
cgen = self->cond->expression.codegen;
ir_block *onfalse;
ir_block *merge;
+ /* Ternary can never create an lvalue... */
+ if (lvalue)
+ return false;
+
/* In theory it shouldn't be possible to pass through a node twice, but
* in case we add any kind of optimization pass for the AST itself, it
* may still happen, thus we remember a created ir_value and simply return one
return true;
}
- /* Ternary can never create an lvalue... */
- if (lvalue)
- return false;
-
/* In the following, contraty to ast_ifthen, we assume both paths exist. */
/* generate the condition */
(void)lvalue;
(void)out;
+ if (self->expression.outr) {
+ printf("internal error: ast_loop cannot be reused, it bears no result!\n");
+ return false;
+ }
+ self->expression.outr = (ir_value*)1;
+
/* NOTE:
* Should we ever need some kind of block ordering, better make this function
* move blocks around than write a block ordering algorithm later... after all
ir_value *funval = NULL;
- /* return values are never rvalues */
+ /* return values are never lvalues */
(void)lvalue;
+ if (self->expression.outr) {
+ *out = self->expression.outr;
+ return true;
+ }
+
cgen = self->func->expression.codegen;
if (!(*cgen)((ast_expression*)(self->func), func, false, &funval))
return false;
}
*out = ir_call_value(callinstr);
+ self->expression.outr = *out;
MEM_VECTOR_CLEAR(¶ms, v);
return true;