forked from Imagelibrary/binutils-gdb
Remove some Rust expression helpers
When I did the big expression conversion, I left some helper functions lying around, primarily because the conversion was already quite large and I didn't want to add on. This patch removes a couple such helpers, turning them into methods on the appropriate operation objects. Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
@@ -33,14 +33,6 @@ extern struct value *eval_op_rust_array (struct type *expect_type,
|
||||
enum exp_opcode opcode,
|
||||
struct value *ncopies,
|
||||
struct value *elt);
|
||||
extern struct value *rust_subscript (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside, bool for_addr,
|
||||
struct value *lhs, struct value *rhs);
|
||||
extern struct value *rust_range (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside, enum range_flag kind,
|
||||
struct value *low, struct value *high);
|
||||
|
||||
namespace expr
|
||||
{
|
||||
@@ -75,22 +67,26 @@ public:
|
||||
struct expression *exp,
|
||||
enum noside noside) override
|
||||
{
|
||||
value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
return rust_subscript (expect_type, exp, noside, false, arg1, arg2);
|
||||
return subscript (exp, noside, false);
|
||||
}
|
||||
|
||||
value *slice (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside)
|
||||
{
|
||||
value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
return rust_subscript (expect_type, exp, noside, true, arg1, arg2);
|
||||
return subscript (exp, noside, true);
|
||||
}
|
||||
|
||||
enum exp_opcode opcode () const override
|
||||
{ return BINOP_SUBSCRIPT; }
|
||||
|
||||
private:
|
||||
|
||||
/* Helper function that does the work of evaluation. FOR_ADDR is
|
||||
true if we're evaluating a slice. */
|
||||
value *subscript (struct expression *exp, enum noside noside,
|
||||
bool for_addr);
|
||||
|
||||
};
|
||||
|
||||
class rust_unop_addr_operation
|
||||
@@ -126,17 +122,7 @@ public:
|
||||
|
||||
value *evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside) override
|
||||
{
|
||||
auto kind = std::get<0> (m_storage);
|
||||
value *low = nullptr;
|
||||
if (std::get<1> (m_storage) != nullptr)
|
||||
low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
value *high = nullptr;
|
||||
if (std::get<2> (m_storage) != nullptr)
|
||||
high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
return rust_range (expect_type, exp, noside, kind, low, high);
|
||||
}
|
||||
enum noside noside) override;
|
||||
|
||||
enum exp_opcode opcode () const override
|
||||
{ return OP_RANGE; }
|
||||
|
||||
@@ -1142,13 +1142,22 @@ rust_slice_type (const char *name, struct type *elt_type,
|
||||
|
||||
|
||||
|
||||
/* A helper for rust_evaluate_subexp that handles OP_RANGE. */
|
||||
namespace expr
|
||||
{
|
||||
|
||||
struct value *
|
||||
rust_range (struct type *expect_type, struct expression *exp,
|
||||
enum noside noside, enum range_flag kind,
|
||||
struct value *low, struct value *high)
|
||||
rust_range_operation::evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside)
|
||||
{
|
||||
auto kind = std::get<0> (m_storage);
|
||||
value *low = nullptr;
|
||||
if (std::get<1> (m_storage) != nullptr)
|
||||
low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
value *high = nullptr;
|
||||
if (std::get<2> (m_storage) != nullptr)
|
||||
high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
|
||||
struct value *addrval, *result;
|
||||
CORE_ADDR addr;
|
||||
struct type *range_type;
|
||||
@@ -1225,6 +1234,8 @@ rust_range (struct type *expect_type, struct expression *exp,
|
||||
return result;
|
||||
}
|
||||
|
||||
} /* namespace expr */
|
||||
|
||||
/* A helper function to compute the range and kind given a range
|
||||
value. TYPE is the type of the range value. RANGE is the range
|
||||
value. LOW, HIGH, and KIND are out parameters. The LOW and HIGH
|
||||
@@ -1266,13 +1277,16 @@ rust_compute_range (struct type *type, struct value *range,
|
||||
}
|
||||
}
|
||||
|
||||
/* A helper for rust_evaluate_subexp that handles BINOP_SUBSCRIPT. */
|
||||
namespace expr
|
||||
{
|
||||
|
||||
struct value *
|
||||
rust_subscript (struct type *expect_type, struct expression *exp,
|
||||
enum noside noside, bool for_addr,
|
||||
struct value *lhs, struct value *rhs)
|
||||
rust_subscript_operation::subscript (struct expression *exp,
|
||||
enum noside noside, bool for_addr)
|
||||
{
|
||||
value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
|
||||
struct value *result;
|
||||
struct type *rhstype;
|
||||
LONGEST low, high_bound;
|
||||
@@ -1413,9 +1427,6 @@ rust_subscript (struct type *expect_type, struct expression *exp,
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace expr
|
||||
{
|
||||
|
||||
struct value *
|
||||
rust_unop_ind_operation::evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
|
||||
Reference in New Issue
Block a user