#include "rust-lang.h"
#include "valprint.h"
#include "varobj.h"
+#include <string>
+#include <vector>
extern initialize_file_ftype _initialize_rust_language;
int i;
int num_args = exp->elts[*pos + 1].longconst;
const char *method;
- char *name;
struct value *function, *result, *arg0;
- struct value **args;
- struct cleanup *cleanup;
struct type *type, *fn_type;
const struct block *block;
struct block_symbol sym;
return arg0;
}
- args = XNEWVEC (struct value *, num_args + 1);
- cleanup = make_cleanup (xfree, args);
+ std::vector<struct value *> args (num_args + 1);
args[0] = arg0;
/* We don't yet implement real Deref semantics. */
if (TYPE_TAG_NAME (type) == NULL)
error (_("Method call on nameless type"));
- name = concat (TYPE_TAG_NAME (type), "::", method, (char *) NULL);
- make_cleanup (xfree, name);
+ std::string name = std::string (TYPE_TAG_NAME (type)) + "::" + method;
block = get_selected_block (0);
- sym = lookup_symbol (name, block, VAR_DOMAIN, NULL);
+ sym = lookup_symbol (name.c_str (), block, VAR_DOMAIN, NULL);
if (sym.symbol == NULL)
- error (_("Could not find function named '%s'"), name);
+ error (_("Could not find function named '%s'"), name.c_str ());
fn_type = SYMBOL_TYPE (sym.symbol);
if (TYPE_NFIELDS (fn_type) == 0)
- error (_("Function '%s' takes no arguments"), name);
+ error (_("Function '%s' takes no arguments"), name.c_str ());
if (TYPE_CODE (TYPE_FIELD_TYPE (fn_type, 0)) == TYPE_CODE_PTR)
args[0] = value_addr (args[0]);
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);
- do_cleanups (cleanup);
+ result = call_function_by_hand (function, num_args + 1, args.data ());
return result;
}
{
CORE_ADDR addr;
int i;
- struct value **eltvec = XNEWVEC (struct value *, copies);
- struct cleanup *cleanup = make_cleanup (xfree, eltvec);
+ std::vector<struct value *> eltvec (copies);
for (i = 0; i < copies; ++i)
eltvec[i] = elt;
- result = value_array (0, copies - 1, eltvec);
-
- do_cleanups (cleanup);
+ result = value_array (0, copies - 1, eltvec.data ());
}
else
{
if (scope[0] != '\0')
{
- char *scopedname = concat (scope, "::", name, (char *) NULL);
- struct cleanup *cleanup = make_cleanup (xfree, scopedname);
+ std::string scopedname = std::string (scope) + "::" + name;
- result = lookup_symbol_in_static_block (scopedname, block,
+ result = lookup_symbol_in_static_block (scopedname.c_str (), block,
domain);
if (result.symbol == NULL)
- result = lookup_global_symbol (scopedname, block, domain);
- do_cleanups (cleanup);
+ result = lookup_global_symbol (scopedname.c_str (), block, domain);
}
}
return result;