]> git.saurik.com Git - cycript.git/blobdiff - Replace.cpp
Move lib/cycript to cycript0.9 to free up cycript.
[cycript.git] / Replace.cpp
index 83a5c47328840c8238115c6908ac47563dafa51b..f914af98b82aed992fd4363c8849b8c94a917de7 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)));
 }
 
+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 {
 
@@ -885,6 +898,11 @@ CYStatement *CYTypeDefinition::Replace(CYContext &context) {
     return $E($ CYAssign($V(typed_->identifier_), typed_->Replace(context)));
 }
 
+CYExpression *CYTypeError::Replace(CYContext &context) {
+    _assert(false);
+    return NULL;
+}
+
 CYExpression *CYTypeModifier::Replace(CYContext &context, CYExpression *type) { $T(type)
     return Replace_(context, type);
 }
@@ -893,16 +911,40 @@ CYExpression *CYTypeFunctionWith::Replace_(CYContext &context, CYExpression *typ
     return next_->Replace(context, $ CYCall($ CYDirectMember(type, $ CYString("functionWith")), parameters_->Argument(context)));
 }
 
+CYExpression *CYTypeLong::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(specifier_->Replace(context), $ CYString("long")));
+}
+
 CYExpression *CYTypePointerTo::Replace_(CYContext &context, CYExpression *type) {
     return next_->Replace(context, $ CYCall($ CYDirectMember(type, $ CYString("pointerTo"))));
 }
 
+CYExpression *CYTypeShort::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(specifier_->Replace(context), $ CYString("short")));
+}
+
+CYExpression *CYTypeSigned::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(specifier_->Replace(context), $ CYString("signed")));
+}
+
+CYExpression *CYTypeUnsigned::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(specifier_->Replace(context), $ CYString("unsigned")));
+}
+
+CYExpression *CYTypeVariable::Replace(CYContext &context) {
+    return $V(name_);
+}
+
+CYExpression *CYTypeVoid::Replace(CYContext &context) {
+    return $N1($V("Type"), $ CYString("v"));
+}
+
 CYExpression *CYTypeVolatile::Replace_(CYContext &context, CYExpression *type) {
     return next_->Replace(context, $ CYCall($ CYDirectMember(type, $ CYString("volatile"))));
 }
 
 CYExpression *CYTypedIdentifier::Replace(CYContext &context) {
-    return modifier_->Replace(context, type_);
+    return modifier_->Replace(context, specifier_->Replace(context));
 }
 
 CYArgument *CYTypedParameter::Argument(CYContext &context) { $T(NULL)
@@ -914,7 +956,7 @@ CYFunctionParameter *CYTypedParameter::Parameters(CYContext &context) { $T(NULL)
 }
 
 CYExpression *CYTypedParameter::TypeSignature(CYContext &context, CYExpression *prefix) { $T(prefix)
-    return next_->TypeSignature(context, $ CYAdd(prefix, typed_->type_->Replace(context)));
+    return next_->TypeSignature(context, $ CYAdd(prefix, typed_->Replace(context)));
 }
 
 CYStatement *CYVar::Replace(CYContext &context) {