macro.h revision 60484
133965Sjdp/* macro.h - header file for macro support for gas and gasp
260484Sobrien   Copyright (C) 1994, 95, 96, 97, 1998 Free Software Foundation, Inc.
333965Sjdp
433965Sjdp   Written by Steve and Judy Chamberlain of Cygnus Support,
533965Sjdp      sac@cygnus.com
633965Sjdp
733965Sjdp   This file is part of GAS, the GNU Assembler.
833965Sjdp
933965Sjdp   GAS is free software; you can redistribute it and/or modify
1033965Sjdp   it under the terms of the GNU General Public License as published by
1133965Sjdp   the Free Software Foundation; either version 2, or (at your option)
1233965Sjdp   any later version.
1333965Sjdp
1433965Sjdp   GAS is distributed in the hope that it will be useful,
1533965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1633965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1733965Sjdp   GNU General Public License for more details.
1833965Sjdp
1933965Sjdp   You should have received a copy of the GNU General Public License
2033965Sjdp   along with GAS; see the file COPYING.  If not, write to the Free
2133965Sjdp   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2233965Sjdp   02111-1307, USA. */
2333965Sjdp
2433965Sjdp#ifndef MACRO_H
2533965Sjdp
2633965Sjdp#define MACRO_H
2733965Sjdp
2833965Sjdp#include "ansidecl.h"
2933965Sjdp#include "sb.h"
3033965Sjdp
3160484Sobrien/* Structures used to store macros.
3260484Sobrien
3360484Sobrien   Each macro knows its name and included text.  It gets built with a
3460484Sobrien   list of formal arguments, and also keeps a hash table which points
3560484Sobrien   into the list to speed up formal search.  Each formal knows its
3660484Sobrien   name and its default value.  Each time the macro is expanded, the
3760484Sobrien   formals get the actual values attatched to them. */
3860484Sobrien
3960484Sobrien/* describe the formal arguments to a macro */
4060484Sobrien
4160484Sobrientypedef struct formal_struct
4260484Sobrien  {
4360484Sobrien    struct formal_struct *next;	/* next formal in list */
4460484Sobrien    sb name;			/* name of the formal */
4560484Sobrien    sb def;			/* the default value */
4660484Sobrien    sb actual;			/* the actual argument (changed on each expansion) */
4760484Sobrien    int index;			/* the index of the formal 0..formal_count-1 */
4860484Sobrien  }
4960484Sobrienformal_entry;
5060484Sobrien
5160484Sobrien/* Other values found in the index field of a formal_entry.  */
5260484Sobrien#define QUAL_INDEX (-1)
5360484Sobrien#define NARG_INDEX (-2)
5460484Sobrien#define LOCAL_INDEX (-3)
5560484Sobrien
5660484Sobrien/* describe the macro. */
5760484Sobrien
5860484Sobrientypedef struct macro_struct
5960484Sobrien  {
6060484Sobrien    sb sub;			/* substitution text. */
6160484Sobrien    int formal_count;		/* number of formal args. */
6260484Sobrien    formal_entry *formals;	/* pointer to list of formal_structs */
6360484Sobrien    struct hash_control *formal_hash; /* hash table of formals. */
6460484Sobrien  }
6560484Sobrienmacro_entry;
6660484Sobrien
6733965Sjdp/* Whether any macros have been defined.  */
6833965Sjdp
6933965Sjdpextern int macro_defined;
7033965Sjdp
7133965Sjdp/* The macro nesting level.  */
7233965Sjdp
7333965Sjdpextern int macro_nest;
7433965Sjdp
7533965Sjdpextern int buffer_and_nest
7633965Sjdp  PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *))));
7733965Sjdpextern void macro_init
7833965Sjdp  PARAMS ((int alternate, int mri, int strip_at,
7933965Sjdp	   int (*) PARAMS ((const char *, int, sb *, int *))));
8060484Sobrienextern void macro_mri_mode PARAMS ((int));
8133965Sjdpextern const char *define_macro
8233965Sjdp  PARAMS ((int idx, sb *in, sb *label, int (*get_line) PARAMS ((sb *)),
8333965Sjdp	   const char **namep));
8460484Sobrienextern int check_macro PARAMS ((const char *, sb *, int, const char **,
8560484Sobrien                                macro_entry **));
8633965Sjdpextern void delete_macro PARAMS ((const char *));
8733965Sjdpextern const char *expand_irp
8833965Sjdp  PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *)), int));
8933965Sjdp
9033965Sjdp#endif
91