Annotation of GNUtools/cctools/as/expr.h, revision 1.1.1.1

1.1       root        1: /* expr.h -> header file for expr.c
                      2:    Copyright (C) 1987 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GAS, the GNU Assembler.
                      5: 
                      6: GAS 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 1, or (at your option)
                      9: any later version.
                     10: 
                     11: GAS 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 GAS; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: #import "struc-symbol.h"
                     21: #import "bignum.h"
                     22: #import "flonum.h"
                     23: 
                     24: /*
                     25:  * This table describes the use of segments as EXPRESSION types.
                     26:  *
                     27:  *     X_seg   X_add_symbol  X_subtract_symbol X_add_number
                     28:  * SEG_NONE                                            no (legal) expression
                     29:  * SEG_BIG                                     *       > 32 bits const.
                     30:  * SEG_ABSOLUTE                                        0
                     31:  * SEG_SECT            *                       0
                     32:  * SEG_UNKNOWN         *                       0
                     33:  * SEG_DIFFSECT                0               *       0
                     34:  *
                     35:  * The blank fields MUST be 0, and are nugatory.
                     36:  * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
                     37:  *
                     38:  * SEG_BIG: A floating point number or an integer larger than 32 bits.
                     39:  *   For a floating point number:
                     40:  *     X_add_number is < 0
                     41:  *         The result is in the global variable generic_floating_point_number.
                     42:  *         The value in X_add_number is -'c' where c is the character that
                     43:  *         introduced the constant.  e.g. "0f6.9" will have  -'f' as a
                     44:  *         X_add_number value.
                     45:  *   For an integer larger than 32 bits:
                     46:  *     X_add_number > 0
                     47:  *         The result is in the global variable generic_bignum.
                     48:  *         The value in X_add_number is a count of how many littlenums it
                     49:  *         took to represent the bignum.
                     50:  */
                     51: typedef enum {
                     52:     SEG_ABSOLUTE,      /* absolute */
                     53:     SEG_SECT,          /* normal defined section */
                     54:     SEG_DIFFSECT,      /* difference between symbols in sections */
                     55:     SEG_UNKNOWN,       /* expression involving an undefined symbol */
                     56:     SEG_NONE,          /* no expression */
                     57:     SEG_BIG            /* bigger than 32 bits constant */
                     58: } segT;
                     59: 
                     60: extern char *seg_name[];
                     61: extern segT N_TYPE_seg[];
                     62: 
                     63: /*
                     64:  * When an expression is SEG_BIG, it is in these globals (see comments above
                     65:  * about SEG_BIG).  This data may be clobbered whenever expr() is called.
                     66:  */
                     67: extern FLONUM_TYPE    generic_floating_point_number;
                     68: extern LITTLENUM_TYPE generic_bignum[];
                     69: #define SIZE_OF_LARGE_NUMBER (20)      /* Number of littlenums in above */
                     70:                                        /* generic_bignum which is enough to */
                     71:                                        /* hold most precise flonum. */
                     72: 
                     73: /*
                     74:  * Abbreviations (mnemonics).
                     75:  *
                     76:  *     O       operator
                     77:  *     Q       quantity,  operand
                     78:  *     X       eXpression
                     79:  */
                     80: 
                     81: /*
                     82:  * By popular demand, we define a struct to represent an expression.
                     83:  * This will no doubt mutate as expressions become baroque.
                     84:  *
                     85:  * Currently, we support expressions like "foo-bar+42".
                     86:  * In other words we permit a (possibly undefined) minuend, a
                     87:  * (possibly undefined) subtrahend and an (absolute) augend.
                     88:  * RMS says this is so we can have 1-pass assembly for any compiler
                     89:  * emmissions, and a 'case' statement might emit 'undefined1 - undefined2'.
                     90:  *
                     91:  * To simplify table-driven dispatch, we also have a "segment" for the
                     92:  * entire expression. That way we don't require complex reasoning about
                     93:  * whether particular components are defined; and we can change component
                     94:  * semantics without re-working all the dispatch tables in the assembler.
                     95:  * In other words the "type" of an expression is its segment.
                     96:  */
                     97: 
                     98: typedef struct {
                     99:     symbolS *X_add_symbol;     /* foo */
                    100:     symbolS *X_subtract_symbol;        /* bar */
                    101:     long     X_add_number;     /* 42 (must be signed) */
                    102:     segT     X_seg;            /* What segment (expr type) */
                    103: } expressionS;
                    104: 
                    105: extern segT expression(
                    106:     expressionS *resultP);
                    107: extern char get_symbol_end(
                    108:     void);
                    109: extern segT try_to_make_absolute(
                    110:     expressionS *expressionP);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.