macro.h revision 77298
133965Sjdp/* macro.h - header file for macro support for gas and gasp
277298Sobrien   Copyright (C) 1994, 95, 96, 97, 98, 2000 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
2277298Sobrien   02111-1307, USA.  */
2333965Sjdp
2433965Sjdp#ifndef MACRO_H
2533965Sjdp
2633965Sjdp#define MACRO_H
2733965Sjdp
2833965Sjdp#include "ansidecl.h"
2933965Sjdp#include "sb.h"
3033965Sjdp
3177298Sobrien/* 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
3777298Sobrien   formals get the actual values attatched to them.  */
3860484Sobrien
3960484Sobrien/* describe the formal arguments to a macro */
4060484Sobrien
4177298Sobrientypedef struct formal_struct {
4277298Sobrien  struct formal_struct *next;	/* next formal in list */
4377298Sobrien  sb name;			/* name of the formal */
4477298Sobrien  sb def;			/* the default value */
4577298Sobrien  sb actual;			/* the actual argument (changed on each expansion) */
4677298Sobrien  int index;			/* the index of the formal 0..formal_count-1 */
4777298Sobrien} formal_entry;
4860484Sobrien
4960484Sobrien/* Other values found in the index field of a formal_entry.  */
5060484Sobrien#define QUAL_INDEX (-1)
5160484Sobrien#define NARG_INDEX (-2)
5260484Sobrien#define LOCAL_INDEX (-3)
5360484Sobrien
5477298Sobrien/* describe the macro.  */
5560484Sobrien
5677298Sobrientypedef struct macro_struct {
5777298Sobrien  sb sub;			/* substitution text.  */
5877298Sobrien  int formal_count;		/* number of formal args.  */
5977298Sobrien  formal_entry *formals;	/* pointer to list of formal_structs */
6077298Sobrien  struct hash_control *formal_hash; /* hash table of formals.  */
6177298Sobrien} macro_entry;
6260484Sobrien
6333965Sjdp/* Whether any macros have been defined.  */
6433965Sjdp
6533965Sjdpextern int macro_defined;
6633965Sjdp
6733965Sjdp/* The macro nesting level.  */
6833965Sjdp
6933965Sjdpextern int macro_nest;
7033965Sjdp
7133965Sjdpextern int buffer_and_nest
7233965Sjdp  PARAMS ((const char *, const char *, sb *, int (*) PARAMS ((sb *))));
7333965Sjdpextern void macro_init
7433965Sjdp  PARAMS ((int alternate, int mri, int strip_at,
7533965Sjdp	   int (*) PARAMS ((const char *, int, sb *, int *))));
7660484Sobrienextern void macro_mri_mode PARAMS ((int));
7733965Sjdpextern const char *define_macro
7833965Sjdp  PARAMS ((int idx, sb *in, sb *label, int (*get_line) PARAMS ((sb *)),
7933965Sjdp	   const char **namep));
8077298Sobrienextern int check_macro PARAMS ((const char *, sb *, int, const char **,
8160484Sobrien                                macro_entry **));
8233965Sjdpextern void delete_macro PARAMS ((const char *));
8333965Sjdpextern const char *expand_irp
8433965Sjdp  PARAMS ((int, int, sb *, sb *, int (*) PARAMS ((sb *)), int));
8533965Sjdp
8633965Sjdp#endif
87