From: Jay Freeman (saurik) Date: Tue, 21 Jan 2014 11:35:43 +0000 (-0800) Subject: Implement internal multiply (for the compiler). X-Git-Tag: v0.9.500~16 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/62f398e4aed5b34ee2bd8edff9fb3afa80d75e25?ds=inline Implement internal multiply (for the compiler). --- diff --git a/Parser.hpp b/Parser.hpp index 0e4b51f..59e657f 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -2043,7 +2043,7 @@ CYPrefix_(false, "-", Negate) CYPrefix_(false, "~", BitwiseNot) CYPrefix_(false, "!", LogicalNot) -CYInfix_(false, 5, "*", Multiply) +CYInfix_(false, 5, "*", Multiply, CYReplace) CYInfix_(false, 5, "/", Divide) CYInfix_(false, 5, "%", Modulus) CYInfix_(false, 6, "+", Add, CYReplace) diff --git a/Replace.cpp b/Replace.cpp index 83a5c47..f577919 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -533,6 +533,19 @@ CYStatement *CYLetStatement::Replace(CYContext &context) { return $E($ CYCall(CYNonLocalize(context, $ CYFunctionExpression(NULL, declarations_->Parameter(context), code_)), declarations_->Argument(context))); } +CYExpression *CYMultiply::Replace(CYContext &context) { + CYInfix::Replace(context); + + CYExpression *lhp(lhs_->Primitive(context)); + CYExpression *rhp(rhs_->Primitive(context)); + + if (CYNumber *lhn = lhp->Number(context)) + if (CYNumber *rhn = rhp->Number(context)) + return $D(lhn->Value() * rhn->Value()); + + return this; +} + namespace cy { namespace Syntax {