/* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2010 Jay Freeman (saurik)
+ * Copyright (C) 2009-2012 Jay Freeman (saurik)
*/
/* GNU Lesser General Public License, Version 3 {{{ */
if (data == NULL || fout == NULL)
return;
- if (!expand || data[0] != '"' && data[0] != '\'')
+ if (!expand ||
+ data[0] != '@' && data[0] != '"' && data[0] != '\'' ||
+ data[0] == '@' && data[1] != '"' && data[1] != '\''
+ )
fputs(data, fout);
else for (size_t i(0); i != size; ++i)
if (data[i] != '\\')
Setup(driver, parser);
if (parser.parse() != 0 || !driver.errors_.empty())
- _assert(false);
+ return NULL;
+
+ CYOptions options;
+ CYContext context(options);
- CYExpress *express(dynamic_cast<CYExpress *>(driver.program_->statements_));
- _assert(express != NULL);
- return express->expression_;
+ // XXX: this could be replaced with a CYStatement::Primitive()
+ if (CYExpress *express = dynamic_cast<CYExpress *>(driver.program_->statements_))
+ return express->expression_->Primitive(context);
+
+ return NULL;
}
static int client_;
case CYDriver::AutoMessage: {
CYDriver::Context &thing(driver.contexts_.back());
- expression = $M($M($ CYIndirect(thing.context_), $S("isa")), $S("messages"));
+ expression = $M($C1($V("object_getClass"), thing.context_), $S("messages"));
for (CYDriver::Context::Words::const_iterator part(thing.words_.begin()); part != thing.words_.end(); ++part)
prefix << (*part)->word_ << ':';
} break;
driver.program_ = $ CYProgram($ CYExpress($C3(ParseExpression(
" function(object, prefix, word) {\n"
" var names = [];\n"
- " var pattern = '^' + prefix + word;\n"
- " var length = prefix.length;\n"
+ " var before = prefix.length;\n"
+ " prefix += word;\n"
+ " var entire = prefix.length;\n"
" for (name in object)\n"
- " if (name.match(pattern) != null)\n"
- " names.push(name.substr(length));\n"
+ " if (name.substring(0, entire) == prefix)\n"
+ " names.push(name.substr(before));\n"
" return names;\n"
" }\n"
), expression, $S(begin.c_str()), $S(word))));
CYUTF8String json(Run(pool, client_, code));
CYExpression *result(ParseExpression(json));
+ if (result == NULL)
+ return NULL;
+
CYArray *array(dynamic_cast<CYArray *>(result));
if (array == NULL) {