macro.h revision 78828
133965Sjdp/* macro.h - header file for macro support for gas and gasp
278828Sobrien   Copyright 1994, 1995, 1996, 1997, 1998, 2000
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
3877298Sobrien   formals get the actual values attatched to them.  */
3960484Sobrien
4060484Sobrien/* describe the formal arguments to a macro */
4160484Sobrien
4277298Sobrientypedef struct formal_struct {
4377298Sobrien  struct formal_struct *next;	/* next formal in list */
4477298Sobrien  sb name;			/* name of the formal */
4577298Sobrien  sb def;			/* the default value */
4677298Sobrien  sb actual;			/* the actual argument (changed on each expansion) */
4777298Sobrien  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
5577298Sobrien/* describe the macro.  */
5660484Sobrien
5777298Sobrientypedef struct macro_struct {
5877298Sobrien  sb sub;			/* substitution text.  */
5977298Sobrien  int formal_count;		/* number of formal args.  */
6077298Sobrien  formal_entry *formals;	/* pointer to list of formal_structs */
6177298Sobrien  struct hash_control *formal_hash; /* hash table of formals.  */
6277298Sobrien} macro_entry;
6360484Sobrien
6433965Sjdp/* Whether any macros have been defined.  */
6533965Sjdp
6633965Sjdpextern int macro_defined;
6733965Sjdp
6833965Sjdp/* The macro nesting level.  */
6933965Sjdp
7033965Sjdpextern int macro_nest;
7133965Sjdp
7233965Sjdpextern int buffer_and_nest
7333965Sjdp  PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *))));
7433965Sjdpextern void macro_init
7533965Sjdp  PARAMS ((int alternate, int mri, int strip_at,
7633965Sjdp	   int (*) PARAMS ((const char *, int, sb *, int *))));
7760484Sobrienextern void macro_mri_mode PARAMS ((int));
7833965Sjdpextern const char *define_macro
7933965Sjdp  PARAMS ((int idx, sb *in, sb *label, int (*get_line) PARAMS ((sb *)),
8033965Sjdp	   const char **namep));
8177298Sobrienextern int check_macro PARAMS ((const char *, sb *, int, const char **,
8260484Sobrien                                macro_entry **));
8333965Sjdpextern void delete_macro PARAMS ((const char *));
8433965Sjdpextern const char *expand_irp
8533965Sjdp  PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *)), int));
8633965Sjdp
8733965Sjdp#endif
88