PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/gdb-7.4.50.20120714/gdb/jv-exp.y

#
Happy | 1454 lines | 1276 code | 178 blank | 0 comment | 0 complexity | d8ff166bb1a58e7c0c2ef3173837eb49 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, GPL-3.0, LGPL-2.1
  1. /* YACC parser for Java expressions, for GDB.
  2. Copyright (C) 1997-2000, 2006-2012 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. /* Parse a Java expression from text in a string,
  15. and return the result as a struct expression pointer.
  16. That structure contains arithmetic operations in reverse polish,
  17. with constants represented by operations that are followed by special data.
  18. See expression.h for the details of the format.
  19. What is important here is that it can be built up sequentially
  20. during the process of parsing; the lower levels of the tree always
  21. come first in the result. Well, almost always; see ArrayAccess.
  22. Note that malloc's and realloc's in this file are transformed to
  23. xmalloc and xrealloc respectively by the same sed command in the
  24. makefile that remaps any other malloc/realloc inserted by the parser
  25. generator. Doing this with #defines and trying to control the interaction
  26. with include files (<malloc.h> and <stdlib.h> for example) just became
  27. too messy, particularly when such includes can be inserted at random
  28. times by the parser generator. */
  29. %{
  30. #include "defs.h"
  31. #include "gdb_string.h"
  32. #include <ctype.h>
  33. #include "expression.h"
  34. #include "value.h"
  35. #include "parser-defs.h"
  36. #include "language.h"
  37. #include "jv-lang.h"
  38. #include "bfd.h" /* Required by objfiles.h. */
  39. #include "symfile.h" /* Required by objfiles.h. */
  40. #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
  41. #include "block.h"
  42. #define parse_type builtin_type (parse_gdbarch)
  43. #define parse_java_type builtin_java_type (parse_gdbarch)
  44. /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
  45. as well as gratuitiously global symbol names, so we can have multiple
  46. yacc generated parsers in gdb. Note that these are only the variables
  47. produced by yacc. If other parser generators (bison, byacc, etc) produce
  48. additional global names that conflict at link time, then those parser
  49. generators need to be fixed instead of adding those names to this list. */
  50. #define yymaxdepth java_maxdepth
  51. #define yyparse java_parse
  52. #define yylex java_lex
  53. #define yyerror java_error
  54. #define yylval java_lval
  55. #define yychar java_char
  56. #define yydebug java_debug
  57. #define yypact java_pact
  58. #define yyr1 java_r1
  59. #define yyr2 java_r2
  60. #define yydef java_def
  61. #define yychk java_chk
  62. #define yypgo java_pgo
  63. #define yyact java_act
  64. #define yyexca java_exca
  65. #define yyerrflag java_errflag
  66. #define yynerrs java_nerrs
  67. #define yyps java_ps
  68. #define yypv java_pv
  69. #define yys java_s
  70. #define yy_yys java_yys
  71. #define yystate java_state
  72. #define yytmp java_tmp
  73. #define yyv java_v
  74. #define yy_yyv java_yyv
  75. #define yyval java_val
  76. #define yylloc java_lloc
  77. #define yyreds java_reds /* With YYDEBUG defined */
  78. #define yytoks java_toks /* With YYDEBUG defined */
  79. #define yyname java_name /* With YYDEBUG defined */
  80. #define yyrule java_rule /* With YYDEBUG defined */
  81. #define yylhs java_yylhs
  82. #define yylen java_yylen
  83. #define yydefred java_yydefred
  84. #define yydgoto java_yydgoto
  85. #define yysindex java_yysindex
  86. #define yyrindex java_yyrindex
  87. #define yygindex java_yygindex
  88. #define yytable java_yytable
  89. #define yycheck java_yycheck
  90. #define yyss java_yyss
  91. #define yysslim java_yysslim
  92. #define yyssp java_yyssp
  93. #define yystacksize java_yystacksize
  94. #define yyvs java_yyvs
  95. #define yyvsp java_yyvsp
  96. #ifndef YYDEBUG
  97. #define YYDEBUG 1 /* Default to yydebug support */
  98. #endif
  99. #define YYFPRINTF parser_fprintf
  100. int yyparse (void);
  101. static int yylex (void);
  102. void yyerror (char *);
  103. static struct type *java_type_from_name (struct stoken);
  104. static void push_expression_name (struct stoken);
  105. static void push_fieldnames (struct stoken);
  106. static struct expression *copy_exp (struct expression *, int);
  107. static void insert_exp (int, struct expression *);
  108. %}
  109. /* Although the yacc "value" of an expression is not used,
  110. since the result is stored in the structure being created,
  111. other node types do have values. */
  112. %union
  113. {
  114. LONGEST lval;
  115. struct {
  116. LONGEST val;
  117. struct type *type;
  118. } typed_val_int;
  119. struct {
  120. DOUBLEST dval;
  121. struct type *type;
  122. } typed_val_float;
  123. struct symbol *sym;
  124. struct type *tval;
  125. struct stoken sval;
  126. struct ttype tsym;
  127. struct symtoken ssym;
  128. struct block *bval;
  129. enum exp_opcode opcode;
  130. struct internalvar *ivar;
  131. int *ivec;
  132. }
  133. %{
  134. /* YYSTYPE gets defined by %union */
  135. static int parse_number (char *, int, int, YYSTYPE *);
  136. %}
  137. %type <lval> rcurly Dims Dims_opt
  138. %type <tval> ClassOrInterfaceType ClassType /* ReferenceType Type ArrayType */
  139. %type <tval> IntegralType FloatingPointType NumericType PrimitiveType ArrayType PrimitiveOrArrayType
  140. %token <typed_val_int> INTEGER_LITERAL
  141. %token <typed_val_float> FLOATING_POINT_LITERAL
  142. %token <sval> IDENTIFIER
  143. %token <sval> STRING_LITERAL
  144. %token <lval> BOOLEAN_LITERAL
  145. %token <tsym> TYPENAME
  146. %type <sval> Name SimpleName QualifiedName ForcedName
  147. /* A NAME_OR_INT is a symbol which is not known in the symbol table,
  148. but which would parse as a valid number in the current input radix.
  149. E.g. "c" when input_radix==16. Depending on the parse, it will be
  150. turned into a name or into a number. */
  151. %token <sval> NAME_OR_INT
  152. %token ERROR
  153. /* Special type cases, put in to allow the parser to distinguish different
  154. legal basetypes. */
  155. %token LONG SHORT BYTE INT CHAR BOOLEAN DOUBLE FLOAT
  156. %token VARIABLE
  157. %token <opcode> ASSIGN_MODIFY
  158. %token SUPER NEW
  159. %left ','
  160. %right '=' ASSIGN_MODIFY
  161. %right '?'
  162. %left OROR
  163. %left ANDAND
  164. %left '|'
  165. %left '^'
  166. %left '&'
  167. %left EQUAL NOTEQUAL
  168. %left '<' '>' LEQ GEQ
  169. %left LSH RSH
  170. %left '+' '-'
  171. %left '*' '/' '%'
  172. %right INCREMENT DECREMENT
  173. %right '.' '[' '('
  174. %%
  175. start : exp1
  176. | type_exp
  177. ;
  178. type_exp: PrimitiveOrArrayType
  179. {
  180. write_exp_elt_opcode(OP_TYPE);
  181. write_exp_elt_type($1);
  182. write_exp_elt_opcode(OP_TYPE);
  183. }
  184. ;
  185. PrimitiveOrArrayType:
  186. PrimitiveType
  187. | ArrayType
  188. ;
  189. StringLiteral:
  190. STRING_LITERAL
  191. {
  192. write_exp_elt_opcode (OP_STRING);
  193. write_exp_string ($1);
  194. write_exp_elt_opcode (OP_STRING);
  195. }
  196. ;
  197. Literal:
  198. INTEGER_LITERAL
  199. { write_exp_elt_opcode (OP_LONG);
  200. write_exp_elt_type ($1.type);
  201. write_exp_elt_longcst ((LONGEST)($1.val));
  202. write_exp_elt_opcode (OP_LONG); }
  203. | NAME_OR_INT
  204. { YYSTYPE val;
  205. parse_number ($1.ptr, $1.length, 0, &val);
  206. write_exp_elt_opcode (OP_LONG);
  207. write_exp_elt_type (val.typed_val_int.type);
  208. write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
  209. write_exp_elt_opcode (OP_LONG);
  210. }
  211. | FLOATING_POINT_LITERAL
  212. { write_exp_elt_opcode (OP_DOUBLE);
  213. write_exp_elt_type ($1.type);
  214. write_exp_elt_dblcst ($1.dval);
  215. write_exp_elt_opcode (OP_DOUBLE); }
  216. | BOOLEAN_LITERAL
  217. { write_exp_elt_opcode (OP_LONG);
  218. write_exp_elt_type (parse_java_type->builtin_boolean);
  219. write_exp_elt_longcst ((LONGEST)$1);
  220. write_exp_elt_opcode (OP_LONG); }
  221. | StringLiteral
  222. ;
  223. /* UNUSED:
  224. Type:
  225. PrimitiveType
  226. | ReferenceType
  227. ;
  228. */
  229. PrimitiveType:
  230. NumericType
  231. | BOOLEAN
  232. { $$ = parse_java_type->builtin_boolean; }
  233. ;
  234. NumericType:
  235. IntegralType
  236. | FloatingPointType
  237. ;
  238. IntegralType:
  239. BYTE
  240. { $$ = parse_java_type->builtin_byte; }
  241. | SHORT
  242. { $$ = parse_java_type->builtin_short; }
  243. | INT
  244. { $$ = parse_java_type->builtin_int; }
  245. | LONG
  246. { $$ = parse_java_type->builtin_long; }
  247. | CHAR
  248. { $$ = parse_java_type->builtin_char; }
  249. ;
  250. FloatingPointType:
  251. FLOAT
  252. { $$ = parse_java_type->builtin_float; }
  253. | DOUBLE
  254. { $$ = parse_java_type->builtin_double; }
  255. ;
  256. /* UNUSED:
  257. ReferenceType:
  258. ClassOrInterfaceType
  259. | ArrayType
  260. ;
  261. */
  262. ClassOrInterfaceType:
  263. Name
  264. { $$ = java_type_from_name ($1); }
  265. ;
  266. ClassType:
  267. ClassOrInterfaceType
  268. ;
  269. ArrayType:
  270. PrimitiveType Dims
  271. { $$ = java_array_type ($1, $2); }
  272. | Name Dims
  273. { $$ = java_array_type (java_type_from_name ($1), $2); }
  274. ;
  275. Name:
  276. IDENTIFIER
  277. | QualifiedName
  278. ;
  279. ForcedName:
  280. SimpleName
  281. | QualifiedName
  282. ;
  283. SimpleName:
  284. IDENTIFIER
  285. | NAME_OR_INT
  286. ;
  287. QualifiedName:
  288. Name '.' SimpleName
  289. { $$.length = $1.length + $3.length + 1;
  290. if ($1.ptr + $1.length + 1 == $3.ptr
  291. && $1.ptr[$1.length] == '.')
  292. $$.ptr = $1.ptr; /* Optimization. */
  293. else
  294. {
  295. $$.ptr = (char *) malloc ($$.length + 1);
  296. make_cleanup (free, $$.ptr);
  297. sprintf ($$.ptr, "%.*s.%.*s",
  298. $1.length, $1.ptr, $3.length, $3.ptr);
  299. } }
  300. ;
  301. /*
  302. type_exp: type
  303. { write_exp_elt_opcode(OP_TYPE);
  304. write_exp_elt_type($1);
  305. write_exp_elt_opcode(OP_TYPE);}
  306. ;
  307. */
  308. /* Expressions, including the comma operator. */
  309. exp1 : Expression
  310. | exp1 ',' Expression
  311. { write_exp_elt_opcode (BINOP_COMMA); }
  312. ;
  313. Primary:
  314. PrimaryNoNewArray
  315. | ArrayCreationExpression
  316. ;
  317. PrimaryNoNewArray:
  318. Literal
  319. | '(' Expression ')'
  320. | ClassInstanceCreationExpression
  321. | FieldAccess
  322. | MethodInvocation
  323. | ArrayAccess
  324. | lcurly ArgumentList rcurly
  325. { write_exp_elt_opcode (OP_ARRAY);
  326. write_exp_elt_longcst ((LONGEST) 0);
  327. write_exp_elt_longcst ((LONGEST) $3);
  328. write_exp_elt_opcode (OP_ARRAY); }
  329. ;
  330. lcurly:
  331. '{'
  332. { start_arglist (); }
  333. ;
  334. rcurly:
  335. '}'
  336. { $$ = end_arglist () - 1; }
  337. ;
  338. ClassInstanceCreationExpression:
  339. NEW ClassType '(' ArgumentList_opt ')'
  340. { internal_error (__FILE__, __LINE__,
  341. _("FIXME - ClassInstanceCreationExpression")); }
  342. ;
  343. ArgumentList:
  344. Expression
  345. { arglist_len = 1; }
  346. | ArgumentList ',' Expression
  347. { arglist_len++; }
  348. ;
  349. ArgumentList_opt:
  350. /* EMPTY */
  351. { arglist_len = 0; }
  352. | ArgumentList
  353. ;
  354. ArrayCreationExpression:
  355. NEW PrimitiveType DimExprs Dims_opt
  356. { internal_error (__FILE__, __LINE__,
  357. _("FIXME - ArrayCreationExpression")); }
  358. | NEW ClassOrInterfaceType DimExprs Dims_opt
  359. { internal_error (__FILE__, __LINE__,
  360. _("FIXME - ArrayCreationExpression")); }
  361. ;
  362. DimExprs:
  363. DimExpr
  364. | DimExprs DimExpr
  365. ;
  366. DimExpr:
  367. '[' Expression ']'
  368. ;
  369. Dims:
  370. '[' ']'
  371. { $$ = 1; }
  372. | Dims '[' ']'
  373. { $$ = $1 + 1; }
  374. ;
  375. Dims_opt:
  376. Dims
  377. | /* EMPTY */
  378. { $$ = 0; }
  379. ;
  380. FieldAccess:
  381. Primary '.' SimpleName
  382. { push_fieldnames ($3); }
  383. | VARIABLE '.' SimpleName
  384. { push_fieldnames ($3); }
  385. /*| SUPER '.' SimpleName { FIXME } */
  386. ;
  387. FuncStart:
  388. Name '('
  389. { push_expression_name ($1); }
  390. ;
  391. MethodInvocation:
  392. FuncStart
  393. { start_arglist(); }
  394. ArgumentList_opt ')'
  395. { write_exp_elt_opcode (OP_FUNCALL);
  396. write_exp_elt_longcst ((LONGEST) end_arglist ());
  397. write_exp_elt_opcode (OP_FUNCALL); }
  398. | Primary '.' SimpleName '(' ArgumentList_opt ')'
  399. { error (_("Form of method invocation not implemented")); }
  400. | SUPER '.' SimpleName '(' ArgumentList_opt ')'
  401. { error (_("Form of method invocation not implemented")); }
  402. ;
  403. ArrayAccess:
  404. Name '[' Expression ']'
  405. {
  406. /* Emit code for the Name now, then exchange it in the
  407. expout array with the Expression's code. We could
  408. introduce a OP_SWAP code or a reversed version of
  409. BINOP_SUBSCRIPT, but that makes the rest of GDB pay
  410. for our parsing kludges. */
  411. struct expression *name_expr;
  412. push_expression_name ($1);
  413. name_expr = copy_exp (expout, expout_ptr);
  414. expout_ptr -= name_expr->nelts;
  415. insert_exp (expout_ptr-length_of_subexp (expout, expout_ptr),
  416. name_expr);
  417. free (name_expr);
  418. write_exp_elt_opcode (BINOP_SUBSCRIPT);
  419. }
  420. | VARIABLE '[' Expression ']'
  421. { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
  422. | PrimaryNoNewArray '[' Expression ']'
  423. { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
  424. ;
  425. PostfixExpression:
  426. Primary
  427. | Name
  428. { push_expression_name ($1); }
  429. | VARIABLE
  430. /* Already written by write_dollar_variable. */
  431. | PostIncrementExpression
  432. | PostDecrementExpression
  433. ;
  434. PostIncrementExpression:
  435. PostfixExpression INCREMENT
  436. { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
  437. ;
  438. PostDecrementExpression:
  439. PostfixExpression DECREMENT
  440. { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
  441. ;
  442. UnaryExpression:
  443. PreIncrementExpression
  444. | PreDecrementExpression
  445. | '+' UnaryExpression
  446. | '-' UnaryExpression
  447. { write_exp_elt_opcode (UNOP_NEG); }
  448. | '*' UnaryExpression
  449. { write_exp_elt_opcode (UNOP_IND); } /*FIXME not in Java */
  450. | UnaryExpressionNotPlusMinus
  451. ;
  452. PreIncrementExpression:
  453. INCREMENT UnaryExpression
  454. { write_exp_elt_opcode (UNOP_PREINCREMENT); }
  455. ;
  456. PreDecrementExpression:
  457. DECREMENT UnaryExpression
  458. { write_exp_elt_opcode (UNOP_PREDECREMENT); }
  459. ;
  460. UnaryExpressionNotPlusMinus:
  461. PostfixExpression
  462. | '~' UnaryExpression
  463. { write_exp_elt_opcode (UNOP_COMPLEMENT); }
  464. | '!' UnaryExpression
  465. { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
  466. | CastExpression
  467. ;
  468. CastExpression:
  469. '(' PrimitiveType Dims_opt ')' UnaryExpression
  470. { write_exp_elt_opcode (UNOP_CAST);
  471. write_exp_elt_type (java_array_type ($2, $3));
  472. write_exp_elt_opcode (UNOP_CAST); }
  473. | '(' Expression ')' UnaryExpressionNotPlusMinus
  474. {
  475. int last_exp_size = length_of_subexp(expout, expout_ptr);
  476. struct type *type;
  477. int i;
  478. int base = expout_ptr - last_exp_size - 3;
  479. if (base < 0 || expout->elts[base+2].opcode != OP_TYPE)
  480. error (_("Invalid cast expression"));
  481. type = expout->elts[base+1].type;
  482. /* Remove the 'Expression' and slide the
  483. UnaryExpressionNotPlusMinus down to replace it. */
  484. for (i = 0; i < last_exp_size; i++)
  485. expout->elts[base + i] = expout->elts[base + i + 3];
  486. expout_ptr -= 3;
  487. if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
  488. type = lookup_pointer_type (type);
  489. write_exp_elt_opcode (UNOP_CAST);
  490. write_exp_elt_type (type);
  491. write_exp_elt_opcode (UNOP_CAST);
  492. }
  493. | '(' Name Dims ')' UnaryExpressionNotPlusMinus
  494. { write_exp_elt_opcode (UNOP_CAST);
  495. write_exp_elt_type (java_array_type (java_type_from_name ($2), $3));
  496. write_exp_elt_opcode (UNOP_CAST); }
  497. ;
  498. MultiplicativeExpression:
  499. UnaryExpression
  500. | MultiplicativeExpression '*' UnaryExpression
  501. { write_exp_elt_opcode (BINOP_MUL); }
  502. | MultiplicativeExpression '/' UnaryExpression
  503. { write_exp_elt_opcode (BINOP_DIV); }
  504. | MultiplicativeExpression '%' UnaryExpression
  505. { write_exp_elt_opcode (BINOP_REM); }
  506. ;
  507. AdditiveExpression:
  508. MultiplicativeExpression
  509. | AdditiveExpression '+' MultiplicativeExpression
  510. { write_exp_elt_opcode (BINOP_ADD); }
  511. | AdditiveExpression '-' MultiplicativeExpression
  512. { write_exp_elt_opcode (BINOP_SUB); }
  513. ;
  514. ShiftExpression:
  515. AdditiveExpression
  516. | ShiftExpression LSH AdditiveExpression
  517. { write_exp_elt_opcode (BINOP_LSH); }
  518. | ShiftExpression RSH AdditiveExpression
  519. { write_exp_elt_opcode (BINOP_RSH); }
  520. /* | ShiftExpression >>> AdditiveExpression { FIXME } */
  521. ;
  522. RelationalExpression:
  523. ShiftExpression
  524. | RelationalExpression '<' ShiftExpression
  525. { write_exp_elt_opcode (BINOP_LESS); }
  526. | RelationalExpression '>' ShiftExpression
  527. { write_exp_elt_opcode (BINOP_GTR); }
  528. | RelationalExpression LEQ ShiftExpression
  529. { write_exp_elt_opcode (BINOP_LEQ); }
  530. | RelationalExpression GEQ ShiftExpression
  531. { write_exp_elt_opcode (BINOP_GEQ); }
  532. /* | RelationalExpresion INSTANCEOF ReferenceType { FIXME } */
  533. ;
  534. EqualityExpression:
  535. RelationalExpression
  536. | EqualityExpression EQUAL RelationalExpression
  537. { write_exp_elt_opcode (BINOP_EQUAL); }
  538. | EqualityExpression NOTEQUAL RelationalExpression
  539. { write_exp_elt_opcode (BINOP_NOTEQUAL); }
  540. ;
  541. AndExpression:
  542. EqualityExpression
  543. | AndExpression '&' EqualityExpression
  544. { write_exp_elt_opcode (BINOP_BITWISE_AND); }
  545. ;
  546. ExclusiveOrExpression:
  547. AndExpression
  548. | ExclusiveOrExpression '^' AndExpression
  549. { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
  550. ;
  551. InclusiveOrExpression:
  552. ExclusiveOrExpression
  553. | InclusiveOrExpression '|' ExclusiveOrExpression
  554. { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
  555. ;
  556. ConditionalAndExpression:
  557. InclusiveOrExpression
  558. | ConditionalAndExpression ANDAND InclusiveOrExpression
  559. { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
  560. ;
  561. ConditionalOrExpression:
  562. ConditionalAndExpression
  563. | ConditionalOrExpression OROR ConditionalAndExpression
  564. { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
  565. ;
  566. ConditionalExpression:
  567. ConditionalOrExpression
  568. | ConditionalOrExpression '?' Expression ':' ConditionalExpression
  569. { write_exp_elt_opcode (TERNOP_COND); }
  570. ;
  571. AssignmentExpression:
  572. ConditionalExpression
  573. | Assignment
  574. ;
  575. Assignment:
  576. LeftHandSide '=' ConditionalExpression
  577. { write_exp_elt_opcode (BINOP_ASSIGN); }
  578. | LeftHandSide ASSIGN_MODIFY ConditionalExpression
  579. { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
  580. write_exp_elt_opcode ($2);
  581. write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
  582. ;
  583. LeftHandSide:
  584. ForcedName
  585. { push_expression_name ($1); }
  586. | VARIABLE
  587. /* Already written by write_dollar_variable. */
  588. | FieldAccess
  589. | ArrayAccess
  590. ;
  591. Expression:
  592. AssignmentExpression
  593. ;
  594. %%
  595. /* Take care of parsing a number (anything that starts with a digit).
  596. Set yylval and return the token type; update lexptr.
  597. LEN is the number of characters in it. */
  598. /*** Needs some error checking for the float case ***/
  599. static int
  600. parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
  601. {
  602. ULONGEST n = 0;
  603. ULONGEST limit, limit_div_base;
  604. int c;
  605. int base = input_radix;
  606. struct type *type;
  607. if (parsed_float)
  608. {
  609. const char *suffix;
  610. int suffix_len;
  611. if (! parse_float (p, len, &putithere->typed_val_float.dval, &suffix))
  612. return ERROR;
  613. suffix_len = p + len - suffix;
  614. if (suffix_len == 0)
  615. putithere->typed_val_float.type = parse_type->builtin_double;
  616. else if (suffix_len == 1)
  617. {
  618. /* See if it has `f' or `d' suffix (float or double). */
  619. if (tolower (*suffix) == 'f')
  620. putithere->typed_val_float.type =
  621. parse_type->builtin_float;
  622. else if (tolower (*suffix) == 'd')
  623. putithere->typed_val_float.type =
  624. parse_type->builtin_double;
  625. else
  626. return ERROR;
  627. }
  628. else
  629. return ERROR;
  630. return FLOATING_POINT_LITERAL;
  631. }
  632. /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
  633. if (p[0] == '0')
  634. switch (p[1])
  635. {
  636. case 'x':
  637. case 'X':
  638. if (len >= 3)
  639. {
  640. p += 2;
  641. base = 16;
  642. len -= 2;
  643. }
  644. break;
  645. case 't':
  646. case 'T':
  647. case 'd':
  648. case 'D':
  649. if (len >= 3)
  650. {
  651. p += 2;
  652. base = 10;
  653. len -= 2;
  654. }
  655. break;
  656. default:
  657. base = 8;
  658. break;
  659. }
  660. c = p[len-1];
  661. /* A paranoid calculation of (1<<64)-1. */
  662. limit = (ULONGEST)0xffffffff;
  663. limit = ((limit << 16) << 16) | limit;
  664. if (c == 'l' || c == 'L')
  665. {
  666. type = parse_java_type->builtin_long;
  667. len--;
  668. }
  669. else
  670. {
  671. type = parse_java_type->builtin_int;
  672. }
  673. limit_div_base = limit / (ULONGEST) base;
  674. while (--len >= 0)
  675. {
  676. c = *p++;
  677. if (c >= '0' && c <= '9')
  678. c -= '0';
  679. else if (c >= 'A' && c <= 'Z')
  680. c -= 'A' - 10;
  681. else if (c >= 'a' && c <= 'z')
  682. c -= 'a' - 10;
  683. else
  684. return ERROR; /* Char not a digit */
  685. if (c >= base)
  686. return ERROR;
  687. if (n > limit_div_base
  688. || (n *= base) > limit - c)
  689. error (_("Numeric constant too large"));
  690. n += c;
  691. }
  692. /* If the type is bigger than a 32-bit signed integer can be, implicitly
  693. promote to long. Java does not do this, so mark it as
  694. parse_type->builtin_uint64 rather than parse_java_type->builtin_long.
  695. 0x80000000 will become -0x80000000 instead of 0x80000000L, because we
  696. don't know the sign at this point. */
  697. if (type == parse_java_type->builtin_int && n > (ULONGEST)0x80000000)
  698. type = parse_type->builtin_uint64;
  699. putithere->typed_val_int.val = n;
  700. putithere->typed_val_int.type = type;
  701. return INTEGER_LITERAL;
  702. }
  703. struct token
  704. {
  705. char *operator;
  706. int token;
  707. enum exp_opcode opcode;
  708. };
  709. static const struct token tokentab3[] =
  710. {
  711. {">>=", ASSIGN_MODIFY, BINOP_RSH},
  712. {"<<=", ASSIGN_MODIFY, BINOP_LSH}
  713. };
  714. static const struct token tokentab2[] =
  715. {
  716. {"+=", ASSIGN_MODIFY, BINOP_ADD},
  717. {"-=", ASSIGN_MODIFY, BINOP_SUB},
  718. {"*=", ASSIGN_MODIFY, BINOP_MUL},
  719. {"/=", ASSIGN_MODIFY, BINOP_DIV},
  720. {"%=", ASSIGN_MODIFY, BINOP_REM},
  721. {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
  722. {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
  723. {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
  724. {"++", INCREMENT, BINOP_END},
  725. {"--", DECREMENT, BINOP_END},
  726. {"&&", ANDAND, BINOP_END},
  727. {"||", OROR, BINOP_END},
  728. {"<<", LSH, BINOP_END},
  729. {">>", RSH, BINOP_END},
  730. {"==", EQUAL, BINOP_END},
  731. {"!=", NOTEQUAL, BINOP_END},
  732. {"<=", LEQ, BINOP_END},
  733. {">=", GEQ, BINOP_END}
  734. };
  735. /* Read one token, getting characters through lexptr. */
  736. static int
  737. yylex (void)
  738. {
  739. int c;
  740. int namelen;
  741. unsigned int i;
  742. char *tokstart;
  743. char *tokptr;
  744. int tempbufindex;
  745. static char *tempbuf;
  746. static int tempbufsize;
  747. retry:
  748. prev_lexptr = lexptr;
  749. tokstart = lexptr;
  750. /* See if it is a special token of length 3. */
  751. for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
  752. if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
  753. {
  754. lexptr += 3;
  755. yylval.opcode = tokentab3[i].opcode;
  756. return tokentab3[i].token;
  757. }
  758. /* See if it is a special token of length 2. */
  759. for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
  760. if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
  761. {
  762. lexptr += 2;
  763. yylval.opcode = tokentab2[i].opcode;
  764. return tokentab2[i].token;
  765. }
  766. switch (c = *tokstart)
  767. {
  768. case 0:
  769. return 0;
  770. case ' ':
  771. case '\t':
  772. case '\n':
  773. lexptr++;
  774. goto retry;
  775. case '\'':
  776. /* We either have a character constant ('0' or '\177' for example)
  777. or we have a quoted symbol reference ('foo(int,int)' in C++
  778. for example). */
  779. lexptr++;
  780. c = *lexptr++;
  781. if (c == '\\')
  782. c = parse_escape (parse_gdbarch, &lexptr);
  783. else if (c == '\'')
  784. error (_("Empty character constant"));
  785. yylval.typed_val_int.val = c;
  786. yylval.typed_val_int.type = parse_java_type->builtin_char;
  787. c = *lexptr++;
  788. if (c != '\'')
  789. {
  790. namelen = skip_quoted (tokstart) - tokstart;
  791. if (namelen > 2)
  792. {
  793. lexptr = tokstart + namelen;
  794. if (lexptr[-1] != '\'')
  795. error (_("Unmatched single quote"));
  796. namelen -= 2;
  797. tokstart++;
  798. goto tryname;
  799. }
  800. error (_("Invalid character constant"));
  801. }
  802. return INTEGER_LITERAL;
  803. case '(':
  804. paren_depth++;
  805. lexptr++;
  806. return c;
  807. case ')':
  808. if (paren_depth == 0)
  809. return 0;
  810. paren_depth--;
  811. lexptr++;
  812. return c;
  813. case ',':
  814. if (comma_terminates && paren_depth == 0)
  815. return 0;
  816. lexptr++;
  817. return c;
  818. case '.':
  819. /* Might be a floating point number. */
  820. if (lexptr[1] < '0' || lexptr[1] > '9')
  821. goto symbol; /* Nope, must be a symbol. */
  822. /* FALL THRU into number case. */
  823. case '0':
  824. case '1':
  825. case '2':
  826. case '3':
  827. case '4':
  828. case '5':
  829. case '6':
  830. case '7':
  831. case '8':
  832. case '9':
  833. {
  834. /* It's a number. */
  835. int got_dot = 0, got_e = 0, toktype;
  836. char *p = tokstart;
  837. int hex = input_radix > 10;
  838. if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
  839. {
  840. p += 2;
  841. hex = 1;
  842. }
  843. else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
  844. {
  845. p += 2;
  846. hex = 0;
  847. }
  848. for (;; ++p)
  849. {
  850. /* This test includes !hex because 'e' is a valid hex digit
  851. and thus does not indicate a floating point number when
  852. the radix is hex. */
  853. if (!hex && !got_e && (*p == 'e' || *p == 'E'))
  854. got_dot = got_e = 1;
  855. /* This test does not include !hex, because a '.' always indicates
  856. a decimal floating point number regardless of the radix. */
  857. else if (!got_dot && *p == '.')
  858. got_dot = 1;
  859. else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
  860. && (*p == '-' || *p == '+'))
  861. /* This is the sign of the exponent, not the end of the
  862. number. */
  863. continue;
  864. /* We will take any letters or digits. parse_number will
  865. complain if past the radix, or if L or U are not final. */
  866. else if ((*p < '0' || *p > '9')
  867. && ((*p < 'a' || *p > 'z')
  868. && (*p < 'A' || *p > 'Z')))
  869. break;
  870. }
  871. toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
  872. if (toktype == ERROR)
  873. {
  874. char *err_copy = (char *) alloca (p - tokstart + 1);
  875. memcpy (err_copy, tokstart, p - tokstart);
  876. err_copy[p - tokstart] = 0;
  877. error (_("Invalid number \"%s\""), err_copy);
  878. }
  879. lexptr = p;
  880. return toktype;
  881. }
  882. case '+':
  883. case '-':
  884. case '*':
  885. case '/':
  886. case '%':
  887. case '|':
  888. case '&':
  889. case '^':
  890. case '~':
  891. case '!':
  892. case '<':
  893. case '>':
  894. case '[':
  895. case ']':
  896. case '?':
  897. case ':':
  898. case '=':
  899. case '{':
  900. case '}':
  901. symbol:
  902. lexptr++;
  903. return c;
  904. case '"':
  905. /* Build the gdb internal form of the input string in tempbuf,
  906. translating any standard C escape forms seen. Note that the
  907. buffer is null byte terminated *only* for the convenience of
  908. debugging gdb itself and printing the buffer contents when
  909. the buffer contains no embedded nulls. Gdb does not depend
  910. upon the buffer being null byte terminated, it uses the length
  911. string instead. This allows gdb to handle C strings (as well
  912. as strings in other languages) with embedded null bytes */
  913. tokptr = ++tokstart;
  914. tempbufindex = 0;
  915. do {
  916. /* Grow the static temp buffer if necessary, including allocating
  917. the first one on demand. */
  918. if (tempbufindex + 1 >= tempbufsize)
  919. {
  920. tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
  921. }
  922. switch (*tokptr)
  923. {
  924. case '\0':
  925. case '"':
  926. /* Do nothing, loop will terminate. */
  927. break;
  928. case '\\':
  929. tokptr++;
  930. c = parse_escape (parse_gdbarch, &tokptr);
  931. if (c == -1)
  932. {
  933. continue;
  934. }
  935. tempbuf[tempbufindex++] = c;
  936. break;
  937. default:
  938. tempbuf[tempbufindex++] = *tokptr++;
  939. break;
  940. }
  941. } while ((*tokptr != '"') && (*tokptr != '\0'));
  942. if (*tokptr++ != '"')
  943. {
  944. error (_("Unterminated string in expression"));
  945. }
  946. tempbuf[tempbufindex] = '\0'; /* See note above */
  947. yylval.sval.ptr = tempbuf;
  948. yylval.sval.length = tempbufindex;
  949. lexptr = tokptr;
  950. return (STRING_LITERAL);
  951. }
  952. if (!(c == '_' || c == '$'
  953. || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
  954. /* We must have come across a bad character (e.g. ';'). */
  955. error (_("Invalid character '%c' in expression"), c);
  956. /* It's a name. See how long it is. */
  957. namelen = 0;
  958. for (c = tokstart[namelen];
  959. (c == '_'
  960. || c == '$'
  961. || (c >= '0' && c <= '9')
  962. || (c >= 'a' && c <= 'z')
  963. || (c >= 'A' && c <= 'Z')
  964. || c == '<');
  965. )
  966. {
  967. if (c == '<')
  968. {
  969. int i = namelen;
  970. while (tokstart[++i] && tokstart[i] != '>');
  971. if (tokstart[i] == '>')
  972. namelen = i;
  973. }
  974. c = tokstart[++namelen];
  975. }
  976. /* The token "if" terminates the expression and is NOT
  977. removed from the input stream. */
  978. if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
  979. {
  980. return 0;
  981. }
  982. lexptr += namelen;
  983. tryname:
  984. /* Catch specific keywords. Should be done with a data structure. */
  985. switch (namelen)
  986. {
  987. case 7:
  988. if (strncmp (tokstart, "boolean", 7) == 0)
  989. return BOOLEAN;
  990. break;
  991. case 6:
  992. if (strncmp (tokstart, "double", 6) == 0)
  993. return DOUBLE;
  994. break;
  995. case 5:
  996. if (strncmp (tokstart, "short", 5) == 0)
  997. return SHORT;
  998. if (strncmp (tokstart, "false", 5) == 0)
  999. {
  1000. yylval.lval = 0;
  1001. return BOOLEAN_LITERAL;
  1002. }
  1003. if (strncmp (tokstart, "super", 5) == 0)
  1004. return SUPER;
  1005. if (strncmp (tokstart, "float", 5) == 0)
  1006. return FLOAT;
  1007. break;
  1008. case 4:
  1009. if (strncmp (tokstart, "long", 4) == 0)
  1010. return LONG;
  1011. if (strncmp (tokstart, "byte", 4) == 0)
  1012. return BYTE;
  1013. if (strncmp (tokstart, "char", 4) == 0)
  1014. return CHAR;
  1015. if (strncmp (tokstart, "true", 4) == 0)
  1016. {
  1017. yylval.lval = 1;
  1018. return BOOLEAN_LITERAL;
  1019. }
  1020. break;
  1021. case 3:
  1022. if (strncmp (tokstart, "int", 3) == 0)
  1023. return INT;
  1024. if (strncmp (tokstart, "new", 3) == 0)
  1025. return NEW;
  1026. break;
  1027. default:
  1028. break;
  1029. }
  1030. yylval.sval.ptr = tokstart;
  1031. yylval.sval.length = namelen;
  1032. if (*tokstart == '$')
  1033. {
  1034. write_dollar_variable (yylval.sval);
  1035. return VARIABLE;
  1036. }
  1037. /* Input names that aren't symbols but ARE valid hex numbers,
  1038. when the input radix permits them, can be names or numbers
  1039. depending on the parse. Note we support radixes > 16 here. */
  1040. if (((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
  1041. (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
  1042. {
  1043. YYSTYPE newlval; /* Its value is ignored. */
  1044. int hextype = parse_number (tokstart, namelen, 0, &newlval);
  1045. if (hextype == INTEGER_LITERAL)
  1046. return NAME_OR_INT;
  1047. }
  1048. return IDENTIFIER;
  1049. }
  1050. void
  1051. yyerror (char *msg)
  1052. {
  1053. if (prev_lexptr)
  1054. lexptr = prev_lexptr;
  1055. if (msg)
  1056. error (_("%s: near `%s'"), msg, lexptr);
  1057. else
  1058. error (_("error in expression, near `%s'"), lexptr);
  1059. }
  1060. static struct type *
  1061. java_type_from_name (struct stoken name)
  1062. {
  1063. char *tmp = copy_name (name);
  1064. struct type *typ = java_lookup_class (tmp);
  1065. if (typ == NULL || TYPE_CODE (typ) != TYPE_CODE_STRUCT)
  1066. error (_("No class named `%s'"), tmp);
  1067. return typ;
  1068. }
  1069. /* If NAME is a valid variable name in this scope, push it and return 1.
  1070. Otherwise, return 0. */
  1071. static int
  1072. push_variable (struct stoken name)
  1073. {
  1074. char *tmp = copy_name (name);
  1075. int is_a_field_of_this = 0;
  1076. struct symbol *sym;
  1077. sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,
  1078. &is_a_field_of_this);
  1079. if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
  1080. {
  1081. if (symbol_read_needs_frame (sym))
  1082. {
  1083. if (innermost_block == 0 ||
  1084. contained_in (block_found, innermost_block))
  1085. innermost_block = block_found;
  1086. }
  1087. write_exp_elt_opcode (OP_VAR_VALUE);
  1088. /* We want to use the selected frame, not another more inner frame
  1089. which happens to be in the same block. */
  1090. write_exp_elt_block (NULL);
  1091. write_exp_elt_sym (sym);
  1092. write_exp_elt_opcode (OP_VAR_VALUE);
  1093. return 1;
  1094. }
  1095. if (is_a_field_of_this)
  1096. {
  1097. /* it hangs off of `this'. Must not inadvertently convert from a
  1098. method call to data ref. */
  1099. if (innermost_block == 0 ||
  1100. contained_in (block_found, innermost_block))
  1101. innermost_block = block_found;
  1102. write_exp_elt_opcode (OP_THIS);
  1103. write_exp_elt_opcode (OP_THIS);
  1104. write_exp_elt_opcode (STRUCTOP_PTR);
  1105. write_exp_string (name);
  1106. write_exp_elt_opcode (STRUCTOP_PTR);
  1107. return 1;
  1108. }
  1109. return 0;
  1110. }
  1111. /* Assuming a reference expression has been pushed, emit the
  1112. STRUCTOP_PTR ops to access the field named NAME. If NAME is a
  1113. qualified name (has '.'), generate a field access for each part. */
  1114. static void
  1115. push_fieldnames (struct stoken name)
  1116. {
  1117. int i;
  1118. struct stoken token;
  1119. token.ptr = name.ptr;
  1120. for (i = 0; ; i++)
  1121. {
  1122. if (i == name.length || name.ptr[i] == '.')
  1123. {
  1124. /* token.ptr is start of current field name. */
  1125. token.length = &name.ptr[i] - token.ptr;
  1126. write_exp_elt_opcode (STRUCTOP_PTR);
  1127. write_exp_string (token);
  1128. write_exp_elt_opcode (STRUCTOP_PTR);
  1129. token.ptr += token.length + 1;
  1130. }
  1131. if (i >= name.length)
  1132. break;
  1133. }
  1134. }
  1135. /* Helper routine for push_expression_name.
  1136. Handle a qualified name, where DOT_INDEX is the index of the first '.' */
  1137. static void
  1138. push_qualified_expression_name (struct stoken name, int dot_index)
  1139. {
  1140. struct stoken token;
  1141. char *tmp;
  1142. struct type *typ;
  1143. token.ptr = name.ptr;
  1144. token.length = dot_index;
  1145. if (push_variable (token))
  1146. {
  1147. token.ptr = name.ptr + dot_index + 1;
  1148. token.length = name.length - dot_index - 1;
  1149. push_fieldnames (token);
  1150. return;
  1151. }
  1152. token.ptr = name.ptr;
  1153. for (;;)
  1154. {
  1155. token.length = dot_index;
  1156. tmp = copy_name (token);
  1157. typ = java_lookup_class (tmp);
  1158. if (typ != NULL)
  1159. {
  1160. if (dot_index == name.length)
  1161. {
  1162. write_exp_elt_opcode(OP_TYPE);
  1163. write_exp_elt_type(typ);
  1164. write_exp_elt_opcode(OP_TYPE);
  1165. return;
  1166. }
  1167. dot_index++; /* Skip '.' */
  1168. name.ptr += dot_index;
  1169. name.length -= dot_index;
  1170. dot_index = 0;
  1171. while (dot_index < name.length && name.ptr[dot_index] != '.')
  1172. dot_index++;
  1173. token.ptr = name.ptr;
  1174. token.length = dot_index;
  1175. write_exp_elt_opcode (OP_SCOPE);
  1176. write_exp_elt_type (typ);
  1177. write_exp_string (token);
  1178. write_exp_elt_opcode (OP_SCOPE);
  1179. if (dot_index < name.length)
  1180. {
  1181. dot_index++;
  1182. name.ptr += dot_index;
  1183. name.length -= dot_index;
  1184. push_fieldnames (name);
  1185. }
  1186. return;
  1187. }
  1188. else if (dot_index >= name.length)
  1189. break;
  1190. dot_index++; /* Skip '.' */
  1191. while (dot_index < name.length && name.ptr[dot_index] != '.')
  1192. dot_index++;
  1193. }
  1194. error (_("unknown type `%.*s'"), name.length, name.ptr);
  1195. }
  1196. /* Handle Name in an expression (or LHS).
  1197. Handle VAR, TYPE, TYPE.FIELD1....FIELDN and VAR.FIELD1....FIELDN. */
  1198. static void
  1199. push_expression_name (struct stoken name)
  1200. {
  1201. char *tmp;
  1202. struct type *typ;
  1203. int i;
  1204. for (i = 0; i < name.length; i++)
  1205. {
  1206. if (name.ptr[i] == '.')
  1207. {
  1208. /* It's a Qualified Expression Name. */
  1209. push_qualified_expression_name (name, i);
  1210. return;
  1211. }
  1212. }
  1213. /* It's a Simple Expression Name. */
  1214. if (push_variable (name))
  1215. return;
  1216. tmp = copy_name (name);
  1217. typ = java_lookup_class (tmp);
  1218. if (typ != NULL)
  1219. {
  1220. write_exp_elt_opcode(OP_TYPE);
  1221. write_exp_elt_type(typ);
  1222. write_exp_elt_opcode(OP_TYPE);
  1223. }
  1224. else
  1225. {
  1226. struct minimal_symbol *msymbol;
  1227. msymbol = lookup_minimal_symbol (tmp, NULL, NULL);
  1228. if (msymbol != NULL)
  1229. write_exp_msymbol (msymbol);
  1230. else if (!have_full_symbols () && !have_partial_symbols ())
  1231. error (_("No symbol table is loaded. Use the \"file\" command"));
  1232. else
  1233. error (_("No symbol \"%s\" in current context"), tmp);
  1234. }
  1235. }
  1236. /* The following two routines, copy_exp and insert_exp, aren't specific to
  1237. Java, so they could go in parse.c, but their only purpose is to support
  1238. the parsing kludges we use in this file, so maybe it's best to isolate
  1239. them here. */
  1240. /* Copy the expression whose last element is at index ENDPOS - 1 in EXPR
  1241. into a freshly malloc'ed struct expression. Its language_defn is set
  1242. to null. */
  1243. static struct expression *
  1244. copy_exp (struct expression *expr, int endpos)
  1245. {
  1246. int len = length_of_subexp (expr, endpos);
  1247. struct expression *new
  1248. = (struct expression *) malloc (sizeof (*new) + EXP_ELEM_TO_BYTES (len));
  1249. new->nelts = len;
  1250. memcpy (new->elts, expr->elts + endpos - len, EXP_ELEM_TO_BYTES (len));
  1251. new->language_defn = 0;
  1252. return new;
  1253. }
  1254. /* Insert the expression NEW into the current expression (expout) at POS. */
  1255. static void
  1256. insert_exp (int pos, struct expression *new)
  1257. {
  1258. int newlen = new->nelts;
  1259. /* Grow expout if necessary. In this function's only use at present,
  1260. this should never be necessary. */
  1261. if (expout_ptr + newlen > expout_size)
  1262. {
  1263. expout_size = max (expout_size * 2, expout_ptr + newlen + 10);
  1264. expout = (struct expression *)
  1265. realloc ((char *) expout, (sizeof (struct expression)
  1266. + EXP_ELEM_TO_BYTES (expout_size)));
  1267. }
  1268. {
  1269. int i;
  1270. for (i = expout_ptr - 1; i >= pos; i--)
  1271. expout->elts[i + newlen] = expout->elts[i];
  1272. }
  1273. memcpy (expout->elts + pos, new->elts, EXP_ELEM_TO_BYTES (newlen));
  1274. expout_ptr += newlen;
  1275. }