X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/b799113bd4ec270504dd9f552142c1adfd6e583a..fc44232bcff15a35c016ddfc1dc34b6503125020:/ObjectiveC/Replace.cpp diff --git a/ObjectiveC/Replace.cpp b/ObjectiveC/Replace.cpp index 9197a26..1502aa2 100644 --- a/ObjectiveC/Replace.cpp +++ b/ObjectiveC/Replace.cpp @@ -78,42 +78,26 @@ CYStatement *CYClassStatement::Replace(CYContext &context) { return $E(Replace_(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"))); -} - -CYExpression *CYTypePointerTo::Replace(CYContext &context) { - return $ CYCall($ CYDirectMember(next_->Replace(context), $ CYString("pointerTo"))); -} - -CYExpression *CYTypeVariable::Replace(CYContext &context) { - return expression_; -} - -CYExpression *CYEncodedType::Replace(CYContext &context) { - return type_->Replace(context); -} - CYStatement *CYField::Replace(CYContext &context) const { $T(NULL) CYVariable *cyn($V("$cyn")); CYVariable *cyt($V("$cyt")); - CYExpression *type($C0($M(type_, $S("toString")))); + CYExpression *type($C0($M(typed_->Replace(context), $S("toString")))); return $ CYBlock($$->* - next_->Replace(context)->* $E($ CYAssign(cyt, type))->* $E($ CYAssign(cyn, $N1($V("Type"), cyt)))->* - $E($C5($V("class_addIvar"), $V("$cyc"), $S(name_->Word()), $M(cyn, $S("size")), $M(cyn, $S("alignment")), cyt)) + $E($C5($V("class_addIvar"), $V("$cyc"), $S(typed_->identifier_->Word()), $M(cyn, $S("size")), $M(cyn, $S("alignment")), cyt))->* + next_->Replace(context) ); } CYStatement *CYImport::Replace(CYContext &context) { - return this; + return $ CYVar($L1($L(module_->part_->Word(), $C1($V("require"), module_->Replace(context, "/"))))); +} + +CYExpression *CYInstanceLiteral::Replace(CYContext &context) { + return $N1($V("Instance"), number_); } CYStatement *CYMessage::Replace(CYContext &context, bool replace) const { $T(NULL) @@ -132,7 +116,7 @@ CYStatement *CYMessage::Replace(CYContext &context, bool replace) const { $T(NUL $V(instance_ ? "$cyc" : "$cym"), cyn, $N2($V("Functor"), $F(NULL, $P2($L("self"), $L("_cmd"), parameters_->Parameters(context)), $$->* - $ CYVar($L1($L("$cyr", $N2($V("Super"), self, _class))))->* + $ CYVar($L1($L("$cyr", $N2($V("objc_super"), self, _class))))->* $ CYReturn($C1($M($F(NULL, NULL, code_), $S("call")), self)) ), cyt), cyt @@ -162,12 +146,18 @@ CYExpression *CYMessageParameter::TypeSignature(CYContext &context) const { return MessageType(context, type_, next_); } +CYString *CYModule::Replace(CYContext &context, const char *separator) const { + if (next_ == NULL) + return $ CYString(part_); + return $ CYString($pool.strcat(next_->Replace(context, separator)->Value(), separator, part_->Word(), NULL)); +} + CYExpression *CYBox::Replace(CYContext &context) { return $C1($M($V("Instance"), $S("box")), value_); } CYExpression *CYObjCBlock::Replace(CYContext &context) { - return $N2($V("Functor"), $ CYFunctionExpression(NULL, $ CYFunctionParameter($ CYDeclaration($ CYIdentifier("$cyt")), parameters_->Parameters(context)), statements_), parameters_->TypeSignature(context, $ CYAdd(type_->Replace(context), $ CYString("@")))); + return $C1($ CYEncodedType(($ CYTypedIdentifier(*typed_))->Modify($ CYTypeBlockWith(parameters_))), $ CYFunctionExpression(NULL, parameters_->Parameters(context), statements_)); } CYStatement *CYProtocol::Replace(CYContext &context) const { $T(NULL) @@ -216,17 +206,9 @@ CYExpression *CYSendDirect::Replace(CYContext &context) { argument = &(*argument)->next_; } - return $C2($V("objc_msgSend"), self_, ($ CYSelector(selector))->Replace(context), arguments_); + return $C2($V("objc_msgSend"), self_, selector->Replace(context), arguments_); } CYExpression *CYSendSuper::Replace(CYContext &context) { return $ CYSendDirect($V("$cyr"), arguments_); } - -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))); -}