}
QML_V4_END_INSTR(StrictNotEqualString, binaryop)
+ QML_V4_BEGIN_INSTR(MathMaxReal, binaryop)
+ {
+ const Register &left = registers[instr->binaryop.left];
+ const Register &right = registers[instr->binaryop.right];
+ Register &output = registers[instr->binaryop.output];
+ if (left.isUndefined() || right.isUndefined()) output.setUndefined();
+ else output.setqreal(qMax(left.getqreal(), right.getqreal()));
+ }
+ QML_V4_END_INSTR(MathMaxReal, binaryop)
+
+ QML_V4_BEGIN_INSTR(MathMinReal, binaryop)
+ {
+ const Register &left = registers[instr->binaryop.left];
+ const Register &right = registers[instr->binaryop.right];
+ Register &output = registers[instr->binaryop.output];
+ if (left.isUndefined() || right.isUndefined()) output.setUndefined();
+ else output.setqreal(qMin(left.getqreal(), right.getqreal()));
+ }
+ QML_V4_END_INSTR(MathMinReal, binaryop)
+
QML_V4_BEGIN_INSTR(NewString, construct)
{
Register &output = registers[instr->construct.reg];
} return;
case IR::MathPIBuiltinConstant:
+ default:
break;
} // switch
+ } else {
+ if (name->builtin == IR::MathMaxBuiltinFunction ||
+ name->builtin == IR::MathMinBuiltinFunction) {
+
+ //only handles the most common case of exactly two arguments
+ if (call->args && call->args->next && !call->args->next->next) {
+ IR::Expr *arg1 = call->args->expr;
+ IR::Expr *arg2 = call->args->next->expr;
+
+ if (arg1 != 0 && arg1->type == IR::RealType &&
+ arg2 != 0 && arg2->type == IR::RealType) {
+
+ traceExpression(arg1, currentReg);
+ traceExpression(arg2, currentReg + 1);
+
+ if (name->builtin == IR::MathMaxBuiltinFunction) {
+ Instr::MathMaxReal i;
+ i.left = currentReg;
+ i.right = currentReg + 1;
+ i.output = currentReg;
+ gen(i);
+ return;
+ } else if (name->builtin == IR::MathMinBuiltinFunction) {
+ Instr::MathMinReal i;
+ i.left = currentReg;
+ i.right = currentReg + 1;
+ i.output = currentReg;
+ gen(i);
+ return;
+ }
+ }
+ }
+ }
}
}
case V4Instr::StrictNotEqualString:
INSTR_DUMP << "\t" << "StrictNotEqualString" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
break;
+ case V4Instr::MathMaxReal:
+ INSTR_DUMP << "\t" << "MathMaxReal" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
+ case V4Instr::MathMinReal:
+ INSTR_DUMP << "\t" << "MathMinReal" << "\t" << "Input_Reg(" << i->binaryop.left << ") Input_Reg(" << i->binaryop.right << ") -> Output_Reg(" << i->binaryop.output << ")";
+ break;
case V4Instr::NewString:
INSTR_DUMP << "\t" << "NewString" << "\t\t" << "Register(" << i->construct.reg << ")";
break;
F(NotEqualString, binaryop) \
F(StrictEqualString, binaryop) \
F(StrictNotEqualString, binaryop) \
+ F(MathMaxReal, binaryop) \
+ F(MathMinReal, binaryop) \
F(NewString, construct) \
F(NewUrl, construct) \
F(CleanupRegister, cleanup) \
builtin = MathFloorBultinFunction;
} else if (id->length() == 9 && *id == QLatin1String("Math.ceil")) {
builtin = MathCeilBuiltinFunction;
+ } else if (id->length() == 8 && *id == QLatin1String("Math.max")) {
+ builtin = MathMaxBuiltinFunction;
+ } else if (id->length() == 8 && *id == QLatin1String("Math.min")) {
+ builtin = MathMinBuiltinFunction;
} else if (id->length() == 7 && *id == QLatin1String("Math.PI")) {
builtin = MathPIBuiltinConstant;
this->type = RealType;
case MathSinBultinFunction:
case MathCosBultinFunction:
case MathAbsBuiltinFunction: //### type could also be Int if input was Int
+ case MathMaxBuiltinFunction:
+ case MathMinBuiltinFunction:
return RealType;
case MathRoundBultinFunction:
MathFloorBultinFunction,
MathCeilBuiltinFunction,
MathAbsBuiltinFunction,
+ MathMaxBuiltinFunction,
+ MathMinBuiltinFunction,
MathPIBuiltinConstant
};