mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 04:58:21 +00:00
script optimization fixes for pattern tables
This commit is contained in:
parent
709d410fcd
commit
f573036099
4 changed files with 58 additions and 25 deletions
|
@ -418,7 +418,16 @@ const ZAMStmt ZAMCompiler::CompileInExpr(const NameExpr* n1, const NameExpr* n2,
|
|||
|
||||
ZOp a;
|
||||
|
||||
if ( op2->GetType()->Tag() == TYPE_PATTERN )
|
||||
auto& op2_t = op2->GetType();
|
||||
auto& op3_t = op3->GetType();
|
||||
|
||||
if ( op3_t->Tag() == TYPE_TABLE ) {
|
||||
if ( op3_t->AsTableType()->IsPatternIndex() && op2_t->Tag() == TYPE_STRING )
|
||||
a = n2 ? OP_STR_IN_PAT_TBL_VVV : OP_STR_IN_PAT_TBL_VCV;
|
||||
else
|
||||
a = n2 ? OP_VAL_IS_IN_TABLE_VVV : OP_CONST_IS_IN_TABLE_VCV;
|
||||
}
|
||||
else if ( op2->GetType()->Tag() == TYPE_PATTERN )
|
||||
a = n2 ? (n3 ? OP_P_IN_S_VVV : OP_P_IN_S_VVC) : OP_P_IN_S_VCV;
|
||||
|
||||
else if ( op2->GetType()->Tag() == TYPE_STRING )
|
||||
|
@ -427,9 +436,6 @@ const ZAMStmt ZAMCompiler::CompileInExpr(const NameExpr* n1, const NameExpr* n2,
|
|||
else if ( op2->GetType()->Tag() == TYPE_ADDR && op3->GetType()->Tag() == TYPE_SUBNET )
|
||||
a = n2 ? (n3 ? OP_A_IN_S_VVV : OP_A_IN_S_VVC) : OP_A_IN_S_VCV;
|
||||
|
||||
else if ( op3->GetType()->Tag() == TYPE_TABLE )
|
||||
a = n2 ? OP_VAL_IS_IN_TABLE_VVV : OP_CONST_IS_IN_TABLE_VCV;
|
||||
|
||||
else
|
||||
reporter->InternalError("bad types when compiling \"in\"");
|
||||
|
||||
|
@ -650,19 +656,25 @@ const ZAMStmt ZAMCompiler::CompileIndex(const NameExpr* n1, int n2_slot, const T
|
|||
}
|
||||
|
||||
if ( n2tag == TYPE_TABLE ) {
|
||||
if ( n3 ) {
|
||||
if ( is_pat_str_ind ) {
|
||||
auto n1_slot = Frame1Slot(n1, OP1_WRITE);
|
||||
if ( n3 ) {
|
||||
int n3_slot = FrameSlot(n3);
|
||||
z = ZInstI(OP_TABLE_PATSTR_INDEX_VVV, n1_slot, n2_slot, n3_slot);
|
||||
}
|
||||
else
|
||||
z = ZInstI(OP_TABLE_PATSTR_INDEX_VVC, n1_slot, n2_slot, c3);
|
||||
}
|
||||
else if ( n3 ) {
|
||||
int n3_slot = FrameSlot(n3);
|
||||
auto op = is_pat_str_ind ? OP_TABLE_PATSTR_INDEX1_VVV : OP_TABLE_INDEX1_VVV;
|
||||
auto zop = AssignmentFlavor(op, n1->GetType()->Tag());
|
||||
auto zop = AssignmentFlavor(OP_TABLE_INDEX1_VVV, n1->GetType()->Tag());
|
||||
z = ZInstI(zop, Frame1Slot(n1, zop), n2_slot, n3_slot);
|
||||
z.SetType(n3->GetType());
|
||||
}
|
||||
|
||||
else {
|
||||
ASSERT(c3);
|
||||
|
||||
auto op = is_pat_str_ind ? OP_TABLE_PATSTR_INDEX1_VVC : OP_TABLE_INDEX1_VVC;
|
||||
auto zop = AssignmentFlavor(op, n1->GetType()->Tag());
|
||||
auto zop = AssignmentFlavor(OP_TABLE_INDEX1_VVC, n1->GetType()->Tag());
|
||||
z = ZInstI(zop, Frame1Slot(n1, zop), n2_slot, c3);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue