mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
clang-format: Set IndentCaseBlocks to false
This commit is contained in:
parent
02206f3215
commit
4423574d26
58 changed files with 4729 additions and 4766 deletions
|
@ -362,43 +362,43 @@ void ZAMCompiler::ComputeFrameLifetimes()
|
|||
{
|
||||
case OP_NEXT_TABLE_ITER_VV:
|
||||
case OP_NEXT_TABLE_ITER_VAL_VAR_VVV:
|
||||
{
|
||||
// These assign to an arbitrary long list of variables.
|
||||
auto& iter_vars = inst->aux->loop_vars;
|
||||
auto depth = inst->loop_depth;
|
||||
|
||||
for ( auto v : iter_vars )
|
||||
{
|
||||
// These assign to an arbitrary long list of variables.
|
||||
auto& iter_vars = inst->aux->loop_vars;
|
||||
auto depth = inst->loop_depth;
|
||||
CheckSlotAssignment(v, inst);
|
||||
|
||||
for ( auto v : iter_vars )
|
||||
{
|
||||
CheckSlotAssignment(v, inst);
|
||||
|
||||
// Also mark it as usage throughout the
|
||||
// loop. Otherwise, we risk pruning the
|
||||
// variable if it happens to not be used
|
||||
// (which will mess up the iteration logic)
|
||||
// or doubling it up with some other value
|
||||
// inside the loop (which will fail when
|
||||
// the loop var has memory management
|
||||
// associated with it).
|
||||
ExtendLifetime(v, EndOfLoop(inst, depth));
|
||||
}
|
||||
|
||||
// No need to check the additional "var" associated
|
||||
// with OP_NEXT_TABLE_ITER_VAL_VAR_VVV as that's
|
||||
// a slot-1 assignment. However, similar to other
|
||||
// loop variables, mark this as a usage.
|
||||
if ( inst->op == OP_NEXT_TABLE_ITER_VAL_VAR_VVV )
|
||||
ExtendLifetime(inst->v1, EndOfLoop(inst, depth));
|
||||
// Also mark it as usage throughout the
|
||||
// loop. Otherwise, we risk pruning the
|
||||
// variable if it happens to not be used
|
||||
// (which will mess up the iteration logic)
|
||||
// or doubling it up with some other value
|
||||
// inside the loop (which will fail when
|
||||
// the loop var has memory management
|
||||
// associated with it).
|
||||
ExtendLifetime(v, EndOfLoop(inst, depth));
|
||||
}
|
||||
|
||||
// No need to check the additional "var" associated
|
||||
// with OP_NEXT_TABLE_ITER_VAL_VAR_VVV as that's
|
||||
// a slot-1 assignment. However, similar to other
|
||||
// loop variables, mark this as a usage.
|
||||
if ( inst->op == OP_NEXT_TABLE_ITER_VAL_VAR_VVV )
|
||||
ExtendLifetime(inst->v1, EndOfLoop(inst, depth));
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_NEXT_TABLE_ITER_NO_VARS_VV:
|
||||
break;
|
||||
|
||||
case OP_NEXT_TABLE_ITER_VAL_VAR_NO_VARS_VVV:
|
||||
{
|
||||
auto depth = inst->loop_depth;
|
||||
ExtendLifetime(inst->v1, EndOfLoop(inst, depth));
|
||||
}
|
||||
{
|
||||
auto depth = inst->loop_depth;
|
||||
ExtendLifetime(inst->v1, EndOfLoop(inst, depth));
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_NEXT_VECTOR_ITER_VVV:
|
||||
|
@ -417,30 +417,30 @@ void ZAMCompiler::ComputeFrameLifetimes()
|
|||
case OP_INIT_TABLE_LOOP_VV:
|
||||
case OP_INIT_VECTOR_LOOP_VV:
|
||||
case OP_INIT_STRING_LOOP_VV:
|
||||
{
|
||||
// For all of these, the scope of the aggregate being
|
||||
// looped over is the entire loop, even if it doesn't
|
||||
// directly appear in it, and not just the initializer.
|
||||
// For all three, the aggregate is in v1.
|
||||
ASSERT(i < insts1.size() - 1);
|
||||
auto succ = insts1[i + 1];
|
||||
ASSERT(succ->live);
|
||||
auto depth = succ->loop_depth;
|
||||
ExtendLifetime(inst->v1, EndOfLoop(succ, depth));
|
||||
{
|
||||
// For all of these, the scope of the aggregate being
|
||||
// looped over is the entire loop, even if it doesn't
|
||||
// directly appear in it, and not just the initializer.
|
||||
// For all three, the aggregate is in v1.
|
||||
ASSERT(i < insts1.size() - 1);
|
||||
auto succ = insts1[i + 1];
|
||||
ASSERT(succ->live);
|
||||
auto depth = succ->loop_depth;
|
||||
ExtendLifetime(inst->v1, EndOfLoop(succ, depth));
|
||||
|
||||
// Important: we skip the usual UsesSlots analysis
|
||||
// below since we've already set it, and don't want
|
||||
// to perturb ExtendLifetime's consistency check.
|
||||
continue;
|
||||
}
|
||||
// Important: we skip the usual UsesSlots analysis
|
||||
// below since we've already set it, and don't want
|
||||
// to perturb ExtendLifetime's consistency check.
|
||||
continue;
|
||||
}
|
||||
|
||||
case OP_STORE_GLOBAL_V:
|
||||
{
|
||||
// Use of the global goes to here.
|
||||
auto slot = frame_layout1[globalsI[inst->v1].id.get()];
|
||||
ExtendLifetime(slot, EndOfLoop(inst, 1));
|
||||
break;
|
||||
}
|
||||
{
|
||||
// Use of the global goes to here.
|
||||
auto slot = frame_layout1[globalsI[inst->v1].id.get()];
|
||||
ExtendLifetime(slot, EndOfLoop(inst, 1));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Look for slots in auxiliary information.
|
||||
|
@ -559,15 +559,15 @@ void ZAMCompiler::ReMapFrame()
|
|||
{
|
||||
case OP_NEXT_TABLE_ITER_VV:
|
||||
case OP_NEXT_TABLE_ITER_VAL_VAR_VVV:
|
||||
{
|
||||
// Rewrite iteration variables.
|
||||
auto& iter_vars = inst->aux->loop_vars;
|
||||
for ( auto& v : iter_vars )
|
||||
{
|
||||
// Rewrite iteration variables.
|
||||
auto& iter_vars = inst->aux->loop_vars;
|
||||
for ( auto& v : iter_vars )
|
||||
{
|
||||
ASSERT(v >= 0 && v < n1_slots);
|
||||
v = frame1_to_frame2[v];
|
||||
}
|
||||
ASSERT(v >= 0 && v < n1_slots);
|
||||
v = frame1_to_frame2[v];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -24,32 +24,32 @@ const ZAMStmt ZAMCompiler::CompileExpr(const Expr* e)
|
|||
return CompileAssignExpr(static_cast<const AssignExpr*>(e));
|
||||
|
||||
case EXPR_INDEX_ASSIGN:
|
||||
{
|
||||
auto iae = static_cast<const IndexAssignExpr*>(e);
|
||||
auto t = iae->GetOp1()->GetType()->Tag();
|
||||
if ( t == TYPE_VECTOR )
|
||||
return AssignVecElems(iae);
|
||||
{
|
||||
auto iae = static_cast<const IndexAssignExpr*>(e);
|
||||
auto t = iae->GetOp1()->GetType()->Tag();
|
||||
if ( t == TYPE_VECTOR )
|
||||
return AssignVecElems(iae);
|
||||
|
||||
ASSERT(t == TYPE_TABLE);
|
||||
return AssignTableElem(iae);
|
||||
}
|
||||
ASSERT(t == TYPE_TABLE);
|
||||
return AssignTableElem(iae);
|
||||
}
|
||||
|
||||
case EXPR_FIELD_LHS_ASSIGN:
|
||||
{
|
||||
auto flhs = static_cast<const FieldLHSAssignExpr*>(e);
|
||||
return CompileFieldLHSAssignExpr(flhs);
|
||||
}
|
||||
{
|
||||
auto flhs = static_cast<const FieldLHSAssignExpr*>(e);
|
||||
return CompileFieldLHSAssignExpr(flhs);
|
||||
}
|
||||
|
||||
case EXPR_SCHEDULE:
|
||||
return CompileScheduleExpr(static_cast<const ScheduleExpr*>(e));
|
||||
|
||||
case EXPR_EVENT:
|
||||
{
|
||||
auto ee = static_cast<const EventExpr*>(e);
|
||||
auto h = ee->Handler().Ptr();
|
||||
auto args = ee->Args();
|
||||
return EventHL(h, args);
|
||||
}
|
||||
{
|
||||
auto ee = static_cast<const EventExpr*>(e);
|
||||
auto h = ee->Handler().Ptr();
|
||||
auto args = ee->Args();
|
||||
return EventHL(h, args);
|
||||
}
|
||||
|
||||
default:
|
||||
reporter->InternalError("bad statement type in ZAMCompile::CompileExpr");
|
||||
|
@ -1111,31 +1111,31 @@ const ZAMStmt ZAMCompiler::ArithCoerce(const NameExpr* n, const Expr* e)
|
|||
switch ( targ_it )
|
||||
{
|
||||
case TYPE_INTERNAL_DOUBLE:
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_INT )
|
||||
a = nt_is_vec ? OP_COERCE_DI_VEC_VV : OP_COERCE_DI_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_DU_VEC_VV : OP_COERCE_DU_VV;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_INT )
|
||||
a = nt_is_vec ? OP_COERCE_DI_VEC_VV : OP_COERCE_DI_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_DU_VEC_VV : OP_COERCE_DU_VV;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_INT:
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_UNSIGNED )
|
||||
a = nt_is_vec ? OP_COERCE_IU_VEC_VV : OP_COERCE_IU_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_ID_VEC_VV : OP_COERCE_ID_VV;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_UNSIGNED )
|
||||
a = nt_is_vec ? OP_COERCE_IU_VEC_VV : OP_COERCE_IU_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_ID_VEC_VV : OP_COERCE_ID_VV;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_UNSIGNED:
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_INT )
|
||||
a = nt_is_vec ? OP_COERCE_UI_VEC_VV : OP_COERCE_UI_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_UD_VEC_VV : OP_COERCE_UD_VV;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if ( op_it == TYPE_INTERNAL_INT )
|
||||
a = nt_is_vec ? OP_COERCE_UI_VEC_VV : OP_COERCE_UI_VV;
|
||||
else
|
||||
a = nt_is_vec ? OP_COERCE_UD_VEC_VV : OP_COERCE_UD_VV;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
reporter->InternalError("bad target internal type in coercion");
|
||||
|
|
|
@ -81,11 +81,11 @@ string find_type_accessor(ZAM_ExprType et)
|
|||
return "re_val";
|
||||
|
||||
default:
|
||||
{
|
||||
string acc = find_type_info(et).accessor;
|
||||
transform(acc.begin(), acc.end(), acc.begin(), ::tolower);
|
||||
return acc + "_val";
|
||||
}
|
||||
{
|
||||
string acc = find_type_info(et).accessor;
|
||||
transform(acc.begin(), acc.end(), acc.begin(), ::tolower);
|
||||
return acc + "_val";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ const ZAMStmt ZAMCompiler::CompileStmt(const Stmt* s)
|
|||
return CompileDel(static_cast<const DelStmt*>(s));
|
||||
|
||||
case STMT_EVENT:
|
||||
{
|
||||
auto es = static_cast<const EventStmt*>(s);
|
||||
auto e = static_cast<const EventExpr*>(es->StmtExpr());
|
||||
return CompileExpr(e);
|
||||
}
|
||||
{
|
||||
auto es = static_cast<const EventStmt*>(s);
|
||||
auto e = static_cast<const EventExpr*>(es->StmtExpr());
|
||||
return CompileExpr(e);
|
||||
}
|
||||
|
||||
case STMT_WHILE:
|
||||
return CompileWhile(static_cast<const WhileStmt*>(s));
|
||||
|
@ -67,12 +67,12 @@ const ZAMStmt ZAMCompiler::CompileStmt(const Stmt* s)
|
|||
return CompileWhen(static_cast<const WhenStmt*>(s));
|
||||
|
||||
case STMT_CHECK_ANY_LEN:
|
||||
{
|
||||
auto cs = static_cast<const CheckAnyLenStmt*>(s);
|
||||
auto n = cs->StmtExpr()->AsNameExpr();
|
||||
auto expected_len = cs->ExpectedLen();
|
||||
return CheckAnyLenVi(n, expected_len);
|
||||
}
|
||||
{
|
||||
auto cs = static_cast<const CheckAnyLenStmt*>(s);
|
||||
auto n = cs->StmtExpr()->AsNameExpr();
|
||||
auto expected_len = cs->ExpectedLen();
|
||||
return CheckAnyLenVi(n, expected_len);
|
||||
}
|
||||
|
||||
case STMT_NEXT:
|
||||
return CompileNext();
|
||||
|
@ -520,29 +520,29 @@ const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v,
|
|||
break;
|
||||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
{
|
||||
// This leaks, but only statically so not worth
|
||||
// tracking the value for ultimate deletion.
|
||||
auto sv = cv->AsString()->Render();
|
||||
std::string s(sv);
|
||||
new_str_cases[s] = case_body_start;
|
||||
delete[] sv;
|
||||
break;
|
||||
}
|
||||
{
|
||||
// This leaks, but only statically so not worth
|
||||
// tracking the value for ultimate deletion.
|
||||
auto sv = cv->AsString()->Render();
|
||||
std::string s(sv);
|
||||
new_str_cases[s] = case_body_start;
|
||||
delete[] sv;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_ADDR:
|
||||
{
|
||||
auto a = cv->AsAddr().AsString();
|
||||
new_str_cases[a] = case_body_start;
|
||||
break;
|
||||
}
|
||||
{
|
||||
auto a = cv->AsAddr().AsString();
|
||||
new_str_cases[a] = case_body_start;
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_INTERNAL_SUBNET:
|
||||
{
|
||||
auto n = cv->AsSubNet().AsString();
|
||||
new_str_cases[n] = case_body_start;
|
||||
break;
|
||||
}
|
||||
{
|
||||
auto n = cv->AsSubNet().AsString();
|
||||
new_str_cases[n] = case_body_start;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
reporter->InternalError("bad recovered type when compiling switch");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue