Skip to content

Commit a93cc27

Browse files
author
Reini Urban
committed
[GH #67] Use rurban/gh870-pmc_class nqp_group.h information
pmc2c from rurban/gh870-pmc_class exports the dynpmc types, which we use to check for NQPLexInfo in NQPLexPad, to discriminate for Proxy. Proxy info is read-only. This does not work yet
1 parent 6d8b63d commit a93cc27

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

src/pmc/nqplexpad.pmc

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#include "pmc_nqplexinfo.h"
2+
#ifdef PARROT_HAS_THREADS
3+
#include "pmc_proxy.h"
4+
/* requires pmc2c since parrot 4.11 */
5+
#include "../../nqp_group.h"
6+
#endif
27

38
/* Locates the register number for getting the specified name
49
* and type of lexical. */
@@ -107,22 +112,25 @@ Return the LexInfo PMC, if any or a Null PMC.
107112
/* Check if we need to put any static values in place. */
108113
PMC *info;
109114
Hash *hash;
115+
int proxied = 0;
116+
110117
GET_ATTR_lexinfo(INTERP, SELF, info);
111-
if (info->vtable->base_type != enum_class_LexInfo
112-
#ifdef PARROT_HAS_THREADS
113-
&& info->vtable->base_type != enum_class_Proxy
114-
#endif
115-
) {
118+
if (info->vtable->base_type == enum_class_Proxy) {
119+
info = PARROT_PROXY(info)->target;
120+
proxied = 1;
121+
}
122+
if (info->vtable->base_type == pmc_class_NQPLexInfo) {
116123
PMC *name_map;
117124
GETATTR_NQPLexInfo_name_to_register_map(INTERP, info, name_map);
118125
hash = (Hash *)VTABLE_get_pointer(INTERP, name_map);
126+
SET_ATTR_lexinfo_hash(INTERP, SELF, hash);
119127
}
120-
else {
128+
else if (info->vtable->base_type == enum_class_LexInfo) {
121129
hash = (Hash *)VTABLE_get_pointer(INTERP, info);
130+
SET_ATTR_lexinfo_hash(INTERP, SELF, hash);
122131
}
123-
SET_ATTR_lexinfo_hash(INTERP, SELF, hash);
124132

125-
if (info->vtable->base_type != enum_class_LexInfo) {
133+
if (!proxied && info->vtable->base_type == pmc_class_NQPLexInfo) {
126134
PMC *static_slots_cache;
127135
GETATTR_NQPLexInfo_static_slots_cache(INTERP, info, static_slots_cache);
128136
if (!PMC_IS_NULL(static_slots_cache)) {
@@ -147,14 +155,20 @@ Return the LexInfo PMC, if any or a Null PMC.
147155
VTABLE INTVAL elements() {
148156
PMC *info;
149157
GET_ATTR_lexinfo(INTERP, SELF, info);
158+
if (info->vtable->base_type == enum_class_Proxy) {
159+
info = PARROT_PROXY(info)->target;
160+
}
150161
return VTABLE_elements(interp, info);
151162
}
152163

153164
VTABLE INTVAL exists_keyed_str(STRING *name) {
154165
PMC *info, *name_map;
155166
const Hash *hash;
156167
GET_ATTR_lexinfo(INTERP, SELF, info);
157-
if (info->vtable->base_type != enum_class_LexInfo) {
168+
if (info->vtable->base_type == enum_class_Proxy) {
169+
info = PARROT_PROXY(info)->target;
170+
}
171+
if (info->vtable->base_type == pmc_class_NQPLexInfo) {
158172
GETATTR_NQPLexInfo_name_to_register_map(INTERP, info, name_map);
159173
hash = (const Hash *)VTABLE_get_pointer(INTERP, name_map);
160174
}
@@ -311,9 +325,11 @@ Return the LexInfo PMC, if any or a Null PMC.
311325
}
312326

313327
METHOD get_lexinfo() {
314-
PMC *lexinfo;
315-
GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
316-
RETURN(PMC *lexinfo);
328+
PMC *info;
329+
GET_ATTR_lexinfo(INTERP, SELF, info);
330+
if (info->vtable->base_type == enum_class_Proxy)
331+
info = PARROT_PROXY(info)->target;
332+
RETURN(PMC *info);
317333
}
318334

319335
/*
@@ -326,9 +342,11 @@ Get iterator for declared lexicals.
326342

327343
*/
328344
VTABLE PMC *get_iter() {
329-
PMC *lexinfo;
330-
GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
331-
return VTABLE_get_iter(INTERP, lexinfo);
345+
PMC *info;
346+
GET_ATTR_lexinfo(INTERP, SELF, info);
347+
if (info->vtable->base_type == enum_class_Proxy)
348+
info = PARROT_PROXY(info)->target;
349+
return VTABLE_get_iter(INTERP, info);
332350
}
333351

334352
}

0 commit comments

Comments
 (0)