#include <string>
#include <vector>
-extern initialize_file_ftype _initialize_rust_language;
-
/* Returns the last segment of a Rust path like foo::bar::baz. Will
not handle cases where the last segment contains generics. This
will return NULL if the last segment cannot be found. */
fputs_filtered ("[", stream);
rust_print_type (TYPE_TARGET_TYPE (type), NULL,
stream, show - 1, level, flags);
- fputs_filtered ("; ", stream);
if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
|| TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
- fprintf_filtered (stream, "variable length");
+ fprintf_filtered (stream, "; variable length");
else if (get_array_bounds (type, &low_bound, &high_bound))
- fprintf_filtered (stream, "%s",
+ fprintf_filtered (stream, "; %s",
plongest (high_bound - low_bound + 1));
fputs_filtered ("]", stream);
}
if (noside == EVAL_AVOID_SIDE_EFFECTS)
result = value_zero (TYPE_TARGET_TYPE (fn_type), not_lval);
else
- result = call_function_by_hand (function, num_args + 1, args.data ());
+ result = call_function_by_hand (function, NULL, num_args + 1, args.data ());
return result;
}
case STRUCTOP_STRUCT:
{
- struct value* lhs;
+ struct value *lhs;
struct type *type;
int tem, pc;
(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
lhs = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ const char *field_name = &exp->elts[pc + 2].string;
type = value_type (lhs);
if (TYPE_CODE (type) == TYPE_CODE_UNION
&& !rust_union_is_untagged (type))
{
int i, start;
struct disr_info disr;
- struct type* variant_type;
- char* field_name;
-
- field_name = &exp->elts[pc + 2].string;
+ struct type *variant_type;
disr = rust_get_disr_info (type, value_contents (lhs),
value_embedded_offset (lhs),
}
else
{
- /* Field access in structs and untagged unions works like C. */
- *pos = pc;
- result = evaluate_subexp_standard (expect_type, exp, pos, noside);
+ result = value_struct_elt (&lhs, NULL, field_name, NULL,
+ "structure");
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ result = value_zero (value_type (result), VALUE_LVAL (result));
}
}
break;
\f
+/* la_watch_location_expression for Rust. */
+
+static gdb::unique_xmalloc_ptr<char>
+rust_watch_location_expression (struct type *type, CORE_ADDR addr)
+{
+ type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+ std::string name = type_to_string (type);
+ return gdb::unique_xmalloc_ptr<char>
+ (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
+ name.c_str ()));
+}
+
+\f
+
static const struct exp_descriptor exp_descriptor_rust =
{
rust_print_subexp,
".rs", NULL
};
-static const struct language_defn rust_language_defn =
+extern const struct language_defn rust_language_defn =
{
"rust",
"Rust",
1, /* c-style arrays */
0, /* String lower bound */
default_word_break_characters,
- default_make_symbol_completion_list,
+ default_collect_symbol_completion_matches,
rust_language_arch_info,
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ rust_watch_location_expression,
NULL, /* la_get_symbol_name_cmp */
iterate_over_symbols,
&default_varobj_ops,
NULL,
LANG_MAGIC
};
-
-void
-_initialize_rust_language (void)
-{
- add_language (&rust_language_defn);
-}