annotate nasmbuild/nasm-2.13rc9/asm/pragma.c @ 10557:23e8673c32c3

<moonythedwarf> ` cd nasmbuild/nasm-2.13rc9; ./configure > confoutput
author HackBot
date Thu, 30 Mar 2017 21:05:13 +0000
parents 587a0a262d22
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10554
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
1 /* ----------------------------------------------------------------------- *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
2 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
3 * Copyright 1996-2017 The NASM Authors - All Rights Reserved
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
4 * See the file AUTHORS included with the NASM distribution for
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
5 * the specific copyright holders.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
6 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
7 * Redistribution and use in source and binary forms, with or without
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
8 * modification, are permitted provided that the following
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
9 * conditions are met:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
10 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
11 * * Redistributions of source code must retain the above copyright
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
12 * notice, this list of conditions and the following disclaimer.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
13 * * Redistributions in binary form must reproduce the above
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
14 * copyright notice, this list of conditions and the following
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
15 * disclaimer in the documentation and/or other materials provided
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
16 * with the distribution.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
17 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
31 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
32 * ----------------------------------------------------------------------- */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
33
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
34 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
35 * Parse and handle [pragma] directives. The preprocessor handles
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
36 * %pragma preproc directives separately, all other namespaces are
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
37 * simply converted to [pragma].
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
38 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
39
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
40 #include "compiler.h"
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
41
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
42 #include <stdlib.h>
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
43 #include <string.h>
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
44 #include <ctype.h>
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
45 #include <limits.h>
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
46
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
47 #include "nasm.h"
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
48 #include "nasmlib.h"
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
49 #include "assemble.h"
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
50 #include "error.h"
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
51
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
52 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
53 * Handle [pragma] directives. [pragma] is generally produced by
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
54 * the %pragma preprocessor directive, which simply passes on any
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
55 * string that it finds *except* %pragma preproc. The idea is
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
56 * that pragmas are of the form:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
57 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
58 * %pragma <facility> <opname> [<options>...]
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
59 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
60 * ... where "facility" can be either a generic facility or a backend
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
61 * name.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
62 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
63 * The following names are currently reserved for global facilities;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
64 * so far none of these have any defined pragmas at all:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
65 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
66 * preproc - preprocessor
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
67 * asm - assembler
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
68 * list - listing generator
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
69 * file - generic file handling
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
70 * input - input file handling
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
71 * output - backend-independent output handling
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
72 * debug - backend-independent debug handling
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
73 * ignore - dummy pragma (can be used to "comment out")
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
74 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
75 * This function should generally not error out if it doesn't understand
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
76 * what a pragma is for, for unknown arguments, etc; the whole point of
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
77 * a pragma is that future releases might add new ones that should be
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
78 * ignored rather than be an error. Erroring out is acceptable for
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
79 * known pragmas suffering from parsing errors and so on.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
80 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
81 * Adding default-suppressed warnings would, however, be a good idea
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
82 * at some point.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
83 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
84 static struct pragma_facility global_pragmas[] =
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
85 {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
86 { "preproc", NULL }, /* This shouldn't happen... */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
87 { "asm", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
88 { "list", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
89 { "file", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
90 { "input", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
91 { "output", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
92 { "debug", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
93 { "ignore", NULL },
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
94 { NULL, NULL }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
95 };
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
96
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
97 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
98 * Search a pragma list for a known pragma facility and if so, invoke
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
99 * the handler. Return true if processing is complete.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
100 * The "default name", if set, matches the final NULL entry (used
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
101 * for backends, so multiple backends can share the same list under
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
102 * some circumstances.)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
103 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
104 static bool search_pragma_list(const struct pragma_facility *list,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
105 const char *default_name,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
106 struct pragma *pragma)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
107 {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
108 const struct pragma_facility *pf;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
109 enum directive_result rv;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
110
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
111 if (!list)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
112 return false;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
113
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
114 for (pf = list; pf->name; pf++) {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
115 if (!nasm_stricmp(pragma->facility_name, pf->name))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
116 goto found_it;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
117 }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
118
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
119 if (default_name && !nasm_stricmp(pragma->facility_name, default_name))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
120 goto found_it;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
121
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
122 return false;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
123
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
124 found_it:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
125 pragma->facility = pf;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
126
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
127 /* If the handler is NULL all pragmas are unknown... */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
128 if (pf->handler)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
129 rv = pf->handler(pragma);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
130 else
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
131 rv = DIRR_UNKNOWN;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
132
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
133 switch (rv) {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
134 case DIRR_UNKNOWN:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
135 switch (pragma->opcode) {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
136 case D_none:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
137 nasm_error(ERR_WARNING|ERR_PASS2|ERR_WARN_BAD_PRAGMA,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
138 "empty %%pragma %s", pragma->facility_name);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
139 break;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
140 default:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
141 nasm_error(ERR_WARNING|ERR_PASS2|ERR_WARN_UNKNOWN_PRAGMA,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
142 "unknown %%pragma %s %s",
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
143 pragma->facility_name, pragma->opname);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
144 break;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
145 }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
146 break;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
147
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
148 case DIRR_OK:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
149 case DIRR_ERROR:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
150 break; /* Nothing to do */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
151
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
152 case DIRR_BADPARAM:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
153 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
154 * This one is an error. Don't use it if forward compatibility
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
155 * would be compromised, as opposed to an inherent error.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
156 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
157 nasm_error(ERR_NONFATAL, "bad argument to %%pragma %s %s",
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
158 pragma->facility_name, pragma->opname);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
159 break;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
160
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
161 default:
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
162 panic();
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
163 }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
164 return true;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
165 }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
166
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
167 void process_pragma(char *str)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
168 {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
169 struct pragma pragma;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
170 char *p;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
171
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
172 nasm_zero(&pragma);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
173
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
174 pragma.facility_name = nasm_get_word(str, &p);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
175 if (!pragma.facility_name) {
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
176 nasm_error(ERR_WARNING|ERR_PASS2|ERR_WARN_BAD_PRAGMA,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
177 "empty pragma directive");
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
178 return; /* Empty pragma */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
179 }
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
180
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
181 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
182 * The facility "ignore" means just that; don't even complain of
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
183 * the absence of an operation.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
184 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
185 if (!nasm_stricmp(pragma.facility_name, "ignore"))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
186 return;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
187
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
188 pragma.opname = nasm_get_word(p, &p);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
189 if (!pragma.opname)
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
190 pragma.opcode = D_none;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
191 else
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
192 pragma.opcode = find_directive(pragma.opname);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
193
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
194 pragma.tail = nasm_skip_spaces(p);
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
195
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
196 /* Look for a global pragma namespace */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
197 if (search_pragma_list(global_pragmas, NULL, &pragma))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
198 return;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
199
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
200 /* Look to see if it is an output backend pragma */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
201 if (search_pragma_list(ofmt->pragmas, ofmt->shortname, &pragma))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
202 return;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
203
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
204 /* Look to see if it is a debug format pragma */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
205 if (search_pragma_list(dfmt->pragmas, dfmt->shortname, &pragma))
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
206 return;
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
207
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
208 /*
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
209 * Note: it would be nice to warn for an unknown namespace,
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
210 * but in order to do so we need to walk *ALL* the backends
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
211 * in order to make sure we aren't dealing with a pragma that
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
212 * is for another backend. On the other hand, that could
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
213 * also be a warning with a separate warning flag.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
214 *
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
215 * Leave this for the future, however, the warning classes are
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
216 * already defined for future compatibility.
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
217 */
587a0a262d22 <moonythedwarf> ` cd nasmbuild; tar -xf nasm.tar.gz
HackBot
parents:
diff changeset
218 }