#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
+#ifdef __GNUC__
+#define INLINE __inline__
+#endif
+
typedef union
{
LONGEST lval;
- unsigned LONGEST ulval;
+ ULONGEST ulval;
struct {
LONGEST val;
struct type *type;
};
/* Forward declarations. */
-static void parse_expr ();
-static void parse_primval ();
-static void parse_untyped_expr ();
-static int parse_opt_untyped_expr ();
-static void parse_if_expression_body PARAMS((void));
+
static void write_lower_upper_value PARAMS ((enum exp_opcode, struct type *));
-static enum ch_terminal ch_lex ();
-static void calculate_array_length PARAMS ((struct type *));
+static enum ch_terminal match_bitstring_literal PARAMS ((void));
+static enum ch_terminal match_integer_literal PARAMS ((void));
+static enum ch_terminal match_character_literal PARAMS ((void));
+static enum ch_terminal match_string_literal PARAMS ((void));
+static enum ch_terminal match_float_literal PARAMS ((void));
+static enum ch_terminal match_float_literal PARAMS ((void));
+static int decode_integer_literal PARAMS ((LONGEST *, char **));
+static int decode_integer_value PARAMS ((int, char **, LONGEST *));
+static char *match_simple_name_string PARAMS ((void));
+static void growbuf_by_size PARAMS ((int));
+static void parse_untyped_expr PARAMS ((void));
+static void parse_if_expression PARAMS ((void));
+static void parse_else_alternative PARAMS ((void));
+static void parse_then_alternative PARAMS ((void));
+static void parse_expr PARAMS ((void));
+static void parse_operand0 PARAMS ((void));
+static void parse_operand1 PARAMS ((void));
+static void parse_operand2 PARAMS ((void));
+static void parse_operand3 PARAMS ((void));
+static void parse_operand4 PARAMS ((void));
+static void parse_operand5 PARAMS ((void));
+static void parse_operand6 PARAMS ((void));
+static void parse_primval PARAMS ((void));
+static void parse_tuple PARAMS ((struct type *));
+static void parse_opt_element_list PARAMS ((struct type *));
+static void parse_tuple_element PARAMS ((struct type *));
+static void parse_named_record_element PARAMS ((void));
+static void parse_call PARAMS ((void));
+static struct type *parse_mode_or_normal_call PARAMS ((void));
+#if 0
+static struct type *parse_mode_call PARAMS ((void));
+#endif
+static void parse_unary_call PARAMS ((void));
+static int parse_opt_untyped_expr PARAMS ((void));
+static void parse_case_label PARAMS ((void));
+static int expect PARAMS ((enum ch_terminal, char *));
+static void parse_expr PARAMS ((void));
+static void parse_primval PARAMS ((void));
+static void parse_untyped_expr PARAMS ((void));
+static int parse_opt_untyped_expr PARAMS ((void));
+static void parse_if_expression_body PARAMS((void));
+static enum ch_terminal ch_lex PARAMS ((void));
+INLINE static enum ch_terminal PEEK_TOKEN PARAMS ((void));
+static enum ch_terminal peek_token_ PARAMS ((int));
+static void forward_token_ PARAMS ((void));
+static void require PARAMS ((enum ch_terminal));
+static int check_token PARAMS ((enum ch_terminal));
#define MAX_LOOK_AHEAD 2
static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD+1] = {
/*int current_token, lookahead_token;*/
-#ifdef __GNUC__
-__inline__
-#endif
-static enum ch_terminal
+INLINE static enum ch_terminal
PEEK_TOKEN()
{
if (terminal_buffer[0] == TOKEN_NOT_READ)
/* Skip the next token.
if it isn't TOKEN, the parser is broken. */
-void
+static void
require(token)
enum ch_terminal token;
{
FORWARD_TOKEN();
}
-int
+static int
check_token (token)
enum ch_terminal token;
{
/* return 0 if expected token was not found,
else return 1.
*/
-int
-expect(token, message)
+static int
+expect (token, message)
enum ch_terminal token;
char *message;
{
/* Parse NAME '(' MODENAME ')'. */
-struct type *
+#if 0
+
+static struct type *
parse_mode_call ()
{
struct type *type;
return type;
}
-struct type *
+#endif
+
+static struct type *
parse_mode_or_normal_call ()
{
struct type *type;
parse_named_record_element ()
{
struct stoken label;
+ char buf[256];
label = PEEK_LVAL ().sval;
- expect (FIELD_NAME, "expected a field name here `%s'", lexptr);
+ sprintf (buf, "expected a field name here `%s'", lexptr);
+ expect (FIELD_NAME, buf);
if (check_token (','))
parse_named_record_element ();
else if (check_token (':'))
write_exp_elt_opcode (OP_LABELED);
}
-/* Returns one or nore TREE_LIST nodes, in reverse order. */
+/* Returns one or more TREE_LIST nodes, in reverse order. */
static void
-parse_tuple_element ()
+parse_tuple_element (type)
+ struct type *type;
{
if (PEEK_TOKEN () == FIELD_NAME)
{
if (check_token ('*'))
{
expect (')', "missing ')' after '*' case label list");
- error ("(*) not implemented in case label list");
+ if (type)
+ {
+ if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+ {
+ /* do this as a range from low to high */
+ struct type *range_type = TYPE_FIELD_TYPE (type, 0);
+ LONGEST low_bound, high_bound;
+ if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
+ error ("cannot determine bounds for (*)");
+ /* lower bound */
+ write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (range_type);
+ write_exp_elt_longcst (low_bound);
+ write_exp_elt_opcode (OP_LONG);
+ /* upper bound */
+ write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (range_type);
+ write_exp_elt_longcst (high_bound);
+ write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (BINOP_RANGE);
+ }
+ else
+ error ("(*) in invalid context");
+ }
+ else
+ error ("(*) only possible with modename in front of tuple (mode[..])");
}
else
{
/* Matches: a COMMA-separated list of tuple elements.
Returns a list (of TREE_LIST nodes). */
static void
-parse_opt_element_list ()
+parse_opt_element_list (type)
+ struct type *type;
{
arglist_len = 0;
if (PEEK_TOKEN () == ']')
return;
for (;;)
{
- parse_tuple_element ();
+ parse_tuple_element (type);
arglist_len++;
if (PEEK_TOKEN () == ']')
break;
parse_tuple (mode)
struct type *mode;
{
+ struct type *type;
+ if (mode)
+ type = check_typedef (mode);
+ else
+ type = 0;
require ('[');
start_arglist ();
- parse_opt_element_list ();
+ parse_opt_element_list (type);
expect (']', "missing ']' after tuple");
write_exp_elt_opcode (OP_ARRAY);
write_exp_elt_longcst ((LONGEST) 0);
write_exp_elt_longcst ((LONGEST) end_arglist () - 1);
write_exp_elt_opcode (OP_ARRAY);
- if (mode)
+ if (type)
{
- struct type *type = check_typedef (mode);
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
&& TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_SET)
break;
case GENERAL_PROCEDURE_NAME:
case LOCATION_NAME:
- {
- struct type *type;
-
- /* FIXME: look at calculate_array_length */
- type = PEEK_LVAL().ssym.sym->type;
- if (type && TYPE_CODE (type) == TYPE_CODE_ARRAY &&
- TYPE_LENGTH (type) == 0)
- calculate_array_length (type);
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
- FORWARD_TOKEN ();
- }
+ write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (NULL);
+ write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
+ write_exp_elt_opcode (OP_VAR_VALUE);
+ FORWARD_TOKEN ();
break;
case GDB_VARIABLE: /* gdb specific */
FORWARD_TOKEN ();
write_exp_elt_opcode (opcode);
else
{
- extern LONGEST type_lower_upper ();
struct type *result_type;
LONGEST val = type_lower_upper (opcode, type, &result_type);
write_exp_elt_opcode (OP_LONG);
}
}
-/* In certain cases it could happen, that an array type doesn't
- have a length (this have to do with seizing). The reason is
- shown in the following stabs:
-
- .stabs "m_x:Tt81=s36i:1,0,32;ar:82=ar80;0;1;83=xsm_struct:,32,256;;",128,0,25,0
-
- .stabs "m_struct:Tt83=s16f1:9,0,16;f2:85=*84,32,32;f3:84,64,64;;",128,0,10,0
-
- When processing t81, the array ar80 doesn't have a length, cause
- struct m_struct is specified extern at thse moment. Afterwards m_struct
- gets specified and updated, but not the surrounding type.
-
- So we walk through array's till we find a type with a length and
- calculate the array length.
-
- FIXME: Where may this happen too ?
- */
-
-static void
-calculate_array_length (type)
- struct type *type;
-{
- struct type *target_type;
- struct type *range_type;
- LONGEST lower_bound, upper_bound;
-
- if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
- /* not an array, stop processing */
- return;
-
- target_type = TYPE_TARGET_TYPE (type);
- range_type = TYPE_FIELD_TYPE (type, 0);
- lower_bound = TYPE_FIELD_BITPOS (range_type, 0);
- upper_bound = TYPE_FIELD_BITPOS (range_type, 1);
-
- if (TYPE_LENGTH (target_type) == 0 &&
- TYPE_CODE (target_type) == TYPE_CODE_ARRAY)
- /* we've got another array */
- calculate_array_length (target_type);
-
- TYPE_LENGTH (type) = (upper_bound - lower_bound + 1) * TYPE_LENGTH (target_type);
-}
-
void
chill_error (msg)
char *msg;