X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/574d47203e63ac4a85f0d609098118d19e6bbf09..824bc1ec28c62ea1d63622c46e1edfd911c38b64:/Syntax.hpp diff --git a/Syntax.hpp b/Syntax.hpp index abf05bc..fa27dd4 100644 --- a/Syntax.hpp +++ b/Syntax.hpp @@ -150,6 +150,7 @@ enum CYFlags { CYNoRightHand = (1 << 5), CYNoDangle = (1 << 6), CYNoInteger = (1 << 7), + CYNoColon = (1 << 8), CYNoBFC = (CYNoBrace | CYNoFunction | CYNoClass), }; @@ -534,6 +535,10 @@ struct CYTarget : return false; } + virtual bool IsNew() const { + return false; + } + virtual CYStatement *Initialize(CYContext &context, CYExpression *value); virtual CYTarget *Replace(CYContext &context) = 0; @@ -962,6 +967,22 @@ struct CYVariable : virtual CYFunctionParameter *Parameter() const; }; +struct CYSymbol : + CYTarget +{ + const char *name_; + + CYSymbol(const char *name) : + name_(name) + { + } + + CYPrecedence(0) + + virtual CYTarget *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + struct CYPrefix : CYExpression { @@ -1399,6 +1420,8 @@ struct CYObject : { } + CYTarget *Replace(CYContext &context, CYTarget *seed); + virtual CYTarget *Replace(CYContext &context); void Output(CYOutput &out, CYFlags flags) const; }; @@ -1448,6 +1471,34 @@ struct CYIndirectMember : virtual void Output(CYOutput &out, CYFlags flags) const; }; +struct CYResolveMember : + CYMember +{ + CYResolveMember(CYExpression *object, CYExpression *property) : + CYMember(object, property) + { + } + + CYPrecedence(1) + + virtual CYTarget *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + +struct CYSubscriptMember : + CYMember +{ + CYSubscriptMember(CYExpression *object, CYExpression *property) : + CYMember(object, property) + { + } + + CYPrecedence(1) + + virtual CYTarget *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + namespace cy { namespace Syntax { @@ -1467,6 +1518,9 @@ struct New : return arguments_ == NULL ? 2 : 1; } + virtual bool IsNew() const { + return true; + } virtual CYTarget *Replace(CYContext &context); virtual void Output(CYOutput &out, CYFlags flags) const; @@ -1520,26 +1574,55 @@ struct CYEval : struct CYRubyProc; -struct CYRubyBlock : +struct CYBraced : CYTarget { - CYExpression *call_; - CYRubyProc *proc_; + CYTarget *lhs_; - CYRubyBlock(CYExpression *call, CYRubyProc *proc) : - call_(call), - proc_(proc) + CYBraced(CYTarget *lhs = NULL) : + lhs_(lhs) { } CYPrecedence(1) + void SetLeft(CYTarget *lhs) { + lhs_ = lhs; + } +}; + +struct CYRubyBlock : + CYBraced +{ + CYRubyProc *proc_; + + CYRubyBlock(CYTarget *lhs, CYRubyProc *proc) : + CYBraced(lhs), + proc_(proc) + { + } + virtual CYTarget *Replace(CYContext &context); virtual void Output(CYOutput &out, CYFlags flags) const; virtual CYTarget *AddArgument(CYContext &context, CYExpression *value); }; +struct CYExtend : + CYBraced +{ + CYObject object_; + + CYExtend(CYTarget *lhs, CYProperty *properties = NULL) : + CYBraced(lhs), + object_(properties) + { + } + + virtual CYTarget *Replace(CYContext &context); + virtual void Output(CYOutput &out, CYFlags flags) const; +}; + struct CYIf : CYStatement {