4 * Library routines to manipulate expression data types.
10 * Return true if the argument is a simple scalar. (Or a far-
11 * absolute, which counts.)
13 int is_simple(expr * vect)
15 while (vect->type && !vect->value)
19 if (vect->type != EXPR_SIMPLE)
23 } while (vect->type && !vect->value);
24 if (vect->type && vect->type < EXPR_SEGBASE + SEG_ABS)
30 * Return true if the argument is a simple scalar, _NOT_ a far-
33 int is_really_simple(expr * vect)
35 while (vect->type && !vect->value)
39 if (vect->type != EXPR_SIMPLE)
43 } while (vect->type && !vect->value);
50 * Return true if the argument is relocatable (i.e. a simple
51 * scalar, plus at most one segment-base, plus possibly a WRT).
53 int is_reloc(expr * vect)
55 while (vect->type && !vect->value) /* skip initial value-0 terms */
57 if (!vect->type) /* trivially return true if nothing */
58 return 1; /* is present apart from value-0s */
59 if (vect->type < EXPR_SIMPLE) /* false if a register is present */
61 if (vect->type == EXPR_SIMPLE) { /* skip over a pure number term... */
64 } while (vect->type && !vect->value);
65 if (!vect->type) /* ...returning true if that's all */
68 if (vect->type == EXPR_WRT) { /* skip over a WRT term... */
71 } while (vect->type && !vect->value);
72 if (!vect->type) /* ...returning true if that's all */
75 if (vect->value != 0 && vect->value != 1)
76 return 0; /* segment base multiplier non-unity */
77 do { /* skip over _one_ seg-base term... */
79 } while (vect->type && !vect->value);
80 if (!vect->type) /* ...returning true if that's all */
82 return 0; /* And return false if there's more */
86 * Return true if the argument contains an `unknown' part.
88 int is_unknown(expr * vect)
90 while (vect->type && vect->type < EXPR_UNKNOWN)
92 return (vect->type == EXPR_UNKNOWN);
96 * Return true if the argument contains nothing but an `unknown'
99 int is_just_unknown(expr * vect)
101 while (vect->type && !vect->value)
103 return (vect->type == EXPR_UNKNOWN);
107 * Return the scalar part of a relocatable vector. (Including
108 * simple scalar vectors - those qualify as relocatable.)
110 int64_t reloc_value(expr * vect)
112 while (vect->type && !vect->value)
116 if (vect->type == EXPR_SIMPLE)
123 * Return the segment number of a relocatable vector, or NO_SEG for
126 int32_t reloc_seg(expr * vect)
128 while (vect->type && (vect->type == EXPR_WRT || !vect->value))
130 if (vect->type == EXPR_SIMPLE) {
133 } while (vect->type && (vect->type == EXPR_WRT || !vect->value));
138 return vect->type - EXPR_SEGBASE;
142 * Return the WRT segment number of a relocatable vector, or NO_SEG
143 * if no WRT part is present.
145 int32_t reloc_wrt(expr * vect)
147 while (vect->type && vect->type < EXPR_WRT)
149 if (vect->type == EXPR_WRT) {