+2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (ada_language_data): Delete la_is_string_type_p
+ initializer.
+ (ada_language::is_string_type_p): New member function.
+ * c-lang.c (c_language_data): Delete la_is_string_type_p
+ initializer.
+ (cplus_language_data): Likewise.
+ (asm_language_data): Likewise.
+ (minimal_language_data): Likewise.
+ * d-lang.c (d_language_data): Likewise.
+ * f-lang.c (f_is_string_type_p): Delete function, implementation
+ moved to f_language::is_string_type_p.
+ (f_language_data): Delete la_is_string_type_p initializer.
+ (f_language::is_string_type_p): New member function,
+ implementation from f_is_string_type_p.
+ * go-lang.c (go_is_string_type_p): Delete function, implementation
+ moved to go_language::is_string_type_p.
+ (go_language_data): Delete la_is_string_type_p initializer.
+ (go_language::is_string_type_p): New member function,
+ implementation from go_is_string_type_p.
+ * language.c (language_defn::is_string_type_p): Define new member
+ function.
+ (default_is_string_type_p): Make static, add comment copied from
+ header file.
+ (unknown_language_data): Delete la_is_string_type_p initializer.
+ (unknown_language::is_string_type_p): New member function.
+ (auto_language_data): Delete la_is_string_type_p initializer.
+ (auto_language::is_string_type_p): New member function.
+ * language.h (language_data): Delete la_is_string_type_p field.
+ (language_defn::is_string_type_p): Declare new function.
+ (default_is_string_type_p): Delete desclaration, move comment to
+ definition.
+ * m2-lang.c (m2_is_string_type_p): Delete function, implementation
+ moved to m2_language::is_string_type_p.
+ (m2_language_data): Delete la_is_string_type_p initializer.
+ (m2_language::is_string_type_p): New member function,
+ implementation from m2_is_string_type_p.
+ * objc-lang.c (objc_language_data): Delete la_is_string_type_p
+ initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_is_string_type_p): Delete function,
+ implementation moved to pascal_language::is_string_type_p.
+ (pascal_language_data): Delete la_is_string_type_p initializer.
+ (pascal_language::is_string_type_p): New member function,
+ implementation from pascal_is_string_type_p.
+ * rust-lang.c (rust_is_string_type_p): Delete function,
+ implementation moved to rust_language::is_string_type_p.
+ (rust_language_data): Delete la_is_string_type_p initializer.
+ (rust_language::is_string_type_p): New member function,
+ implementation from rust_is_string_type_p.
+ * valprint.c (val_print_scalar_or_string_type_p): Update call to
+ is_string_type_p.
+
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
* ada-lang.c (ada_language_data): Delete la_print_typedef
0, /* c-style arrays */
1, /* String lower bound */
&ada_varobj_ops,
- ada_is_string_type,
"(...)" /* la_struct_too_deep_ellipsis */
};
ada_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return ada_is_string_type (type);
+ }
+
+
protected:
/* See language.h. */
1, /* c-style arrays */
0, /* String lower bound */
&c_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
1, /* c-style arrays */
0, /* String lower bound */
&cplus_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
1, /* C-style arrays. */
0, /* String lower bound. */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
return nullptr;
}
-/* Return true if TYPE is a string. */
-
-static bool
-f_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- return (type->code () == TYPE_CODE_STRING
- || (type->code () == TYPE_CODE_ARRAY
- && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR));
-}
-
/* Special expression lengths for Fortran. */
static void
0, /* arrays are first-class (not c-style) */
1, /* String lower bound */
&default_varobj_ops,
- f_is_string_type_p,
"(...)" /* la_struct_too_deep_ellipsis */
};
f_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ return (type->code () == TYPE_CODE_STRING
+ || (type->code () == TYPE_CODE_ARRAY
+ && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR));
+ }
+
protected:
/* See language.h. */
return GO_TYPE_NONE;
}
-/* Return true if TYPE is a string. */
-
-static bool
-go_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- return (type->code () == TYPE_CODE_STRUCT
- && go_classify_struct_type (type) == GO_TYPE_STRING);
-}
-
/* Subroutine of unpack_mangled_go_symbol to simplify it.
Given "[foo.]bar.baz", store "bar" in *PACKAGEP and "baz" in *OBJECTP.
We stomp on the last '.' to nul-terminate "bar".
1, /* C-style arrays. */
0, /* String lower bound. */
&default_varobj_ops,
- go_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
{
return go_parse (ps);
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ return (type->code () == TYPE_CODE_STRUCT
+ && go_classify_struct_type (type) == GO_TYPE_STRING);
+ }
+
};
/* Single instance of the Go language class. */
c_print_typedef (type, new_symbol, stream);
}
+/* See language.h. */
+
+bool
+language_defn::is_string_type_p (struct type *type) const
+{
+ return c_is_string_type_p (type);
+}
+
/* The default implementation of the get_symbol_name_matcher_inner method
from the language_defn class. Matches with strncmp_iw. */
return default_symbol_name_matcher;
}
-/* See language.h. */
+/* Return true if TYPE is a string type, otherwise return false. This
+ default implementation only detects TYPE_CODE_STRING. */
-bool
+static bool
default_is_string_type_p (struct type *type)
{
type = check_typedef (type);
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
{
error (_("unimplemented unknown_language::print_typedef called"));
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return default_is_string_type_p (type);
+ }
};
/* Single instance of the unknown language class. */
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
{
error (_("unimplemented auto_language::print_typedef called"));
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return default_is_string_type_p (type);
+ }
};
/* Single instance of the fake "auto" language. */
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
- /* Return true if TYPE is a string type. */
- bool (*la_is_string_type_p) (struct type *type);
-
/* This string is used by the 'set print max-depth' setting. When GDB
replaces a struct or union (during value printing) that is "too
deep" this string is displayed instead. */
virtual void print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream) const;
+ /* Return true if TYPE is a string type. */
+ virtual bool is_string_type_p (struct type *type) const;
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
extern int pointer_type (struct type *);
-/* Return true if TYPE is a string type, otherwise return false. This
- default implementation only detects TYPE_CODE_STRING. */
-extern bool default_is_string_type_p (struct type *type);
-
/* Error messages */
extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
fputs_filtered ("'", stream);
}
-/* Return true if TYPE is a string. */
-
-static bool
-m2_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- if (type->code () == TYPE_CODE_ARRAY
- && TYPE_LENGTH (type) > 0
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
- {
- struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
-
- if (TYPE_LENGTH (elttype) == 1
- && (elttype->code () == TYPE_CODE_INT
- || elttype->code () == TYPE_CODE_CHAR))
- return true;
- }
-
- return false;
-}
-
static struct value *
evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
0, /* arrays are first-class (not c-style) */
0, /* String lower bound */
&default_varobj_ops,
- m2_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
m2_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ if (type->code () == TYPE_CODE_ARRAY
+ && TYPE_LENGTH (type) > 0
+ && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ {
+ struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (TYPE_LENGTH (elttype) == 1
+ && (elttype->code () == TYPE_CODE_INT
+ || elttype->code () == TYPE_CODE_CHAR))
+ return true;
+ }
+
+ return false;
+ }
};
/* Single instance of the M2 language. */
1, /* C-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
return 0;
}
-/* This is a wrapper around IS_PASCAL_STRING_TYPE that returns true if TYPE
- is a string. */
-
-static bool
-pascal_is_string_type_p (struct type *type)
-{
- return is_pascal_string_type (type, nullptr, nullptr, nullptr,
- nullptr, nullptr) > 0;
-}
-
static void pascal_one_char (int, struct ui_file *, int *);
/* Print the character C on STREAM as part of the contents of a literal
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- pascal_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
pascal_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return is_pascal_string_type (type, nullptr, nullptr, nullptr,
+ nullptr, nullptr) > 0;
+ }
};
/* Single instance of the Pascal language class. */
&& TYPE_UNSIGNED (type));
}
-/* Return true if TYPE is a string type. */
-
-static bool
-rust_is_string_type_p (struct type *type)
-{
- LONGEST low_bound, high_bound;
-
- type = check_typedef (type);
- return ((type->code () == TYPE_CODE_STRING)
- || (type->code () == TYPE_CODE_PTR
- && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ARRAY
- && rust_u8_type_p (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)))
- && get_array_bounds (TYPE_TARGET_TYPE (type), &low_bound,
- &high_bound)))
- || (type->code () == TYPE_CODE_STRUCT
- && !rust_enum_p (type)
- && rust_slice_type_p (type)
- && strcmp (type->name (), "&str") == 0));
-}
-
/* If VALUE represents a trait object pointer, return the underlying
pointer with the correct (i.e., runtime) type. Otherwise, return
NULL. */
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- rust_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
type_print (type, "", stream, 0);
fprintf_filtered (stream, ";");
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ LONGEST low_bound, high_bound;
+
+ type = check_typedef (type);
+ return ((type->code () == TYPE_CODE_STRING)
+ || (type->code () == TYPE_CODE_PTR
+ && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ARRAY
+ && rust_u8_type_p (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)))
+ && get_array_bounds (TYPE_TARGET_TYPE (type), &low_bound,
+ &high_bound)))
+ || (type->code () == TYPE_CODE_STRUCT
+ && !rust_enum_p (type)
+ && rust_slice_type_p (type)
+ && strcmp (type->name (), "&str") == 0));
+ }
};
/* Single instance of the Rust language class. */
const struct language_defn *language)
{
return (val_print_scalar_type_p (type)
- || language->la_is_string_type_p (type));
+ || language->is_string_type_p (type));
}
/* See its definition in value.h. */