X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/7085e1abd73d7405804870e2404d38c4d22ea73e..972562bf68a236b4580b6074415cbf4e07b0a0c6:/Syntax.hpp diff --git a/Syntax.hpp b/Syntax.hpp index 786b9f7..f11c2f2 100644 --- a/Syntax.hpp +++ b/Syntax.hpp @@ -199,6 +199,13 @@ struct CYStatement : typedef CYList CYStatements; +struct CYForInitializer : + CYStatement +{ + virtual CYForInitializer *Replace(CYContext &context) = 0; + virtual void Output(CYOutput &out, CYFlags flags) const = 0; +}; + struct CYWord : CYThing, CYPropertyName @@ -452,11 +459,6 @@ struct CYBlock : virtual CYStatement *Return(); }; -struct CYForInitializer { - virtual CYExpression *Replace(CYContext &context) = 0; - virtual void Output(CYOutput &out, CYFlags flags) const = 0; -}; - struct CYTarget; struct CYVar; @@ -473,7 +475,6 @@ struct CYNumber; struct CYString; struct CYExpression : - CYForInitializer, CYThing { virtual int Precedence() const = 0; @@ -895,6 +896,12 @@ struct CYThis : struct CYBoolean : CYTrivial { + CYPrecedence(4) + + virtual bool RightHand() const { + return true; + } + virtual bool Value() const = 0; virtual void Output(CYOutput &out, CYFlags flags) const; }; @@ -1020,8 +1027,8 @@ struct CYAssignment : { } - void SetLeft(CYTarget *lhs) { - lhs_ = lhs; + void SetRight(CYExpression *rhs) { + rhs_ = rhs; } virtual const char *Operator() const = 0; @@ -1205,22 +1212,8 @@ struct CYDeclarations : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYForDeclarations : - CYForInitializer -{ - CYDeclarations *declarations_; - - CYForDeclarations(CYDeclarations *declarations) : - declarations_(declarations) - { - } - - virtual CYExpression *Replace(CYContext &context); - virtual void Output(CYOutput &out, CYFlags flags) const; -}; - struct CYVar : - CYStatement + CYForInitializer { CYDeclarations *declarations_; @@ -1231,12 +1224,12 @@ struct CYVar : CYCompact(None) - virtual CYStatement *Replace(CYContext &context); + virtual CYForInitializer *Replace(CYContext &context); virtual void Output(CYOutput &out, CYFlags flags) const; }; struct CYLet : - CYStatement + CYForInitializer { bool constant_; CYDeclarations *declarations_; @@ -1249,7 +1242,7 @@ struct CYLet : CYCompact(None) - virtual CYStatement *Replace(CYContext &context); + virtual CYForInitializer *Replace(CYContext &context); virtual void Output(CYOutput &out, CYFlags flags) const; }; @@ -1274,6 +1267,8 @@ struct CYProperty : { } + virtual bool Update() const; + CYProperty *ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update); void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, bool protect); @@ -1341,6 +1336,26 @@ struct CYForIn : virtual void Output(CYOutput &out, CYFlags flags) const; }; +struct CYForInitialized : + CYStatement +{ + CYDeclaration *declaration_; + CYExpression *set_; + CYStatement *code_; + + CYForInitialized(CYDeclaration *declaration, CYExpression *set, CYStatement *code) : + declaration_(declaration), + set_(set), + code_(code) + { + } + + CYCompact(Long) + + virtual CYStatement *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + struct CYForOf : CYStatement { @@ -1708,6 +1723,8 @@ struct CYPropertyMethod : { } + bool Update() const override; + virtual CYFunctionExpression *Constructor(); virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect); @@ -1801,7 +1818,7 @@ struct CYSuperAccess : }; struct CYExpress : - CYStatement + CYForInitializer { CYExpression *expression_; @@ -1814,7 +1831,7 @@ struct CYExpress : CYCompact(None) - CYStatement *Replace(CYContext &context) override; + CYForInitializer *Replace(CYContext &context) override; virtual void Output(CYOutput &out, CYFlags flags) const; virtual CYStatement *Return(); @@ -1901,11 +1918,11 @@ struct CYYieldValue : }; struct CYEmpty : - CYStatement + CYForInitializer { CYCompact(Short) - virtual CYStatement *Replace(CYContext &context); + virtual CYForInitializer *Replace(CYContext &context); virtual void Output(CYOutput &out, CYFlags flags) const; };