macro.h revision 130561
1130561Sobrien/* macro.h - header file for macro support for gas
2130561Sobrien   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002
378828Sobrien   Free Software Foundation, Inc.
433965Sjdp
533965Sjdp   Written by Steve and Judy Chamberlain of Cygnus Support,
633965Sjdp      sac@cygnus.com
733965Sjdp
833965Sjdp   This file is part of GAS, the GNU Assembler.
933965Sjdp
1033965Sjdp   GAS is free software; you can redistribute it and/or modify
1133965Sjdp   it under the terms of the GNU General Public License as published by
1233965Sjdp   the Free Software Foundation; either version 2, or (at your option)
1333965Sjdp   any later version.
1433965Sjdp
1533965Sjdp   GAS is distributed in the hope that it will be useful,
1633965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1733965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1833965Sjdp   GNU General Public License for more details.
1933965Sjdp
2033965Sjdp   You should have received a copy of the GNU General Public License
2133965Sjdp   along with GAS; see the file COPYING.  If not, write to the Free
2233965Sjdp   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2377298Sobrien   02111-1307, USA.  */
2433965Sjdp
2533965Sjdp#ifndef MACRO_H
2633965Sjdp
2733965Sjdp#define MACRO_H
2833965Sjdp
2933965Sjdp#include "ansidecl.h"
3033965Sjdp#include "sb.h"
3133965Sjdp
3277298Sobrien/* Structures used to store macros.
3360484Sobrien
3460484Sobrien   Each macro knows its name and included text.  It gets built with a
3560484Sobrien   list of formal arguments, and also keeps a hash table which points
3660484Sobrien   into the list to speed up formal search.  Each formal knows its
3760484Sobrien   name and its default value.  Each time the macro is expanded, the
38130561Sobrien   formals get the actual values attached to them.  */
3960484Sobrien
40130561Sobrien/* Describe the formal arguments to a macro.  */
4160484Sobrien
4277298Sobrientypedef struct formal_struct {
43130561Sobrien  struct formal_struct *next;	/* Next formal in list.  */
44130561Sobrien  sb name;			/* Name of the formal.  */
45130561Sobrien  sb def;			/* The default value.  */
46130561Sobrien  sb actual;			/* The actual argument (changed on each expansion).  */
47130561Sobrien  int index;			/* The index of the formal 0..formal_count - 1.  */
4877298Sobrien} formal_entry;
4960484Sobrien
5060484Sobrien/* Other values found in the index field of a formal_entry.  */
5160484Sobrien#define QUAL_INDEX (-1)
5260484Sobrien#define NARG_INDEX (-2)
5360484Sobrien#define LOCAL_INDEX (-3)
5460484Sobrien
55130561Sobrien/* Describe the macro.  */
5660484Sobrien
57130561Sobrientypedef struct macro_struct
58130561Sobrien{
59130561Sobrien  sb sub;				/* Substitution text.  */
60130561Sobrien  int formal_count;			/* Number of formal args.  */
61130561Sobrien  formal_entry *formals;		/* Pointer to list of formal_structs.  */
62130561Sobrien  struct hash_control *formal_hash;	/* Hash table of formals.  */
6377298Sobrien} macro_entry;
6460484Sobrien
6533965Sjdp/* Whether any macros have been defined.  */
6633965Sjdp
6733965Sjdpextern int macro_defined;
6833965Sjdp
6933965Sjdp/* The macro nesting level.  */
7033965Sjdp
7133965Sjdpextern int macro_nest;
7233965Sjdp
73130561Sobrienextern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
7433965Sjdpextern void macro_init
75130561Sobrien  (int, int, int, int (*) (const char *, int, sb *, int *));
76130561Sobrienextern void macro_mri_mode (int);
7733965Sjdpextern const char *define_macro
78130561Sobrien  (int, sb *, sb *, int (*) (sb *), const char **);
79130561Sobrienextern int check_macro (const char *, sb *, const char **, macro_entry **);
80130561Sobrienextern void delete_macro (const char *);
81130561Sobrienextern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *));
8233965Sjdp
8333965Sjdp#endif
84