[svn:parrot] r40777 - in branches/context_pmc3/src: . interp pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Aug 25 10:35:56 UTC 2009


Author: bacek
Date: Tue Aug 25 10:35:55 2009
New Revision: 40777
URL: https://trac.parrot.org/parrot/changeset/40777

Log:
[core] Use Context.lex_pad and outer_lex accessor functions instead of poking in struct

Modified:
   branches/context_pmc3/src/interp/inter_misc.c
   branches/context_pmc3/src/pmc/coroutine.pmc
   branches/context_pmc3/src/pmc/parrotinterpreter.pmc
   branches/context_pmc3/src/pmc/sub.pmc
   branches/context_pmc3/src/sub.c

Modified: branches/context_pmc3/src/interp/inter_misc.c
==============================================================================
--- branches/context_pmc3/src/interp/inter_misc.c	Tue Aug 25 10:35:29 2009	(r40776)
+++ branches/context_pmc3/src/interp/inter_misc.c	Tue Aug 25 10:35:55 2009	(r40777)
@@ -294,7 +294,7 @@
         case CURRENT_OBJECT:
             return CURRENT_CONTEXT_FIELD(interp, current_object);
         case CURRENT_LEXPAD:
-            return CURRENT_CONTEXT_FIELD(interp, lex_pad);
+            return Parrot_cx_get_lex_pad(interp, CONTEXT(interp));
         default:        /* or a warning only? */
             Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
                 "illegal argument in interpinfo");

Modified: branches/context_pmc3/src/pmc/coroutine.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/coroutine.pmc	Tue Aug 25 10:35:29 2009	(r40776)
+++ branches/context_pmc3/src/pmc/coroutine.pmc	Tue Aug 25 10:35:55 2009	(r40777)
@@ -161,10 +161,10 @@
 
             /* create pad if needed */
             if (!PMC_IS_NULL(co->lex_info)) {
-                CONTEXT_FIELD(INTERP, ctx, lex_pad) = pmc_new_init(INTERP,
+                Parrot_cx_set_lex_pad(INTERP, ctx, pmc_new_init(INTERP,
                         Parrot_get_ctx_HLL_type(interp, enum_class_LexPad),
-                        co->lex_info);
-                VTABLE_set_pointer(INTERP, CONTEXT_FIELD(INTERP, ctx, lex_pad), ctx);
+                        co->lex_info));
+                VTABLE_set_pointer(INTERP, Parrot_cx_get_lex_pad(INTERP, ctx), ctx);
             }
 
             PObj_get_FLAGS(SELF) |= SUB_FLAG_CORO_FF;

Modified: branches/context_pmc3/src/pmc/parrotinterpreter.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/parrotinterpreter.pmc	Tue Aug 25 10:35:29 2009	(r40776)
+++ branches/context_pmc3/src/pmc/parrotinterpreter.pmc	Tue Aug 25 10:35:55 2009	(r40777)
@@ -482,7 +482,7 @@
 
         if (outer) {
             for (; level; --level) {
-                ctx = CONTEXT_FIELD(interp, ctx, outer_ctx);
+                ctx = Parrot_cx_get_outer_ctx(interp, ctx);
                 if (PMC_IS_NULL(ctx))
                     Parrot_ex_throw_from_c_args(interp, NULL,
                         CONTROL_ERROR, "No such outer depth");
@@ -515,7 +515,7 @@
         s = CONST_STRING(interp, "lexpad");
 
         if (Parrot_str_equal(interp, item, s))
-            return CONTEXT_FIELD(interp, ctx, lex_pad);
+            return Parrot_cx_get_lex_pad(interp, ctx);
 
         s = CONST_STRING(interp, "namespace");
 

Modified: branches/context_pmc3/src/pmc/sub.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/sub.pmc	Tue Aug 25 10:35:29 2009	(r40776)
+++ branches/context_pmc3/src/pmc/sub.pmc	Tue Aug 25 10:35:55 2009	(r40777)
@@ -317,20 +317,20 @@
          *      and factor out common code with coroutine pmc
          */
         if (!PMC_IS_NULL(sub->lex_info)) {
-            CONTEXT_FIELD(interp, context, lex_pad) = pmc_new_init(INTERP,
+            Parrot_cx_set_lex_pad(interp, context, pmc_new_init(INTERP,
                     Parrot_get_ctx_HLL_type(interp, enum_class_LexPad),
-                    sub->lex_info);
-            VTABLE_set_pointer(INTERP, CONTEXT_FIELD(interp, context, lex_pad), context);
+                    sub->lex_info));
+            VTABLE_set_pointer(INTERP, Parrot_cx_get_lex_pad(interp, context), context);
         }
 
         if (sub->outer_ctx) {
             /* set outer context */
-            CONTEXT_FIELD(interp, context, outer_ctx) = sub->outer_ctx;
+            Parrot_cx_set_outer_ctx(interp, context, sub->outer_ctx);
         }
         else {
             /* autoclose */
             PMC *c;
-            for (c = context; !CONTEXT_FIELD(interp, c, outer_ctx); c = CONTEXT_FIELD(interp, c, outer_ctx)) {
+            for (c = context; PMC_IS_NULL(Parrot_cx_get_outer_ctx(interp, c)); c = Parrot_cx_get_outer_ctx(interp, c)) {
 
                 PMC         *outer_pmc;
                 Parrot_Sub_attributes *current_sub, *outer_sub;
@@ -349,17 +349,18 @@
                     CONTEXT_FIELD(interp, dummy, current_sub)    = outer_pmc;
 
                     if (!PMC_IS_NULL(outer_sub->lex_info)) {
-                        CONTEXT_FIELD(interp, dummy, lex_pad )= pmc_new_init(INTERP,
+                        Parrot_cx_set_lex_pad(interp, dummy, pmc_new_init(INTERP,
                                Parrot_get_ctx_HLL_type(interp, enum_class_LexPad),
-                               outer_sub->lex_info);
-                        VTABLE_set_pointer(INTERP, CONTEXT_FIELD(interp, dummy, lex_pad), dummy);
+                               outer_sub->lex_info));
+                        VTABLE_set_pointer(INTERP, Parrot_cx_get_lex_pad(interp, dummy), dummy);
                     }
 
-                    CONTEXT_FIELD(interp, dummy, outer_ctx) = outer_sub->outer_ctx;
+                    if (!PMC_IS_NULL(outer_sub->outer_ctx))
+                        Parrot_cx_set_outer_ctx(interp, dummy, outer_sub->outer_ctx);
                     outer_sub->ctx = dummy;
                 }
 
-                CONTEXT_FIELD(interp, c, outer_ctx) = outer_sub->ctx;
+                Parrot_cx_set_outer_ctx(interp, c, outer_sub->ctx);
             }
         }
 

Modified: branches/context_pmc3/src/sub.c
==============================================================================
--- branches/context_pmc3/src/sub.c	Tue Aug 25 10:35:29 2009	(r40776)
+++ branches/context_pmc3/src/sub.c	Tue Aug 25 10:35:55 2009	(r40777)
@@ -379,8 +379,8 @@
 {
     ASSERT_ARGS(Parrot_find_pad)
     while (1) {
-        PMC * const lex_pad = CONTEXT_FIELD(interp, ctx, lex_pad);
-        PMC        *outer   = CONTEXT_FIELD(interp, ctx, outer_ctx);
+        PMC * const lex_pad = Parrot_cx_get_lex_pad(interp, ctx);
+        PMC        *outer   = Parrot_cx_get_outer_ctx(interp, ctx);
 
         if (!outer)
             return lex_pad;


More information about the parrot-commits mailing list