#define NotSameType(T) \
(exprs[0]->vtype != exprs[1]->vtype || \
exprs[0]->vtype != T)
-
- /* preform any constant folding on operator usage first */
- /*if ((out = fold_op(parser->fold, op, exprs)))*/
- /*goto complete;*/
-
switch (op->id)
{
default:
}
}
break;
+
case opid1('/'):
if (exprs[1]->vtype != TYPE_FLOAT) {
ast_type_to_string(exprs[0], ty1, sizeof(ty1));
return false;
}
if (!(out = fold_op(parser->fold, op, exprs))) {
- if (exprs[0]->vtype == TYPE_FLOAT)
+ if (exprs[0]->vtype == TYPE_FLOAT)
out = (ast_expression*)ast_binary_new(ctx, INSTR_DIV_F, exprs[0], exprs[1]);
- else if (exprs[0]->vtype == TYPE_VECTOR) {
- out = (ast_expression*)ast_binary_new (
- ctx,
- INSTR_MUL_VF,
- exprs[0],
- (ast_expression*)ast_binary_new(
- ctx,
- INSTR_DIV_F,
- (ast_expression*)parser->fold->imm_float[1],
- exprs[1]
- )
- );
- } else {
+ else {
ast_type_to_string(exprs[0], ty1, sizeof(ty1));
ast_type_to_string(exprs[1], ty2, sizeof(ty2));
compile_error(ctx, "invalid types used in expression: cannot divide types %s and %s", ty1, ty2);
break;
}
#undef NotSameType
-/*complete:*/
if (!out) {
compile_error(ctx, "failed to apply operator %s", op->op);
return false;