Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Chill language support routines for GDB, the GNU debugger. |
2 | Copyright 1992, 1995, 1996 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
20 | #include "defs.h" | |
21 | #include "symtab.h" | |
22 | #include "gdbtypes.h" | |
23 | #include "value.h" | |
24 | #include "expression.h" | |
25 | #include "parser-defs.h" | |
26 | #include "language.h" | |
27 | #include "ch-lang.h" | |
28 | ||
392a587b JM |
29 | extern void _initialize_chill_language PARAMS ((void)); |
30 | ||
c906108c SS |
31 | static value_ptr |
32 | evaluate_subexp_chill PARAMS ((struct type *, struct expression *, int *, enum noside)); | |
33 | ||
34 | static value_ptr | |
35 | value_chill_max_min PARAMS ((enum exp_opcode, value_ptr)); | |
36 | ||
37 | static value_ptr | |
38 | value_chill_card PARAMS ((value_ptr)); | |
39 | ||
40 | static value_ptr | |
41 | value_chill_length PARAMS ((value_ptr)); | |
42 | ||
43 | static struct type * | |
44 | chill_create_fundamental_type PARAMS ((struct objfile *, int)); | |
45 | ||
46 | static void | |
47 | chill_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses)); | |
48 | ||
49 | static void | |
50 | chill_printchar PARAMS ((int, GDB_FILE *)); | |
51 | ||
52 | /* For now, Chill uses a simple mangling algorithm whereby you simply | |
53 | discard everything after the occurance of two successive CPLUS_MARKER | |
54 | characters to derive the demangled form. */ | |
55 | ||
56 | char * | |
57 | chill_demangle (mangled) | |
58 | const char *mangled; | |
59 | { | |
60 | const char *joiner = NULL; | |
61 | char *demangled; | |
62 | const char *cp = mangled; | |
63 | ||
64 | while (*cp) | |
65 | { | |
66 | if (is_cplus_marker (*cp)) | |
67 | { | |
68 | joiner = cp; | |
69 | break; | |
70 | } | |
71 | cp++; | |
72 | } | |
73 | if (joiner != NULL && *(joiner + 1) == *joiner) | |
74 | { | |
75 | demangled = savestring (mangled, joiner - mangled); | |
76 | } | |
77 | else | |
78 | { | |
79 | demangled = NULL; | |
80 | } | |
81 | return (demangled); | |
82 | } | |
83 | ||
84 | static void | |
85 | chill_printchar (c, stream) | |
86 | register int c; | |
87 | GDB_FILE *stream; | |
88 | { | |
89 | c &= 0xFF; /* Avoid sign bit follies */ | |
90 | ||
91 | if (PRINT_LITERAL_FORM (c)) | |
92 | { | |
93 | if (c == '\'' || c == '^') | |
94 | fprintf_filtered (stream, "'%c%c'", c, c); | |
95 | else | |
96 | fprintf_filtered (stream, "'%c'", c); | |
97 | } | |
98 | else | |
99 | { | |
100 | fprintf_filtered (stream, "'^(%u)'", (unsigned int) c); | |
101 | } | |
102 | } | |
103 | ||
104 | /* Print the character string STRING, printing at most LENGTH characters. | |
105 | Printing stops early if the number hits print_max; repeat counts | |
106 | are printed as appropriate. Print ellipses at the end if we | |
107 | had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. | |
108 | Note that gdb maintains the length of strings without counting the | |
109 | terminating null byte, while chill strings are typically written with | |
110 | an explicit null byte. So we always assume an implied null byte | |
111 | until gdb is able to maintain non-null terminated strings as well | |
112 | as null terminated strings (FIXME). | |
113 | */ | |
114 | ||
115 | static void | |
116 | chill_printstr (stream, string, length, width, force_ellipses) | |
117 | GDB_FILE *stream; | |
118 | char *string; | |
119 | unsigned int length; | |
120 | int width; | |
121 | int force_ellipses; | |
122 | { | |
123 | register unsigned int i; | |
124 | unsigned int things_printed = 0; | |
125 | int in_literal_form = 0; | |
126 | int in_control_form = 0; | |
127 | int need_slashslash = 0; | |
128 | unsigned int c; | |
129 | extern int repeat_count_threshold; | |
130 | extern int print_max; | |
131 | ||
132 | if (length == 0) | |
133 | { | |
134 | fputs_filtered ("\"\"", stream); | |
135 | return; | |
136 | } | |
137 | ||
138 | for (i = 0; i < length && things_printed < print_max; ++i) | |
139 | { | |
140 | /* Position of the character we are examining | |
141 | to see whether it is repeated. */ | |
142 | unsigned int rep1; | |
143 | /* Number of repetitions we have detected so far. */ | |
144 | unsigned int reps; | |
145 | ||
146 | QUIT; | |
147 | ||
148 | if (need_slashslash) | |
149 | { | |
150 | fputs_filtered ("//", stream); | |
151 | need_slashslash = 0; | |
152 | } | |
153 | ||
154 | rep1 = i + 1; | |
155 | reps = 1; | |
156 | while (rep1 < length && string[rep1] == string[i]) | |
157 | { | |
158 | ++rep1; | |
159 | ++reps; | |
160 | } | |
161 | ||
162 | c = string[i]; | |
163 | if (reps > repeat_count_threshold) | |
164 | { | |
165 | if (in_control_form || in_literal_form) | |
166 | { | |
167 | if (in_control_form) | |
168 | fputs_filtered (")", stream); | |
169 | fputs_filtered ("\"//", stream); | |
170 | in_control_form = in_literal_form = 0; | |
171 | } | |
172 | chill_printchar (c, stream); | |
173 | fprintf_filtered (stream, "<repeats %u times>", reps); | |
174 | i = rep1 - 1; | |
175 | things_printed += repeat_count_threshold; | |
176 | need_slashslash = 1; | |
177 | } | |
178 | else | |
179 | { | |
180 | if (! in_literal_form && ! in_control_form) | |
181 | fputs_filtered ("\"", stream); | |
182 | if (PRINT_LITERAL_FORM (c)) | |
183 | { | |
184 | if (!in_literal_form) | |
185 | { | |
186 | if (in_control_form) | |
187 | { | |
188 | fputs_filtered (")", stream); | |
189 | in_control_form = 0; | |
190 | } | |
191 | in_literal_form = 1; | |
192 | } | |
193 | fprintf_filtered (stream, "%c", c); | |
194 | if (c == '"' || c == '^') | |
195 | /* duplicate this one as must be done at input */ | |
196 | fprintf_filtered (stream, "%c", c); | |
197 | } | |
198 | else | |
199 | { | |
200 | if (!in_control_form) | |
201 | { | |
202 | if (in_literal_form) | |
203 | { | |
204 | in_literal_form = 0; | |
205 | } | |
206 | fputs_filtered ("^(", stream); | |
207 | in_control_form = 1; | |
208 | } | |
209 | else | |
210 | fprintf_filtered (stream, ","); | |
211 | c = c & 0xff; | |
212 | fprintf_filtered (stream, "%u", (unsigned int) c); | |
213 | } | |
214 | ++things_printed; | |
215 | } | |
216 | } | |
217 | ||
218 | /* Terminate the quotes if necessary. */ | |
219 | if (in_control_form) | |
220 | { | |
221 | fputs_filtered (")", stream); | |
222 | } | |
223 | if (in_literal_form || in_control_form) | |
224 | { | |
225 | fputs_filtered ("\"", stream); | |
226 | } | |
227 | if (force_ellipses || (i < length)) | |
228 | { | |
229 | fputs_filtered ("...", stream); | |
230 | } | |
231 | } | |
232 | ||
233 | static struct type * | |
234 | chill_create_fundamental_type (objfile, typeid) | |
235 | struct objfile *objfile; | |
236 | int typeid; | |
237 | { | |
238 | register struct type *type = NULL; | |
239 | ||
240 | switch (typeid) | |
241 | { | |
242 | default: | |
243 | /* FIXME: For now, if we are asked to produce a type not in this | |
244 | language, create the equivalent of a C integer type with the | |
245 | name "<?type?>". When all the dust settles from the type | |
246 | reconstruction work, this should probably become an error. */ | |
247 | type = init_type (TYPE_CODE_INT, 2, 0, "<?type?>", objfile); | |
248 | warning ("internal error: no chill fundamental type %d", typeid); | |
249 | break; | |
250 | case FT_VOID: | |
251 | /* FIXME: Currently the GNU Chill compiler emits some DWARF entries for | |
252 | typedefs, unrelated to anything directly in the code being compiled, | |
253 | that have some FT_VOID types. Just fake it for now. */ | |
254 | type = init_type (TYPE_CODE_VOID, 0, 0, "<?VOID?>", objfile); | |
255 | break; | |
256 | case FT_BOOLEAN: | |
257 | type = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED, "BOOL", objfile); | |
258 | break; | |
259 | case FT_CHAR: | |
260 | type = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED, "CHAR", objfile); | |
261 | break; | |
262 | case FT_SIGNED_CHAR: | |
263 | type = init_type (TYPE_CODE_INT, 1, 0, "BYTE", objfile); | |
264 | break; | |
265 | case FT_UNSIGNED_CHAR: | |
266 | type = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, "UBYTE", objfile); | |
267 | break; | |
268 | case FT_SHORT: /* Chill ints are 2 bytes */ | |
269 | type = init_type (TYPE_CODE_INT, 2, 0, "INT", objfile); | |
270 | break; | |
271 | case FT_UNSIGNED_SHORT: /* Chill ints are 2 bytes */ | |
272 | type = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, "UINT", objfile); | |
273 | break; | |
274 | case FT_INTEGER: /* FIXME? */ | |
275 | case FT_SIGNED_INTEGER: /* FIXME? */ | |
276 | case FT_LONG: /* Chill longs are 4 bytes */ | |
277 | case FT_SIGNED_LONG: /* Chill longs are 4 bytes */ | |
278 | type = init_type (TYPE_CODE_INT, 4, 0, "LONG", objfile); | |
279 | break; | |
280 | case FT_UNSIGNED_INTEGER: /* FIXME? */ | |
281 | case FT_UNSIGNED_LONG: /* Chill longs are 4 bytes */ | |
282 | type = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, "ULONG", objfile); | |
283 | break; | |
284 | case FT_FLOAT: | |
285 | type = init_type (TYPE_CODE_FLT, 4, 0, "REAL", objfile); | |
286 | break; | |
287 | case FT_DBL_PREC_FLOAT: | |
288 | type = init_type (TYPE_CODE_FLT, 8, 0, "LONG_REAL", objfile); | |
289 | break; | |
290 | } | |
291 | return (type); | |
292 | } | |
293 | ||
294 | \f | |
295 | /* Table of operators and their precedences for printing expressions. */ | |
296 | ||
297 | static const struct op_print chill_op_print_tab[] = { | |
298 | {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, | |
299 | {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, | |
300 | {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, | |
301 | {"MOD", BINOP_MOD, PREC_MUL, 0}, | |
302 | {"REM", BINOP_REM, PREC_MUL, 0}, | |
303 | {"SIZE",UNOP_SIZEOF, PREC_BUILTIN_FUNCTION, 0}, | |
304 | {"LOWER",UNOP_LOWER, PREC_BUILTIN_FUNCTION, 0}, | |
305 | {"UPPER",UNOP_UPPER, PREC_BUILTIN_FUNCTION, 0}, | |
306 | {"CARD",UNOP_CARD, PREC_BUILTIN_FUNCTION, 0}, | |
307 | {"MAX",UNOP_CHMAX, PREC_BUILTIN_FUNCTION, 0}, | |
308 | {"MIN",UNOP_CHMIN, PREC_BUILTIN_FUNCTION, 0}, | |
309 | {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, | |
310 | {"=", BINOP_EQUAL, PREC_EQUAL, 0}, | |
311 | {"/=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, | |
312 | {"<=", BINOP_LEQ, PREC_ORDER, 0}, | |
313 | {">=", BINOP_GEQ, PREC_ORDER, 0}, | |
314 | {">", BINOP_GTR, PREC_ORDER, 0}, | |
315 | {"<", BINOP_LESS, PREC_ORDER, 0}, | |
316 | {"+", BINOP_ADD, PREC_ADD, 0}, | |
317 | {"-", BINOP_SUB, PREC_ADD, 0}, | |
318 | {"*", BINOP_MUL, PREC_MUL, 0}, | |
319 | {"/", BINOP_DIV, PREC_MUL, 0}, | |
320 | {"//", BINOP_CONCAT, PREC_PREFIX, 0}, /* FIXME: precedence? */ | |
321 | {"-", UNOP_NEG, PREC_PREFIX, 0}, | |
322 | {"->", UNOP_IND, PREC_SUFFIX, 1}, | |
323 | {"->", UNOP_ADDR, PREC_PREFIX, 0}, | |
324 | {":", BINOP_RANGE, PREC_ASSIGN, 0}, | |
325 | {NULL, 0, 0, 0} | |
326 | }; | |
327 | \f | |
328 | /* The built-in types of Chill. */ | |
329 | ||
330 | struct type *builtin_type_chill_bool; | |
331 | struct type *builtin_type_chill_char; | |
332 | struct type *builtin_type_chill_long; | |
333 | struct type *builtin_type_chill_ulong; | |
334 | struct type *builtin_type_chill_real; | |
335 | ||
336 | struct type ** CONST_PTR (chill_builtin_types[]) = | |
337 | { | |
338 | &builtin_type_chill_bool, | |
339 | &builtin_type_chill_char, | |
340 | &builtin_type_chill_long, | |
341 | &builtin_type_chill_ulong, | |
342 | &builtin_type_chill_real, | |
343 | 0 | |
344 | }; | |
345 | ||
346 | /* Calculate LOWER or UPPER of TYPE. | |
347 | Returns the result as an integer. | |
348 | *RESULT_TYPE is the appropriate type for the result. */ | |
349 | ||
350 | LONGEST | |
351 | type_lower_upper (op, type, result_type) | |
352 | enum exp_opcode op; /* Either UNOP_LOWER or UNOP_UPPER */ | |
353 | struct type *type; | |
354 | struct type **result_type; | |
355 | { | |
356 | LONGEST low, high; | |
357 | *result_type = type; | |
358 | CHECK_TYPEDEF (type); | |
359 | switch (TYPE_CODE (type)) | |
360 | { | |
361 | case TYPE_CODE_STRUCT: | |
362 | *result_type = builtin_type_int; | |
363 | if (chill_varying_type (type)) | |
364 | return type_lower_upper (op, TYPE_FIELD_TYPE (type, 1), result_type); | |
365 | break; | |
366 | case TYPE_CODE_ARRAY: | |
367 | case TYPE_CODE_BITSTRING: | |
368 | case TYPE_CODE_STRING: | |
369 | type = TYPE_FIELD_TYPE (type, 0); /* Get index type */ | |
370 | ||
371 | /* ... fall through ... */ | |
372 | case TYPE_CODE_RANGE: | |
373 | *result_type = TYPE_TARGET_TYPE (type); | |
374 | return op == UNOP_LOWER ? TYPE_LOW_BOUND (type) : TYPE_HIGH_BOUND (type); | |
375 | ||
376 | case TYPE_CODE_ENUM: | |
377 | case TYPE_CODE_BOOL: | |
378 | case TYPE_CODE_INT: | |
379 | case TYPE_CODE_CHAR: | |
380 | if (get_discrete_bounds (type, &low, &high) >= 0) | |
381 | { | |
382 | *result_type = type; | |
383 | return op == UNOP_LOWER ? low : high; | |
384 | } | |
385 | break; | |
386 | case TYPE_CODE_UNDEF: | |
387 | case TYPE_CODE_PTR: | |
388 | case TYPE_CODE_UNION: | |
389 | case TYPE_CODE_FUNC: | |
390 | case TYPE_CODE_FLT: | |
391 | case TYPE_CODE_VOID: | |
392 | case TYPE_CODE_SET: | |
393 | case TYPE_CODE_ERROR: | |
394 | case TYPE_CODE_MEMBER: | |
395 | case TYPE_CODE_METHOD: | |
396 | case TYPE_CODE_REF: | |
397 | case TYPE_CODE_COMPLEX: | |
398 | default: | |
399 | break; | |
400 | } | |
401 | error ("unknown mode for LOWER/UPPER builtin"); | |
402 | } | |
403 | ||
404 | static value_ptr | |
405 | value_chill_length (val) | |
406 | value_ptr val; | |
407 | { | |
408 | LONGEST tmp; | |
409 | struct type *type = VALUE_TYPE (val); | |
410 | struct type *ttype; | |
411 | CHECK_TYPEDEF (type); | |
412 | switch (TYPE_CODE (type)) | |
413 | { | |
414 | case TYPE_CODE_ARRAY: | |
415 | case TYPE_CODE_BITSTRING: | |
416 | case TYPE_CODE_STRING: | |
417 | tmp = type_lower_upper (UNOP_UPPER, type, &ttype) | |
418 | - type_lower_upper (UNOP_LOWER, type, &ttype) + 1; | |
419 | break; | |
420 | case TYPE_CODE_STRUCT: | |
421 | if (chill_varying_type (type)) | |
422 | { | |
423 | tmp = unpack_long (TYPE_FIELD_TYPE (type, 0), VALUE_CONTENTS (val)); | |
424 | break; | |
425 | } | |
426 | /* ... else fall through ... */ | |
427 | default: | |
428 | error ("bad argument to LENGTH builtin"); | |
429 | } | |
430 | return value_from_longest (builtin_type_int, tmp); | |
431 | } | |
432 | ||
433 | static value_ptr | |
434 | value_chill_card (val) | |
435 | value_ptr val; | |
436 | { | |
437 | LONGEST tmp = 0; | |
438 | struct type *type = VALUE_TYPE (val); | |
439 | CHECK_TYPEDEF (type); | |
440 | ||
441 | if (TYPE_CODE (type) == TYPE_CODE_SET) | |
442 | { | |
443 | struct type *range_type = TYPE_INDEX_TYPE (type); | |
444 | LONGEST lower_bound, upper_bound; | |
445 | int i; | |
446 | ||
447 | get_discrete_bounds (range_type, &lower_bound, &upper_bound); | |
448 | for (i = lower_bound; i <= upper_bound; i++) | |
449 | if (value_bit_index (type, VALUE_CONTENTS (val), i) > 0) | |
450 | tmp++; | |
451 | } | |
452 | else | |
453 | error ("bad argument to CARD builtin"); | |
454 | ||
455 | return value_from_longest (builtin_type_int, tmp); | |
456 | } | |
457 | ||
458 | static value_ptr | |
459 | value_chill_max_min (op, val) | |
460 | enum exp_opcode op; | |
461 | value_ptr val; | |
462 | { | |
463 | LONGEST tmp = 0; | |
464 | struct type *type = VALUE_TYPE (val); | |
465 | struct type *elttype; | |
466 | CHECK_TYPEDEF (type); | |
467 | ||
468 | if (TYPE_CODE (type) == TYPE_CODE_SET) | |
469 | { | |
470 | LONGEST lower_bound, upper_bound; | |
471 | int i, empty = 1; | |
472 | ||
473 | elttype = TYPE_INDEX_TYPE (type); | |
474 | CHECK_TYPEDEF (elttype); | |
475 | get_discrete_bounds (elttype, &lower_bound, &upper_bound); | |
476 | ||
477 | if (op == UNOP_CHMAX) | |
478 | { | |
479 | for (i = upper_bound; i >= lower_bound; i--) | |
480 | { | |
481 | if (value_bit_index (type, VALUE_CONTENTS (val), i) > 0) | |
482 | { | |
483 | tmp = i; | |
484 | empty = 0; | |
485 | break; | |
486 | } | |
487 | } | |
488 | } | |
489 | else | |
490 | { | |
491 | for (i = lower_bound; i <= upper_bound; i++) | |
492 | { | |
493 | if (value_bit_index (type, VALUE_CONTENTS (val), i) > 0) | |
494 | { | |
495 | tmp = i; | |
496 | empty = 0; | |
497 | break; | |
498 | } | |
499 | } | |
500 | } | |
501 | if (empty) | |
502 | error ("%s for empty powerset", op == UNOP_CHMAX ? "MAX" : "MIN"); | |
503 | } | |
504 | else | |
505 | error ("bad argument to %s builtin", op == UNOP_CHMAX ? "MAX" : "MIN"); | |
506 | ||
507 | return value_from_longest (TYPE_CODE (elttype) == TYPE_CODE_RANGE | |
508 | ? TYPE_TARGET_TYPE (elttype) | |
509 | : elttype, | |
510 | tmp); | |
511 | } | |
512 | ||
513 | static value_ptr | |
514 | evaluate_subexp_chill (expect_type, exp, pos, noside) | |
515 | struct type *expect_type; | |
516 | register struct expression *exp; | |
517 | register int *pos; | |
518 | enum noside noside; | |
519 | { | |
520 | int pc = *pos; | |
521 | struct type *type; | |
522 | int tem, nargs; | |
523 | value_ptr arg1; | |
524 | value_ptr *argvec; | |
525 | enum exp_opcode op = exp->elts[*pos].opcode; | |
526 | switch (op) | |
527 | { | |
528 | case MULTI_SUBSCRIPT: | |
529 | if (noside == EVAL_SKIP) | |
530 | break; | |
531 | (*pos) += 3; | |
532 | nargs = longest_to_int (exp->elts[pc + 1].longconst); | |
533 | arg1 = evaluate_subexp_with_coercion (exp, pos, noside); | |
534 | type = check_typedef (VALUE_TYPE (arg1)); | |
535 | ||
536 | if (nargs == 1 && TYPE_CODE (type) == TYPE_CODE_INT) | |
537 | { | |
538 | /* Looks like string repetition. */ | |
539 | value_ptr string = evaluate_subexp_with_coercion (exp, pos, noside); | |
540 | return value_concat (arg1, string); | |
541 | } | |
542 | ||
543 | switch (TYPE_CODE (type)) | |
544 | { | |
545 | case TYPE_CODE_PTR: | |
546 | type = check_typedef (TYPE_TARGET_TYPE (type)); | |
547 | if (!type || TYPE_CODE (type) != TYPE_CODE_FUNC) | |
548 | error ("reference value used as function"); | |
549 | /* ... fall through ... */ | |
550 | case TYPE_CODE_FUNC: | |
551 | /* It's a function call. */ | |
552 | if (noside == EVAL_AVOID_SIDE_EFFECTS) | |
553 | break; | |
554 | ||
555 | /* Allocate arg vector, including space for the function to be | |
556 | called in argvec[0] and a terminating NULL */ | |
557 | argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2)); | |
558 | argvec[0] = arg1; | |
559 | tem = 1; | |
560 | for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++) | |
561 | { | |
562 | argvec[tem] | |
563 | = evaluate_subexp_chill (TYPE_FIELD_TYPE (type, tem-1), | |
564 | exp, pos, noside); | |
565 | } | |
566 | for (; tem <= nargs; tem++) | |
567 | argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside); | |
568 | argvec[tem] = 0; /* signal end of arglist */ | |
569 | ||
570 | return call_function_by_hand (argvec[0], nargs, argvec + 1); | |
571 | default: | |
572 | break; | |
573 | } | |
574 | ||
575 | while (nargs-- > 0) | |
576 | { | |
577 | value_ptr index = evaluate_subexp_with_coercion (exp, pos, noside); | |
578 | arg1 = value_subscript (arg1, index); | |
579 | } | |
580 | return (arg1); | |
581 | ||
582 | case UNOP_LOWER: | |
583 | case UNOP_UPPER: | |
584 | (*pos)++; | |
585 | if (noside == EVAL_SKIP) | |
586 | { | |
587 | (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, EVAL_SKIP); | |
588 | goto nosideret; | |
589 | } | |
590 | arg1 = (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, | |
591 | EVAL_AVOID_SIDE_EFFECTS); | |
592 | tem = type_lower_upper (op, VALUE_TYPE (arg1), &type); | |
593 | return value_from_longest (type, tem); | |
594 | ||
595 | case UNOP_LENGTH: | |
596 | (*pos)++; | |
597 | arg1 = (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, noside); | |
598 | return value_chill_length (arg1); | |
599 | ||
600 | case UNOP_CARD: | |
601 | (*pos)++; | |
602 | arg1 = (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, noside); | |
603 | return value_chill_card (arg1); | |
604 | ||
605 | case UNOP_CHMAX: | |
606 | case UNOP_CHMIN: | |
607 | (*pos)++; | |
608 | arg1 = (*exp->language_defn->evaluate_exp) (NULL_TYPE, exp, pos, noside); | |
609 | return value_chill_max_min (op, arg1); | |
610 | ||
611 | case BINOP_COMMA: | |
612 | error ("',' operator used in invalid context"); | |
613 | ||
614 | default: | |
615 | break; | |
616 | } | |
617 | ||
618 | return evaluate_subexp_standard (expect_type, exp, pos, noside); | |
619 | nosideret: | |
620 | return value_from_longest (builtin_type_long, (LONGEST) 1); | |
621 | } | |
622 | ||
623 | const struct language_defn chill_language_defn = { | |
624 | "chill", | |
625 | language_chill, | |
626 | chill_builtin_types, | |
627 | range_check_on, | |
628 | type_check_on, | |
629 | chill_parse, /* parser */ | |
630 | chill_error, /* parser error function */ | |
631 | evaluate_subexp_chill, | |
632 | chill_printchar, /* print a character constant */ | |
633 | chill_printstr, /* function to print a string constant */ | |
634 | NULL, /* Function to print a single char */ | |
635 | chill_create_fundamental_type,/* Create fundamental type in this language */ | |
636 | chill_print_type, /* Print a type using appropriate syntax */ | |
637 | chill_val_print, /* Print a value using appropriate syntax */ | |
638 | chill_value_print, /* Print a top-levl value */ | |
639 | {"", "B'", "", ""}, /* Binary format info */ | |
640 | {"O'%lo", "O'", "o", ""}, /* Octal format info */ | |
641 | {"D'%ld", "D'", "d", ""}, /* Decimal format info */ | |
642 | {"H'%lx", "H'", "x", ""}, /* Hex format info */ | |
643 | chill_op_print_tab, /* expression operators for printing */ | |
644 | 0, /* arrays are first-class (not c-style) */ | |
645 | 0, /* String lower bound */ | |
646 | &builtin_type_chill_char, /* Type of string elements */ | |
647 | LANG_MAGIC | |
648 | }; | |
649 | ||
650 | /* Initialization for Chill */ | |
651 | ||
652 | void | |
653 | _initialize_chill_language () | |
654 | { | |
655 | builtin_type_chill_bool = | |
656 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
657 | TYPE_FLAG_UNSIGNED, | |
658 | "BOOL", (struct objfile *) NULL); | |
659 | builtin_type_chill_char = | |
660 | init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
661 | TYPE_FLAG_UNSIGNED, | |
662 | "CHAR", (struct objfile *) NULL); | |
663 | builtin_type_chill_long = | |
664 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
665 | 0, | |
666 | "LONG", (struct objfile *) NULL); | |
667 | builtin_type_chill_ulong = | |
668 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
669 | TYPE_FLAG_UNSIGNED, | |
670 | "ULONG", (struct objfile *) NULL); | |
671 | builtin_type_chill_real = | |
672 | init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, | |
673 | 0, | |
674 | "LONG_REAL", (struct objfile *) NULL); | |
675 | ||
676 | add_language (&chill_language_defn); | |
677 | } |