]> git.saurik.com Git - cycript.git/commitdiff
Implement internal multiply (for the compiler).
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 21 Jan 2014 11:35:43 +0000 (03:35 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 21 Jan 2014 11:35:43 +0000 (03:35 -0800)
Parser.hpp
Replace.cpp

index 0e4b51f824d6653e2d801a2a7423579092c48c9e..59e657fa17ecc7241c5f75ea22d2c8472e0cb9fc 100644 (file)
@@ -2043,7 +2043,7 @@ CYPrefix_(false, "-", Negate)
 CYPrefix_(false, "~", BitwiseNot)
 CYPrefix_(false, "!", LogicalNot)
 
 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)
 CYInfix_(false, 5, "/", Divide)
 CYInfix_(false, 5, "%", Modulus)
 CYInfix_(false, 6, "+", Add, CYReplace)
index 83a5c47328840c8238115c6908ac47563dafa51b..f5779191689ce3ec9a8b680d292018a943f0c290 100644 (file)
@@ -533,6 +533,19 @@ CYStatement *CYLetStatement::Replace(CYContext &context) {
     return $E($ CYCall(CYNonLocalize(context, $ CYFunctionExpression(NULL, declarations_->Parameter(context), code_)), declarations_->Argument(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 {
 
 namespace cy {
 namespace Syntax {