binpac: Mark overridden methods with 'override'

This commit is contained in:
Tim Wojtulewicz 2023-01-30 17:05:32 -07:00
parent 45ef19049c
commit 299f39e8e2
29 changed files with 260 additions and 257 deletions

View file

@ -17,7 +17,7 @@ public:
AnalyzerAction(ID* action_id, When when, ActionParam* param, EmbeddedCode* code); AnalyzerAction(ID* action_id, When when, ActionParam* param, EmbeddedCode* code);
~AnalyzerAction(); ~AnalyzerAction() override;
When when() const { return when_; } When when() const { return when_; }
ActionParam* param() const { return param_; } ActionParam* param() const { return param_; }

View file

@ -21,16 +21,16 @@ class AnalyzerDecl : public TypeDecl
{ {
public: public:
AnalyzerDecl(ID* id, DeclType decl_type, ParamList* params); AnalyzerDecl(ID* id, DeclType decl_type, ParamList* params);
~AnalyzerDecl(); ~AnalyzerDecl() override;
void AddElements(AnalyzerElementList* elemlist); void AddElements(AnalyzerElementList* elemlist);
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
// void GenCode(Output *out_h, Output *out_cc); // void GenCode(Output *out_h, Output *out_cc);
void GenInitCode(Output* out_cc); void GenInitCode(Output* out_cc) override;
void GenCleanUpCode(Output* out_cc); void GenCleanUpCode(Output* out_cc) override;
string class_name() const; string class_name() const;
// string cookie_name() const; // string cookie_name() const;
@ -41,8 +41,8 @@ protected:
// Generate public/private declarations for member functions and // Generate public/private declarations for member functions and
// variables // variables
void GenPubDecls(Output* out_h, Output* out_cc); void GenPubDecls(Output* out_h, Output* out_cc) override;
void GenPrivDecls(Output* out_h, Output* out_cc); void GenPrivDecls(Output* out_h, Output* out_cc) override;
// Generate the NewData() function // Generate the NewData() function
virtual void GenProcessFunc(Output* out_h, Output* out_cc) = 0; virtual void GenProcessFunc(Output* out_h, Output* out_cc) = 0;
@ -107,7 +107,7 @@ class AnalyzerState : public AnalyzerElement
{ {
public: public:
AnalyzerState(StateVarList* statevars) : AnalyzerElement(STATE), statevars_(statevars) { } AnalyzerState(StateVarList* statevars) : AnalyzerElement(STATE), statevars_(statevars) { }
~AnalyzerState(); ~AnalyzerState() override;
StateVarList* statevars() const { return statevars_; } StateVarList* statevars() const { return statevars_; }
@ -130,7 +130,7 @@ public:
: AnalyzerElement(HELPER), helper_type_(helper_type), code_(code) : AnalyzerElement(HELPER), helper_type_(helper_type), code_(code)
{ {
} }
~AnalyzerHelper(); ~AnalyzerHelper() override;
Type helper_type() const { return helper_type_; } Type helper_type() const { return helper_type_; }
@ -149,7 +149,7 @@ class FlowField : public Field
{ {
public: public:
FlowField(ID* flow_id, ParameterizedType* flow_type); FlowField(ID* flow_id, ParameterizedType* flow_type);
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
}; };
class AnalyzerFlow : public AnalyzerElement class AnalyzerFlow : public AnalyzerElement
@ -161,7 +161,7 @@ public:
DOWN DOWN
}; };
AnalyzerFlow(Direction dir, ID* type_id, ExprList* params); AnalyzerFlow(Direction dir, ID* type_id, ExprList* params);
~AnalyzerFlow(); ~AnalyzerFlow() override;
Direction dir() const { return dir_; } Direction dir() const { return dir_; }
FlowField* flow_field() const { return flow_field_; } FlowField* flow_field() const { return flow_field_; }

View file

@ -10,48 +10,48 @@ class ArrayType : public Type
{ {
public: public:
ArrayType(Type* arg_elemtype, Expr* arg_length = nullptr); ArrayType(Type* arg_elemtype, Expr* arg_length = nullptr);
~ArrayType(); ~ArrayType() override;
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
string DefaultValue() const { return "0"; } string DefaultValue() const override { return "0"; }
Type* ElementDataType() const; Type* ElementDataType() const override;
string EvalElement(const string& array, const string& index) const; string EvalElement(const string& array, const string& index) const override;
void ProcessAttr(Attr* a); void ProcessAttr(Attr* a) override;
void Prepare(Env* env, int flags); void Prepare(Env* env, int flags) override;
void GenPubDecls(Output* out, Env* env); void GenPubDecls(Output* out, Env* env) override;
void GenPrivDecls(Output* out, Env* env); void GenPrivDecls(Output* out, Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
void SetBoundaryChecked(); void SetBoundaryChecked() override;
void GenUntilInputCheck(Output* out_cc, Env* env); void GenUntilInputCheck(Output* out_cc, Env* env);
bool IsPointerType() const { return true; } bool IsPointerType() const override { return true; }
protected: protected:
void init(); void init();
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
void GenArrayLength(Output* out_cc, Env* env, const DataPtr& data); void GenArrayLength(Output* out_cc, Env* env, const DataPtr& data);
string GenArrayInit(Output* out_cc, Env* env, bool known_array_length); string GenArrayInit(Output* out_cc, Env* env, bool known_array_length);
void GenElementAssignment(Output* out_cc, Env* env, string const& array_str, bool use_vector); void GenElementAssignment(Output* out_cc, Env* env, string const& array_str, bool use_vector);
void GenUntilCheck(Output* out_cc, Env* env, Expr* until_condition, bool delete_elem); void GenUntilCheck(Output* out_cc, Env* env, Expr* until_condition, bool delete_elem);
bool ByteOrderSensitive() const { return elemtype_->RequiresByteOrder(); } bool ByteOrderSensitive() const override { return elemtype_->RequiresByteOrder(); }
bool RequiresAnalyzerContext(); bool RequiresAnalyzerContext() override;
Type* DoClone() const; Type* DoClone() const override;
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
const ID* arraylength_var() const; const ID* arraylength_var() const;
const ID* elem_it_var() const; const ID* elem_it_var() const;
@ -60,7 +60,7 @@ protected:
const ID* elem_input_var() const; const ID* elem_input_var() const;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
Type* elemtype_; Type* elemtype_;

View file

@ -33,7 +33,7 @@ public:
Attr(AttrType type, ExprList* exprlist); Attr(AttrType type, ExprList* exprlist);
Attr(AttrType type, SeqEnd* seqend); Attr(AttrType type, SeqEnd* seqend);
virtual ~Attr(); ~Attr() override;
AttrType type() const { return type_; } AttrType type() const { return type_; }
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
@ -42,7 +42,7 @@ public:
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
protected: protected:
void init(); void init();

View file

@ -22,26 +22,26 @@ public:
BITType bit_type() const { return bit_type_; } BITType bit_type() const { return bit_type_; }
bool IsNumericType() const; bool IsNumericType() const override;
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
string DefaultValue() const { return "0"; } string DefaultValue() const override { return "0"; }
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
bool IsPointerType() const { return false; } bool IsPointerType() const override { return false; }
bool ByteOrderSensitive() const { return StaticSize(0) >= 2; } bool ByteOrderSensitive() const override { return StaticSize(0) >= 2; }
void GenInitCode(Output* out_cc, Env* env); void GenInitCode(Output* out_cc, Env* env) override;
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
protected: protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
Type* DoClone() const; Type* DoClone() const override;
BITType bit_type_; BITType bit_type_;

View file

@ -10,39 +10,39 @@ class CaseType : public Type
{ {
public: public:
CaseType(Expr* index, CaseFieldList* cases); CaseType(Expr* index, CaseFieldList* cases);
~CaseType(); ~CaseType() override;
void AddCaseField(CaseField* f); void AddCaseField(CaseField* f);
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
string DefaultValue() const; string DefaultValue() const override;
void Prepare(Env* env, int flags); void Prepare(Env* env, int flags) override;
void GenPubDecls(Output* out, Env* env); void GenPubDecls(Output* out, Env* env) override;
void GenPrivDecls(Output* out, Env* env); void GenPrivDecls(Output* out, Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
void SetBoundaryChecked(); void SetBoundaryChecked() override;
Type* ValueType() const; Type* ValueType() const;
Expr* IndexExpr() const { return index_expr_; } Expr* IndexExpr() const { return index_expr_; }
bool IsPointerType() const { return ValueType()->IsPointerType(); } bool IsPointerType() const override { return ValueType()->IsPointerType(); }
protected: protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
Type* DoClone() const { return nullptr; } Type* DoClone() const override { return nullptr; }
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
bool ByteOrderSensitive() const; bool ByteOrderSensitive() const override;
Expr* index_expr_; Expr* index_expr_;
ID* index_var_; ID* index_var_;
@ -56,7 +56,7 @@ class CaseField : public Field
{ {
public: public:
CaseField(ExprList* index, ID* id, Type* type); CaseField(ExprList* index, ID* id, Type* type);
~CaseField(); ~CaseField() override;
CaseType* case_type() const { return case_type_; } CaseType* case_type() const { return case_type_; }
void set_case_type(CaseType* t) { case_type_ = t; } void set_case_type(CaseType* t) { case_type_ = t; }
@ -68,12 +68,12 @@ public:
const char* CaseStr(Env* env); const char* CaseStr(Env* env);
void set_index_var(const ID* var) { index_var_ = var; } void set_index_var(const ID* var) { index_var_ = var; }
void Prepare(Env* env); void Prepare(Env* env) override;
void GenPubDecls(Output* out, Env* env); void GenPubDecls(Output* out, Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
void GenParseCode(Output* out, Env* env, const DataPtr& data, const ID* size_var); void GenParseCode(Output* out, Env* env, const DataPtr& data, const ID* size_var);
int StaticSize(Env* env) const { return type_->StaticSize(env); } int StaticSize(Env* env) const { return type_->StaticSize(env); }
@ -82,10 +82,10 @@ public:
void SetBoundaryChecked() { type_->SetBoundaryChecked(); } void SetBoundaryChecked() { type_->SetBoundaryChecked(); }
bool RequiresByteOrder() const { return type_->RequiresByteOrder(); } bool RequiresByteOrder() const { return type_->RequiresByteOrder(); }
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const override;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
protected: protected:
CaseType* case_type_; CaseType* case_type_;

View file

@ -8,24 +8,24 @@ class ConnDecl : public AnalyzerDecl
{ {
public: public:
ConnDecl(ID* conn_id, ParamList* params, AnalyzerElementList* elemlist); ConnDecl(ID* conn_id, ParamList* params, AnalyzerElementList* elemlist);
~ConnDecl(); ~ConnDecl() override;
void Prepare(); void Prepare() override;
Type* DataType() const { return data_type_; } Type* DataType() const { return data_type_; }
protected: protected:
void AddBaseClass(vector<string>* base_classes) const; void AddBaseClass(vector<string>* base_classes) const override;
void GenProcessFunc(Output* out_h, Output* out_cc); void GenProcessFunc(Output* out_h, Output* out_cc) override;
void GenGapFunc(Output* out_h, Output* out_cc); void GenGapFunc(Output* out_h, Output* out_cc) override;
void GenEOFFunc(Output* out_h, Output* out_cc); void GenEOFFunc(Output* out_h, Output* out_cc) override;
void GenPubDecls(Output* out_h, Output* out_cc); void GenPubDecls(Output* out_h, Output* out_cc) override;
void GenPrivDecls(Output* out_h, Output* out_cc); void GenPrivDecls(Output* out_h, Output* out_cc) override;
void ProcessFlowElement(AnalyzerFlow* flow_elem); void ProcessFlowElement(AnalyzerFlow* flow_elem) override;
void ProcessDataUnitElement(AnalyzerDataUnit* dataunit_elem); void ProcessDataUnitElement(AnalyzerDataUnit* dataunit_elem) override;
AnalyzerFlow* flows_[2]; AnalyzerFlow* flows_[2];
Type* data_type_; Type* data_type_;

View file

@ -33,7 +33,7 @@ class AnalyzerContextDecl : public TypeDecl
{ {
public: public:
AnalyzerContextDecl(ID* id, ContextFieldList* context_fields); AnalyzerContextDecl(ID* id, ContextFieldList* context_fields);
~AnalyzerContextDecl(); ~AnalyzerContextDecl() override;
void AddFlowBuffer(); void AddFlowBuffer();
@ -42,8 +42,8 @@ public:
// The type of analyzer context as a parameter // The type of analyzer context as a parameter
ParameterizedType* param_type() const { return param_type_; } ParameterizedType* param_type() const { return param_type_; }
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
void GenNamespaceBegin(Output* out) const; void GenNamespaceBegin(Output* out) const;
void GenNamespaceEnd(Output* out) const; void GenNamespaceEnd(Output* out) const;
@ -69,35 +69,38 @@ class DummyType : public Type
public: public:
DummyType() : Type(DUMMY) { } DummyType() : Type(DUMMY) { }
bool DefineValueVar() const { return false; } bool DefineValueVar() const override { return false; }
string DataTypeStr() const string DataTypeStr() const override
{ {
ASSERT(0); ASSERT(0);
return ""; return "";
} }
int StaticSize(Env* env) const int StaticSize(Env* env) const override
{ {
ASSERT(0); ASSERT(0);
return -1; return -1;
} }
bool ByteOrderSensitive() const { return false; } bool ByteOrderSensitive() const override { return false; }
bool IsPointerType() const bool IsPointerType() const override
{ {
ASSERT(0); ASSERT(0);
return false; return false;
} }
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) { ASSERT(0); } void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override
{
ASSERT(0);
}
// Generate code for computing the dynamic size of the type // Generate code for computing the dynamic size of the type
void GenDynamicSize(Output* out, Env* env, const DataPtr& data) { ASSERT(0); } void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override { ASSERT(0); }
protected: protected:
Type* DoClone() const; Type* DoClone() const override;
void DoMarkIncrementalInput() { ASSERT(0); } void DoMarkIncrementalInput() override { ASSERT(0); }
}; };
#endif // pac_context_h #endif // pac_context_h

View file

@ -56,8 +56,8 @@ public:
RequiresAnalyzerContext() : requires_analyzer_context_(false) { } RequiresAnalyzerContext() : requires_analyzer_context_(false) { }
// Returns whether to continue traversal // Returns whether to continue traversal
bool PreProcess(DataDepElement* element); bool PreProcess(DataDepElement* element) override;
bool PostProcess(DataDepElement* element); bool PostProcess(DataDepElement* element) override;
bool requires_analyzer_context() const { return requires_analyzer_context_; } bool requires_analyzer_context() const { return requires_analyzer_context_; }

View file

@ -15,7 +15,7 @@ public:
FLOWUNIT FLOWUNIT
}; };
AnalyzerDataUnit(DataUnitType type, ID* id, ExprList* type_params, ExprList* context_params); AnalyzerDataUnit(DataUnitType type, ID* id, ExprList* type_params, ExprList* context_params);
~AnalyzerDataUnit(); ~AnalyzerDataUnit() override;
void Prepare(Env* env); void Prepare(Env* env);

View file

@ -76,14 +76,14 @@ public:
EXTERN, EXTERN,
}; };
HelperDecl(HelperType type, ID* context_id, EmbeddedCode* code); HelperDecl(HelperType type, ID* context_id, EmbeddedCode* code);
~HelperDecl(); ~HelperDecl() override;
void Prepare(); void Prepare() override;
void GenExternDeclaration(Output* out_h); void GenExternDeclaration(Output* out_h) override;
void GenForwardDeclaration(Output* out_h) void GenForwardDeclaration(Output* out_h) override
{ /* do nothing */ { /* do nothing */
} }
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
private: private:
HelperType helper_type_; HelperType helper_type_;

View file

@ -20,13 +20,13 @@ class EnumDecl : public Decl
{ {
public: public:
EnumDecl(ID* id, EnumList* enumlist); EnumDecl(ID* id, EnumList* enumlist);
~EnumDecl(); ~EnumDecl() override;
Type* DataType() const { return datatype_; } Type* DataType() const { return datatype_; }
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
private: private:
EnumList* enumlist_; EnumList* enumlist_;

View file

@ -29,7 +29,7 @@ public:
Expr(ExprType type, Expr* op1, Expr* op2); Expr(ExprType type, Expr* op1, Expr* op2);
Expr(ExprType type, Expr* op1, Expr* op2, Expr* op3); Expr(ExprType type, Expr* op1, Expr* op2, Expr* op3);
virtual ~Expr(); ~Expr() override;
const char* orig() const { return orig_.c_str(); } const char* orig() const { return orig_.c_str(); }
const ID* id() const { return id_; } const ID* id() const { return id_; }
@ -89,7 +89,7 @@ public:
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
ExprType expr_type_; ExprType expr_type_;
@ -121,7 +121,7 @@ class CaseExpr : public Object, public DataDepElement
{ {
public: public:
CaseExpr(ExprList* index, Expr* value); CaseExpr(ExprList* index, Expr* value);
virtual ~CaseExpr(); ~CaseExpr() override;
ExprList* index() const { return index_; } ExprList* index() const { return index_; }
Expr* value() const { return value_; } Expr* value() const { return value_; }
@ -130,7 +130,7 @@ public:
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
ExprList* index_; ExprList* index_;

View file

@ -19,22 +19,22 @@ public:
}; };
ExternType(const ID* id, EXTType ext_type) : Type(EXTERN), id_(id), ext_type_(ext_type) { } ExternType(const ID* id, EXTType ext_type) : Type(EXTERN), id_(id), ext_type_(ext_type) { }
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
bool ByteOrderSensitive() const; bool ByteOrderSensitive() const override;
string EvalMember(const ID* member_id) const; string EvalMember(const ID* member_id) const override;
bool IsNumericType() const { return ext_type_ == NUMBER; } bool IsNumericType() const override { return ext_type_ == NUMBER; }
bool IsPointerType() const { return ext_type_ == POINTER; } bool IsPointerType() const override { return ext_type_ == POINTER; }
void GenInitCode(Output* out_cc, Env* env); void GenInitCode(Output* out_cc, Env* env) override;
protected: protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
Type* DoClone() const; Type* DoClone() const override;
private: private:
const ID* id_; const ID* id_;

View file

@ -42,7 +42,7 @@ public:
static const int PUBLIC_READABLE = 4; static const int PUBLIC_READABLE = 4;
static const int NOT_PUBLIC_READABLE = 0; static const int NOT_PUBLIC_READABLE = 0;
virtual ~Field(); ~Field() override;
FieldType tof() const { return tof_; } FieldType tof() const { return tof_; }
const ID* id() const { return id_; } const ID* id() const { return id_; }
@ -70,7 +70,7 @@ protected:
int ValueVarType() const; int ValueVarType() const;
bool ToBeParsed() const; bool ToBeParsed() const;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
protected: protected:
FieldType tof_; FieldType tof_;

View file

@ -7,28 +7,28 @@ class FlowDecl : public AnalyzerDecl
{ {
public: public:
FlowDecl(ID* flow_id, ParamList* params, AnalyzerElementList* elemlist); FlowDecl(ID* flow_id, ParamList* params, AnalyzerElementList* elemlist);
~FlowDecl(); ~FlowDecl() override;
void Prepare(); void Prepare() override;
void set_conn_decl(ConnDecl* c) { conn_decl_ = c; } void set_conn_decl(ConnDecl* c) { conn_decl_ = c; }
static ParameterizedType* flow_buffer_type(); static ParameterizedType* flow_buffer_type();
protected: protected:
void AddBaseClass(vector<string>* base_classes) const; void AddBaseClass(vector<string>* base_classes) const override;
void GenInitCode(Output* out_cc); void GenInitCode(Output* out_cc) override;
void GenCleanUpCode(Output* out_cc); void GenCleanUpCode(Output* out_cc) override;
void GenProcessFunc(Output* out_h, Output* out_cc); void GenProcessFunc(Output* out_h, Output* out_cc) override;
void GenEOFFunc(Output* out_h, Output* out_cc); void GenEOFFunc(Output* out_h, Output* out_cc) override;
void GenGapFunc(Output* out_h, Output* out_cc); void GenGapFunc(Output* out_h, Output* out_cc) override;
void GenPubDecls(Output* out_h, Output* out_cc); void GenPubDecls(Output* out_h, Output* out_cc) override;
void GenPrivDecls(Output* out_h, Output* out_cc); void GenPrivDecls(Output* out_h, Output* out_cc) override;
void ProcessFlowElement(AnalyzerFlow* flow_elem); void ProcessFlowElement(AnalyzerFlow* flow_elem) override;
void ProcessDataUnitElement(AnalyzerDataUnit* dataunit_elem); void ProcessDataUnitElement(AnalyzerDataUnit* dataunit_elem) override;
private: private:
void GenNewDataUnit(Output* out_cc); void GenNewDataUnit(Output* out_cc);

View file

@ -42,13 +42,13 @@ class FuncDecl : public Decl
{ {
public: public:
FuncDecl(Function* function); FuncDecl(Function* function);
~FuncDecl(); ~FuncDecl() override;
Function* function() const { return function_; } Function* function() const { return function_; }
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
private: private:
Function* function_; Function* function_;

View file

@ -15,7 +15,7 @@ public:
DataPtr GenDataBeginEnd(Output* out_cc, Env* env); DataPtr GenDataBeginEnd(Output* out_cc, Env* env);
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
Expr* expr_; Expr* expr_;

View file

@ -8,20 +8,20 @@ class LetField : public Field, Evaluatable
{ {
public: public:
LetField(ID* arg_id, Type* type, Expr* arg_expr); LetField(ID* arg_id, Type* type, Expr* arg_expr);
~LetField(); ~LetField() override;
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
void Prepare(Env* env); void Prepare(Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenParseCode(Output* out, Env* env); void GenParseCode(Output* out, Env* env);
void GenEval(Output* out, Env* env); void GenEval(Output* out, Env* env) override;
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const override;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
protected: protected:
Expr* expr_; Expr* expr_;
@ -31,14 +31,14 @@ class LetDecl : public Decl, Evaluatable
{ {
public: public:
LetDecl(ID* id, Type* type, Expr* expr); LetDecl(ID* id, Type* type, Expr* expr);
~LetDecl(); ~LetDecl() override;
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
void GenEval(Output* out, Env* env); void GenEval(Output* out, Env* env) override;
private: private:
Type* type_; Type* type_;

View file

@ -27,8 +27,8 @@ class ParamField : public Field
public: public:
ParamField(const Param* param); ParamField(const Param* param);
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
}; };
// Returns the string with a list of param declarations separated by ','. // Returns the string with a list of param declarations separated by ','.

View file

@ -8,54 +8,54 @@ class ParameterizedType : public Type
{ {
public: public:
ParameterizedType(ID* type_id, ExprList* args); ParameterizedType(ID* type_id, ExprList* args);
~ParameterizedType(); ~ParameterizedType() override;
Type* clone() const; Type* clone() const;
string EvalMember(const ID* member_id) const; string EvalMember(const ID* member_id) const override;
// Env *member_env() const; // Env *member_env() const;
void AddParamArg(Expr* arg); void AddParamArg(Expr* arg);
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
string DefaultValue() const { return "0"; } string DefaultValue() const override { return "0"; }
Type* MemberDataType(const ID* member_id) const; Type* MemberDataType(const ID* member_id) const override;
// "throw_exception" specifies whether to throw an exception // "throw_exception" specifies whether to throw an exception
// if the referred data type is not found // if the referred data type is not found
Type* ReferredDataType(bool throw_exception) const; Type* ReferredDataType(bool throw_exception) const;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
bool IsPointerType() const { return true; } bool IsPointerType() const override { return true; }
bool ByteOrderSensitive() const; bool ByteOrderSensitive() const override;
bool RequiresAnalyzerContext(); bool RequiresAnalyzerContext() override;
void GenInitCode(Output* out_cc, Env* env); void GenInitCode(Output* out_cc, Env* env) override;
string class_name() const; string class_name() const;
string EvalParameters(Output* out_cc, Env* env) const; string EvalParameters(Output* out_cc, Env* env) const;
BufferMode buffer_mode() const; BufferMode buffer_mode() const override;
protected: protected:
void GenNewInstance(Output* out, Env* env); void GenNewInstance(Output* out, Env* env) override;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
Type* DoClone() const; Type* DoClone() const override;
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
private: private:
ID* type_id_; ID* type_id_;
ExprList* args_; ExprList* args_;
bool checking_requires_analyzer_context_; bool checking_requires_analyzer_context_;
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
}; };
#endif // pac_paramtype_h #endif // pac_paramtype_h

View file

@ -31,7 +31,7 @@ public:
PPVal(Expr* expr) : PacPrimitive(VAL), expr_(expr) { } PPVal(Expr* expr) : PacPrimitive(VAL), expr_(expr) { }
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
string ToCode(Env* env); string ToCode(Env* env) override;
private: private:
Expr* expr_; Expr* expr_;
@ -43,7 +43,7 @@ public:
PPSet(Expr* expr) : PacPrimitive(SET), expr_(expr) { } PPSet(Expr* expr) : PacPrimitive(SET), expr_(expr) { }
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
string ToCode(Env* env); string ToCode(Env* env) override;
private: private:
Expr* expr_; Expr* expr_;
@ -55,7 +55,7 @@ public:
PPType(Expr* expr) : PacPrimitive(TYPE), expr_(expr) { } PPType(Expr* expr) : PacPrimitive(TYPE), expr_(expr) { }
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
string ToCode(Env* env); string ToCode(Env* env) override;
private: private:
Expr* expr_; Expr* expr_;
@ -68,7 +68,7 @@ public:
const ID* id() const { return id_; } const ID* id() const { return id_; }
Expr* expr() const { return expr_; } Expr* expr() const { return expr_; }
string ToCode(Env* env); string ToCode(Env* env) override;
private: private:
const ID* id_; const ID* id_;

View file

@ -11,41 +11,41 @@ class RecordType : public Type
{ {
public: public:
RecordType(RecordFieldList* fields); RecordType(RecordFieldList* fields);
~RecordType(); ~RecordType() override;
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
void Prepare(Env* env, int flags); void Prepare(Env* env, int flags) override;
void GenPubDecls(Output* out, Env* env); void GenPubDecls(Output* out, Env* env) override;
void GenPrivDecls(Output* out, Env* env); void GenPrivDecls(Output* out, Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
void SetBoundaryChecked(); void SetBoundaryChecked() override;
const ID* parsing_dataptr_var() const; const ID* parsing_dataptr_var() const;
bool IsPointerType() const bool IsPointerType() const override
{ {
ASSERT(0); ASSERT(0);
return false; return false;
} }
protected: protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
Type* DoClone() const { return nullptr; } Type* DoClone() const override { return nullptr; }
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
bool ByteOrderSensitive() const; bool ByteOrderSensitive() const override;
private: private:
Field* parsing_dataptr_var_field_; Field* parsing_dataptr_var_field_;
@ -60,7 +60,7 @@ class RecordField : public Field
{ {
public: public:
RecordField(FieldType tof, ID* id, Type* type); RecordField(FieldType tof, ID* id, Type* type);
~RecordField(); ~RecordField() override;
RecordType* record_type() const { return record_type_; } RecordType* record_type() const { return record_type_; }
void set_record_type(RecordType* ty) { record_type_ = ty; } void set_record_type(RecordType* ty) { record_type_ = ty; }
@ -115,26 +115,26 @@ class RecordDataField : public RecordField, public Evaluatable
{ {
public: public:
RecordDataField(ID* arg_id, Type* arg_type); RecordDataField(ID* arg_id, Type* arg_type);
~RecordDataField(); ~RecordDataField() override;
// Instantiates abstract class Field // Instantiates abstract class Field
void Prepare(Env* env); void Prepare(Env* env) override;
void GenParseCode(Output* out, Env* env); void GenParseCode(Output* out, Env* env) override;
// Instantiates abstract class Evaluatable // Instantiates abstract class Evaluatable
void GenEval(Output* out, Env* env); void GenEval(Output* out, Env* env) override;
int StaticSize(Env* env, int) const { return type()->StaticSize(env); } int StaticSize(Env* env, int) const override { return type()->StaticSize(env); }
void SetBoundaryChecked(); void SetBoundaryChecked() override;
bool RequiresByteOrder() const { return type()->RequiresByteOrder(); } bool RequiresByteOrder() const override { return type()->RequiresByteOrder(); }
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const override;
protected: protected:
void GenFieldEnd(Output* out, Env* env, const DataPtr& begin); void GenFieldEnd(Output* out, Env* env, const DataPtr& begin) override;
bool GenBoundaryCheck(Output* out_cc, Env* env); bool GenBoundaryCheck(Output* out_cc, Env* env) override;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
}; };
enum PaddingType enum PaddingType
@ -148,33 +148,33 @@ class RecordPaddingField : public RecordField
{ {
public: public:
RecordPaddingField(ID* id, PaddingType ptype, Expr* expr); RecordPaddingField(ID* id, PaddingType ptype, Expr* expr);
~RecordPaddingField(); ~RecordPaddingField() override;
void Prepare(Env* env); void Prepare(Env* env) override;
void GenPubDecls(Output* out, Env* env) void GenPubDecls(Output* out, Env* env) override
{ /* nothing */ { /* nothing */
} }
void GenPrivDecls(Output* out, Env* env) void GenPrivDecls(Output* out, Env* env) override
{ /* nothing */ { /* nothing */
} }
void GenInitCode(Output* out, Env* env) void GenInitCode(Output* out, Env* env) override
{ /* nothing */ { /* nothing */
} }
void GenCleanUpCode(Output* out, Env* env) void GenCleanUpCode(Output* out, Env* env) override
{ /* nothing */ { /* nothing */
} }
void GenParseCode(Output* out, Env* env); void GenParseCode(Output* out, Env* env) override;
int StaticSize(Env* env, int offset) const; int StaticSize(Env* env, int offset) const override;
bool RequiresByteOrder() const { return false; } bool RequiresByteOrder() const override { return false; }
protected: protected:
void GenFieldEnd(Output* out, Env* env, const DataPtr& begin); void GenFieldEnd(Output* out, Env* env, const DataPtr& begin) override;
bool GenBoundaryCheck(Output* out_cc, Env* env); bool GenBoundaryCheck(Output* out_cc, Env* env) override;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
PaddingType ptype_; PaddingType ptype_;

View file

@ -30,9 +30,9 @@ class RegExDecl : public Decl
public: public:
RegExDecl(RegEx* regex); RegExDecl(RegEx* regex);
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
private: private:
RegEx* regex_; RegEx* regex_;

View file

@ -17,28 +17,28 @@ public:
explicit StringType(StringTypeEnum anystr); explicit StringType(StringTypeEnum anystr);
explicit StringType(ConstString* str); explicit StringType(ConstString* str);
explicit StringType(RegEx* regex); explicit StringType(RegEx* regex);
~StringType(); ~StringType() override;
bool DefineValueVar() const; bool DefineValueVar() const override;
string DataTypeStr() const; string DataTypeStr() const override;
string DefaultValue() const { return "0"; } string DefaultValue() const override { return "0"; }
Type* ElementDataType() const; Type* ElementDataType() const override;
void Prepare(Env* env, int flags); void Prepare(Env* env, int flags) override;
void GenPubDecls(Output* out, Env* env); void GenPubDecls(Output* out, Env* env) override;
void GenPrivDecls(Output* out, Env* env); void GenPrivDecls(Output* out, Env* env) override;
void GenInitCode(Output* out, Env* env); void GenInitCode(Output* out, Env* env) override;
void GenCleanUpCode(Output* out, Env* env); void GenCleanUpCode(Output* out, Env* env) override;
void DoMarkIncrementalInput(); void DoMarkIncrementalInput() override;
int StaticSize(Env* env) const; int StaticSize(Env* env) const override;
bool IsPointerType() const { return false; } bool IsPointerType() const override { return false; }
void ProcessAttr(Attr* a); void ProcessAttr(Attr* a) override;
protected: protected:
void init(); void init();
@ -50,21 +50,21 @@ protected:
// Generate a string mismatch exception // Generate a string mismatch exception
void GenStringMismatch(Output* out_cc, Env* env, const DataPtr& data, string pattern); void GenStringMismatch(Output* out_cc, Env* env, const DataPtr& data, string pattern);
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags); void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags) override;
void GenCheckingCStr(Output* out, Env* env, const DataPtr& data, const string& str_size); void GenCheckingCStr(Output* out, Env* env, const DataPtr& data, const string& str_size);
void GenDynamicSize(Output* out, Env* env, const DataPtr& data); void GenDynamicSize(Output* out, Env* env, const DataPtr& data) override;
void GenDynamicSizeAnyStr(Output* out_cc, Env* env, const DataPtr& data); void GenDynamicSizeAnyStr(Output* out_cc, Env* env, const DataPtr& data);
void GenDynamicSizeRegEx(Output* out_cc, Env* env, const DataPtr& data); void GenDynamicSizeRegEx(Output* out_cc, Env* env, const DataPtr& data);
Type* DoClone() const; Type* DoClone() const override;
// TODO: insensitive towards byte order till we support unicode // TODO: insensitive towards byte order till we support unicode
bool ByteOrderSensitive() const { return false; } bool ByteOrderSensitive() const override { return false; }
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
private: private:
const ID* string_length_var() const; const ID* string_length_var() const;

View file

@ -26,7 +26,7 @@ public:
}; };
explicit Type(TypeType tot); explicit Type(TypeType tot);
virtual ~Type(); ~Type() override;
Type* Clone() const; Type* Clone() const;
@ -236,7 +236,7 @@ protected:
// Generate code for computing the dynamic size of the type // Generate code for computing the dynamic size of the type
virtual void GenDynamicSize(Output* out, Env* env, const DataPtr& data) = 0; virtual void GenDynamicSize(Output* out, Env* env, const DataPtr& data) = 0;
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
virtual Type* DoClone() const = 0; virtual Type* DoClone() const = 0;

View file

@ -7,12 +7,12 @@ class TypeDecl : public Decl
{ {
public: public:
TypeDecl(ID* arg_id, ParamList* arg_params, Type* arg_type); TypeDecl(ID* arg_id, ParamList* arg_params, Type* arg_type);
~TypeDecl(); ~TypeDecl() override;
void Prepare(); void Prepare() override;
void GenForwardDeclaration(Output* out_h); void GenForwardDeclaration(Output* out_h) override;
void GenCode(Output* out_h, Output* out_cc); void GenCode(Output* out_h, Output* out_cc) override;
Env* env() const { return env_; } Env* env() const override { return env_; }
Type* type() const { return type_; } Type* type() const { return type_; }
string class_name() const; string class_name() const;
static Type* LookUpType(const ID* id); static Type* LookUpType(const ID* id);
@ -20,7 +20,7 @@ public:
protected: protected:
void AddParam(Param* param); void AddParam(Param* param);
virtual void AddBaseClass(vector<string>* base_classes) const { } virtual void AddBaseClass(vector<string>* base_classes) const { }
void ProcessAttr(Attr* a); void ProcessAttr(Attr* a) override;
virtual void GenPubDecls(Output* out_h, Output* out_cc); virtual void GenPubDecls(Output* out_h, Output* out_cc);
virtual void GenPrivDecls(Output* out_h, Output* out_cc); virtual void GenPrivDecls(Output* out_h, Output* out_cc);

View file

@ -12,7 +12,7 @@ public:
type) type)
{ {
} }
void GenPubDecls(Output* out, Env* env) void GenPubDecls(Output* out, Env* env) override
{ /* do nothing */ { /* do nothing */
} }
}; };
@ -25,7 +25,7 @@ public:
: Field(PUB_VAR_FIELD, TYPE_NOT_TO_BE_PARSED | CLASS_MEMBER | PUBLIC_READABLE, id, type) : Field(PUB_VAR_FIELD, TYPE_NOT_TO_BE_PARSED | CLASS_MEMBER | PUBLIC_READABLE, id, type)
{ {
} }
~PubVarField() { } ~PubVarField() override { }
}; };
// A private variable // A private variable
@ -37,9 +37,9 @@ public:
type) type)
{ {
} }
~PrivVarField() { } ~PrivVarField() override { }
void GenPubDecls(Output* out, Env* env) void GenPubDecls(Output* out, Env* env) override
{ /* do nothing */ { /* do nothing */
} }
}; };
@ -51,7 +51,7 @@ public:
: Field(TEMP_VAR_FIELD, TYPE_NOT_TO_BE_PARSED | NOT_CLASS_MEMBER, id, type) : Field(TEMP_VAR_FIELD, TYPE_NOT_TO_BE_PARSED | NOT_CLASS_MEMBER, id, type)
{ {
} }
~TempVarField() { } ~TempVarField() override { }
}; };
#endif // pac_varfield_h #endif // pac_varfield_h

View file

@ -9,11 +9,11 @@ class WithInputField : public Field, public Evaluatable
{ {
public: public:
WithInputField(ID* id, Type* type, InputBuffer* input); WithInputField(ID* id, Type* type, InputBuffer* input);
virtual ~WithInputField(); ~WithInputField() override;
InputBuffer* input() const { return input_; } InputBuffer* input() const { return input_; }
void Prepare(Env* env); void Prepare(Env* env) override;
// void GenPubDecls(Output* out, Env* env); // void GenPubDecls(Output* out, Env* env);
// void GenPrivDecls(Output* out, Env* env); // void GenPrivDecls(Output* out, Env* env);
@ -24,12 +24,12 @@ public:
void GenParseCode(Output* out, Env* env); void GenParseCode(Output* out, Env* env);
// Instantiate the Evaluatable interface // Instantiate the Evaluatable interface
void GenEval(Output* out, Env* env); void GenEval(Output* out, Env* env) override;
bool RequiresAnalyzerContext() const; bool RequiresAnalyzerContext() const override;
protected: protected:
bool DoTraverse(DataDepVisitor* visitor); bool DoTraverse(DataDepVisitor* visitor) override;
protected: protected:
InputBuffer* input_; InputBuffer* input_;