Mercurial > hg > index.cgi
comparison lwasm/symbol.c @ 370:8764142b3192
Convert internal error/warning handling framework to a new unified system
Replace the ad hoc error and warning handling with a new system that
codifies the errors with specific codes. This makes it possible in the
future for error numbers to be used for testing and other purposes. It also
makes sure the error strings themselves are consistent.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 22 Jun 2015 18:49:38 -0600 |
parents | 3f8abaac214c |
children | b1adf549d181 |
comparison
equal
deleted
inserted
replaced
369:682524a1f32f | 370:8764142b3192 |
---|---|
88 | 88 |
89 if (!(flags & symbol_flag_nocheck)) | 89 if (!(flags & symbol_flag_nocheck)) |
90 { | 90 { |
91 if (!sym || !*sym) | 91 if (!sym || !*sym) |
92 { | 92 { |
93 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); | 93 lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym); |
94 return NULL; | 94 return NULL; |
95 } | 95 } |
96 if (*(unsigned char *)sym < 0x80 && (!strchr(SSYMCHARS, *sym) && !strchr(sym + 1, '$') && !strchr(sym + 1, '@') && !strchr(sym + 1, '?'))) | 96 if (*(unsigned char *)sym < 0x80 && (!strchr(SSYMCHARS, *sym) && !strchr(sym + 1, '$') && !strchr(sym + 1, '@') && !strchr(sym + 1, '?'))) |
97 { | 97 { |
98 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); | 98 lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym); |
99 return NULL; | 99 return NULL; |
100 } | 100 } |
101 | 101 |
102 if ((*sym == '$' || *sym == '@') && (sym[1] >= '0' && sym[1] <= '9')) | 102 if ((*sym == '$' || *sym == '@') && (sym[1] >= '0' && sym[1] <= '9')) |
103 { | 103 { |
104 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); | 104 lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym); |
105 return NULL; | 105 return NULL; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 for (cp = sym; *cp; cp++) | 109 for (cp = sym; *cp; cp++) |
114 islocal = 1; | 114 islocal = 1; |
115 | 115 |
116 // bad symbol | 116 // bad symbol |
117 if (!(flags & symbol_flag_nocheck) && *(unsigned char *)cp < 0x80 && !strchr(SYMCHARS, *cp)) | 117 if (!(flags & symbol_flag_nocheck) && *(unsigned char *)cp < 0x80 && !strchr(SYMCHARS, *cp)) |
118 { | 118 { |
119 lwasm_register_error(as, cl, "Bad symbol (%s)", sym); | 119 lwasm_register_error2(as, cl, E_SYMBOL_BAD, "(%s)", sym); |
120 return NULL; | 120 return NULL; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 if (islocal) | 124 if (islocal) |
161 } | 161 } |
162 | 162 |
163 if (se && version == -1) | 163 if (se && version == -1) |
164 { | 164 { |
165 // multiply defined symbol | 165 // multiply defined symbol |
166 lwasm_register_error(as, cl, "Multiply defined symbol (%s)", sym); | 166 lwasm_register_error2(as, cl, E_SYMBOL_DUPE, "(%s)", sym); |
167 return NULL; | 167 return NULL; |
168 } | 168 } |
169 | 169 |
170 if (flags & symbol_flag_set) | 170 if (flags & symbol_flag_set) |
171 { | 171 { |