diff --git a/src/Expr.cc b/src/Expr.cc index 46b8ade8ac..b1f6922565 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -2954,7 +2954,7 @@ ValPtr IndexExpr::Fold(Val* v1, Val* v2) const break; case TYPE_TABLE: - v = v1->AsTableVal()->FindOrDefault({NewRef{}, v2}); // Then, we jump into the TableVal here. + v = v1->AsTableVal()->FindOrDefault({NewRef{}, v2}); break; case TYPE_STRING: @@ -5286,7 +5286,7 @@ bool check_and_promote_exprs(ListExpr* const elements, TypeList* types) return true; } -bool check_and_promote_args(ListExpr* const args, RecordType* types) +bool check_and_promote_args(ListExpr* const args, const RecordType* types) { ExprPList& el = args->Exprs(); int ntypes = types->NumFields(); @@ -5303,7 +5303,7 @@ bool check_and_promote_args(ListExpr* const args, RecordType* types) // arguments using &default expressions. for ( int i = ntypes - 1; i >= el.length(); --i ) { - TypeDecl* td = types->FieldDecl(i); + auto td = types->FieldDecl(i); const auto& def_attr = td->attrs ? td->attrs->Find(ATTR_DEFAULT).get() : nullptr; if ( ! def_attr ) diff --git a/src/Expr.h b/src/Expr.h index bc5ea43403..64430465c8 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -1645,25 +1645,21 @@ ExprPtr get_assign_expr( ExprPtr op1, ExprPtr op2, bool is_init); -// Type-check the given expression(s) against the given type(s). Complain -// if the expression cannot match the given type, returning 0. If it can -// match, promote it as necessary (modifying the ref parameter accordingly) -// and return 1. -// -// The second, third, and fourth forms are for promoting a list of -// expressions (which is updated in place) to either match a list of -// types or a single type. -// -// Note, the type is not "const" because it can be ref'd. - /** - * Returns nullptr if the expression cannot match or a promoted - * expression. + * Type-check the given expression(s) against the given type(s). Complain + * if the expression cannot match the given type, returning nullptr; + * otherwise, returns an expression reflecting the promotion. + * + * The second, third, and fourth forms are for promoting a list of + * expressions (which is updated in place) to either match a list of + * types or a single type. + * + * Note, the type is not "const" because it can be ref'd. */ extern ExprPtr check_and_promote_expr(Expr* e, Type* t); extern bool check_and_promote_exprs(ListExpr* elements, TypeList* types); -extern bool check_and_promote_args(ListExpr* args, RecordType* types); +extern bool check_and_promote_args(ListExpr* args, const RecordType* types); extern bool check_and_promote_exprs_to_type(ListExpr* elements, Type* type); // Returns a ListExpr simplified down to a list a values, or nil diff --git a/src/Type.h b/src/Type.h index d75168b9f2..d5dda088da 100644 --- a/src/Type.h +++ b/src/Type.h @@ -33,7 +33,7 @@ using ListExprPtr = IntrusivePtr; } // namespace detail -// BRO types. +// Zeek types. enum TypeTag { TYPE_VOID, // 0 TYPE_BOOL, // 1 @@ -171,7 +171,7 @@ public: explicit Type(TypeTag tag, bool base_type = false); - // Performs a shallow clone operation of the Bro type. + // Performs a shallow clone operation of the Zeek type. // This especially means that especially for tables the types // are not recursively cloned; altering one type will in this case // alter one of them. diff --git a/src/Val.cc b/src/Val.cc index 948457b9de..aa71d5e739 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -231,8 +231,6 @@ ValPtr Val::SizeVal() const { switch ( type->InternalType() ) { case TYPE_INTERNAL_INT: - // Return abs value. However abs() only works on ints and llabs - // doesn't work on Mac OS X 10.5. So we do it by hand if ( AsInt() < 0 ) return val_mgr->Count(-AsInt()); else