X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/a86e34d01f829a8b4f58f6066d78148c0901c1dd..2f51d6ab2c7e56fade7ac6118cf02df9107ca3af:/Parser.hpp diff --git a/Parser.hpp b/Parser.hpp index 008be05..6bf18a7 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -243,10 +243,12 @@ struct CYIdentifier : CYWord { CYIdentifier *replace_; + size_t offset_; CYIdentifier(const char *word) : CYWord(word), - replace_(NULL) + replace_(NULL), + offset_(0) { } @@ -309,7 +311,6 @@ enum CYIdentifierFlags { typedef std::set CYCStringSet; typedef std::set CYIdentifierValueSet; -typedef std::set CYIdentifierAddressSet; typedef std::vector CYIdentifierAddressVector; typedef std::map CYIdentifierAddressFlagsMap; @@ -318,17 +319,18 @@ struct CYScope { CYIdentifierAddressFlagsMap internal_; CYIdentifierValueSet identifiers_; - size_t offset_; CYScope() : - parent_(NULL), - offset_(0) + parent_(NULL) { } + virtual ~CYScope() { + } + void Declare(CYContext &context, CYIdentifier *identifier, CYIdentifierFlags flags); virtual CYIdentifier *Lookup(CYContext &context, CYIdentifier *identifier); - void Merge(CYContext &context, CYIdentifierAddressVector &external); + void Merge(CYContext &context, CYIdentifier *identifier); void Scope(CYContext &context, CYStatement *&statements); }; @@ -338,7 +340,6 @@ struct CYProgram : { CYStatement *statements_; CYIdentifierAddressVector rename_; - CYCStringSet external_; CYProgram(CYStatement *statements) : statements_(statements) @@ -349,6 +350,38 @@ struct CYProgram : virtual void Output(CYOutput &out) const; }; +struct CYContext : + CYScope +{ + apr_pool_t *pool_; + CYOptions &options_; + CYScope *scope_; + CYProgram *program_; + + CYContext(apr_pool_t *pool, CYOptions &options) : + pool_(pool), + options_(options), + scope_(this), + program_(NULL) + { + } + + virtual ~CYContext() { + } + + template + void Replace(Type_ *&value) { + for (;;) if (value == NULL) + break; + else { + Type_ *replace(value->Replace(*this)); + if (replace != value) + value = replace; + else break; + } + } +}; + struct CYBlock : CYStatement, CYThing