]> git.saurik.com Git - cycript.git/blobdiff - Parser.hpp
Got true JS booleans working in GNUstep.
[cycript.git] / Parser.hpp
index 87dc682bdc75ce76536dc24e6500e7d484d0c0ce..616d0dd025efd64ee7934b33714b5bd6d81c2021 100644 (file)
@@ -1,4 +1,4 @@
-/* Cycript - Remote Execution Server and Disassembler
+/* Cycript - Error.hppution Server and Disassembler
  * Copyright (C) 2009  Jay Freeman (saurik)
 */
 
@@ -73,6 +73,9 @@ struct CYNext {
 };
 
 struct CYThing {
+    virtual ~CYThing() {
+    }
+
     virtual void Output(struct CYOutput &out) const = 0;
 };
 
@@ -117,6 +120,9 @@ struct CYOutput {
 
 struct CYPropertyName {
     virtual void PropertyName(CYOutput &out) const = 0;
+
+    virtual ~CYPropertyName() {
+    }
 };
 
 struct CYExpression;
@@ -157,6 +163,9 @@ struct CYContext {
 struct CYStatement :
     CYNext<CYStatement>
 {
+    virtual ~CYStatement() {
+    }
+
     void Single(CYOutput &out, CYFlags flags) const;
     void Multiple(CYOutput &out, CYFlags flags = CYNoFlags) const;
 
@@ -198,6 +207,9 @@ struct CYStatements {
 };
 
 struct CYClassName {
+    virtual ~CYClassName() {
+    }
+
     virtual CYExpression *ClassName(CYContext &context, bool object) = 0;
     virtual void ClassName(CYOutput &out, bool object) const = 0;
 };
@@ -346,10 +358,16 @@ class CYDriver {
 };
 
 struct CYForInitialiser {
+    virtual ~CYForInitialiser() {
+    }
+
     virtual void For(CYOutput &out) const = 0;
 };
 
 struct CYForInInitialiser {
+    virtual ~CYForInInitialiser() {
+    }
+
     virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
     virtual const char *ForEachIn() const = 0;
     virtual CYExpression *ForEachIn(CYContext &out) = 0;
@@ -929,13 +947,31 @@ struct CYArray :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
+struct CYProperty :
+    CYNext<CYProperty>,
+    CYThing
+{
+    CYPropertyName *name_;
+    CYExpression *value_;
+
+    CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
+        CYNext<CYProperty>(next),
+        name_(name),
+        value_(value)
+    {
+    }
+
+    void Replace(CYContext &context);
+    virtual void Output(CYOutput &out) const;
+};
+
 struct CYDeclaration :
     CYForInInitialiser
 {
     CYIdentifier *identifier_;
     CYExpression *initialiser_;
 
-    CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser) :
+    CYDeclaration(CYIdentifier *identifier, CYExpression *initialiser = NULL) :
         identifier_(identifier),
         initialiser_(initialiser)
     {
@@ -967,6 +1003,7 @@ struct CYDeclarations :
     virtual void For(CYOutput &out) const;
 
     void Replace(CYContext &context);
+    CYProperty *Property(CYContext &context);
 
     virtual void Output(CYOutput &out) const;
     virtual void Output(CYOutput &out, CYFlags flags) const;
@@ -1058,24 +1095,6 @@ struct CYForEachIn :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
-struct CYProperty :
-    CYNext<CYProperty>,
-    CYThing
-{
-    CYPropertyName *name_;
-    CYExpression *value_;
-
-    CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next = NULL) :
-        CYNext<CYProperty>(next),
-        name_(name),
-        value_(value)
-    {
-    }
-
-    void Replace(CYContext &context);
-    virtual void Output(CYOutput &out) const;
-};
-
 struct CYObject :
     CYLiteral
 {
@@ -1090,22 +1109,6 @@ struct CYObject :
     void Output(CYOutput &out, CYFlags flags) const;
 };
 
-struct CYCatch :
-    CYThing
-{
-    CYIdentifier *name_;
-    CYBlock code_;
-
-    CYCatch(CYIdentifier *name, CYStatement *statements) :
-        name_(name),
-        code_(statements)
-    {
-    }
-
-    void Replace(CYContext &context);
-    virtual void Output(CYOutput &out) const;
-};
-
 struct CYMember :
     CYExpression
 {
@@ -1258,6 +1261,9 @@ struct CYFunction {
     {
     }
 
+    virtual ~CYFunction() {
+    }
+
     virtual void Replace_(CYContext &context);
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
@@ -1368,14 +1374,33 @@ struct CYFinally :
     virtual void Output(CYOutput &out) const;
 };
 
-struct CYTry :
+namespace cy {
+namespace Syntax {
+
+struct Catch :
+    CYThing
+{
+    CYIdentifier *name_;
+    CYBlock code_;
+
+    Catch(CYIdentifier *name, CYStatement *statements) :
+        name_(name),
+        code_(statements)
+    {
+    }
+
+    void Replace(CYContext &context);
+    virtual void Output(CYOutput &out) const;
+};
+
+struct Try :
     CYStatement
 {
     CYBlock code_;
-    CYCatch *catch_;
+    Catch *catch_;
     CYFinally *finally_;
 
-    CYTry(CYStatement *statements, CYCatch *_catch, CYFinally *finally) :
+    Try(CYStatement *statements, Catch *_catch, CYFinally *finally) :
         code_(statements),
         catch_(_catch),
         finally_(finally)
@@ -1386,12 +1411,12 @@ struct CYTry :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
-struct CYThrow :
+struct Throw :
     CYStatement
 {
     CYExpression *value_;
 
-    CYThrow(CYExpression *value) :
+    Throw(CYExpression *value) :
         value_(value)
     {
     }
@@ -1400,6 +1425,8 @@ struct CYThrow :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
+} }
+
 struct CYWith :
     CYStatement
 {
@@ -1478,7 +1505,7 @@ struct CYIndirect :
     }
 
     virtual const char *Operator() const {
-        return "^";
+        return "*";
     }
 
     CYAlphabetic(false)