|
|
1.1 ! root 1: /* Definitions for expressions stored in reversed prefix form, for GDB. ! 2: Copyright (C) 1986 Free Software Foundation, Inc. ! 3: ! 4: GDB is distributed in the hope that it will be useful, but WITHOUT ANY ! 5: WARRANTY. No author or distributor accepts responsibility to anyone ! 6: for the consequences of using it or for whether it serves any ! 7: particular purpose or works at all, unless he says so in writing. ! 8: Refer to the GDB General Public License for full details. ! 9: ! 10: Everyone is granted permission to copy, modify and redistribute GDB, ! 11: but only under the conditions described in the GDB General Public ! 12: License. A copy of this license is supposed to have been given to you ! 13: along with GDB so you can know your rights and responsibilities. It ! 14: should be in a file named COPYING. Among other things, the copyright ! 15: notice and this notice must be preserved on all copies. ! 16: ! 17: In other words, go ahead and share GDB, but don't try to stop ! 18: anyone else from sharing it farther. Help stamp out software hoarding! ! 19: */ ! 20: ! 21: /* Definitions for saved C expressions. */ ! 22: ! 23: /* An expression is represented as a vector of union exp_element's. ! 24: Each exp_element is an opcode, except that some opcodes cause ! 25: the following exp_element to be treated as a long or double constant ! 26: or as a variable. The opcodes are obeyed, using a stack for temporaries. ! 27: The value is left on the temporary stack at the end. */ ! 28: ! 29: /* When it is necessary to include a string, ! 30: it can occupy as many exp_elements as it needs. ! 31: We find the length of the string using strlen, ! 32: divide to find out how many exp_elements are used up, ! 33: and skip that many. Strings, like numbers, are indicated ! 34: by the preceding opcode. */ ! 35: ! 36: enum exp_opcode ! 37: { ! 38: /* BINOP_... operate on two values computed by following subexpressions, ! 39: replacing them by one result value. They take no immediate arguments. */ ! 40: BINOP_ADD, /* + */ ! 41: BINOP_SUB, /* - */ ! 42: BINOP_MUL, /* * */ ! 43: BINOP_DIV, /* / */ ! 44: BINOP_REM, /* % */ ! 45: BINOP_LSH, /* << */ ! 46: BINOP_RSH, /* >> */ ! 47: BINOP_AND, /* && */ ! 48: BINOP_OR, /* || */ ! 49: BINOP_LOGAND, /* & */ ! 50: BINOP_LOGIOR, /* | */ ! 51: BINOP_LOGXOR, /* ^ */ ! 52: BINOP_EQUAL, /* == */ ! 53: BINOP_NOTEQUAL, /* != */ ! 54: BINOP_LESS, /* < */ ! 55: BINOP_GTR, /* > */ ! 56: BINOP_LEQ, /* <= */ ! 57: BINOP_GEQ, /* >= */ ! 58: BINOP_REPEAT, /* @ */ ! 59: BINOP_ASSIGN, /* = */ ! 60: BINOP_COMMA, /* , */ ! 61: BINOP_SUBSCRIPT, /* x[y] */ ! 62: BINOP_EXP, /* Exponentiation */ ! 63: BINOP_END, ! 64: ! 65: BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on. ! 66: The following exp_element is another opcode, ! 67: a BINOP_, saying how to modify. ! 68: Then comes another BINOP_ASSIGN_MODIFY, ! 69: making three exp_elements in total. */ ! 70: ! 71: /* Operates on three values computed by following subexpressions. */ ! 72: TERNOP_COND, /* ?: */ ! 73: ! 74: /* The OP_... series take immediate following arguments. ! 75: After the arguments come another OP_... (the same one) ! 76: so that the grouping can be recognized from the end. */ ! 77: ! 78: /* OP_LONG is followed by a type pointer in the next exp_element ! 79: and the long constant value in the following exp_element. ! 80: Then comes another OP_LONG. ! 81: Thus, the operation occupies four exp_elements. */ ! 82: ! 83: OP_LONG, ! 84: /* OP_DOUBLE is similar but takes a double constant instead of a long one. */ ! 85: OP_DOUBLE, ! 86: /* OP_VAR_VALUE takes one struct symbol * in the following exp_element, ! 87: followed by another OP_VAR_VALUE, making three exp_elements. */ ! 88: OP_VAR_VALUE, ! 89: /* OP_LAST is followed by an integer in the next exp_element. ! 90: The integer is zero for the last value printed, ! 91: or it is the absolute number of a history element. ! 92: With another OP_LAST at the end, this makes three exp_elements. */ ! 93: OP_LAST, ! 94: /* OP_REGISTER is followed by an integer in the next exp_element. ! 95: This is the number of a register to fetch (as an int). ! 96: With another OP_REGISTER at the end, this makes three exp_elements. */ ! 97: OP_REGISTER, ! 98: /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element. ! 99: With another OP_INTERNALVAR at the end, this makes three exp_elements. */ ! 100: OP_INTERNALVAR, ! 101: /* OP_FUNCALL is followed by an integer in the next exp_element. ! 102: The integer is the number of args to the function call. ! 103: That many plus one values from following subexpressions ! 104: are used, the first one being the function. ! 105: The integer is followed by a repeat of OP_FUNCALL, ! 106: making three exp_elements. */ ! 107: OP_FUNCALL, ! 108: /* OP_STRING represents a string constant. ! 109: Its format is the same as that of a STRUCTOP, but the string ! 110: data is just made into a string constant when the operation ! 111: is executed. */ ! 112: OP_STRING, ! 113: ! 114: /* UNOP_CAST is followed by a type pointer in the next exp_element. ! 115: With another UNOP_CAST at the end, this makes three exp_elements. ! 116: It casts the value of the following subexpression. */ ! 117: UNOP_CAST, ! 118: /* UNOP_MEMVAL is followed by a type pointer in the next exp_element ! 119: With another UNOP_MEMVAL at the end, this makes three exp_elements. ! 120: It casts the contents of the word addressed by the value of the ! 121: following subexpression. */ ! 122: UNOP_MEMVAL, ! 123: /* UNOP_... operate on one value from a following subexpression ! 124: and replace it with a result. They take no immediate arguments. */ ! 125: UNOP_NEG, /* Unary - */ ! 126: UNOP_ZEROP, /* Unary ! */ ! 127: UNOP_LOGNOT, /* Unary ~ */ ! 128: UNOP_IND, /* Unary * */ ! 129: UNOP_ADDR, /* Unary & */ ! 130: UNOP_PREINCREMENT, /* ++ before an expression */ ! 131: UNOP_POSTINCREMENT, /* ++ after an expression */ ! 132: UNOP_PREDECREMENT, /* -- before an expression */ ! 133: UNOP_POSTDECREMENT, /* -- after an expression */ ! 134: UNOP_SIZEOF, /* Unary sizeof (followed by expression) */ ! 135: ! 136: /* STRUCTOP_... operate on a value from a following subexpression ! 137: by extracting a structure component specified by a string ! 138: that appears in the following exp_elements (as many as needed). ! 139: STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->". ! 140: They differ only in the error message given in case the value is ! 141: not suitable or the structure component specified is not found. ! 142: ! 143: The length of the string follows in the next exp_element, ! 144: (after the string), followed by another STRUCTOP_... code. */ ! 145: STRUCTOP_STRUCT, ! 146: STRUCTOP_PTR, ! 147: }; ! 148: ! 149: union exp_element ! 150: { ! 151: enum exp_opcode opcode; ! 152: struct symbol *symbol; ! 153: long longconst; ! 154: double doubleconst; ! 155: char string; ! 156: struct type *type; ! 157: struct internalvar *internalvar; ! 158: }; ! 159: ! 160: struct expression ! 161: { ! 162: int nelts; ! 163: union exp_element elts[1]; ! 164: }; ! 165: ! 166: struct expression *parse_c_expression (); ! 167: struct expression *parse_c_1 ();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.