mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Merge branch 'master' of https://github.com/zeek/zeek into topic/zeke/closures
This commit is contained in:
commit
1ed672287b
462 changed files with 7578 additions and 16720 deletions
139
src/Expr.h
139
src/Expr.h
|
@ -53,7 +53,8 @@ typedef enum {
|
|||
EXPR_FLATTEN,
|
||||
EXPR_CAST,
|
||||
EXPR_IS,
|
||||
#define NUM_EXPRS (int(EXPR_IS) + 1)
|
||||
EXPR_INDEX_SLICE_ASSIGN,
|
||||
#define NUM_EXPRS (int(EXPR_INDEX_SLICE_ASSIGN) + 1)
|
||||
} BroExprTag;
|
||||
|
||||
extern const char* expr_name(BroExprTag t);
|
||||
|
@ -62,6 +63,7 @@ class Stmt;
|
|||
class Frame;
|
||||
class ListExpr;
|
||||
class NameExpr;
|
||||
class IndexExpr;
|
||||
class AssignExpr;
|
||||
class CallExpr;
|
||||
class EventExpr;
|
||||
|
@ -90,7 +92,7 @@ public:
|
|||
const;
|
||||
|
||||
// Assign to the given value, if appropriate.
|
||||
virtual void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN);
|
||||
virtual void Assign(Frame* f, Val* v);
|
||||
|
||||
// Returns the type corresponding to this expression interpreted
|
||||
// as an initialization. The type should be Unref()'d when done
|
||||
|
@ -193,10 +195,19 @@ public:
|
|||
return (AssignExpr*) this;
|
||||
}
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
const IndexExpr* AsIndexExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_INDEX, "ExprVal::AsIndexExpr", expr_name)
|
||||
return (const IndexExpr*) this;
|
||||
}
|
||||
|
||||
bool Serialize(SerialInfo* info) const;
|
||||
static Expr* Unserialize(UnserialInfo* info, BroExprTag want = EXPR_ANY);
|
||||
IndexExpr* AsIndexExpr()
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_INDEX, "ExprVal::AsIndexExpr", expr_name)
|
||||
return (IndexExpr*) this;
|
||||
}
|
||||
|
||||
void Describe(ODesc* d) const override;
|
||||
|
||||
virtual TraversalCode Traverse(TraversalCallback* cb) const = 0;
|
||||
|
||||
|
@ -220,8 +231,6 @@ protected:
|
|||
|
||||
void RuntimeErrorWithCallStack(const std::string& msg) const;
|
||||
|
||||
DECLARE_ABSTRACT_SERIAL(Expr);
|
||||
|
||||
BroExprTag tag;
|
||||
BroType* type;
|
||||
|
||||
|
@ -236,7 +245,7 @@ public:
|
|||
ID* Id() const { return id; }
|
||||
|
||||
Val* Eval(Frame* f) const override;
|
||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN) override;
|
||||
void Assign(Frame* f, Val* v) override;
|
||||
Expr* MakeLvalue() override;
|
||||
int IsPure() const override;
|
||||
|
||||
|
@ -248,8 +257,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(NameExpr);
|
||||
|
||||
ID* id;
|
||||
bool in_const_init;
|
||||
};
|
||||
|
@ -270,8 +277,6 @@ protected:
|
|||
ConstExpr() { val = 0; }
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
DECLARE_SERIAL(ConstExpr);
|
||||
|
||||
Val* val;
|
||||
};
|
||||
|
||||
|
@ -300,8 +305,6 @@ protected:
|
|||
// Returns the expression folded using the given constant.
|
||||
virtual Val* Fold(Val* v) const;
|
||||
|
||||
DECLARE_SERIAL(UnaryExpr);
|
||||
|
||||
Expr* op;
|
||||
};
|
||||
|
||||
|
@ -363,8 +366,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(BinaryExpr);
|
||||
|
||||
Expr* op1;
|
||||
Expr* op2;
|
||||
};
|
||||
|
@ -379,8 +380,6 @@ protected:
|
|||
CloneExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(CloneExpr);
|
||||
};
|
||||
|
||||
class IncrExpr : public UnaryExpr {
|
||||
|
@ -394,8 +393,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
IncrExpr() { }
|
||||
|
||||
DECLARE_SERIAL(IncrExpr);
|
||||
};
|
||||
|
||||
class ComplementExpr : public UnaryExpr {
|
||||
|
@ -407,8 +404,6 @@ protected:
|
|||
ComplementExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(ComplementExpr);
|
||||
};
|
||||
|
||||
class NotExpr : public UnaryExpr {
|
||||
|
@ -420,8 +415,6 @@ protected:
|
|||
NotExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(NotExpr);
|
||||
};
|
||||
|
||||
class PosExpr : public UnaryExpr {
|
||||
|
@ -433,8 +426,6 @@ protected:
|
|||
PosExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(PosExpr);
|
||||
};
|
||||
|
||||
class NegExpr : public UnaryExpr {
|
||||
|
@ -446,8 +437,6 @@ protected:
|
|||
NegExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(NegExpr);
|
||||
};
|
||||
|
||||
class SizeExpr : public UnaryExpr {
|
||||
|
@ -460,7 +449,6 @@ protected:
|
|||
SizeExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
DECLARE_SERIAL(SizeExpr);
|
||||
};
|
||||
|
||||
class AddExpr : public BinaryExpr {
|
||||
|
@ -471,9 +459,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
AddExpr() { }
|
||||
|
||||
DECLARE_SERIAL(AddExpr);
|
||||
|
||||
};
|
||||
|
||||
class AddToExpr : public BinaryExpr {
|
||||
|
@ -484,8 +469,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
AddToExpr() { }
|
||||
|
||||
DECLARE_SERIAL(AddToExpr);
|
||||
};
|
||||
|
||||
class RemoveFromExpr : public BinaryExpr {
|
||||
|
@ -496,8 +479,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
RemoveFromExpr() { }
|
||||
|
||||
DECLARE_SERIAL(RemoveFromExpr);
|
||||
};
|
||||
|
||||
class SubExpr : public BinaryExpr {
|
||||
|
@ -507,9 +488,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
SubExpr() { }
|
||||
|
||||
DECLARE_SERIAL(SubExpr);
|
||||
|
||||
};
|
||||
|
||||
class TimesExpr : public BinaryExpr {
|
||||
|
@ -520,9 +498,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
TimesExpr() { }
|
||||
|
||||
DECLARE_SERIAL(TimesExpr);
|
||||
|
||||
};
|
||||
|
||||
class DivideExpr : public BinaryExpr {
|
||||
|
@ -534,9 +509,6 @@ protected:
|
|||
DivideExpr() { }
|
||||
|
||||
Val* AddrFold(Val* v1, Val* v2) const override;
|
||||
|
||||
DECLARE_SERIAL(DivideExpr);
|
||||
|
||||
};
|
||||
|
||||
class ModExpr : public BinaryExpr {
|
||||
|
@ -546,8 +518,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
ModExpr() { }
|
||||
|
||||
DECLARE_SERIAL(ModExpr);
|
||||
};
|
||||
|
||||
class BoolExpr : public BinaryExpr {
|
||||
|
@ -560,8 +530,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
BoolExpr() { }
|
||||
|
||||
DECLARE_SERIAL(BoolExpr);
|
||||
};
|
||||
|
||||
class BitExpr : public BinaryExpr {
|
||||
|
@ -571,8 +539,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
BitExpr() { }
|
||||
|
||||
DECLARE_SERIAL(BitExpr);
|
||||
};
|
||||
|
||||
class EqExpr : public BinaryExpr {
|
||||
|
@ -585,8 +551,6 @@ protected:
|
|||
EqExpr() { }
|
||||
|
||||
Val* Fold(Val* v1, Val* v2) const override;
|
||||
|
||||
DECLARE_SERIAL(EqExpr);
|
||||
};
|
||||
|
||||
class RelExpr : public BinaryExpr {
|
||||
|
@ -597,8 +561,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
RelExpr() { }
|
||||
|
||||
DECLARE_SERIAL(RelExpr);
|
||||
};
|
||||
|
||||
class CondExpr : public Expr {
|
||||
|
@ -621,8 +583,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(CondExpr);
|
||||
|
||||
Expr* op1;
|
||||
Expr* op2;
|
||||
Expr* op3;
|
||||
|
@ -632,14 +592,12 @@ class RefExpr : public UnaryExpr {
|
|||
public:
|
||||
explicit RefExpr(Expr* op);
|
||||
|
||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN) override;
|
||||
void Assign(Frame* f, Val* v) override;
|
||||
Expr* MakeLvalue() override;
|
||||
|
||||
protected:
|
||||
friend class Expr;
|
||||
RefExpr() { }
|
||||
|
||||
DECLARE_SERIAL(RefExpr);
|
||||
};
|
||||
|
||||
class AssignExpr : public BinaryExpr {
|
||||
|
@ -663,12 +621,20 @@ protected:
|
|||
bool TypeCheck(attr_list* attrs = 0);
|
||||
bool TypeCheckArithmetics(TypeTag bt1, TypeTag bt2);
|
||||
|
||||
DECLARE_SERIAL(AssignExpr);
|
||||
|
||||
int is_init;
|
||||
Val* val; // optional
|
||||
};
|
||||
|
||||
class IndexSliceAssignExpr : public AssignExpr {
|
||||
public:
|
||||
IndexSliceAssignExpr(Expr* op1, Expr* op2, int is_init);
|
||||
Val* Eval(Frame* f) const override;
|
||||
|
||||
protected:
|
||||
friend class Expr;
|
||||
IndexSliceAssignExpr() {}
|
||||
};
|
||||
|
||||
class IndexExpr : public BinaryExpr {
|
||||
public:
|
||||
IndexExpr(Expr* op1, ListExpr* op2, bool is_slice = false);
|
||||
|
@ -679,7 +645,7 @@ public:
|
|||
void Add(Frame* f) override;
|
||||
void Delete(Frame* f) override;
|
||||
|
||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN) override;
|
||||
void Assign(Frame* f, Val* v) override;
|
||||
Expr* MakeLvalue() override;
|
||||
|
||||
// Need to override Eval since it can take a vector arg but does
|
||||
|
@ -688,6 +654,8 @@ public:
|
|||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
bool IsSlice() const { return is_slice; }
|
||||
|
||||
protected:
|
||||
friend class Expr;
|
||||
IndexExpr() { }
|
||||
|
@ -696,7 +664,7 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(IndexExpr);
|
||||
bool is_slice;
|
||||
};
|
||||
|
||||
class FieldExpr : public UnaryExpr {
|
||||
|
@ -709,7 +677,7 @@ public:
|
|||
|
||||
int CanDel() const override;
|
||||
|
||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN) override;
|
||||
void Assign(Frame* f, Val* v) override;
|
||||
void Delete(Frame* f) override;
|
||||
|
||||
Expr* MakeLvalue() override;
|
||||
|
@ -722,8 +690,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(FieldExpr);
|
||||
|
||||
const char* field_name;
|
||||
const TypeDecl* td;
|
||||
int field; // -1 = attributes
|
||||
|
@ -746,8 +712,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(HasFieldExpr);
|
||||
|
||||
const char* field_name;
|
||||
int field;
|
||||
};
|
||||
|
@ -765,8 +729,6 @@ protected:
|
|||
Val* Fold(Val* v) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(RecordConstructorExpr);
|
||||
};
|
||||
|
||||
class TableConstructorExpr : public UnaryExpr {
|
||||
|
@ -787,8 +749,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(TableConstructorExpr);
|
||||
|
||||
Attributes* attrs;
|
||||
};
|
||||
|
||||
|
@ -810,8 +770,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(SetConstructorExpr);
|
||||
|
||||
Attributes* attrs;
|
||||
};
|
||||
|
||||
|
@ -828,8 +786,6 @@ protected:
|
|||
Val* InitVal(const BroType* t, Val* aggr) const override;
|
||||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(VectorConstructorExpr);
|
||||
};
|
||||
|
||||
class FieldAssignExpr : public UnaryExpr {
|
||||
|
@ -847,8 +803,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(FieldAssignExpr);
|
||||
|
||||
string field_name;
|
||||
};
|
||||
|
||||
|
@ -862,8 +816,6 @@ protected:
|
|||
|
||||
Val* FoldSingleVal(Val* v, InternalTypeTag t) const;
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(ArithCoerceExpr);
|
||||
};
|
||||
|
||||
class RecordCoerceExpr : public UnaryExpr {
|
||||
|
@ -878,8 +830,6 @@ protected:
|
|||
Val* InitVal(const BroType* t, Val* aggr) const override;
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(RecordCoerceExpr);
|
||||
|
||||
// For each super-record slot, gives subrecord slot with which to
|
||||
// fill it.
|
||||
int* map;
|
||||
|
@ -896,8 +846,6 @@ protected:
|
|||
TableCoerceExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(TableCoerceExpr);
|
||||
};
|
||||
|
||||
class VectorCoerceExpr : public UnaryExpr {
|
||||
|
@ -910,8 +858,6 @@ protected:
|
|||
VectorCoerceExpr() { }
|
||||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(VectorCoerceExpr);
|
||||
};
|
||||
|
||||
// An internal operator for flattening array indices that are records
|
||||
|
@ -926,8 +872,6 @@ protected:
|
|||
|
||||
Val* Fold(Val* v) const override;
|
||||
|
||||
DECLARE_SERIAL(FlattenExpr);
|
||||
|
||||
int num_fields;
|
||||
};
|
||||
|
||||
|
@ -967,8 +911,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(ScheduleExpr);
|
||||
|
||||
Expr* when;
|
||||
EventExpr* event;
|
||||
};
|
||||
|
@ -983,8 +925,6 @@ protected:
|
|||
|
||||
Val* Fold(Val* v1, Val* v2) const override;
|
||||
|
||||
DECLARE_SERIAL(InExpr);
|
||||
|
||||
};
|
||||
|
||||
class CallExpr : public Expr {
|
||||
|
@ -1007,8 +947,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(CallExpr);
|
||||
|
||||
Expr* func;
|
||||
ListExpr* args;
|
||||
};
|
||||
|
@ -1058,8 +996,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(EventExpr);
|
||||
|
||||
string name;
|
||||
EventHandlerPtr handler;
|
||||
ListExpr* args;
|
||||
|
@ -1087,7 +1023,7 @@ public:
|
|||
BroType* InitType() const override;
|
||||
Val* InitVal(const BroType* t, Val* aggr) const override;
|
||||
Expr* MakeLvalue() override;
|
||||
void Assign(Frame* f, Val* v, Opcode op = OP_ASSIGN) override;
|
||||
void Assign(Frame* f, Val* v) override;
|
||||
|
||||
TraversalCode Traverse(TraversalCallback* cb) const override;
|
||||
|
||||
|
@ -1096,8 +1032,6 @@ protected:
|
|||
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(ListExpr);
|
||||
|
||||
expr_list exprs;
|
||||
};
|
||||
|
||||
|
@ -1111,8 +1045,6 @@ public:
|
|||
protected:
|
||||
friend class Expr;
|
||||
RecordAssignExpr() { }
|
||||
|
||||
DECLARE_SERIAL(RecordAssignExpr);
|
||||
};
|
||||
|
||||
class CastExpr : public UnaryExpr {
|
||||
|
@ -1125,8 +1057,6 @@ protected:
|
|||
|
||||
Val* Eval(Frame* f) const override;
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
|
||||
DECLARE_SERIAL(CastExpr);
|
||||
};
|
||||
|
||||
class IsExpr : public UnaryExpr {
|
||||
|
@ -1140,7 +1070,6 @@ protected:
|
|||
|
||||
Val* Fold(Val* v) const override;
|
||||
void ExprDescribe(ODesc* d) const override;
|
||||
DECLARE_SERIAL(IsExpr);
|
||||
|
||||
private:
|
||||
BroType* t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue