|
13 | 13 | #include "common/sys.h" |
14 | 14 | #include "common/pmem.h" |
15 | 15 | #include "common/var.h" |
16 | | -#include "common/var_uds.h" |
17 | | -#include "common/var_hash.h" |
18 | 16 | #include "common/kw.h" |
19 | 17 | #include "common/scan.h" |
20 | 18 |
|
@@ -220,186 +218,7 @@ EXTERN char gsb_last_errmsg[SB_ERRMSG_SIZE + 1]; /**< last error message |
220 | 218 |
|
221 | 219 | #undef EXTERN |
222 | 220 |
|
223 | | -/** |
224 | | - * @ingroup var |
225 | | - * |
226 | | - * returns the next integer and moves the IP 4 bytes forward. |
227 | | - * |
228 | | - * R(long int) <- Code[IP]; IP+=4 |
229 | | - */ |
230 | | -static inline dword code_getnext32(void) { |
231 | | - dword v; |
232 | | - memcpy(&v, prog_source + prog_ip, 4); |
233 | | - prog_ip += 4; |
234 | | - return v; |
235 | | -} |
236 | | - |
237 | | -/** |
238 | | - * @ingroup var |
239 | | - * |
240 | | - * returns the next 64bit and moves the instruction pointer to the next instruction |
241 | | - * |
242 | | - * R(double) <- Code[IP]; IP+=8 |
243 | | - */ |
244 | | -static inline double code_getnext64f() { |
245 | | - double v; |
246 | | - memcpy(&v, prog_source + prog_ip, sizeof(double)); |
247 | | - prog_ip += sizeof(double); |
248 | | - return v; |
249 | | -} |
250 | | - |
251 | | -#if defined(OS_PREC64) |
252 | | - |
253 | | -/** |
254 | | - * @ingroup var |
255 | | - * |
256 | | - * returns the next 64bit and moves the instruction pointer to the next instruction |
257 | | - */ |
258 | | -static inline var_int_t code_getnext64i() { |
259 | | - var_int_t v; |
260 | | - memcpy(&v, prog_source + prog_ip, sizeof(var_int_t)); |
261 | | - prog_ip += sizeof(var_int_t); |
262 | | - return v; |
263 | | -} |
264 | | - |
265 | | -/** |
266 | | - * @ingroup var |
267 | | - * |
268 | | - * returns the next 128bit and moves the instruction pointer to the next instruction |
269 | | - */ |
270 | | -static inline var_num_t code_getnext128f() { |
271 | | - var_num_t v; |
272 | | - memcpy(&v, prog_source + prog_ip, sizeof(var_num_t)); |
273 | | - prog_ip += sizeof(var_num_t); |
274 | | - return v; |
275 | | -} |
276 | | - |
277 | | -#endif |
278 | | - |
279 | | -void err_evsyntax(void); |
280 | | -void err_varisarray(void); |
281 | | -void err_varisnotarray(void); |
282 | | -void err_notavar(void); |
283 | | -var_t *code_resolve_varptr(var_t* var_p, int until_parens); |
284 | | - |
285 | | -/** |
286 | | - * @ingroup var |
287 | | - * |
288 | | - * returns the floating-point value of a var. |
289 | | - * if v is string it will converted to double. |
290 | | - * |
291 | | - * @param v the variable |
292 | | - * @return the numeric value of a variable |
293 | | - */ |
294 | | -static inline var_num_t v_getval(var_t *v) { |
295 | | - switch (v ? v->type : -1) { |
296 | | - case V_UDS: |
297 | | - return uds_to_int(v); |
298 | | - case V_HASH: |
299 | | - return hash_to_int(v); |
300 | | - case V_PTR: |
301 | | - return v->v.ap.p; |
302 | | - case V_INT: |
303 | | - return v->v.i; |
304 | | - case V_NUM: |
305 | | - return v->v.n; |
306 | | - case V_STR: |
307 | | - return numexpr_sb_strtof((char *) v->v.p.ptr); |
308 | | - default: |
309 | | - if (v == NULL) { |
310 | | - err_evsyntax(); |
311 | | - } else { |
312 | | - err_varisarray(); |
313 | | - } |
314 | | - } |
315 | | - return 0; |
316 | | -} |
317 | | - |
318 | | -#define v_getnum(a) v_getval((a)) |
319 | | - |
320 | | -/** |
321 | | - * @ingroup var |
322 | | - * |
323 | | - * returns the integer value of a var. |
324 | | - * if v is string it will converted to integer. |
325 | | - * |
326 | | - * @param v the variable |
327 | | - * @return the integer value of a variable |
328 | | - */ |
329 | | -static inline var_int_t v_igetval(var_t *v) { |
330 | | - switch (v ? v->type : -1) { |
331 | | - case V_UDS: |
332 | | - return uds_to_int(v); |
333 | | - case V_HASH: |
334 | | - return hash_to_int(v); |
335 | | - case V_PTR: |
336 | | - return v->v.ap.p; |
337 | | - case V_INT: |
338 | | - return v->v.i; |
339 | | - case V_NUM: |
340 | | - return v->v.n; |
341 | | - case V_STR: |
342 | | - return numexpr_strtol((char *) v->v.p.ptr); |
343 | | - default: |
344 | | - if (v == NULL) { |
345 | | - err_evsyntax(); |
346 | | - } else { |
347 | | - err_varisarray(); |
348 | | - } |
349 | | - } |
350 | | - return 0; |
351 | | -} |
352 | | - |
353 | | -/** |
354 | | - * @ingroup exec |
355 | | - * |
356 | | - * variant of code_getvarptr() derefence until left parenthesis found |
357 | | - * |
358 | | - * R(var_t*) <- Code[IP]; IP += 2; |
359 | | - * |
360 | | - * @return the var_t* |
361 | | - */ |
362 | | -static inline var_t* code_getvarptr_parens(int until_parens) { |
363 | | - var_t *var_p = NULL; |
364 | | - |
365 | | - switch (code_peek()) { |
366 | | - case kwTYPE_VAR: |
367 | | - code_skipnext(); |
368 | | - var_p = tvar[code_getaddr()]; |
369 | | - switch (var_p->type) { |
370 | | - case V_HASH: |
371 | | - case V_ARRAY: |
372 | | - var_p = code_resolve_varptr(var_p, until_parens); |
373 | | - break; |
374 | | - default: |
375 | | - if (!until_parens && code_peek() == kwTYPE_LEVEL_BEGIN) { |
376 | | - err_varisnotarray(); |
377 | | - } |
378 | | - } |
379 | | - break; |
380 | | - |
381 | | - case kwTYPE_UDS: |
382 | | - code_skipnext(); |
383 | | - var_p = tvar[code_getaddr()]; |
384 | | - var_p = code_resolve_varptr(uds_resolve_fields(var_p), until_parens); |
385 | | - break; |
386 | | - } |
387 | | - |
388 | | - if (var_p == NULL && !prog_error) { |
389 | | - err_notavar(); |
390 | | - return tvar[0]; |
391 | | - } |
392 | | - |
393 | | - return var_p; |
394 | | -} |
395 | | - |
396 | | -/** |
397 | | - * @ingroup var |
398 | | - * |
399 | | - * Returns the varptr of the next variable. if the variable is an array |
400 | | - * returns the element ptr |
401 | | - */ |
402 | | -#define code_getvarptr() code_getvarptr_parens(0) |
| 221 | +#include "common/hotspots.h" |
403 | 222 |
|
404 | 223 | /** |
405 | 224 | * @ingroup exec |
|
0 commit comments