]> git.saurik.com Git - cycript.git/blobdiff - Replace.cpp
CYDisplay{Start,Finish} obsolete by rl_redisplay.
[cycript.git] / Replace.cpp
index 1e0a5ca4cad7eac44fb5b3bad6d00ef852878c40..f1283dec929178d10523a6b132a4ec3942c24c5f 100644 (file)
@@ -210,7 +210,7 @@ void CYContext::NonLocal(CYStatement *&statements) {
 }
 
 CYIdentifier *CYContext::Unique() {
-    return $ CYIdentifier($pool.sprintf("$cy%u", unique_++));
+    return $ CYIdentifier($pool.strcat("$cy", $pool.itoa(unique_++), NULL));
 }
 
 CYStatement *CYContinue::Replace(CYContext &context) {
@@ -521,6 +521,10 @@ CYStatement *CYLabel::Replace(CYContext &context) {
     return this;
 }
 
+CYExpression *CYLambda::Replace(CYContext &context) {
+    return $N2($V("Functor"), $ CYFunctionExpression(NULL, parameters_->Parameters(context), statements_), parameters_->TypeSignature(context, type_->Replace(context)));
+}
+
 CYStatement *CYLetStatement::Replace(CYContext &context) {
     return $E($ CYCall(CYNonLocalize(context, $ CYFunctionExpression(NULL, declarations_->Parameter(context), code_)), declarations_->Argument(context)));
 }
@@ -555,7 +559,7 @@ CYNumber *CYNumber::Number(CYContext &context) {
 
 CYString *CYNumber::String(CYContext &context) {
     // XXX: there is a precise algorithm for this
-    return $S($pool.sprintf("%.17g", Value()));
+    return $S($pool.sprintf(24, "%.17g", Value()));
 }
 
 CYExpression *CYObject::Replace(CYContext &context) {
@@ -619,7 +623,7 @@ void CYProgram::Replace(CYContext &context) {
         const char *name;
 
         if (context.options_.verbose_)
-            name = $pool.sprintf("$%"APR_SIZE_T_FMT"", offset);
+            name = $pool.strcat("$", $pool.itoa(offset), NULL);
         else {
             char id[8];
             id[7] = '\0';
@@ -861,6 +865,42 @@ CYStatement *Try::Replace(CYContext &context) {
 
 } }
 
+CYExpression *CYTypeArrayOf::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("arrayOf")), $ CYArgument(size_));
+}
+
+CYExpression *CYTypeConstant::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("constant")));
+}
+
+CYStatement *CYTypeDefinition::Replace(CYContext &context) {
+    return $E($ CYAssign($V(typed_->identifier_), typed_->type_->Replace(context)));
+}
+
+CYExpression *CYTypeFunctionWith::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("functionWith")), parameters_->Argument(context));
+}
+
+CYExpression *CYTypePointerTo::Replace(CYContext &context) {
+    return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("pointerTo")));
+}
+
+CYExpression *CYTypeVariable::Replace(CYContext &context) {
+    return expression_;
+}
+
+CYArgument *CYTypedParameter::Argument(CYContext &context) { $T(NULL)
+    return $ CYArgument(typed_->type_->Replace(context), next_->Argument(context));
+}
+
+CYFunctionParameter *CYTypedParameter::Parameters(CYContext &context) { $T(NULL)
+    return $ CYFunctionParameter($ CYDeclaration(typed_->identifier_ ?: context.Unique()), next_->Parameters(context));
+}
+
+CYExpression *CYTypedParameter::TypeSignature(CYContext &context, CYExpression *prefix) { $T(prefix)
+    return next_->TypeSignature(context, $ CYAdd(prefix, typed_->type_->Replace(context)));
+}
+
 CYStatement *CYVar::Replace(CYContext &context) {
     declarations_->Replace(context);
     return $E(declarations_->Compound(context));