Lines Matching refs:MACRO
0 /* macro.c - macro support for gas
27 #include "macro.h"
29 /* The routines in this file handle macro definition and expansion.
45 /* The macro hash table. */
69 /* Number of macro expansions that have been done. */
73 /* Initialize macro processing. */
217 the macro. For long macros, one might want to report the
219 the macro definition, but we would need more infrastructure
221 number when expanding the macro), and since for short
495 /* Pick up the formal parameters of a macro definition. */
498 do_formals (macro_entry *macro, size_t idx, sb *in)
500 formal_entry **p = ¯o->formals;
512 if (macro->formal_count)
534 as_bad_where (macro->file,
535 macro->line,
536 _("Missing parameter qualifier for `%s' in macro `%s'"),
538 macro->name);
544 as_bad_where (macro->file,
545 macro->line,
546 _("`%s' is not a valid parameter qualifier for `%s' in macro `%s'"),
549 macro->name);
561 as_warn_where (macro->file,
562 macro->line,
563 _("Pointless default value for required parameter `%s' in macro `%s'"),
565 macro->name);
569 /* Add to macro's hash table. */
570 if (! hash_find (macro->formal_hash, name))
571 hash_jam (macro->formal_hash, name, formal);
573 as_bad_where (macro->file,
574 macro->line,
575 _("A parameter named `%s' already exists for macro `%s'"),
577 macro->name);
579 formal->index = macro->formal_count++;
608 /* Add to macro's hash table. */
609 if (hash_find (macro->formal_hash, name))
610 as_bad_where (macro->file,
611 macro->line,
612 _("Reserved word `%s' used as parameter in macro `%s'"),
614 macro->name);
615 hash_jam (macro->formal_hash, name, formal);
624 /* Free the memory allocated to a macro. */
627 free_macro (macro_entry *macro)
631 for (formal = macro->formals; formal; )
639 hash_die (macro->formal_hash);
640 sb_kill (¯o->sub);
641 free (macro);
644 /* Define a new macro. Returns NULL on success, otherwise returns an
646 the macro which was defined. */
654 macro_entry *macro;
658 macro = (macro_entry *) xmalloc (sizeof (macro_entry));
659 sb_new (¯o->sub);
661 macro->file = file;
662 macro->line = line;
664 macro->formal_count = 0;
665 macro->formals = 0;
666 macro->formal_hash = hash_new_sized (7);
669 if (! buffer_and_nest ("MACRO", "ENDM", ¯o->sub, get_line))
670 error = _("unexpected end of file in macro `%s' definition");
674 macro->name = sb_terminate (&name);
677 /* It's the label: MACRO (formals,...) sort */
678 idx = do_formals (macro, idx + 1, in);
682 error = _("missing `)' after formals in macro definition `%s'");
686 /* It's the label: MACRO formals,... sort */
687 idx = do_formals (macro, idx, in);
695 macro->name = sb_terminate (&name);
697 error = _("Missing macro name");
701 idx = do_formals (macro, idx, in);
706 error = _("Bad parameter list for macro `%s'");
708 /* And stick it in the macro hash table. */
711 if (hash_find (macro_hash, macro->name))
712 error = _("Macro `%s' was already defined");
714 error = hash_jam (macro_hash, macro->name, (void *) macro);
717 *namep = macro->name;
722 free_macro (macro);
751 /* See if it's in the macro's hash table, unless this is
772 /* Doing this permits people to use & in macro bodies. */
790 /* Expand the body of a macro. */
794 struct hash_control *formal_hash, const macro_entry *macro)
818 /* Permit macro parameter substition delineated with
836 else if (!macro)
839 as_bad_where (macro->file, macro->line + macro_line, _("missing `)'"));
843 /* Sub in the macro invocation number. */
894 if (! macro
934 as_bad_where (macro->file,
935 macro->line + macro_line,
1022 /* Assign values to the formal parameters of a macro, and expand the
1046 /* The macro may be called with an optional qualifier, which may
1047 be referred to in the macro body as \0. */
1051 (Macro invocation with empty extension) */
1098 /* Lookup the formal in the macro's list. */
1102 as_bad (_("Parameter named `%s' does not exist for macro `%s'"),
1113 as_warn (_("Value for parameter `%s' of macro `%s' was already specified"),
1186 as_bad (_("Missing value for required parameter `%s' of macro `%s'"),
1231 /* Check for a macro. If one is found, put the expansion into
1232 *EXPAND. Return 1 if a macro is found, 0 otherwise. */
1240 macro_entry *macro;
1259 macro = (macro_entry *) hash_find (macro_hash, copy);
1261 if (macro == NULL)
1270 *error = macro_expand (0, &line_sb, macro, expand);
1274 /* Export the macro information if requested. */
1276 *info = macro;
1281 /* Delete a macro. */
1288 macro_entry *macro;
1299 if ((macro = (macro_entry *) hash_find (macro_hash, copy)) != NULL)
1302 free_macro (macro);
1305 as_warn (_("Attempt to purge non-existant macro `%s'"), copy);
1309 combined macro definition and execution. This returns NULL on