[svn:parrot] r40793 - in branches/context_pmc3: compilers/imcc include/parrot src src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Tue Aug 25 22:20:17 UTC 2009
Author: bacek
Date: Tue Aug 25 22:20:16 2009
New Revision: 40793
URL: https://trac.parrot.org/parrot/changeset/40793
Log:
[core] Add current_HLL accessor to Context and use it
Modified:
branches/context_pmc3/compilers/imcc/imcc.y
branches/context_pmc3/compilers/imcc/imcparser.c
branches/context_pmc3/compilers/imcc/pbc.c
branches/context_pmc3/include/parrot/context.h
branches/context_pmc3/src/context.c
branches/context_pmc3/src/embed.c
branches/context_pmc3/src/global.c
branches/context_pmc3/src/hll.c
branches/context_pmc3/src/multidispatch.c
branches/context_pmc3/src/oo.c
branches/context_pmc3/src/pmc/class.pmc
branches/context_pmc3/src/pmc/coroutine.pmc
branches/context_pmc3/src/pmc/object.pmc
branches/context_pmc3/src/pmc/parrotinterpreter.pmc
branches/context_pmc3/src/pmc/sub.pmc
Modified: branches/context_pmc3/compilers/imcc/imcc.y
==============================================================================
--- branches/context_pmc3/compilers/imcc/imcc.y Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/compilers/imcc/imcc.y Tue Aug 25 22:20:16 2009 (r40793)
@@ -1210,8 +1210,8 @@
HLL STRINGC
{
STRING * const hll_name = Parrot_str_unescape(interp, $2 + 1, '"', NULL);
- CURRENT_CONTEXT_FIELD(interp, current_HLL) =
- Parrot_register_HLL(interp, hll_name);
+ Parrot_cx_set_HLL(interp, CONTEXT(interp),
+ Parrot_register_HLL(interp, hll_name));
IMCC_INFO(interp)->cur_namespace = NULL;
mem_sys_free($2);
Modified: branches/context_pmc3/compilers/imcc/imcparser.c
==============================================================================
--- branches/context_pmc3/compilers/imcc/imcparser.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/compilers/imcc/imcparser.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -3318,8 +3318,8 @@
#line 1211 "compilers/imcc/imcc.y"
{
STRING * const hll_name = Parrot_str_unescape(interp, (yyvsp[(2) - (2)].s) + 1, '"', NULL);
- CURRENT_CONTEXT_FIELD(interp, current_HLL) =
- Parrot_register_HLL(interp, hll_name);
+ Parrot_cx_set_HLL(interp, CONTEXT(interp),
+ Parrot_register_HLL(interp, hll_name));
IMCC_INFO(interp)->cur_namespace = NULL;
mem_sys_free((yyvsp[(2) - (2)].s));
Modified: branches/context_pmc3/compilers/imcc/pbc.c
==============================================================================
--- branches/context_pmc3/compilers/imcc/pbc.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/compilers/imcc/pbc.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -1434,7 +1434,7 @@
sub->namespace_name = ns_pmc;
sub->start_offs = offs;
sub->end_offs = end;
- sub->HLL_id = CURRENT_CONTEXT_FIELD(interp, current_HLL);
+ sub->HLL_id = Parrot_cx_get_HLL(interp, CONTEXT(interp));
for (i = 0; i < 4; ++i)
sub->n_regs_used[i] = unit->n_regs_used[i];
Modified: branches/context_pmc3/include/parrot/context.h
==============================================================================
--- branches/context_pmc3/include/parrot/context.h Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/include/parrot/context.h Tue Aug 25 22:20:16 2009 (r40793)
@@ -92,6 +92,11 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+INTVAL Parrot_cx_get_HLL(PARROT_INTERP, ARGIN(PMC *ctx))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
PMC* Parrot_cx_get_lex_pad(PARROT_INTERP, ARGIN(PMC *ctx))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -146,6 +151,11 @@
__attribute__nonnull__(2);
PARROT_EXPORT
+void Parrot_cx_set_HLL(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL hll)
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_EXPORT
void Parrot_cx_set_lex_pad(PARROT_INTERP,
ARGIN(PMC *ctx),
ARGIN(PMC *lex_pad))
@@ -182,6 +192,9 @@
#define ASSERT_ARGS_Parrot_cx_get_continuation __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_get_HLL __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_get_lex_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
@@ -210,6 +223,9 @@
#define ASSERT_ARGS_Parrot_cx_set_continuation __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_cx_set_HLL __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp) \
+ || PARROT_ASSERT_ARG(ctx)
#define ASSERT_ARGS_Parrot_cx_set_lex_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(ctx) \
Modified: branches/context_pmc3/src/context.c
==============================================================================
--- branches/context_pmc3/src/context.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/context.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -329,6 +329,45 @@
/*
+=item C<INTVAL Parrot_cx_get_HLL(PARROT_INTERP, PMC *ctx)>
+
+Get namespace of Context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+INTVAL
+Parrot_cx_get_HLL(PARROT_INTERP, ARGIN(PMC *ctx))
+{
+ ASSERT_ARGS(Parrot_cx_get_HLL)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ return c->current_HLL;
+}
+
+
+/*
+
+=item C<void Parrot_cx_set_HLL(PARROT_INTERP, PMC *ctx, INTVAL hll)>
+
+Set caller Context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+void
+Parrot_cx_set_HLL(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL hll)
+{
+ ASSERT_ARGS(Parrot_cx_set_HLL)
+ Parrot_Context *c = Parrot_cx_get_context(interp, ctx);
+ c->current_HLL = hll;
+}
+
+/*
+
=item C<PMC* Parrot_cx_get_continuation(PARROT_INTERP, PMC *ctx)>
Get continuation of Context.
Modified: branches/context_pmc3/src/embed.c
==============================================================================
--- branches/context_pmc3/src/embed.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/embed.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -911,7 +911,7 @@
if (offs == interp->resume_offset) {
CURRENT_CONTEXT_FIELD(interp, current_sub) = sub_pmc;
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = sub->HLL_id;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), sub->HLL_id);
return sub_pmc;
}
Modified: branches/context_pmc3/src/global.c
==============================================================================
--- branches/context_pmc3/src/global.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/global.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -378,7 +378,7 @@
base_ns = Parrot_cx_get_namespace(interp, CONTEXT(interp));
else
base_ns = VTABLE_get_pmc_keyed_int(interp, interp->HLL_namespace,
- CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ Parrot_cx_get_HLL(interp, CONTEXT(interp)));
return Parrot_make_namespace_keyed(interp, base_ns, key);
}
@@ -788,7 +788,7 @@
Parrot_store_sub_in_namespace(PARROT_INTERP, ARGIN(PMC *sub_pmc))
{
ASSERT_ARGS(Parrot_store_sub_in_namespace)
- const INTVAL cur_id = CURRENT_CONTEXT_FIELD(interp, current_HLL);
+ const INTVAL cur_id = Parrot_cx_get_HLL(interp, CONTEXT(interp));
PMC *ns;
Parrot_Sub_attributes *sub;
@@ -798,7 +798,7 @@
/* store relative to HLL namespace */
PMC_get_sub(interp, sub_pmc, sub);
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = sub->HLL_id;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), sub->HLL_id);
ns = get_namespace_pmc(interp, sub_pmc);
@@ -824,7 +824,7 @@
}
/* restore HLL_id */
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = cur_id;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), cur_id);
Parrot_unblock_GC_mark(interp);
}
Modified: branches/context_pmc3/src/hll.c
==============================================================================
--- branches/context_pmc3/src/hll.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/hll.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -446,7 +446,7 @@
Parrot_get_ctx_HLL_type(PARROT_INTERP, INTVAL core_type)
{
ASSERT_ARGS(Parrot_get_ctx_HLL_type)
- const INTVAL hll_id = CURRENT_CONTEXT_FIELD(interp, current_HLL);
+ const INTVAL hll_id = Parrot_cx_get_HLL(interp, CONTEXT(interp));
return Parrot_get_HLL_type(interp, hll_id, core_type);
}
@@ -468,7 +468,7 @@
Parrot_get_ctx_HLL_namespace(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_get_ctx_HLL_namespace)
- return Parrot_get_HLL_namespace(interp, CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ return Parrot_get_HLL_namespace(interp, Parrot_cx_get_HLL(interp, CONTEXT(interp)));
}
/*
Modified: branches/context_pmc3/src/multidispatch.c
==============================================================================
--- branches/context_pmc3/src/multidispatch.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/multidispatch.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -1229,7 +1229,7 @@
{
ASSERT_ARGS(mmd_add_multi_to_namespace)
PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
- interp->HLL_namespace, CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ interp->HLL_namespace, Parrot_cx_get_HLL(interp, CONTEXT(interp)));
PMC * const ns = Parrot_make_namespace_keyed_str(interp, hll_ns, ns_name);
PMC *multi_sub = Parrot_get_global(interp, ns, sub_name);
Modified: branches/context_pmc3/src/oo.c
==============================================================================
--- branches/context_pmc3/src/oo.c Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/oo.c Tue Aug 25 22:20:16 2009 (r40793)
@@ -216,7 +216,7 @@
{
PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
interp->HLL_namespace,
- CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ Parrot_cx_get_HLL(interp, CONTEXT(interp)));
PMC * const ns = Parrot_get_namespace_keyed(interp,
hll_ns, key);
@@ -427,7 +427,7 @@
/* First check in current HLL namespace */
PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp, interp->HLL_namespace,
- CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ Parrot_cx_get_HLL(interp, CONTEXT(interp)));
PMC * const ns = Parrot_get_namespace_keyed_str(interp, hll_ns, name);
PMC * const _class = PMC_IS_NULL(ns)
? PMCNULL : VTABLE_get_class(interp, ns);
Modified: branches/context_pmc3/src/pmc/class.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/class.pmc Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/pmc/class.pmc Tue Aug 25 22:20:16 2009 (r40793)
@@ -197,7 +197,7 @@
}
else {
PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
- interp->HLL_namespace, CURRENT_CONTEXT_FIELD(interp, current_HLL));
+ interp->HLL_namespace, Parrot_cx_get_HLL(interp, CONTEXT(interp)));
new_namespace = Parrot_make_namespace_keyed(interp, hll_ns, name_arg);
}
@@ -1168,13 +1168,13 @@
/* Check that we have all methods listed in resolve list. */
const int resolve_count = VTABLE_elements(interp,
_class->resolve_method);
- const INTVAL cur_hll = CURRENT_CONTEXT_FIELD(INTERP, current_HLL);
+ const INTVAL cur_hll = Parrot_cx_get_HLL(interp, CONTEXT(interp));
const INTVAL num_parents = VTABLE_elements(interp, _class->parents);
INTVAL mro_length;
int i;
/* don't use HLL mappings for internal-only data */
- CURRENT_CONTEXT_FIELD(INTERP, current_HLL) = 0;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), 0);
for (i = 0; i < resolve_count; i++) {
STRING * const check_meth =
@@ -1211,7 +1211,7 @@
}
}
- CURRENT_CONTEXT_FIELD(INTERP, current_HLL) = cur_hll;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), cur_hll);
}
/* Set instantiated flag. */
Modified: branches/context_pmc3/src/pmc/coroutine.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/coroutine.pmc Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/pmc/coroutine.pmc Tue Aug 25 22:20:16 2009 (r40793)
@@ -152,7 +152,7 @@
CONTEXT_FIELD(INTERP, ctx, caller_ctx) = caller_ctx;
PMC_cont(ccont)->from_ctx = ctx;
CONTEXT_FIELD(INTERP, ctx, current_sub) = SELF;
- CONTEXT_FIELD(INTERP, ctx, current_HLL) = co->HLL_id;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), co->HLL_id);
Parrot_cx_set_namespace(INTERP, ctx, co->namespace_stash);
Parrot_cx_set_continuation(INTERP, ctx, ccont);
CONTEXT_FIELD(INTERP, ctx, current_object) = NULL;
Modified: branches/context_pmc3/src/pmc/object.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/object.pmc Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/pmc/object.pmc Tue Aug 25 22:20:16 2009 (r40793)
@@ -27,11 +27,11 @@
get_attrib_index(PARROT_INTERP, PMC *self, STRING *name)
{
Parrot_Class_attributes * const _class = PARROT_CLASS(self);
- const INTVAL cur_hll = CURRENT_CONTEXT_FIELD(interp, current_HLL);
+ const INTVAL cur_hll = Parrot_cx_get_HLL(interp, CONTEXT(interp));
int num_classes, i;
INTVAL retval;
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = 0;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), 0);
/* First see if we can find it in the cache. */
retval = VTABLE_get_integer_keyed_str(interp,
@@ -40,7 +40,7 @@
/* there's a semi-predicate problem with a retval of 0 */
if (retval
|| VTABLE_exists_keyed_str(interp, _class->attrib_cache, name)) {
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = cur_hll;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), cur_hll);
return retval;
}
@@ -65,12 +65,12 @@
VTABLE_set_integer_keyed_str(interp, _class->attrib_cache, name,
index);
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = cur_hll;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), cur_hll);
return index;
}
}
- CURRENT_CONTEXT_FIELD(interp, current_HLL) = cur_hll;
+ Parrot_cx_set_HLL(interp, CONTEXT(interp), cur_hll);
return -1;
}
Modified: branches/context_pmc3/src/pmc/parrotinterpreter.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/parrotinterpreter.pmc Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/pmc/parrotinterpreter.pmc Tue Aug 25 22:20:16 2009 (r40793)
@@ -802,7 +802,7 @@
METHOD hll_map(PMC *core_type, PMC *hll_type) {
INTVAL core_type_id = VTABLE_type(INTERP, core_type);
INTVAL hll_type_id = VTABLE_type(INTERP, hll_type);
- INTVAL hll_id = CURRENT_CONTEXT_FIELD(interp, current_HLL);
+ INTVAL hll_id = Parrot_cx_get_HLL(interp, CONTEXT(interp));
Parrot_register_HLL_type(INTERP, hll_id, core_type_id, hll_type_id);
}
Modified: branches/context_pmc3/src/pmc/sub.pmc
==============================================================================
--- branches/context_pmc3/src/pmc/sub.pmc Tue Aug 25 21:54:40 2009 (r40792)
+++ branches/context_pmc3/src/pmc/sub.pmc Tue Aug 25 22:20:16 2009 (r40793)
@@ -309,7 +309,7 @@
INTERP->current_object = NULL;
}
- CONTEXT_FIELD(interp, context, current_HLL) = sub->HLL_id;
+ Parrot_cx_set_HLL(interp, context, sub->HLL_id);
Parrot_cx_set_namespace(interp, context, sub->namespace_stash);
/* create pad if needed
More information about the parrot-commits
mailing list