[svn:parrot] r40878 - in branches/context_pmc3: include/parrot src/call

bacek at svn.parrot.org bacek at svn.parrot.org
Sun Aug 30 13:02:42 UTC 2009


Author: bacek
Date: Sun Aug 30 13:02:42 2009
New Revision: 40878
URL: https://trac.parrot.org/parrot/changeset/40878

Log:
Add Parrot_pcc_get_(int|num)_constants functions and use it.

Modified:
   branches/context_pmc3/include/parrot/call.h
   branches/context_pmc3/src/call/context.c
   branches/context_pmc3/src/call/pcc.c

Modified: branches/context_pmc3/include/parrot/call.h
==============================================================================
--- branches/context_pmc3/include/parrot/call.h	Sun Aug 30 13:02:16 2009	(r40877)
+++ branches/context_pmc3/include/parrot/call.h	Sun Aug 30 13:02:42 2009	(r40878)
@@ -812,6 +812,14 @@
         __attribute__nonnull__(2);
 
 PARROT_EXPORT
+PARROT_CAN_RETURN_NULL
+INTVAL Parrot_pcc_get_int_constant(PARROT_INTERP,
+    ARGIN(PMC *ctx),
+    INTVAL idx)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_EXPORT
 PARROT_CANNOT_RETURN_NULL
 PMC* Parrot_pcc_get_lex_pad(PARROT_INTERP, ARGIN(PMC *ctx))
         __attribute__nonnull__(1)
@@ -825,6 +833,14 @@
 
 PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
+FLOATVAL Parrot_pcc_get_num_constant(PARROT_INTERP,
+    ARGIN(PMC *ctx),
+    INTVAL idx)
+        __attribute__nonnull__(1)
+        __attribute__nonnull__(2);
+
+PARROT_EXPORT
+PARROT_CAN_RETURN_NULL
 PMC* Parrot_pcc_get_object(PARROT_INTERP, ARGIN(PMC *ctx))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -1059,12 +1075,18 @@
 #define ASSERT_ARGS_Parrot_pcc_get_HLL __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_pcc_get_int_constant __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(ctx)
 #define ASSERT_ARGS_Parrot_pcc_get_lex_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)
 #define ASSERT_ARGS_Parrot_pcc_get_namespace __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)
+#define ASSERT_ARGS_Parrot_pcc_get_num_constant __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+       PARROT_ASSERT_ARG(interp) \
+    || PARROT_ASSERT_ARG(ctx)
 #define ASSERT_ARGS_Parrot_pcc_get_object __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp) \
     || PARROT_ASSERT_ARG(ctx)

Modified: branches/context_pmc3/src/call/context.c
==============================================================================
--- branches/context_pmc3/src/call/context.c	Sun Aug 30 13:02:16 2009	(r40877)
+++ branches/context_pmc3/src/call/context.c	Sun Aug 30 13:02:42 2009	(r40878)
@@ -42,7 +42,8 @@
 PARROT_EXPORT
 PARROT_CAN_RETURN_NULL
 void
-Parrot_pcc_set_constants(PARROT_INTERP, ARGIN(PMC *ctx), ARGIN_NULLOK(struct PackFile_Constant **constants))
+Parrot_pcc_set_constants(PARROT_INTERP, ARGIN(PMC *ctx),
+        ARGIN_NULLOK(struct PackFile_Constant **constants))
 {
     ASSERT_ARGS(Parrot_pcc_set_constants)
     Parrot_Context * c = Parrot_pcc_get_context_struct(interp, ctx);
@@ -51,6 +52,47 @@
 
 /*
 
+=item C<INTVAL Parrot_pcc_get_int_constant(PARROT_INTERP, PMC *ctx, INTVAL idx)>
+
+Get FLOATVAL constant from context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CAN_RETURN_NULL
+INTVAL
+Parrot_pcc_get_int_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+{
+    ASSERT_ARGS(Parrot_pcc_get_int_constant)
+    Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+    return c->constants[idx]->u.integer;
+}
+
+/*
+
+=item C<FLOATVAL Parrot_pcc_get_num_constant(PARROT_INTERP, PMC *ctx, INTVAL
+idx)>
+
+Get PMC constant from context.
+
+=cut
+
+*/
+
+PARROT_EXPORT
+PARROT_CAN_RETURN_NULL
+FLOATVAL
+Parrot_pcc_get_num_constant(PARROT_INTERP, ARGIN(PMC *ctx), INTVAL idx)
+{
+    ASSERT_ARGS(Parrot_pcc_get_num_constant)
+    Parrot_Context const * c = Parrot_pcc_get_context_struct(interp, ctx);
+    return c->constants[idx]->u.number;
+}
+
+/*
+
 =item C<STRING* Parrot_pcc_get_string_constant(PARROT_INTERP, PMC *ctx, INTVAL
 idx)>
 

Modified: branches/context_pmc3/src/call/pcc.c
==============================================================================
--- branches/context_pmc3/src/call/pcc.c	Sun Aug 30 13:02:16 2009	(r40877)
+++ branches/context_pmc3/src/call/pcc.c	Sun Aug 30 13:02:42 2009	(r40878)
@@ -843,7 +843,7 @@
             break;
         }
         case PARROT_ARG_FLOATVAL:
-            UVal_num(st->val) = constant ? CONTEXT_FIELD(interp, st->src.ctx, constants[idx])->u.number
+            UVal_num(st->val) = constant ? Parrot_pcc_get_num_constant(interp, st->src.ctx, idx)
                                          : CTX_REG_NUM(st->src.ctx, idx);
             break;
         case PARROT_ARG_PMC:


More information about the parrot-commits mailing list