1 |
38 |
julius |
/* macro.h - header file for macro support for gas
|
2 |
|
|
Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2006,
|
3 |
|
|
2007 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 3, 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, 51 Franklin Street - Fifth Floor, Boston, MA
|
23 |
|
|
02110-1301, USA. */
|
24 |
|
|
|
25 |
|
|
#ifndef MACRO_H
|
26 |
|
|
|
27 |
|
|
#define MACRO_H
|
28 |
|
|
|
29 |
|
|
/* Structures used to store macros.
|
30 |
|
|
|
31 |
|
|
Each macro knows its name and included text. It gets built with a
|
32 |
|
|
list of formal arguments, and also keeps a hash table which points
|
33 |
|
|
into the list to speed up formal search. Each formal knows its
|
34 |
|
|
name and its default value. Each time the macro is expanded, the
|
35 |
|
|
formals get the actual values attached to them. */
|
36 |
|
|
|
37 |
|
|
/* Describe the formal arguments to a macro. */
|
38 |
|
|
|
39 |
|
|
typedef struct formal_struct {
|
40 |
|
|
struct formal_struct *next; /* Next formal in list. */
|
41 |
|
|
sb name; /* Name of the formal. */
|
42 |
|
|
sb def; /* The default value. */
|
43 |
|
|
sb actual; /* The actual argument (changed on each expansion). */
|
44 |
|
|
int index; /* The index of the formal 0..formal_count - 1. */
|
45 |
|
|
enum formal_type
|
46 |
|
|
{
|
47 |
|
|
FORMAL_OPTIONAL,
|
48 |
|
|
FORMAL_REQUIRED,
|
49 |
|
|
FORMAL_VARARG
|
50 |
|
|
} type; /* The kind of the formal. */
|
51 |
|
|
} formal_entry;
|
52 |
|
|
|
53 |
|
|
/* Other values found in the index field of a formal_entry. */
|
54 |
|
|
#define QUAL_INDEX (-1)
|
55 |
|
|
#define NARG_INDEX (-2)
|
56 |
|
|
#define LOCAL_INDEX (-3)
|
57 |
|
|
|
58 |
|
|
/* Describe the macro. */
|
59 |
|
|
|
60 |
|
|
typedef struct macro_struct
|
61 |
|
|
{
|
62 |
|
|
sb sub; /* Substitution text. */
|
63 |
|
|
int formal_count; /* Number of formal args. */
|
64 |
|
|
formal_entry *formals; /* Pointer to list of formal_structs. */
|
65 |
|
|
struct hash_control *formal_hash; /* Hash table of formals. */
|
66 |
|
|
const char *name; /* Macro name. */
|
67 |
|
|
char *file; /* File the macro was defined in. */
|
68 |
|
|
unsigned int line; /* Line number of definition. */
|
69 |
|
|
} macro_entry;
|
70 |
|
|
|
71 |
|
|
/* Whether any macros have been defined. */
|
72 |
|
|
|
73 |
|
|
extern int macro_defined;
|
74 |
|
|
|
75 |
|
|
/* The macro nesting level. */
|
76 |
|
|
|
77 |
|
|
extern int macro_nest;
|
78 |
|
|
|
79 |
|
|
/* The macro hash table. */
|
80 |
|
|
|
81 |
|
|
extern struct hash_control *macro_hash;
|
82 |
|
|
|
83 |
|
|
extern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
|
84 |
|
|
extern void macro_init
|
85 |
|
|
(int, int, int, int (*) (const char *, int, sb *, int *));
|
86 |
|
|
extern void macro_set_alternate (int);
|
87 |
|
|
extern void macro_mri_mode (int);
|
88 |
|
|
extern const char *define_macro
|
89 |
|
|
(int, sb *, sb *, int (*) (sb *), char *, unsigned int, const char **);
|
90 |
|
|
extern int check_macro (const char *, sb *, const char **, macro_entry **);
|
91 |
|
|
extern void delete_macro (const char *);
|
92 |
|
|
extern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *));
|
93 |
|
|
|
94 |
|
|
#endif
|