Back to index

cell-binutils  2.17cvs20070401
macro.h
Go to the documentation of this file.
00001 /* macro.h - header file for macro support for gas
00002    Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2006
00003    Free Software Foundation, Inc.
00004 
00005    Written by Steve and Judy Chamberlain of Cygnus Support,
00006       sac@cygnus.com
00007 
00008    This file is part of GAS, the GNU Assembler.
00009 
00010    GAS is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 2, or (at your option)
00013    any later version.
00014 
00015    GAS is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with GAS; see the file COPYING.  If not, write to the Free
00022    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00023    02110-1301, USA.  */
00024 
00025 #ifndef MACRO_H
00026 
00027 #define MACRO_H
00028 
00029 /* Structures used to store macros.
00030 
00031    Each macro knows its name and included text.  It gets built with a
00032    list of formal arguments, and also keeps a hash table which points
00033    into the list to speed up formal search.  Each formal knows its
00034    name and its default value.  Each time the macro is expanded, the
00035    formals get the actual values attached to them.  */
00036 
00037 /* Describe the formal arguments to a macro.  */
00038 
00039 typedef struct formal_struct {
00040   struct formal_struct *next;      /* Next formal in list.  */
00041   sb name;                  /* Name of the formal.  */
00042   sb def;                   /* The default value.  */
00043   sb actual;                /* The actual argument (changed on each expansion).  */
00044   int index;                /* The index of the formal 0..formal_count - 1.  */
00045   enum formal_type
00046     {
00047       FORMAL_OPTIONAL,
00048       FORMAL_REQUIRED,
00049       FORMAL_VARARG
00050     } type;                 /* The kind of the formal.  */
00051 } formal_entry;
00052 
00053 /* Other values found in the index field of a formal_entry.  */
00054 #define QUAL_INDEX (-1)
00055 #define NARG_INDEX (-2)
00056 #define LOCAL_INDEX (-3)
00057 
00058 /* Describe the macro.  */
00059 
00060 typedef struct macro_struct
00061 {
00062   sb sub;                          /* Substitution text.  */
00063   int formal_count;                /* Number of formal args.  */
00064   formal_entry *formals;           /* Pointer to list of formal_structs.  */
00065   struct hash_control *formal_hash;       /* Hash table of formals.  */
00066   const char *name;                /* Macro name.  */
00067   char *file;                      /* File the macro was defined in.  */
00068   unsigned int line;               /* Line number of definition.  */
00069 } macro_entry;
00070 
00071 /* Whether any macros have been defined.  */
00072 
00073 extern int macro_defined;
00074 
00075 /* The macro nesting level.  */
00076 
00077 extern int macro_nest;
00078 
00079 /* The macro hash table.  */
00080 
00081 extern struct hash_control *macro_hash;
00082 
00083 extern int buffer_and_nest (const char *, const char *, sb *, int (*) (sb *));
00084 extern void macro_init
00085   (int, int, int, int (*) (const char *, int, sb *, int *));
00086 extern void macro_set_alternate (int);
00087 extern void macro_mri_mode (int);
00088 extern const char *define_macro
00089   (int, sb *, sb *, int (*) (sb *), char *, unsigned int, const char **);
00090 extern int check_macro (const char *, sb *, const char **, macro_entry **);
00091 extern void delete_macro (const char *);
00092 extern const char *expand_irp (int, int, sb *, sb *, int (*) (sb *));
00093 
00094 #endif