X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/0a35647487f508be5a48feaf18734086e6d460d4..309b053540b80defe4313836161c68ea9112d56d:/Parser.hpp?ds=sidebyside diff --git a/Parser.hpp b/Parser.hpp index 6bf18a7..f48e81b 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -50,6 +50,7 @@ #include #include +#include #include #include "location.hh" @@ -244,11 +245,13 @@ struct CYIdentifier : { CYIdentifier *replace_; size_t offset_; + size_t usage_; CYIdentifier(const char *word) : CYWord(word), replace_(NULL), - offset_(0) + offset_(0), + usage_(0) { } @@ -311,13 +314,19 @@ enum CYIdentifierFlags { typedef std::set CYCStringSet; typedef std::set CYIdentifierValueSet; -typedef std::vector CYIdentifierAddressVector; typedef std::map CYIdentifierAddressFlagsMap; +struct CYIdentifierUsage { + CYIdentifier *identifier_; + size_t usage_; +}; + +typedef std::vector CYIdentifierUsageVector; + struct CYScope { CYScope *parent_; - CYIdentifierAddressFlagsMap internal_; + CYIdentifierAddressFlagsMap internal_; CYIdentifierValueSet identifiers_; CYScope() : @@ -335,11 +344,9 @@ struct CYScope { }; struct CYProgram : - CYScope, CYThing { CYStatement *statements_; - CYIdentifierAddressVector rename_; CYProgram(CYStatement *statements) : statements_(statements) @@ -350,19 +357,16 @@ struct CYProgram : virtual void Output(CYOutput &out) const; }; -struct CYContext : - CYScope -{ +struct CYContext { apr_pool_t *pool_; CYOptions &options_; CYScope *scope_; - CYProgram *program_; + CYIdentifierUsageVector rename_; CYContext(apr_pool_t *pool, CYOptions &options) : pool_(pool), options_(options), - scope_(this), - program_(NULL) + scope_(NULL) { } @@ -387,11 +391,9 @@ struct CYBlock : CYThing { CYStatement *statements_; - CYScope *scope_; - CYBlock(CYStatement *statements, CYScope *scope = NULL) : - statements_(statements), - scope_(scope) + CYBlock(CYStatement *statements) : + statements_(statements) { } @@ -1364,9 +1366,7 @@ struct CYWhile : virtual void Output(CYOutput &out, CYFlags flags) const; }; -struct CYFunction : - CYScope -{ +struct CYFunction { CYIdentifier *name_; CYFunctionParameter *parameters_; CYBlock code_; @@ -1374,7 +1374,7 @@ struct CYFunction : CYFunction(CYIdentifier *name, CYFunctionParameter *parameters, CYStatement *statements) : name_(name), parameters_(parameters), - code_(statements, this) + code_(statements) { }