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