X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/64b8d29fad73d4dee83b8f0a9f35f30d9cc72846..55c6d6ab933f1db37899604a17298cd6fc768fc3:/ObjectiveC/Output.mm?ds=sidebyside diff --git a/ObjectiveC/Output.mm b/ObjectiveC/Output.mm index d8f8345..a2d765c 100644 --- a/ObjectiveC/Output.mm +++ b/ObjectiveC/Output.mm @@ -1,40 +1,22 @@ -/* Cycript - Inlining/Optimizing JavaScript Compiler - * Copyright (C) 2009 Jay Freeman (saurik) +/* Cycript - Optimizing JavaScript Compiler/Runtime + * Copyright (C) 2009-2012 Jay Freeman (saurik) */ -/* Modified BSD License {{{ */ +/* GNU Lesser General Public License, Version 3 {{{ */ /* - * Redistribution and use in source and binary - * forms, with or without modification, are permitted - * provided that the following conditions are met: + * Cycript is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. * - * 1. Redistributions of source code must retain the - * above copyright notice, this list of conditions - * and the following disclaimer. - * 2. Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions - * and the following disclaimer in the documentation - * and/or other materials provided with the - * distribution. - * 3. The name of the author may not be used to endorse - * or promote products derived from this software - * without specific prior written permission. + * Cycript is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * You should have received a copy of the GNU Lesser General Public License + * along with Cycript. If not, see . +**/ /* }}} */ #include "Replace.hpp" @@ -79,7 +61,7 @@ void CYClass::Output(CYOutput &out, CYFlags flags) const { out << "return $cyc;"; out << "}("; if (super_ != NULL) - super_->Output(out, CYPA, CYNoFlags); + super_->Output(out, CYAssign::Precedence_, CYNoFlags); else out << "null"; out << "))"; @@ -93,13 +75,23 @@ void CYClassStatement::Output(CYOutput &out, CYFlags flags) const { CYClass::Output(out, flags); } +void CYEncodedType::Output(CYOutput &out, CYFlags flags) const { + out << "@encode("; + // XXX: this is seriously wrong + out << ")"; +} + void CYField::Output(CYOutput &out) const { } +void CYImport::Output(CYOutput &out, CYFlags flags) const { + out << "@import"; +} + void CYMessage::Output(CYOutput &out, bool replace) const { out << (instance_ ? '-' : '+'); - for (CYMessageParameter *parameter(parameters_); parameter != NULL; parameter = parameter->next_) + CYForEach (parameter, parameters_) if (parameter->tag_ != NULL) { out << ' ' << *parameter->tag_; if (parameter->name_ != NULL) @@ -109,8 +101,21 @@ void CYMessage::Output(CYOutput &out, bool replace) const { out << code_; } +void CYBox::Output(CYOutput &out, CYFlags flags) const { + out << '@'; + value_->Output(out, Precedence(), CYRight(flags)); +} + +void CYObjCBlock::Output(CYOutput &out, CYFlags flags) const { + // XXX: this is seriously wrong + out << "^("; + out << ")"; + out << "{"; + out << "}"; +} + void CYProtocol::Output(CYOutput &out) const { - name_->Output(out, CYPA, CYNoFlags); + name_->Output(out, CYAssign::Precedence_, CYNoFlags); if (next_ != NULL) out << ',' << ' ' << *next_; } @@ -127,7 +132,7 @@ void CYSelectorPart::Output(CYOutput &out) const { } void CYSend::Output(CYOutput &out, CYFlags flags) const { - for (CYArgument *argument(arguments_); argument != NULL; argument = argument->next_) + CYForEach (argument, arguments_) if (argument->name_ != NULL) { out << ' ' << *argument->name_; if (argument->value_ != NULL) @@ -137,7 +142,7 @@ void CYSend::Output(CYOutput &out, CYFlags flags) const { void CYSendDirect::Output(CYOutput &out, CYFlags flags) const { out << '['; - self_->Output(out, CYPA, CYNoFlags); + self_->Output(out, CYAssign::Precedence_, CYNoFlags); CYSend::Output(out, flags); out << ']'; }