ada-exp.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. /* Definitions for Ada expressions
  2. Copyright (C) 2020-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef ADA_EXP_H
  15. #define ADA_EXP_H
  16. #include "expop.h"
  17. extern struct value *ada_unop_neg (struct type *expect_type,
  18. struct expression *exp,
  19. enum noside noside, enum exp_opcode op,
  20. struct value *arg1);
  21. extern struct value *ada_atr_tag (struct type *expect_type,
  22. struct expression *exp,
  23. enum noside noside, enum exp_opcode op,
  24. struct value *arg1);
  25. extern struct value *ada_atr_size (struct type *expect_type,
  26. struct expression *exp,
  27. enum noside noside, enum exp_opcode op,
  28. struct value *arg1);
  29. extern struct value *ada_abs (struct type *expect_type,
  30. struct expression *exp,
  31. enum noside noside, enum exp_opcode op,
  32. struct value *arg1);
  33. extern struct value *ada_unop_in_range (struct type *expect_type,
  34. struct expression *exp,
  35. enum noside noside, enum exp_opcode op,
  36. struct value *arg1, struct type *type);
  37. extern struct value *ada_mult_binop (struct type *expect_type,
  38. struct expression *exp,
  39. enum noside noside, enum exp_opcode op,
  40. struct value *arg1, struct value *arg2);
  41. extern struct value *ada_equal_binop (struct type *expect_type,
  42. struct expression *exp,
  43. enum noside noside, enum exp_opcode op,
  44. struct value *arg1, struct value *arg2);
  45. extern struct value *ada_ternop_slice (struct expression *exp,
  46. enum noside noside,
  47. struct value *array,
  48. struct value *low_bound_val,
  49. struct value *high_bound_val);
  50. extern struct value *ada_binop_in_bounds (struct expression *exp,
  51. enum noside noside,
  52. struct value *arg1,
  53. struct value *arg2,
  54. int n);
  55. extern struct value *ada_binop_minmax (struct type *expect_type,
  56. struct expression *exp,
  57. enum noside noside, enum exp_opcode op,
  58. struct value *arg1,
  59. struct value *arg2);
  60. extern struct value *ada_pos_atr (struct type *expect_type,
  61. struct expression *exp,
  62. enum noside noside, enum exp_opcode op,
  63. struct value *arg);
  64. extern struct value *ada_val_atr (enum noside noside, struct type *type,
  65. struct value *arg);
  66. extern struct value *ada_binop_exp (struct type *expect_type,
  67. struct expression *exp,
  68. enum noside noside, enum exp_opcode op,
  69. struct value *arg1, struct value *arg2);
  70. namespace expr
  71. {
  72. /* The base class for Ada type resolution. Ada operations that want
  73. to participate in resolution implement this interface. */
  74. struct ada_resolvable
  75. {
  76. /* Resolve this object. EXP is the expression being resolved.
  77. DEPROCEDURE_P is true if a symbol that refers to a zero-argument
  78. function may be turned into a function call. PARSE_COMPLETION
  79. and TRACKER are passed in from the parser context. CONTEXT_TYPE
  80. is the expected type of the expression, or nullptr if none is
  81. known. This method should return true if the operation should be
  82. replaced by a function call with this object as the callee. */
  83. virtual bool resolve (struct expression *exp,
  84. bool deprocedure_p,
  85. bool parse_completion,
  86. innermost_block_tracker *tracker,
  87. struct type *context_type) = 0;
  88. /* Possibly replace this object with some other expression object.
  89. This is like 'resolve', but can return a replacement.
  90. The default implementation calls 'resolve' and wraps this object
  91. in a function call if that call returns true. OWNER is a
  92. reference to the unique pointer that owns the 'this'; it can be
  93. 'move'd from to construct the replacement.
  94. This should either return a new object, or OWNER -- never
  95. nullptr. */
  96. virtual operation_up replace (operation_up &&owner,
  97. struct expression *exp,
  98. bool deprocedure_p,
  99. bool parse_completion,
  100. innermost_block_tracker *tracker,
  101. struct type *context_type);
  102. };
  103. /* In Ada, some generic operations must be wrapped with a handler that
  104. handles some Ada-specific type conversions. */
  105. class ada_wrapped_operation
  106. : public tuple_holding_operation<operation_up>
  107. {
  108. public:
  109. using tuple_holding_operation::tuple_holding_operation;
  110. value *evaluate (struct type *expect_type,
  111. struct expression *exp,
  112. enum noside noside) override;
  113. enum exp_opcode opcode () const override
  114. { return std::get<0> (m_storage)->opcode (); }
  115. };
  116. /* An Ada string constant. */
  117. class ada_string_operation
  118. : public string_operation
  119. {
  120. public:
  121. using string_operation::string_operation;
  122. /* Return the underlying string. */
  123. const char *get_name () const
  124. {
  125. return std::get<0> (m_storage).c_str ();
  126. }
  127. value *evaluate (struct type *expect_type,
  128. struct expression *exp,
  129. enum noside noside) override;
  130. };
  131. /* The Ada TYPE'(EXP) construct. */
  132. class ada_qual_operation
  133. : public tuple_holding_operation<operation_up, struct type *>
  134. {
  135. public:
  136. using tuple_holding_operation::tuple_holding_operation;
  137. value *evaluate (struct type *expect_type,
  138. struct expression *exp,
  139. enum noside noside) override;
  140. enum exp_opcode opcode () const override
  141. { return UNOP_QUAL; }
  142. };
  143. /* Ternary in-range operator. */
  144. class ada_ternop_range_operation
  145. : public tuple_holding_operation<operation_up, operation_up, operation_up>
  146. {
  147. public:
  148. using tuple_holding_operation::tuple_holding_operation;
  149. value *evaluate (struct type *expect_type,
  150. struct expression *exp,
  151. enum noside noside) override;
  152. enum exp_opcode opcode () const override
  153. { return TERNOP_IN_RANGE; }
  154. };
  155. using ada_neg_operation = unop_operation<UNOP_NEG, ada_unop_neg>;
  156. using ada_atr_tag_operation = unop_operation<OP_ATR_TAG, ada_atr_tag>;
  157. using ada_atr_size_operation = unop_operation<OP_ATR_SIZE, ada_atr_size>;
  158. using ada_abs_operation = unop_operation<UNOP_ABS, ada_abs>;
  159. using ada_pos_operation = unop_operation<OP_ATR_POS, ada_pos_atr>;
  160. /* The in-range operation, given a type. */
  161. class ada_unop_range_operation
  162. : public tuple_holding_operation<operation_up, struct type *>
  163. {
  164. public:
  165. using tuple_holding_operation::tuple_holding_operation;
  166. value *evaluate (struct type *expect_type,
  167. struct expression *exp,
  168. enum noside noside) override
  169. {
  170. value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
  171. return ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE,
  172. val, std::get<1> (m_storage));
  173. }
  174. enum exp_opcode opcode () const override
  175. { return UNOP_IN_RANGE; }
  176. };
  177. /* The Ada + and - operators. */
  178. class ada_binop_addsub_operation
  179. : public tuple_holding_operation<enum exp_opcode, operation_up, operation_up>
  180. {
  181. public:
  182. using tuple_holding_operation::tuple_holding_operation;
  183. value *evaluate (struct type *expect_type,
  184. struct expression *exp,
  185. enum noside noside) override;
  186. enum exp_opcode opcode () const override
  187. { return std::get<0> (m_storage); }
  188. };
  189. using ada_binop_mul_operation = binop_operation<BINOP_MUL, ada_mult_binop>;
  190. using ada_binop_div_operation = binop_operation<BINOP_DIV, ada_mult_binop>;
  191. using ada_binop_rem_operation = binop_operation<BINOP_REM, ada_mult_binop>;
  192. using ada_binop_mod_operation = binop_operation<BINOP_MOD, ada_mult_binop>;
  193. using ada_binop_min_operation = binop_operation<BINOP_MIN, ada_binop_minmax>;
  194. using ada_binop_max_operation = binop_operation<BINOP_MAX, ada_binop_minmax>;
  195. using ada_binop_exp_operation = binop_operation<BINOP_EXP, ada_binop_exp>;
  196. /* Implement the equal and not-equal operations for Ada. */
  197. class ada_binop_equal_operation
  198. : public tuple_holding_operation<enum exp_opcode, operation_up, operation_up>
  199. {
  200. public:
  201. using tuple_holding_operation::tuple_holding_operation;
  202. value *evaluate (struct type *expect_type,
  203. struct expression *exp,
  204. enum noside noside) override
  205. {
  206. value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
  207. value *arg2 = std::get<2> (m_storage)->evaluate (value_type (arg1),
  208. exp, noside);
  209. return ada_equal_binop (expect_type, exp, noside, std::get<0> (m_storage),
  210. arg1, arg2);
  211. }
  212. enum exp_opcode opcode () const override
  213. { return std::get<0> (m_storage); }
  214. };
  215. /* Bitwise operators for Ada. */
  216. template<enum exp_opcode OP>
  217. class ada_bitwise_operation
  218. : public maybe_constant_operation<operation_up, operation_up>
  219. {
  220. public:
  221. using maybe_constant_operation::maybe_constant_operation;
  222. value *evaluate (struct type *expect_type,
  223. struct expression *exp,
  224. enum noside noside) override
  225. {
  226. value *lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
  227. value *rhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
  228. value *result = eval_op_binary (expect_type, exp, noside, OP, lhs, rhs);
  229. return value_cast (value_type (lhs), result);
  230. }
  231. enum exp_opcode opcode () const override
  232. { return OP; }
  233. };
  234. using ada_bitwise_and_operation = ada_bitwise_operation<BINOP_BITWISE_AND>;
  235. using ada_bitwise_ior_operation = ada_bitwise_operation<BINOP_BITWISE_IOR>;
  236. using ada_bitwise_xor_operation = ada_bitwise_operation<BINOP_BITWISE_XOR>;
  237. /* Ada array- or string-slice operation. */
  238. class ada_ternop_slice_operation
  239. : public maybe_constant_operation<operation_up, operation_up, operation_up>,
  240. public ada_resolvable
  241. {
  242. public:
  243. using maybe_constant_operation::maybe_constant_operation;
  244. value *evaluate (struct type *expect_type,
  245. struct expression *exp,
  246. enum noside noside) override
  247. {
  248. value *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
  249. value *low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
  250. value *high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
  251. return ada_ternop_slice (exp, noside, array, low, high);
  252. }
  253. enum exp_opcode opcode () const override
  254. { return TERNOP_SLICE; }
  255. bool resolve (struct expression *exp,
  256. bool deprocedure_p,
  257. bool parse_completion,
  258. innermost_block_tracker *tracker,
  259. struct type *context_type) override;
  260. };
  261. /* Implement BINOP_IN_BOUNDS for Ada. */
  262. class ada_binop_in_bounds_operation
  263. : public maybe_constant_operation<operation_up, operation_up, int>
  264. {
  265. public:
  266. using maybe_constant_operation::maybe_constant_operation;
  267. value *evaluate (struct type *expect_type,
  268. struct expression *exp,
  269. enum noside noside) override
  270. {
  271. value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
  272. value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
  273. return ada_binop_in_bounds (exp, noside, arg1, arg2,
  274. std::get<2> (m_storage));
  275. }
  276. enum exp_opcode opcode () const override
  277. { return BINOP_IN_BOUNDS; }
  278. };
  279. /* Implement several unary Ada OP_ATR_* operations. */
  280. class ada_unop_atr_operation
  281. : public maybe_constant_operation<operation_up, enum exp_opcode, int>
  282. {
  283. public:
  284. using maybe_constant_operation::maybe_constant_operation;
  285. value *evaluate (struct type *expect_type,
  286. struct expression *exp,
  287. enum noside noside) override;
  288. enum exp_opcode opcode () const override
  289. { return std::get<1> (m_storage); }
  290. };
  291. /* Variant of var_value_operation for Ada. */
  292. class ada_var_value_operation
  293. : public var_value_operation, public ada_resolvable
  294. {
  295. public:
  296. using var_value_operation::var_value_operation;
  297. value *evaluate (struct type *expect_type,
  298. struct expression *exp,
  299. enum noside noside) override;
  300. value *evaluate_for_cast (struct type *expect_type,
  301. struct expression *exp,
  302. enum noside noside) override;
  303. const block *get_block () const
  304. { return std::get<0> (m_storage).block; }
  305. bool resolve (struct expression *exp,
  306. bool deprocedure_p,
  307. bool parse_completion,
  308. innermost_block_tracker *tracker,
  309. struct type *context_type) override;
  310. protected:
  311. using operation::do_generate_ax;
  312. };
  313. /* Variant of var_msym_value_operation for Ada. */
  314. class ada_var_msym_value_operation
  315. : public var_msym_value_operation
  316. {
  317. public:
  318. using var_msym_value_operation::var_msym_value_operation;
  319. value *evaluate_for_cast (struct type *expect_type,
  320. struct expression *exp,
  321. enum noside noside) override;
  322. protected:
  323. using operation::do_generate_ax;
  324. };
  325. /* Implement the Ada 'val attribute. */
  326. class ada_atr_val_operation
  327. : public tuple_holding_operation<struct type *, operation_up>
  328. {
  329. public:
  330. using tuple_holding_operation::tuple_holding_operation;
  331. value *evaluate (struct type *expect_type,
  332. struct expression *exp,
  333. enum noside noside) override;
  334. enum exp_opcode opcode () const override
  335. { return OP_ATR_VAL; }
  336. };
  337. /* The indirection operator for Ada. */
  338. class ada_unop_ind_operation
  339. : public unop_ind_base_operation
  340. {
  341. public:
  342. using unop_ind_base_operation::unop_ind_base_operation;
  343. value *evaluate (struct type *expect_type,
  344. struct expression *exp,
  345. enum noside noside) override;
  346. };
  347. /* Implement STRUCTOP_STRUCT for Ada. */
  348. class ada_structop_operation
  349. : public structop_base_operation
  350. {
  351. public:
  352. using structop_base_operation::structop_base_operation;
  353. value *evaluate (struct type *expect_type,
  354. struct expression *exp,
  355. enum noside noside) override;
  356. enum exp_opcode opcode () const override
  357. { return STRUCTOP_STRUCT; }
  358. /* Set the completion prefix. */
  359. void set_prefix (std::string &&prefix)
  360. {
  361. m_prefix = std::move (prefix);
  362. }
  363. bool complete (struct expression *exp, completion_tracker &tracker) override
  364. {
  365. return structop_base_operation::complete (exp, tracker, m_prefix.c_str ());
  366. }
  367. void dump (struct ui_file *stream, int depth) const override
  368. {
  369. structop_base_operation::dump (stream, depth);
  370. dump_for_expression (stream, depth + 1, m_prefix);
  371. }
  372. private:
  373. /* We may need to provide a prefix to field name completion. See
  374. ada-exp.y:find_completion_bounds for details. */
  375. std::string m_prefix;
  376. };
  377. /* Function calls for Ada. */
  378. class ada_funcall_operation
  379. : public tuple_holding_operation<operation_up, std::vector<operation_up>>,
  380. public ada_resolvable
  381. {
  382. public:
  383. using tuple_holding_operation::tuple_holding_operation;
  384. value *evaluate (struct type *expect_type,
  385. struct expression *exp,
  386. enum noside noside) override;
  387. bool resolve (struct expression *exp,
  388. bool deprocedure_p,
  389. bool parse_completion,
  390. innermost_block_tracker *tracker,
  391. struct type *context_type) override;
  392. enum exp_opcode opcode () const override
  393. { return OP_FUNCALL; }
  394. };
  395. /* An Ada assignment operation. */
  396. class ada_assign_operation
  397. : public assign_operation
  398. {
  399. public:
  400. using assign_operation::assign_operation;
  401. value *evaluate (struct type *expect_type,
  402. struct expression *exp,
  403. enum noside noside) override;
  404. enum exp_opcode opcode () const override
  405. { return BINOP_ASSIGN; }
  406. };
  407. /* This abstract class represents a single component in an Ada
  408. aggregate assignment. */
  409. class ada_component
  410. {
  411. public:
  412. /* Assign to LHS, which is part of CONTAINER. EXP is the expression
  413. being evaluated. INDICES, LOW, and HIGH indicate which
  414. sub-components have already been assigned; INDICES should be
  415. updated by this call. */
  416. virtual void assign (struct value *container,
  417. struct value *lhs, struct expression *exp,
  418. std::vector<LONGEST> &indices,
  419. LONGEST low, LONGEST high) = 0;
  420. /* Same as operation::uses_objfile. */
  421. virtual bool uses_objfile (struct objfile *objfile) = 0;
  422. /* Same as operation::dump. */
  423. virtual void dump (ui_file *stream, int depth) = 0;
  424. virtual ~ada_component () = default;
  425. protected:
  426. ada_component () = default;
  427. DISABLE_COPY_AND_ASSIGN (ada_component);
  428. };
  429. /* Unique pointer specialization for Ada assignment components. */
  430. typedef std::unique_ptr<ada_component> ada_component_up;
  431. /* An operation that holds a single component. */
  432. class ada_aggregate_operation
  433. : public tuple_holding_operation<ada_component_up>
  434. {
  435. public:
  436. using tuple_holding_operation::tuple_holding_operation;
  437. /* Assuming that LHS represents an lvalue having a record or array
  438. type, evaluate an assignment of this aggregate's value to LHS.
  439. CONTAINER is an lvalue containing LHS (possibly LHS itself).
  440. Does not modify the inferior's memory, nor does it modify the
  441. contents of LHS (unless == CONTAINER). Returns the modified
  442. CONTAINER. */
  443. value *assign_aggregate (struct value *container,
  444. struct value *lhs,
  445. struct expression *exp);
  446. value *evaluate (struct type *expect_type,
  447. struct expression *exp,
  448. enum noside noside) override
  449. {
  450. error (_("Aggregates only allowed on the right of an assignment"));
  451. }
  452. enum exp_opcode opcode () const override
  453. { return OP_AGGREGATE; }
  454. };
  455. /* A component holding a vector of other components to assign. */
  456. class ada_aggregate_component : public ada_component
  457. {
  458. public:
  459. explicit ada_aggregate_component (std::vector<ada_component_up> &&components)
  460. : m_components (std::move (components))
  461. {
  462. }
  463. void assign (struct value *container,
  464. struct value *lhs, struct expression *exp,
  465. std::vector<LONGEST> &indices,
  466. LONGEST low, LONGEST high) override;
  467. bool uses_objfile (struct objfile *objfile) override;
  468. void dump (ui_file *stream, int depth) override;
  469. private:
  470. std::vector<ada_component_up> m_components;
  471. };
  472. /* A component that assigns according to a provided index (which is
  473. relative to the "low" value). */
  474. class ada_positional_component : public ada_component
  475. {
  476. public:
  477. ada_positional_component (int index, operation_up &&op)
  478. : m_index (index),
  479. m_op (std::move (op))
  480. {
  481. }
  482. void assign (struct value *container,
  483. struct value *lhs, struct expression *exp,
  484. std::vector<LONGEST> &indices,
  485. LONGEST low, LONGEST high) override;
  486. bool uses_objfile (struct objfile *objfile) override;
  487. void dump (ui_file *stream, int depth) override;
  488. private:
  489. int m_index;
  490. operation_up m_op;
  491. };
  492. /* A component which handles an "others" clause. */
  493. class ada_others_component : public ada_component
  494. {
  495. public:
  496. explicit ada_others_component (operation_up &&op)
  497. : m_op (std::move (op))
  498. {
  499. }
  500. void assign (struct value *container,
  501. struct value *lhs, struct expression *exp,
  502. std::vector<LONGEST> &indices,
  503. LONGEST low, LONGEST high) override;
  504. bool uses_objfile (struct objfile *objfile) override;
  505. void dump (ui_file *stream, int depth) override;
  506. private:
  507. operation_up m_op;
  508. };
  509. /* An interface that represents an association that is used in
  510. aggregate assignment. */
  511. class ada_association
  512. {
  513. public:
  514. /* Like ada_component::assign, but takes an operation as a
  515. parameter. The operation is evaluated and then assigned into LHS
  516. according to the rules of the concrete implementation. */
  517. virtual void assign (struct value *container,
  518. struct value *lhs,
  519. struct expression *exp,
  520. std::vector<LONGEST> &indices,
  521. LONGEST low, LONGEST high,
  522. operation_up &op) = 0;
  523. /* Same as operation::uses_objfile. */
  524. virtual bool uses_objfile (struct objfile *objfile) = 0;
  525. /* Same as operation::dump. */
  526. virtual void dump (ui_file *stream, int depth) = 0;
  527. virtual ~ada_association () = default;
  528. protected:
  529. ada_association () = default;
  530. DISABLE_COPY_AND_ASSIGN (ada_association);
  531. };
  532. /* Unique pointer specialization for Ada assignment associations. */
  533. typedef std::unique_ptr<ada_association> ada_association_up;
  534. /* A component that holds a vector of associations and an operation.
  535. The operation is re-evaluated for each choice. */
  536. class ada_choices_component : public ada_component
  537. {
  538. public:
  539. explicit ada_choices_component (operation_up &&op)
  540. : m_op (std::move (op))
  541. {
  542. }
  543. /* Set the vector of associations. This is done separately from the
  544. constructor because it was simpler for the implementation of the
  545. parser. */
  546. void set_associations (std::vector<ada_association_up> &&assoc)
  547. {
  548. m_assocs = std::move (assoc);
  549. }
  550. void assign (struct value *container,
  551. struct value *lhs, struct expression *exp,
  552. std::vector<LONGEST> &indices,
  553. LONGEST low, LONGEST high) override;
  554. bool uses_objfile (struct objfile *objfile) override;
  555. void dump (ui_file *stream, int depth) override;
  556. private:
  557. std::vector<ada_association_up> m_assocs;
  558. operation_up m_op;
  559. };
  560. /* An association that uses a discrete range. */
  561. class ada_discrete_range_association : public ada_association
  562. {
  563. public:
  564. ada_discrete_range_association (operation_up &&low, operation_up &&high)
  565. : m_low (std::move (low)),
  566. m_high (std::move (high))
  567. {
  568. }
  569. void assign (struct value *container,
  570. struct value *lhs, struct expression *exp,
  571. std::vector<LONGEST> &indices,
  572. LONGEST low, LONGEST high,
  573. operation_up &op) override;
  574. bool uses_objfile (struct objfile *objfile) override;
  575. void dump (ui_file *stream, int depth) override;
  576. private:
  577. operation_up m_low;
  578. operation_up m_high;
  579. };
  580. /* An association that uses a name. The name may be an expression
  581. that evaluates to an integer (for arrays), or an Ada string or
  582. variable value operation. */
  583. class ada_name_association : public ada_association
  584. {
  585. public:
  586. explicit ada_name_association (operation_up val)
  587. : m_val (std::move (val))
  588. {
  589. }
  590. void assign (struct value *container,
  591. struct value *lhs, struct expression *exp,
  592. std::vector<LONGEST> &indices,
  593. LONGEST low, LONGEST high,
  594. operation_up &op) override;
  595. bool uses_objfile (struct objfile *objfile) override;
  596. void dump (ui_file *stream, int depth) override;
  597. private:
  598. operation_up m_val;
  599. };
  600. /* A character constant expression. This is a separate operation so
  601. that it can participate in resolution, so that TYPE'(CST) can
  602. work correctly for enums with character enumerators. */
  603. class ada_char_operation : public long_const_operation,
  604. public ada_resolvable
  605. {
  606. public:
  607. using long_const_operation::long_const_operation;
  608. bool resolve (struct expression *exp,
  609. bool deprocedure_p,
  610. bool parse_completion,
  611. innermost_block_tracker *tracker,
  612. struct type *context_type) override
  613. {
  614. /* This should never be called, because this class also implements
  615. 'replace'. */
  616. gdb_assert_not_reached ("unexpected call");
  617. }
  618. operation_up replace (operation_up &&owner,
  619. struct expression *exp,
  620. bool deprocedure_p,
  621. bool parse_completion,
  622. innermost_block_tracker *tracker,
  623. struct type *context_type) override;
  624. value *evaluate (struct type *expect_type,
  625. struct expression *exp,
  626. enum noside noside) override;
  627. };
  628. class ada_concat_operation : public concat_operation
  629. {
  630. public:
  631. using concat_operation::concat_operation;
  632. value *evaluate (struct type *expect_type,
  633. struct expression *exp,
  634. enum noside noside) override;
  635. };
  636. } /* namespace expr */
  637. #endif /* ADA_EXP_H */