/* Bison parser for Rust expressions, for GDB.
- Copyright (C) 2016-2019 Free Software Foundation, Inc.
+ Copyright (C) 2016-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdb_regex.h"
#include "rust-lang.h"
#include "parser-defs.h"
-#include "common/selftest.h"
+#include "gdbsupport/selftest.h"
#include "value.h"
-#include "common/vec.h"
+#include "gdbarch.h"
#define GDB_YY_REMAP_PREFIX rust
#include "yy-remap.h"
const char *
rust_parser::copy_name (const char *name, int len)
{
- return (const char *) obstack_copy0 (&obstack, name, len);
+ return obstack_strndup (&obstack, name, len);
}
/* Helper function to make an stoken from a C string. */
return SYMBOL_TYPE (result.symbol);
}
- type = lookup_typename (language (), arch (), name, NULL, 1);
+ type = lookup_typename (language (), name, NULL, 1);
if (type != NULL)
return type;
call expression. */
rust_op_vector *params = operation->right.params;
- if (TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
+ if (type->code () != TYPE_CODE_NAMESPACE)
{
if (!rust_tuple_struct_type_p (type))
error (_("Type %s is not a tuple struct"), varname);
error (_("No symbol '%s' in current context"), varname);
if (!want_type
- && TYPE_CODE (type) == TYPE_CODE_STRUCT
- && TYPE_NFIELDS (type) == 0)
+ && type->code () == TYPE_CODE_STRUCT
+ && type->num_fields () == 0)
{
/* A unit-like struct. */
write_exp_elt_opcode (pstate, OP_AGGREGATE);
if (type == NULL)
error (_("Could not find type '%s'"), operation->left.sval.ptr);
- if (TYPE_CODE (type) != TYPE_CODE_STRUCT
+ if (type->code () != TYPE_CODE_STRUCT
|| rust_tuple_type_p (type)
|| rust_tuple_struct_type_p (type))
error (_("Struct expression applied to non-struct type"));
{
int i;
- // Set up dummy "parser", so that rust_type works.
- struct parser_state ps (&rust_language_defn, target_gdbarch (),
+ /* Set up dummy "parser", so that rust_type works. */
+ struct parser_state ps (language_def (language_rust), target_gdbarch (),
nullptr, 0, 0, nullptr, 0, nullptr);
rust_parser parser (&ps);
#endif /* GDB_SELF_TEST */
+void _initialize_rust_exp ();
void
-_initialize_rust_exp (void)
+_initialize_rust_exp ()
{
int code = regcomp (&number_regex, number_regex_text, REG_EXTENDED);
/* If the regular expression was incorrect, it was a programming