1 /* cond.c - conditional assembly pseudo-ops, and .include
2 Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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)
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.
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. */
20 /* static const char rcsid[] = "$Id$"; */
29 /* register char c; */
30 register char *name
; /* points to name of symbol */
31 register struct symbol
* symbolP
; /* Points to symbol */
33 SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
34 name
= input_line_pointer
;
35 if (!is_name_beginner(*name
)) {
36 as_bad("invalid identifier for .ifdef");
37 obstack_1grow (&cond_obstack
, 0);
41 symbolP
= symbol_find(name
);
43 /* ??? Should we try to optimize such that if we hit a .endif
44 before a .else, we don't need to push state? */
45 obstack_1grow(&cond_obstack
, (symbolP
!= 0) ^ arg
);
49 /* This is allocated to grow and shrink as .ifdef/.endif pairs
50 are scanned. When the top element is nonzero, it means
51 we should accept input. Otherwise, we should ignore input. */
52 struct obstack cond_obstack
;
59 SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
62 if (operand
.X_add_symbol
!= NULL
63 || operand
.X_subtract_symbol
!= NULL
)
64 as_bad("non-constant expression in .if statement");
66 /* If the above error is signaled, this will dispatch
67 using an undefined result. No big deal. */
68 obstack_1grow(&cond_obstack
, (operand
.X_add_number
!= 0) ^ arg
);
74 char *base
= obstack_base(&cond_obstack
);
75 char *ptr
= obstack_next_free(&cond_obstack
);
78 as_bad("unbalanced .endif");
80 obstack_free(&cond_obstack
, ptr
-1);
81 cond_obstack
.object_base
= base
;
88 char *ptr
= obstack_next_free(&cond_obstack
);
89 if (ptr
-1 == obstack_base(&cond_obstack
)) {
90 as_bad(".else without matching .if");
99 as_bad("ifeqs not implemented.");
109 char *ptr
= obstack_next_free (&cond_obstack
);
111 /* We cannot ignore certain pseudo ops. */
112 if (input_line_pointer
[-1] == '.')
114 if (input_line_pointer
[0] == 'i'
115 && (!strncmp (input_line_pointer
, "if", 2)
116 || !strncmp (input_line_pointer
, "ifdef", 5)
117 || !strncmp (input_line_pointer
, "ifndef", 6)))
119 if (input_line_pointer
[0] == 'e'
120 && (!strncmp (input_line_pointer
, "else", 4)
121 || !strncmp (input_line_pointer
, "endif", 5)))
125 return (ptr
[-1] == 0);
126 } /* ignore_input() */
This page took 0.033625 seconds and 5 git commands to generate.