Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mark enum_class_Proxy sections with PARROT_THREAD_H_GUARD
Provide an experimental fallback "static int enum_class_Proxy = 0" for non-threaded code.
  • Loading branch information
Reini Urban committed Dec 3, 2012
1 parent b7d9acd commit 2032137
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/pmc/nqplexpad.pmc
@@ -1,8 +1,8 @@
#include "pmc_nqplexinfo.h"
#ifdef PARROT_HAS_THREADS
#ifdef PARROT_THREAD_H_GUARD
#include "pmc_proxy.h"
/* requires pmc2c since parrot 4.11 */
#include "../../nqp_group.h"
#else
static int enum_class_Proxy = 0;
#endif

/* Locates the register number for getting the specified name
Expand Down Expand Up @@ -49,7 +49,7 @@ pmclass NQPLexPad
ATTR Hash *lexinfo_hash;

VTABLE void init() {
UNUSED(SELF);
UNUSED(SELF)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
"Cannot create a NQPLexPad PMC without an initializer");
}
Expand Down Expand Up @@ -116,10 +116,12 @@ Return the LexInfo PMC, if any or a Null PMC.
int proxied = 0;

GET_ATTR_lexinfo(INTERP, SELF, info);
#ifdef PARROT_THREAD_H_GUARD
if (info->vtable->base_type == enum_class_Proxy) {
info = PARROT_PROXY(info)->target;
proxied = 1;
}
#endif
if (info->vtable->base_type == dynpmc_class_NQPLexInfo) {
PMC *name_map;
GETATTR_NQPLexInfo_name_to_register_map(INTERP, info, name_map);
Expand All @@ -131,7 +133,7 @@ Return the LexInfo PMC, if any or a Null PMC.
SET_ATTR_lexinfo_hash(INTERP, SELF, hash);
}

if (!proxied && info->vtable->base_type == dynpmc_class_NQPLexInfo) {
if (info->vtable->base_type == dynpmc_class_NQPLexInfo) {
PMC *static_slots_cache;
GETATTR_NQPLexInfo_static_slots_cache(INTERP, info, static_slots_cache);
if (!PMC_IS_NULL(static_slots_cache)) {
Expand All @@ -156,19 +158,21 @@ Return the LexInfo PMC, if any or a Null PMC.
VTABLE INTVAL elements() {
PMC *info;
GET_ATTR_lexinfo(INTERP, SELF, info);
if (info->vtable->base_type == enum_class_Proxy) {
#ifdef PARROT_THREAD_H_GUARD
if (info->vtable->base_type == enum_class_Proxy)
info = PARROT_PROXY(info)->target;
}
#endif
return VTABLE_elements(interp, info);
}

VTABLE INTVAL exists_keyed_str(STRING *name) {
PMC *info, *name_map;
const Hash *hash;
GET_ATTR_lexinfo(INTERP, SELF, info);
if (info->vtable->base_type == enum_class_Proxy) {
#ifdef PARROT_THREAD_H_GUARD
if (info->vtable->base_type == enum_class_Proxy)
info = PARROT_PROXY(info)->target;
}
#endif
if (info->vtable->base_type == dynpmc_class_NQPLexInfo) {
GETATTR_NQPLexInfo_name_to_register_map(INTERP, info, name_map);
hash = (const Hash *)VTABLE_get_pointer(INTERP, name_map);
Expand Down Expand Up @@ -328,8 +332,10 @@ Return the LexInfo PMC, if any or a Null PMC.
METHOD get_lexinfo() {
PMC *info;
GET_ATTR_lexinfo(INTERP, SELF, info);
#ifdef PARROT_THREAD_H_GUARD
if (info->vtable->base_type == enum_class_Proxy)
info = PARROT_PROXY(info)->target;
#endif
RETURN(PMC *info);
}

Expand All @@ -345,8 +351,10 @@ Get iterator for declared lexicals.
VTABLE PMC *get_iter() {
PMC *info;
GET_ATTR_lexinfo(INTERP, SELF, info);
#ifdef PARROT_THREAD_H_GUARD
if (info->vtable->base_type == enum_class_Proxy)
info = PARROT_PROXY(info)->target;
#endif
return VTABLE_get_iter(INTERP, info);
}

Expand Down

0 comments on commit 2032137

Please sign in to comment.