[svn:parrot] r40763 - in branches/context_pmc3: include/parrot src src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Aug 24 12:10:29 UTC 2009
Author: bacek
Date: Mon Aug 24 12:10:29 2009
New Revision: 40763
URL: https://trac.parrot.org/parrot/changeset/40763
Log:
[core] Add caller_context accessors
Modified:
branches/context_pmc3/include/parrot/context.h
branches/context_pmc3/src/context.c
branches/context_pmc3/src/pmc/sub.pmc
Modified: branches/context_pmc3/include/parrot/context.h
==============================================================================
--- branches/context_pmc3/include/parrot/context.h Mon Aug 24 12:09:42 2009 (r40762)
+++ branches/context_pmc3/include/parrot/context.h Mon Aug 24 12:10:29 2009 (r40763)
@@ -80,6 +80,11 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+PMC* Parrot_cx_get_caller_ctx(PARROT_INTERP, ARGIN(PMC *ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
PARROT_CAN_RETURN_NULL
Parrot_Context* Parrot_cx_get_context(PARROT_INTERP, ARGIN_NULLOK(PMC *ctx))
__attribute__nonnull__(1);
@@ -108,12 +113,23 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+PARROT_EXPORT
+void Parrot_cx_set_caller_ctx(PARROT_INTERP,
+ ARGIN(PMC *ctx),
+ ARGIN(PMC *caller_ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3);
+
#define ASSERT_ARGS_Parrot_cx_constants __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_dec_recursion_depth __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_get_caller_ctx __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_get_context __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_cx_get_pmc_constant __attribute__unused__ int _ASSERT_ARGS_CHECK = \
@@ -128,6 +144,10 @@
#define ASSERT_ARGS_Parrot_cx_inc_recursion_depth __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_set_caller_ctx __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx) \
+ || PARROT_ASSERT_ARG(caller_ctx)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/context.c */
Modified: branches/context_pmc3/src/context.c
==============================================================================
--- branches/context_pmc3/src/context.c Mon Aug 24 12:09:42 2009 (r40762)
+++ branches/context_pmc3/src/context.c Mon Aug 24 12:10:29 2009 (r40763)
@@ -173,6 +173,47 @@
/*
+=item C<PMC* Parrot_cx_get_caller_ctx(PARROT_INTERP, PMC *ctx)>
+
+Get caller Context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PMC*
+Parrot_cx_get_caller_ctx(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_cx_dec_recursion_depth)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ return c->caller_ctx;
+}
+
+
+/*
+
+=item C<void Parrot_cx_set_caller_ctx(PARROT_INTERP, PMC *ctx, PMC *caller_ctx)>
+
+Set caller Context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_cx_set_caller_ctx(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN(PMC *caller_ctx))
+{
+ ASSERT_ARGS(Parrot_cx_dec_recursion_depth)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ c->caller_ctx = caller_ctx;
+}
+
+
+
+/*
+
=back
*/
Modified: branches/context_pmc3/src/pmc/sub.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/sub.pmc Mon Aug 24 12:09:42 2009 (r40762)
+++ branches/context_pmc3/src/pmc/sub.pmc Mon Aug 24 12:10:29 2009 (r40763)
@@ -945,7 +945,7 @@
METHOD set_outer(PMC *outer) {
/* Set outer sub. */
Parrot_Sub_attributes *sub;
- PMC *tmp;
+ PMC *tmp1, *tmp2;
PMC_get_sub(INTERP, SELF, sub);
sub->outer_sub = outer;
@@ -963,13 +963,15 @@
/* If we've got a context around for the outer sub, set it as the
* outer context. */
+ /* XXX This code looks very suspicious. */
/* (CONTEXT(interp)->caller_ctx->caller_ctx->current_sub */
- tmp = CONTEXT_FIELD(interp, CURRENT_CONTEXT_FIELD(interp, caller_ctx), caller_ctx);
- if (CONTEXT_FIELD(interp, tmp, current_sub) == outer)
- sub->outer_ctx = tmp;
+ tmp1 = Parrot_cx_get_caller_ctx(interp, CONTEXT(interp));
+ tmp2 = Parrot_cx_get_caller_ctx(interp, tmp1);
+ if (CONTEXT_FIELD(interp, tmp2, current_sub) == outer)
+ sub->outer_ctx = tmp2;
/* else if (CONTEXT(interp)->caller_ctx->current_sub == outer) */
- else if (CONTEXT_FIELD(interp, CURRENT_CONTEXT_FIELD(interp, caller_ctx), current_sub) == outer)
- sub->outer_ctx = CURRENT_CONTEXT_FIELD(interp, caller_ctx);
+ else if (CONTEXT_FIELD(interp, tmp1, current_sub) == outer)
+ sub->outer_ctx = tmp1;
}
METHOD get_multisig() {
More information about the parrot-commits
mailing list