|
1 | 1 | #include "pmc_nqplexinfo.h"
|
2 | 2 |
|
| 3 | +/* Possible options for boxed primitives. */ |
| 4 | +#define STORAGE_SPEC_BP_NONE 0 |
| 5 | +#define STORAGE_SPEC_BP_INT 1 |
| 6 | +#define STORAGE_SPEC_BP_NUM 2 |
| 7 | +#define STORAGE_SPEC_BP_STR 3 |
| 8 | + |
3 | 9 | /* Locates the register number for getting the specified name
|
4 | 10 | * and type of lexical. */
|
5 | 11 | static INTVAL register_number_for_get(PARROT_INTERP, Hash *hash,
|
@@ -316,6 +322,24 @@ Return the LexInfo PMC, if any or a Null PMC.
|
316 | 322 | GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
|
317 | 323 | RETURN(PMC *lexinfo);
|
318 | 324 | }
|
| 325 | + |
| 326 | + METHOD get_lex_type(STRING *name) { |
| 327 | + Hash *hash; |
| 328 | + HashBucket *b; |
| 329 | + INTVAL spec; |
| 330 | + GET_ATTR_lexinfo_hash(INTERP, SELF, hash); |
| 331 | + b = Parrot_hash_get_bucket(interp, hash, name); |
| 332 | + if (!b) |
| 333 | + Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LEX_NOT_FOUND, |
| 334 | + "Lexical '%Ss' not found", name); |
| 335 | + switch ((INTVAL)b->value & 3) { |
| 336 | + case REGNO_INT: spec = STORAGE_SPEC_BP_INT; break; |
| 337 | + case REGNO_NUM: spec = STORAGE_SPEC_BP_NUM; break; |
| 338 | + case REGNO_STR: spec = STORAGE_SPEC_BP_STR; break; |
| 339 | + default: spec = STORAGE_SPEC_BP_NONE; break; |
| 340 | + } |
| 341 | + RETURN(INTVAL spec); |
| 342 | + } |
319 | 343 |
|
320 | 344 | /*
|
321 | 345 |
|
|
0 commit comments