1 /* macro.h - header file for macro support for gas
2 Copyright (C) 1994-2016 Free Software Foundation, Inc.
4 Written by Steve and Judy Chamberlain of Cygnus Support,
7 This file is part of GAS, the GNU Assembler.
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 3, or (at your option)
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.
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, 51 Franklin Street - Fifth Floor, Boston, MA
28 /* Structures used to store macros.
30 Each macro knows its name and included text. It gets built with a
31 list of formal arguments, and also keeps a hash table which points
32 into the list to speed up formal search. Each formal knows its
33 name and its default value. Each time the macro is expanded, the
34 formals get the actual values attached to them. */
43 /* Describe the formal arguments to a macro. */
45 typedef struct formal_struct {
46 struct formal_struct *next; /* Next formal in list. */
47 sb name; /* Name of the formal. */
48 sb def; /* The default value. */
49 sb actual; /* The actual argument (changed on each expansion). */
50 int index; /* The index of the formal 0..formal_count - 1. */
51 enum formal_type type; /* The kind of the formal. */
54 /* Other values found in the index field of a formal_entry. */
55 #define QUAL_INDEX (-1)
56 #define NARG_INDEX (-2)
57 #define LOCAL_INDEX (-3)
59 /* Describe the macro. */
61 typedef struct macro_struct
63 sb sub; /* Substitution text. */
64 int formal_count; /* Number of formal args. */
65 formal_entry *formals; /* Pointer to list of formal_structs. */
66 struct hash_control *formal_hash; /* Hash table of formals. */
67 const char *name; /* Macro name. */
68 char *file; /* File the macro was defined in. */
69 unsigned int line; /* Line number of definition. */
72 /* Whether any macros have been defined. */
74 extern int macro_defined;
76 /* The macro nesting level. */
78 extern int macro_nest;
80 /* The macro hash table. */
82 extern struct hash_control *macro_hash;
84 extern int buffer_and_nest (const char *, const char *, sb *,
86 extern void macro_init (int, int, int,
87 size_t (*) (const char *, size_t, sb *, offsetT *));
88 extern void macro_set_alternate (int);
89 extern void macro_mri_mode (int);
90 extern const char *define_macro (size_t, sb *, sb *, size_t (*) (sb *),
91 char *, unsigned int, const char **);
92 extern int check_macro (const char *, sb *, const char **, macro_entry **);
93 extern void delete_macro (const char *);
94 extern const char *expand_irp (int, size_t, sb *, sb *, size_t (*) (sb *));