tidying with respect to "const", and streamlining OuterIDBindingFinder

This commit is contained in:
Vern Paxson 2021-03-18 08:24:14 -07:00
parent 01bf4b8484
commit cde212ac18
3 changed files with 12 additions and 12 deletions

View file

@ -681,7 +681,7 @@ public:
TraversalCode PostExpr(const Expr*) override;
std::vector<Scope*> scopes;
std::unordered_set<const NameExpr*> outer_id_references;
std::unordered_set<ID*> outer_id_references;
};
TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
@ -707,7 +707,7 @@ TraversalCode OuterIDBindingFinder::PreExpr(const Expr* expr)
// not something we have to worry about also being at outer scope.
return TC_CONTINUE;
outer_id_references.insert(e);
outer_id_references.insert(e->Id());
return TC_CONTINUE;
}
@ -773,8 +773,8 @@ IDPList gather_outer_ids(Scope* scope, Stmt* body)
IDPList idl;
for ( auto ne : cb.outer_id_references )
idl.append(ne->Id());
for ( auto id : cb.outer_id_references )
idl.append(id);
return idl;
}

View file

@ -29,7 +29,7 @@ public:
ExprPtr CheckForInlining(CallExprPtr c);
// True if the given function has been inlined.
bool WasInlined(Func* f) { return inline_ables.count(f) > 0; }
bool WasInlined(const Func* f) { return inline_ables.count(f) > 0; }
protected:
// Driver routine that analyzes all of the script functions and
@ -44,7 +44,7 @@ protected:
std::vector<FuncInfo>& funcs;
// Functions that we've determined to be suitable for inlining.
std::unordered_set<Func*> inline_ables;
std::unordered_set<const Func*> inline_ables;
// As we do inlining for a given function, this tracks the
// largest frame size of any inlined function.

View file

@ -64,12 +64,12 @@ class FuncInfo {
public:
FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body);
ScriptFunc* Func() { return func.get(); }
ScriptFuncPtr FuncPtr() { return func; }
ScopePtr Scope() { return scope; }
StmtPtr Body() { return body; }
std::shared_ptr<ProfileFunc> Profile() { return pf; }
const std::string& SaveFile() { return save_file; }
ScriptFunc* Func() const { return func.get(); }
ScriptFuncPtr FuncPtr() const { return func; }
ScopePtr Scope() const { return scope; }
StmtPtr Body() const { return body; }
std::shared_ptr<ProfileFunc> Profile() const { return pf; }
const std::string& SaveFile() const { return save_file; }
void SetBody(StmtPtr new_body) { body = std::move(new_body); }
void SetProfile(std::shared_ptr<ProfileFunc> _pf);