]> git.saurik.com Git - cycript.git/blobdiff - Complete.cpp
Use Object.defineProperty as ES6 class visibility.
[cycript.git] / Complete.cpp
index 75b80c0c542d007f1435078364c8c1c72ffbb921..c81f90eb15cde39166ce5967b61ead5298679c5e 100644 (file)
@@ -22,7 +22,6 @@
 #include "cycript.hpp"
 
 #include "Driver.hpp"
 #include "cycript.hpp"
 
 #include "Driver.hpp"
-#include "Cycript.tab.hh"
 #include "Replace.hpp"
 #include "String.hpp"
 
 #include "Replace.hpp"
 #include "String.hpp"
 
@@ -30,19 +29,17 @@ static CYExpression *ParseExpression(CYPool &pool, CYUTF8String code) {
     std::stringstream stream;
     stream << '(' << code << ')';
     CYDriver driver(pool, stream);
     std::stringstream stream;
     stream << '(' << code << ')';
     CYDriver driver(pool, stream);
-
-    cy::parser parser(driver);
-    if (parser.parse() != 0 || !driver.errors_.empty())
+    if (driver.Parse() || !driver.errors_.empty())
         return NULL;
 
     CYOptions options;
     CYContext context(options);
 
         return NULL;
 
     CYOptions options;
     CYContext context(options);
 
-    CYStatement *statement(driver.program_->code_);
+    CYStatement *statement(driver.script_->code_);
     _assert(statement != NULL);
     _assert(statement->next_ == NULL);
 
     _assert(statement != NULL);
     _assert(statement->next_ == NULL);
 
-    CYExpress *express(dynamic_cast<CYExpress *>(driver.program_->code_));
+    CYExpress *express(dynamic_cast<CYExpress *>(driver.script_->code_));
     _assert(express != NULL);
 
     CYParenthetical *parenthetical(dynamic_cast<CYParenthetical *>(express->expression_));
     _assert(express != NULL);
 
     CYParenthetical *parenthetical(dynamic_cast<CYParenthetical *>(express->expression_));
@@ -59,8 +56,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
 
     driver.auto_ = true;
 
 
     driver.auto_ = true;
 
-    cy::parser parser(driver);
-    if (parser.parse() != 0 || !driver.errors_.empty())
+    if (driver.Parse() || !driver.errors_.empty())
         return NULL;
 
     if (driver.mode_ == CYDriver::AutoNone)
         return NULL;
 
     if (driver.mode_ == CYDriver::AutoNone)
@@ -99,7 +95,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
 
     std::string begin(prefix.str());
 
 
     std::string begin(prefix.str());
 
-    driver.program_ = $ CYProgram($ CYExpress($C3(ParseExpression(pool,
+    driver.script_ = $ CYScript($ CYExpress($C3(ParseExpression(pool,
     "   function(object, prefix, word) {\n"
     "       var names = [];\n"
     "       var before = prefix.length;\n"
     "   function(object, prefix, word) {\n"
     "       var names = [];\n"
     "       var before = prefix.length;\n"
@@ -112,11 +108,11 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     "   }\n"
     ), expression, $S(begin.c_str()), $S(word))));
 
     "   }\n"
     ), expression, $S(begin.c_str()), $S(word))));
 
-    driver.program_->Replace(context);
+    driver.script_->Replace(context);
 
     std::stringbuf str;
     CYOutput out(str, options);
 
     std::stringbuf str;
     CYOutput out(str, options);
-    out << *driver.program_;
+    out << *driver.script_;
 
     std::string code(str.str());
     CYUTF8String json(run(pool, code));
 
     std::string code(str.str());
     CYUTF8String json(run(pool, code));
@@ -137,8 +133,12 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     std::string common;
     bool rest(false);
 
     std::string common;
     bool rest(false);
 
-    CYForEach (element, array->elements_) {
-        CYString *string(dynamic_cast<CYString *>(element->value_));
+    for (CYElement *element(array->elements_); element != NULL; ) {
+        CYElementValue *value(dynamic_cast<CYElementValue *>(element));
+        _assert(value != NULL);
+        element = value->next_;
+
+        CYString *string(dynamic_cast<CYString *>(value->value_));
         _assert(string != NULL);
 
         std::string completion;
         _assert(string != NULL);
 
         std::string completion;