339
|
1 /*
|
|
2 pragma.c
|
|
3 Copyright © 2009 William Astle
|
|
4
|
|
5 This file is part of LWASM.
|
|
6
|
|
7 LWASM is free software: you can redistribute it and/or modify it under the
|
|
8 terms of the GNU General Public License as published by the Free Software
|
|
9 Foundation, either version 3 of the License, or (at your option) any later
|
|
10 version.
|
|
11
|
|
12 This program is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
15 more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License along with
|
|
18 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
|
20
|
|
21 This file contains stuff associated with lwasm specific strangeness
|
|
22 */
|
|
23 #include <config.h>
|
|
24 #include <ctype.h>
|
|
25 #include <stdlib.h>
|
|
26 #include <string.h>
|
|
27 #include "lwasm.h"
|
|
28
|
|
29 void pseudo_pragma_real(asmstate_t *as, void *cl, char **optr, int error)
|
|
30 {
|
|
31 char pragma[128];
|
|
32 int c = 0;
|
|
33
|
|
34 while (**optr && isspace(**optr))
|
|
35 (*optr)++;
|
|
36
|
|
37 pragmaagain:
|
|
38 c = 0;
|
|
39 while (c < 127 && **optr && **optr != ',' && !isspace(**optr))
|
|
40 {
|
|
41 pragma[c++] = **optr;
|
|
42 (*optr)++;
|
|
43 }
|
|
44
|
|
45 if (c == 0 || (**optr && **optr != ',' && !isspace(**optr)))
|
|
46 {
|
|
47 if (error)
|
|
48 {
|
|
49 // register_error(as, cl, 1, "Unrecognized pragma");
|
|
50 }
|
|
51 if (error == 2)
|
|
52 {
|
|
53 *optr = NULL;
|
|
54 }
|
|
55 return;
|
|
56 }
|
|
57 pragma[c] = 0;
|
|
58 if (!strcasecmp(pragma, "noindex0tonone"))
|
|
59 {
|
|
60 as -> pragmas |= PRAGMA_NOINDEX0TONONE;
|
|
61 }
|
|
62 else if (!strcasecmp(pragma, "index0tonone"))
|
|
63 {
|
|
64 as -> pragmas &= ~PRAGMA_NOINDEX0TONONE;
|
|
65 }
|
|
66 else if (!strcasecmp(pragma, "undefextern"))
|
|
67 {
|
|
68 as -> pragmas |= PRAGMA_UNDEFEXTERN;
|
|
69 }
|
|
70 else if (!strcasecmp(pragma, "noundefextern"))
|
|
71 {
|
|
72 as -> pragmas &= ~PRAGMA_UNDEFEXTERN;
|
|
73 }
|
|
74 else if (!strcasecmp(pragma, "cescapes"))
|
|
75 {
|
|
76 as -> pragmas |= PRAGMA_CESCAPES;
|
|
77 }
|
|
78 else if (!strcasecmp(pragma, "nocescapes"))
|
|
79 {
|
|
80 as -> pragmas &= ~PRAGMA_CESCAPES;
|
|
81 }
|
|
82 else if (!strcasecmp(pragma, "importundefexport"))
|
|
83 {
|
|
84 as -> pragmas |= PRAGMA_IMPORTUNDEFEXPORT;
|
|
85 }
|
|
86 else if (!strcasecmp(pragma, "noimportundefexport"))
|
|
87 {
|
|
88 as -> pragmas &= ~PRAGMA_IMPORTUNDEFEXPORT;
|
|
89 }
|
|
90 else if (!strcasecmp(pragma, "dollarnotlocal") || !strcasecmp(pragma, "nodollarlocal"))
|
|
91 {
|
|
92 as -> pragmas |= PRAGMA_DOLLARNOTLOCAL;
|
|
93 }
|
|
94 else if (!strcasecmp(pragma, "dollarlocal") || !strcasecmp(pragma, "nodollarnotlocal"))
|
|
95 {
|
|
96 as -> pragmas &= ~PRAGMA_DOLLARNOTLOCAL;
|
|
97 }
|
|
98 else
|
|
99 {
|
|
100 if (error)
|
|
101 {
|
|
102 // register_error(as, cl, 1, "Unrecognized pragma");
|
|
103 if (error == 2)
|
|
104 {
|
|
105 *optr = NULL;
|
|
106 }
|
|
107 }
|
|
108 }
|
|
109 if (*optr && **optr == ',')
|
|
110 {
|
|
111 (*optr)++;
|
|
112 goto pragmaagain;
|
|
113 }
|
|
114 }
|