diff --git a/src/Stmt.cc b/src/Stmt.cc index 646cf06d45..4304cada4d 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -235,7 +235,7 @@ ExprListStmt::ExprListStmt(StmtTag t, ListExprPtr arg_l) ExprListStmt::~ExprListStmt() = default; -ValPtr ExprListStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr ExprListStmt::Exec(Frame* f, StmtFlowType& flow) { last_access = run_state::network_time; flow = FLOW_NEXT; @@ -303,7 +303,7 @@ static void print_log(const std::vector& vals) } ValPtr PrintStmt::DoExec(std::vector vals, - StmtFlowType& /* flow */) const + StmtFlowType& /* flow */) { RegisterAccess(); @@ -393,7 +393,7 @@ ExprPtr ExprStmt::StmtExprPtr() const return e; } -ValPtr ExprStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr ExprStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -406,7 +406,7 @@ ValPtr ExprStmt::Exec(Frame* f, StmtFlowType& flow) const return nullptr; } -ValPtr ExprStmt::DoExec(Frame* /* f */, Val* /* v */, StmtFlowType& /* flow */) const +ValPtr ExprStmt::DoExec(Frame* /* f */, Val* /* v */, StmtFlowType& /* flow */) { return nullptr; } @@ -470,7 +470,7 @@ IfStmt::IfStmt(ExprPtr test, IfStmt::~IfStmt() = default; -ValPtr IfStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) const +ValPtr IfStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) { // Treat 0 as false, but don't require 1 for true. Stmt* do_stmt = v->IsZero() ? s2.get() : s1.get(); @@ -917,7 +917,7 @@ std::pair SwitchStmt::FindCaseLabelMatch(const Val* v) const return std::make_pair(label_idx, label_id); } -ValPtr SwitchStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) const +ValPtr SwitchStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) { ValPtr rval; @@ -930,7 +930,7 @@ ValPtr SwitchStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) const for ( int i = matching_label_idx; i < cases->length(); ++i ) { - const Case* c = (*cases)[i]; + auto c = (*cases)[i]; if ( matching_id ) { @@ -1033,7 +1033,7 @@ AddStmt::AddStmt(ExprPtr arg_e) : AddDelStmt(STMT_ADD, std::move(arg_e)) Error("illegal add statement"); } -ValPtr AddStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr AddStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1051,7 +1051,7 @@ DelStmt::DelStmt(ExprPtr arg_e) : AddDelStmt(STMT_DELETE, std::move(arg_e)) Error("illegal delete statement"); } -ValPtr DelStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr DelStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1065,7 +1065,7 @@ EventStmt::EventStmt(EventExprPtr arg_e) { } -ValPtr EventStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr EventStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); auto args = eval_list(f, event_expr->Args()); @@ -1142,7 +1142,7 @@ TraversalCode WhileStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -ValPtr WhileStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr WhileStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1288,7 +1288,7 @@ ForStmt::~ForStmt() delete loop_vars; } -ValPtr ForStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) const +ValPtr ForStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) { ValPtr ret; @@ -1430,7 +1430,7 @@ TraversalCode ForStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -ValPtr NextStmt::Exec(Frame* /* f */, StmtFlowType& flow) const +ValPtr NextStmt::Exec(Frame* /* f */, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_LOOP; @@ -1457,7 +1457,7 @@ TraversalCode NextStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -ValPtr BreakStmt::Exec(Frame* /* f */, StmtFlowType& flow) const +ValPtr BreakStmt::Exec(Frame* /* f */, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_BREAK; @@ -1484,7 +1484,7 @@ TraversalCode BreakStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -ValPtr FallthroughStmt::Exec(Frame* /* f */, StmtFlowType& flow) const +ValPtr FallthroughStmt::Exec(Frame* /* f */, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_FALLTHROUGH; @@ -1555,7 +1555,7 @@ ReturnStmt::ReturnStmt(ExprPtr arg_e) } } -ValPtr ReturnStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr ReturnStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_RETURN; @@ -1597,7 +1597,7 @@ StmtList::~StmtList() delete stmts; } -ValPtr StmtList::Exec(Frame* f, StmtFlowType& flow) const +ValPtr StmtList::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1684,7 +1684,7 @@ InitStmt::InitStmt(std::vector arg_inits) : Stmt(STMT_INIT) SetLocationInfo(inits[0]->GetLocationInfo()); } -ValPtr InitStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr InitStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1749,7 +1749,7 @@ TraversalCode InitStmt::Traverse(TraversalCallback* cb) const HANDLE_TC_STMT_POST(tc); } -ValPtr NullStmt::Exec(Frame* /* f */, StmtFlowType& flow) const +ValPtr NullStmt::Exec(Frame* /* f */, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; @@ -1804,7 +1804,7 @@ WhenStmt::WhenStmt(ExprPtr arg_cond, WhenStmt::~WhenStmt() = default; -ValPtr WhenStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr WhenStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT; diff --git a/src/Stmt.h b/src/Stmt.h index 60d1ae35fa..bd26492afe 100644 --- a/src/Stmt.h +++ b/src/Stmt.h @@ -33,9 +33,8 @@ protected: ~ExprListStmt() override; - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; - virtual ValPtr DoExec(std::vector vals, - StmtFlowType& flow) const = 0; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; + virtual ValPtr DoExec(std::vector vals, StmtFlowType& flow) = 0; void StmtDescribe(ODesc* d) const override; @@ -57,8 +56,7 @@ public: StmtPtr Duplicate() override; protected: - ValPtr DoExec(std::vector vals, - StmtFlowType& flow) const override; + ValPtr DoExec(std::vector vals, StmtFlowType& flow) override; // Optimization-related: StmtPtr DoSubclassReduce(ListExprPtr singletons, Reducer* c) override; @@ -74,7 +72,7 @@ public: // not allowing us to use "friend" for protected access. ExprStmt(StmtTag t, ExprPtr e); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; const Expr* StmtExpr() const { return e.get(); } ExprPtr StmtExprPtr() const; @@ -91,7 +89,7 @@ public: StmtPtr DoReduce(Reducer* c) override; protected: - virtual ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) const; + virtual ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow); bool IsPure() const override; @@ -120,7 +118,7 @@ public: bool NoFlowAfter(bool ignore_break) const override; protected: - ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) const override; + ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) override; bool IsPure() const override; StmtPtr s1; @@ -180,7 +178,7 @@ public: bool NoFlowAfter(bool ignore_break) const override; protected: - ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) const override; + ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) override; bool IsPure() const override; // Initialize composite hash and case label map. @@ -229,7 +227,7 @@ class AddStmt final : public AddDelStmt { public: explicit AddStmt(ExprPtr e); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; // Optimization-related: StmtPtr Duplicate() override; @@ -239,7 +237,7 @@ class DelStmt final : public AddDelStmt { public: explicit DelStmt(ExprPtr e); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; // Optimization-related: StmtPtr Duplicate() override; @@ -249,7 +247,7 @@ class EventStmt final : public ExprStmt { public: explicit EventStmt(EventExprPtr e); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; TraversalCode Traverse(TraversalCallback* cb) const override; @@ -290,7 +288,7 @@ public: // execute zero times, so it's always the default of "false". protected: - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; ExprPtr loop_condition; StmtPtr body; @@ -339,7 +337,7 @@ public: // execute zero times, so it's always the default of "false". protected: - ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) const override; + ValPtr DoExec(Frame* f, Val* v, StmtFlowType& flow) override; IDPList* loop_vars; StmtPtr body; @@ -352,7 +350,7 @@ class NextStmt final : public Stmt { public: NextStmt() : Stmt(STMT_NEXT) { } - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; void StmtDescribe(ODesc* d) const override; @@ -371,7 +369,7 @@ class BreakStmt final : public Stmt { public: BreakStmt() : Stmt(STMT_BREAK) { } - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; void StmtDescribe(ODesc* d) const override; @@ -391,7 +389,7 @@ class FallthroughStmt final : public Stmt { public: FallthroughStmt() : Stmt(STMT_FALLTHROUGH) { } - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; void StmtDescribe(ODesc* d) const override; @@ -409,7 +407,7 @@ class ReturnStmt final : public ExprStmt { public: explicit ReturnStmt(ExprPtr e); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; void StmtDescribe(ODesc* d) const override; @@ -432,7 +430,7 @@ public: StmtList(); ~StmtList() override; - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; const StmtPList& Stmts() const { return *stmts; } StmtPList& Stmts() { return *stmts; } @@ -474,7 +472,7 @@ class InitStmt final : public Stmt { public: explicit InitStmt(std::vector arg_inits); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; const std::vector& Inits() const { return inits; } @@ -497,7 +495,7 @@ class NullStmt final : public Stmt { public: NullStmt() : Stmt(STMT_NULL) { } - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; void StmtDescribe(ODesc* d) const override; @@ -516,7 +514,7 @@ public: ExprPtr timeout, bool is_return); ~WhenStmt() override; - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; const Expr* Cond() const { return cond.get(); } @@ -560,7 +558,7 @@ public: // or nil if it hasn't (the common case). StmtPtr AssignStmt() const { return assign_stmt; } - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; bool IsPure() const override; @@ -597,7 +595,7 @@ class CheckAnyLenStmt : public ExprStmt { public: explicit CheckAnyLenStmt(ExprPtr e, int expected_len); - ValPtr Exec(Frame* f, StmtFlowType& flow) const override; + ValPtr Exec(Frame* f, StmtFlowType& flow) override; StmtPtr Duplicate() override; diff --git a/src/StmtBase.h b/src/StmtBase.h index f6f64d6e21..127fd7c8b3 100644 --- a/src/StmtBase.h +++ b/src/StmtBase.h @@ -54,7 +54,7 @@ public: ~Stmt() override; - virtual ValPtr Exec(Frame* f, StmtFlowType& flow) const = 0; + virtual ValPtr Exec(Frame* f, StmtFlowType& flow) = 0; Stmt* Ref() { zeek::Ref(this); return this; } StmtPtr ThisPtr() { return {NewRef{}, this}; } diff --git a/src/script_opt/Stmt.cc b/src/script_opt/Stmt.cc index 7aef4c85ec..8e18280629 100644 --- a/src/script_opt/Stmt.cc +++ b/src/script_opt/Stmt.cc @@ -960,7 +960,7 @@ CatchReturnStmt::CatchReturnStmt(StmtPtr _block, NameExprPtr _ret_var) ret_var = _ret_var; } -ValPtr CatchReturnStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr CatchReturnStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); @@ -1047,7 +1047,7 @@ CheckAnyLenStmt::CheckAnyLenStmt(ExprPtr arg_e, int _expected_len) expected_len = _expected_len; } -ValPtr CheckAnyLenStmt::Exec(Frame* f, StmtFlowType& flow) const +ValPtr CheckAnyLenStmt::Exec(Frame* f, StmtFlowType& flow) { RegisterAccess(); flow = FLOW_NEXT;