mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +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
240
src/Expr.cc
240
src/Expr.cc
|
@ -320,75 +320,75 @@ const char* assign_to_index(ValPtr v1, ValPtr v2, ValPtr v3, bool& iterators_inv
|
|||
switch ( v1->GetType()->Tag() )
|
||||
{
|
||||
case TYPE_VECTOR:
|
||||
{
|
||||
const ListVal* lv = v2->AsListVal();
|
||||
VectorVal* v1_vect = v1->AsVectorVal();
|
||||
|
||||
if ( lv->Length() > 1 )
|
||||
{
|
||||
const ListVal* lv = v2->AsListVal();
|
||||
VectorVal* v1_vect = v1->AsVectorVal();
|
||||
auto len = v1_vect->Size();
|
||||
bro_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len);
|
||||
bro_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len);
|
||||
|
||||
if ( lv->Length() > 1 )
|
||||
{
|
||||
auto len = v1_vect->Size();
|
||||
bro_int_t first = get_slice_index(lv->Idx(0)->CoerceToInt(), len);
|
||||
bro_int_t last = get_slice_index(lv->Idx(1)->CoerceToInt(), len);
|
||||
// Remove the elements from the vector within the slice.
|
||||
for ( auto idx = first; idx < last; idx++ )
|
||||
v1_vect->Remove(first);
|
||||
|
||||
// Remove the elements from the vector within the slice.
|
||||
for ( auto idx = first; idx < last; idx++ )
|
||||
v1_vect->Remove(first);
|
||||
// Insert the new elements starting at the first
|
||||
// position.
|
||||
|
||||
// Insert the new elements starting at the first
|
||||
// position.
|
||||
VectorVal* v_vect = v3->AsVectorVal();
|
||||
|
||||
VectorVal* v_vect = v3->AsVectorVal();
|
||||
|
||||
for ( auto idx = 0u; idx < v_vect->Size(); idx++, first++ )
|
||||
v1_vect->Insert(first, v_vect->ValAt(idx));
|
||||
}
|
||||
|
||||
else if ( ! v1_vect->Assign(lv->Idx(0)->CoerceToUnsigned(), std::move(v3)) )
|
||||
{
|
||||
v3 = std::move(v_extra);
|
||||
|
||||
if ( v3 )
|
||||
{
|
||||
ODesc d;
|
||||
v3->Describe(&d);
|
||||
const auto& vt = v3->GetType();
|
||||
auto vtt = vt->Tag();
|
||||
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
||||
return util::fmt(
|
||||
"vector index assignment failed for invalid type '%s', value: %s",
|
||||
tn.data(), d.Description());
|
||||
}
|
||||
else
|
||||
return "assignment failed with null value";
|
||||
}
|
||||
break;
|
||||
for ( auto idx = 0u; idx < v_vect->Size(); idx++, first++ )
|
||||
v1_vect->Insert(first, v_vect->ValAt(idx));
|
||||
}
|
||||
|
||||
else if ( ! v1_vect->Assign(lv->Idx(0)->CoerceToUnsigned(), std::move(v3)) )
|
||||
{
|
||||
v3 = std::move(v_extra);
|
||||
|
||||
if ( v3 )
|
||||
{
|
||||
ODesc d;
|
||||
v3->Describe(&d);
|
||||
const auto& vt = v3->GetType();
|
||||
auto vtt = vt->Tag();
|
||||
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
||||
return util::fmt(
|
||||
"vector index assignment failed for invalid type '%s', value: %s",
|
||||
tn.data(), d.Description());
|
||||
}
|
||||
else
|
||||
return "assignment failed with null value";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_TABLE:
|
||||
{
|
||||
if ( ! v1->AsTableVal()->Assign(std::move(v2), std::move(v3), true,
|
||||
&iterators_invalidated) )
|
||||
{
|
||||
if ( ! v1->AsTableVal()->Assign(std::move(v2), std::move(v3), true,
|
||||
&iterators_invalidated) )
|
||||
v3 = std::move(v_extra);
|
||||
|
||||
if ( v3 )
|
||||
{
|
||||
v3 = std::move(v_extra);
|
||||
|
||||
if ( v3 )
|
||||
{
|
||||
ODesc d;
|
||||
v3->Describe(&d);
|
||||
const auto& vt = v3->GetType();
|
||||
auto vtt = vt->Tag();
|
||||
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
||||
return util::fmt(
|
||||
"table index assignment failed for invalid type '%s', value: %s",
|
||||
tn.data(), d.Description());
|
||||
}
|
||||
else
|
||||
return "assignment failed with null value";
|
||||
ODesc d;
|
||||
v3->Describe(&d);
|
||||
const auto& vt = v3->GetType();
|
||||
auto vtt = vt->Tag();
|
||||
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
||||
return util::fmt(
|
||||
"table index assignment failed for invalid type '%s', value: %s", tn.data(),
|
||||
d.Description());
|
||||
}
|
||||
|
||||
break;
|
||||
else
|
||||
return "assignment failed with null value";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TYPE_STRING:
|
||||
return "assignment via string index accessor not allowed";
|
||||
break;
|
||||
|
@ -925,54 +925,54 @@ ValPtr BinaryExpr::Fold(Val* v1, Val* v2) const
|
|||
DO_FOLD(*);
|
||||
break;
|
||||
case EXPR_DIVIDE:
|
||||
{
|
||||
if ( is_integral )
|
||||
{
|
||||
if ( is_integral )
|
||||
{
|
||||
if ( i2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
if ( i2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
|
||||
i3 = i1 / i2;
|
||||
}
|
||||
|
||||
else if ( is_unsigned )
|
||||
{
|
||||
if ( u2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
|
||||
u3 = u1 / u2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( d2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
|
||||
d3 = d1 / d2;
|
||||
}
|
||||
i3 = i1 / i2;
|
||||
}
|
||||
|
||||
else if ( is_unsigned )
|
||||
{
|
||||
if ( u2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
|
||||
u3 = u1 / u2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( d2 == 0 )
|
||||
RuntimeError("division by zero");
|
||||
|
||||
d3 = d1 / d2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EXPR_MOD:
|
||||
{
|
||||
if ( is_integral )
|
||||
{
|
||||
if ( is_integral )
|
||||
{
|
||||
if ( i2 == 0 )
|
||||
RuntimeError("modulo by zero");
|
||||
if ( i2 == 0 )
|
||||
RuntimeError("modulo by zero");
|
||||
|
||||
i3 = i1 % i2;
|
||||
}
|
||||
|
||||
else if ( is_unsigned )
|
||||
{
|
||||
if ( u2 == 0 )
|
||||
RuntimeError("modulo by zero");
|
||||
|
||||
u3 = u1 % u2;
|
||||
}
|
||||
|
||||
else
|
||||
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
|
||||
i3 = i1 % i2;
|
||||
}
|
||||
|
||||
else if ( is_unsigned )
|
||||
{
|
||||
if ( u2 == 0 )
|
||||
RuntimeError("modulo by zero");
|
||||
|
||||
u3 = u1 % u2;
|
||||
}
|
||||
|
||||
else
|
||||
RuntimeErrorWithCallStack("bad type in BinaryExpr::Fold");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EXPR_AND:
|
||||
|
@ -1061,13 +1061,13 @@ ValPtr BinaryExpr::StringFold(Val* v1, Val* v2) const
|
|||
|
||||
case EXPR_ADD:
|
||||
case EXPR_ADD_TO:
|
||||
{
|
||||
std::vector<const String*> strings;
|
||||
strings.push_back(s1);
|
||||
strings.push_back(s2);
|
||||
{
|
||||
std::vector<const String*> strings;
|
||||
strings.push_back(s1);
|
||||
strings.push_back(s2);
|
||||
|
||||
return make_intrusive<StringVal>(concatenate(strings));
|
||||
}
|
||||
return make_intrusive<StringVal>(concatenate(strings));
|
||||
}
|
||||
|
||||
default:
|
||||
BadTag("BinaryExpr::StringFold", expr_name(tag));
|
||||
|
@ -1102,24 +1102,24 @@ ValPtr BinaryExpr::SetFold(Val* v1, Val* v2) const
|
|||
return tv1->Intersection(*tv2);
|
||||
|
||||
case EXPR_OR:
|
||||
{
|
||||
auto rval = v1->Clone();
|
||||
{
|
||||
auto rval = v1->Clone();
|
||||
|
||||
if ( ! tv2->AddTo(rval.get(), false, false) )
|
||||
reporter->InternalError("set union failed to type check");
|
||||
if ( ! tv2->AddTo(rval.get(), false, false) )
|
||||
reporter->InternalError("set union failed to type check");
|
||||
|
||||
return rval;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
case EXPR_SUB:
|
||||
{
|
||||
auto rval = v1->Clone();
|
||||
{
|
||||
auto rval = v1->Clone();
|
||||
|
||||
if ( ! tv2->RemoveFrom(rval.get()) )
|
||||
reporter->InternalError("set difference failed to type check");
|
||||
if ( ! tv2->RemoveFrom(rval.get()) )
|
||||
reporter->InternalError("set difference failed to type check");
|
||||
|
||||
return rval;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
case EXPR_EQ:
|
||||
res = tv1->EqualTo(*tv2);
|
||||
|
@ -3020,15 +3020,15 @@ ValPtr IndexExpr::Fold(Val* v1, Val* v2) const
|
|||
switch ( v1->GetType()->Tag() )
|
||||
{
|
||||
case TYPE_VECTOR:
|
||||
{
|
||||
VectorVal* vect = v1->AsVectorVal();
|
||||
const ListVal* lv = v2->AsListVal();
|
||||
{
|
||||
VectorVal* vect = v1->AsVectorVal();
|
||||
const ListVal* lv = v2->AsListVal();
|
||||
|
||||
if ( lv->Length() == 1 )
|
||||
v = vect->ValAt(lv->Idx(0)->CoerceToUnsigned());
|
||||
else
|
||||
return index_slice(vect, lv);
|
||||
}
|
||||
if ( lv->Length() == 1 )
|
||||
v = vect->ValAt(lv->Idx(0)->CoerceToUnsigned());
|
||||
else
|
||||
return index_slice(vect, lv);
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_TABLE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue