1 | /* macro.h - header file for macro support for gas and gasp |
---|
2 | Copyright 1994, 1995, 1996, 1997, 1998, 2000 |
---|
3 | Free Software Foundation, Inc. |
---|
4 | |
---|
5 | Written by Steve and Judy Chamberlain of Cygnus Support, |
---|
6 | sac@cygnus.com |
---|
7 | |
---|
8 | This file is part of GAS, the GNU Assembler. |
---|
9 | |
---|
10 | GAS is free software; you can redistribute it and/or modify |
---|
11 | it under the terms of the GNU General Public License as published by |
---|
12 | the Free Software Foundation; either version 2, or (at your option) |
---|
13 | any later version. |
---|
14 | |
---|
15 | GAS is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with GAS; see the file COPYING. If not, write to the Free |
---|
22 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
---|
23 | 02111-1307, USA. */ |
---|
24 | |
---|
25 | #ifndef MACRO_H |
---|
26 | |
---|
27 | #define MACRO_H |
---|
28 | |
---|
29 | #include "ansidecl.h" |
---|
30 | #include "sb.h" |
---|
31 | |
---|
32 | /* Structures used to store macros. |
---|
33 | |
---|
34 | Each macro knows its name and included text. It gets built with a |
---|
35 | list of formal arguments, and also keeps a hash table which points |
---|
36 | into the list to speed up formal search. Each formal knows its |
---|
37 | name and its default value. Each time the macro is expanded, the |
---|
38 | formals get the actual values attatched to them. */ |
---|
39 | |
---|
40 | /* describe the formal arguments to a macro */ |
---|
41 | |
---|
42 | typedef struct formal_struct { |
---|
43 | struct formal_struct *next; /* next formal in list */ |
---|
44 | sb name; /* name of the formal */ |
---|
45 | sb def; /* the default value */ |
---|
46 | sb actual; /* the actual argument (changed on each expansion) */ |
---|
47 | int index; /* the index of the formal 0..formal_count-1 */ |
---|
48 | } formal_entry; |
---|
49 | |
---|
50 | /* Other values found in the index field of a formal_entry. */ |
---|
51 | #define QUAL_INDEX (-1) |
---|
52 | #define NARG_INDEX (-2) |
---|
53 | #define LOCAL_INDEX (-3) |
---|
54 | |
---|
55 | /* describe the macro. */ |
---|
56 | |
---|
57 | typedef struct macro_struct { |
---|
58 | sb sub; /* substitution text. */ |
---|
59 | int formal_count; /* number of formal args. */ |
---|
60 | formal_entry *formals; /* pointer to list of formal_structs */ |
---|
61 | struct hash_control *formal_hash; /* hash table of formals. */ |
---|
62 | } macro_entry; |
---|
63 | |
---|
64 | /* Whether any macros have been defined. */ |
---|
65 | |
---|
66 | extern int macro_defined; |
---|
67 | |
---|
68 | /* The macro nesting level. */ |
---|
69 | |
---|
70 | extern int macro_nest; |
---|
71 | |
---|
72 | extern int buffer_and_nest |
---|
73 | PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *)))); |
---|
74 | extern void macro_init |
---|
75 | PARAMS ((int alternate, int mri, int strip_at, |
---|
76 | int (*) PARAMS ((const char *, int, sb *, int *)))); |
---|
77 | extern void macro_mri_mode PARAMS ((int)); |
---|
78 | extern const char *define_macro |
---|
79 | PARAMS ((int idx, sb *in, sb *label, int (*get_line) PARAMS ((sb *)), |
---|
80 | const char **namep)); |
---|
81 | extern int check_macro PARAMS ((const char *, sb *, int, const char **, |
---|
82 | macro_entry **)); |
---|
83 | extern void delete_macro PARAMS ((const char *)); |
---|
84 | extern const char *expand_irp |
---|
85 | PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *)), int)); |
---|
86 | |
---|
87 | #endif |
---|