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) {
: LexOf WordNoUnary[tag] ":" AssignmentExpression[value] ArgumentList_[next] { $$ = CYNew CYArgument($tag, $value, $next); }
;
/* }}} */
+/* JavaScript FTW: Subscript Access {{{ */
+MemberAccess
+ : "." "[" AssignmentExpression[property] "]" { $$ = CYNew CYSubscriptMember(NULL, $property); }
+ ;
+/* }}} */
/* JavaScript FTW: Java "Anonymous Inner Classes" {{{ */
BracedParameter
}
CYExpression *CYAssignment::Replace(CYContext &context) {
+ // XXX: this is a horrible hack but I'm a month over schedule :(
+ if (CYSubscriptMember *subscript = dynamic_cast<CYSubscriptMember *>(lhs_))
+ return $C2($M(subscript->object_, $S("$cys")), subscript->property_, rhs_);
context.Replace(lhs_);
context.Replace(rhs_);
return this;
default:; } }
}
+CYTarget *CYSubscriptMember::Replace(CYContext &context) {
+ return $C1($M(object_, $S("$cyg")), property_);
+}
+
CYElementValue *CYSpan::Replace(CYContext &context) { $T(NULL)
return $ CYElementValue(expression_, $ CYElementValue(string_, next_->Replace(context)));
}
virtual void Output(CYOutput &out, CYFlags flags) const;
};
+struct CYSubscriptMember :
+ CYMember
+{
+ CYSubscriptMember(CYExpression *object, CYExpression *property) :
+ CYMember(object, property)
+ {
+ }
+
+ CYPrecedence(1)
+
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
namespace cy {
namespace Syntax {
return `new java.lang.Double(${this.value})`;
},
});
+
+ $cy_set(java.lang.Object.prototype, {
+ // XXX: due to lack of interface prototypes :(
+ $cyg: function(key) {
+ return this.get(key);
+ },
+
+ // XXX: due to lack of interface prototypes :(
+ $cys: function(key, value) {
+ if ("set" in this)
+ this.set(key, value);
+ else
+ this.put(key, value);
+ },
+ });
+}
+
+if ("ObjectiveC" in Cycript) {
+ $cy_set(NSArray.prototype, {
+ $cyg: function(key) {
+ return objc_msgSend(this, "objectAtIndex:", key);
+ },
+
+ $cys: function(key, value) {
+ return objc_msgSend(this, "setObject:atIndex:", value, key);
+ },
+ });
+
+ $cy_set(NSDictionary.prototype, {
+ $cyg: function(key) {
+ return objc_msgSend(this, "objectForKey:", key);
+ },
+
+ $cys: function(key, value) {
+ return objc_msgSend(this, "setObject:forKey:", value, key);
+ },
+ });
}
let IsFile = function(path) {