X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/2fad14e52c8cde8c45003a2ebb6907a57ca380e4..53cb77ff9ae5b8dc87f7924ede75be1e1944e004:/Output.cpp diff --git a/Output.cpp b/Output.cpp index c436b3c..0bc1172 100644 --- a/Output.cpp +++ b/Output.cpp @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -452,8 +452,13 @@ void CYExpression::Output(CYOutput &out, int precedence, CYFlags flags) const { Output(out, flags); } +void CYExtend::Output(CYOutput &out, CYFlags flags) const { + lhs_->Output(out, CYLeft(flags)); + out << ' ' << object_; +} + void CYExternal::Output(CYOutput &out, CYFlags flags) const { - out << "extern" << abi_ << typed_; + out << "extern" << ' ' << abi_ << ' ' << typed_; out.Terminate(); } @@ -660,7 +665,7 @@ void CYTemplate::Output(CYOutput &out, CYFlags flags) const { } void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const { - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, false); out << '['; out << size_; out << ']'; @@ -668,17 +673,17 @@ void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const { void CYTypeBlockWith::Output(CYOutput &out, CYIdentifier *identifier) const { out << '(' << '^'; - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, false); out << ')' << '(' << parameters_ << ')'; } void CYTypeConstant::Output(CYOutput &out, CYIdentifier *identifier) const { - out << "const" << ' '; - next_->Output(out, Precedence(), identifier); + out << "const"; + next_->Output(out, Precedence(), identifier, false); } void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const { - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, false); out << '(' << parameters_; if (variadic_) { if (parameters_ != NULL) @@ -690,15 +695,20 @@ void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const { void CYTypePointerTo::Output(CYOutput &out, CYIdentifier *identifier) const { out << '*'; - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, false); } void CYTypeVolatile::Output(CYOutput &out, CYIdentifier *identifier) const { out << "volatile"; - next_->Output(out, Precedence(), identifier); + next_->Output(out, Precedence(), identifier, true); } -void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier) const { +void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier, bool space) const { + if (this == NULL && identifier == NULL) + return; + else if (space) + out << ' '; + if (this == NULL) { out << identifier; return; @@ -715,7 +725,7 @@ void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identif void CYTypedIdentifier::Output(CYOutput &out) const { specifier_->Output(out); - modifier_->Output(out, 0, identifier_); + modifier_->Output(out, 0, identifier_, true); } void CYEncodedType::Output(CYOutput &out, CYFlags flags) const { @@ -872,7 +882,7 @@ void CYReturn::Output(CYOutput &out, CYFlags flags) const { } void CYRubyBlock::Output(CYOutput &out, CYFlags flags) const { - call_->Output(out, CYLeft(flags)); + lhs_->Output(out, CYLeft(flags)); out << ' '; proc_->Output(out, CYRight(flags)); } @@ -885,6 +895,11 @@ void CYRubyProc::Output(CYOutput &out, CYFlags flags) const { out << '\t' << '}'; } +void CYSubscriptMember::Output(CYOutput &out, CYFlags flags) const { + object_->Output(out, Precedence(), CYLeft(flags)); + out << "." << '[' << *property_ << ']'; +} + void CYStatement::Multiple(CYOutput &out, CYFlags flags) const { bool first(true); CYForEach (next, this) { @@ -980,7 +995,7 @@ void CYStructTail::Output(CYOutput &out) const { out << '\n'; } --out.indent_; - out << '}'; + out << '\t' << '}'; } void CYSuperAccess::Output(CYOutput &out, CYFlags flags) const {