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