#include "cycript.hpp"
+#ifdef CY_EXECUTE
+#include "JavaScript.hpp"
+#endif
+
#include <cstdio>
#include <sstream>
driver.strict_ = true;
}
-void Setup(CYOutput &out, CYDriver &driver) {
+void Setup(CYOutput &out, CYDriver &driver, CYOptions &options) {
out.pretty_ = pretty_;
-
- CYContext context(driver.pool_);
+ CYContext context(driver.pool_, options);
driver.program_->Replace(context);
}
int (*append_history$)(int, const char *);
-static void Console(apr_pool_t *pool, int client) {
+static void Console(apr_pool_t *pool, int client, CYOptions &options) {
passwd *passwd;
if (const char *username = getenv("LOGNAME"))
passwd = getpwnam(username);
code = command;
else {
std::ostringstream str;
- CYOutput out(str);
- Setup(out, driver);
+ CYOutput out(str, options);
+ Setup(out, driver, options);
out << *driver.program_;
code = str.str();
}
if (debug)
std::cout << code << std::endl;
- if (!bypass)
- code = "with(Cycript.all){" + code + "}";
Run(client, code, fout, expand);
}
int Main(int argc, char const * const argv[], char const * const envp[]) {
bool tty(isatty(STDIN_FILENO));
bool compile(false);
+ CYOptions options;
append_history$ = reinterpret_cast<int (*)(int, const char *)>(dlsym(RTLD_DEFAULT, "append_history"));
case 'g':
if (false);
+ else if (strcmp(arg, "rename") == 0)
+ options.verbose_ = true;
#if YYDEBUG
else if (strcmp(arg, "bison") == 0)
bison_ = true;
#endif
if (script == NULL && tty)
- Console(pool, client);
+ Console(pool, client, options);
else {
CYDriver driver(script ?: "<stdin>");
cy::parser parser(driver);
} else if (driver.program_ != NULL)
if (client != -1) {
std::string code(start, end-start);
- code = "with(Cycript.all){" + code + "}";
Run(client, code, stdout);
} else {
std::ostringstream str;
- CYOutput out(str);
- Setup(out, driver);
+ CYOutput out(str, options);
+ Setup(out, driver, options);
out << *driver.program_;
std::string code(str.str());
if (compile)
std::cout << code;
- else {
- code = "with(Cycript.all){" + code + "}";
+ else
Run(client, code, stdout);
- }
}
}