track current script body's priority as well as its AST

This commit is contained in:
Vern Paxson 2021-04-19 16:08:45 -07:00
parent 00d66f1ac2
commit 3796e2508b
2 changed files with 8 additions and 4 deletions

View file

@ -305,7 +305,7 @@ ScriptFunc::ScriptFunc(const IDPtr& arg_id, StmtPtr arg_body,
Body b; Body b;
b.stmts = AddInits(std::move(arg_body), aggr_inits); b.stmts = AddInits(std::move(arg_body), aggr_inits);
current_body = b.stmts; current_body = b.stmts;
b.priority = priority; current_priority = b.priority = priority;
bodies.push_back(b); bodies.push_back(b);
} }
} }
@ -542,9 +542,8 @@ void ScriptFunc::AddBody(StmtPtr new_body,
Body b; Body b;
b.stmts = new_body; b.stmts = new_body;
b.priority = priority;
current_body = new_body; current_body = new_body;
current_priority = b.priority = priority;
bodies.push_back(b); bodies.push_back(b);
sort(bodies.begin(), bodies.end()); sort(bodies.begin(), bodies.end());
@ -558,6 +557,7 @@ void ScriptFunc::ReplaceBody(const StmtPtr& old_body, StmtPtr new_body)
if ( body.stmts.get() == old_body.get() ) if ( body.stmts.get() == old_body.get() )
{ {
body.stmts = new_body; body.stmts = new_body;
current_priority = body.priority;
found_it = true; found_it = true;
} }

View file

@ -239,6 +239,7 @@ public:
detail::StmtPtr new_body); detail::StmtPtr new_body);
StmtPtr CurrentBody() const { return current_body; } StmtPtr CurrentBody() const { return current_body; }
int CurrentPriority() const { return current_priority; }
/** /**
* Returns the function's frame size. * Returns the function's frame size.
@ -307,8 +308,11 @@ private:
OffsetMap* captures_offset_mapping = nullptr; OffsetMap* captures_offset_mapping = nullptr;
// The most recently added/updated body. // The most recently added/updated body ...
StmtPtr current_body; StmtPtr current_body;
// ... and its priority.
int current_priority;
}; };
using built_in_func = BifReturnVal (*)(Frame* frame, const Args* args); using built_in_func = BifReturnVal (*)(Frame* frame, const Args* args);