macro.h revision 60484
1139825Simp/* macro.h - header file for macro support for gas and gasp
288436Sjake   Copyright (C) 1994, 95, 96, 97, 1998 Free Software Foundation, Inc.
388436Sjake
488436Sjake   Written by Steve and Judy Chamberlain of Cygnus Support,
588436Sjake      sac@cygnus.com
688436Sjake
788436Sjake   This file is part of GAS, the GNU Assembler.
888436Sjake
988436Sjake   GAS is free software; you can redistribute it and/or modify
1088436Sjake   it under the terms of the GNU General Public License as published by
1188436Sjake   the Free Software Foundation; either version 2, or (at your option)
1288436Sjake   any later version.
1388436Sjake
1488436Sjake   GAS is distributed in the hope that it will be useful,
1588436Sjake   but WITHOUT ANY WARRANTY; without even the implied warranty of
1688436Sjake   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1788436Sjake   GNU General Public License for more details.
1888436Sjake
1988436Sjake   You should have received a copy of the GNU General Public License
2088436Sjake   along with GAS; see the file COPYING.  If not, write to the Free
2188436Sjake   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2288436Sjake   02111-1307, USA. */
2388436Sjake
2488436Sjake#ifndef MACRO_H
2588436Sjake
2688436Sjake#define MACRO_H
2788436Sjake
2888436Sjake#include "ansidecl.h"
2988436Sjake#include "sb.h"
3088436Sjake
3188436Sjake/* Structures used to store macros.
3288436Sjake
3388436Sjake   Each macro knows its name and included text.  It gets built with a
3488436Sjake   list of formal arguments, and also keeps a hash table which points
3591147Sjake   into the list to speed up formal search.  Each formal knows its
3691147Sjake   name and its default value.  Each time the macro is expanded, the
3791147Sjake   formals get the actual values attatched to them. */
3891147Sjake
3988436Sjake/* describe the formal arguments to a macro */
4097445Sjake
4197445Sjaketypedef struct formal_struct
4297445Sjake  {
4397445Sjake    struct formal_struct *next;	/* next formal in list */
4497445Sjake    sb name;			/* name of the formal */
4588436Sjake    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  }
49formal_entry;
50
51/* Other values found in the index field of a formal_entry.  */
52#define QUAL_INDEX (-1)
53#define NARG_INDEX (-2)
54#define LOCAL_INDEX (-3)
55
56/* describe the macro. */
57
58typedef struct macro_struct
59  {
60    sb sub;			/* substitution text. */
61    int formal_count;		/* number of formal args. */
62    formal_entry *formals;	/* pointer to list of formal_structs */
63    struct hash_control *formal_hash; /* hash table of formals. */
64  }
65macro_entry;
66
67/* Whether any macros have been defined.  */
68
69extern int macro_defined;
70
71/* The macro nesting level.  */
72
73extern int macro_nest;
74
75extern int buffer_and_nest
76  PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *))));
77extern void macro_init
78  PARAMS ((int alternate, int mri, int strip_at,
79	   int (*) PARAMS ((const char *, int, sb *, int *))));
80extern void macro_mri_mode PARAMS ((int));
81extern const char *define_macro
82  PARAMS ((int idx, sb *in, sb *label, int (*get_line) PARAMS ((sb *)),
83	   const char **namep));
84extern int check_macro PARAMS ((const char *, sb *, int, const char **,
85                                macro_entry **));
86extern void delete_macro PARAMS ((const char *));
87extern const char *expand_irp
88  PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *)), int));
89
90#endif
91