[svn:parrot] r43081 - in branches/pmc_freeze_cleanup: include/parrot src
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Wed Dec 16 03:41:09 UTC 2009
Author: plobsing
Date: Wed Dec 16 03:41:06 2009
New Revision: 43081
URL: https://trac.parrot.org/parrot/changeset/43081
Log:
Add {push,shift}_pmc ops to visit_info.
these forward to visit_pmc_now for now.
src/hash.c is an example use of this.
Modified:
branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h
branches/pmc_freeze_cleanup/src/hash.c
branches/pmc_freeze_cleanup/src/pmc_freeze.c
Modified: branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h
==============================================================================
--- branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h Wed Dec 16 03:37:48 2009 (r43080)
+++ branches/pmc_freeze_cleanup/include/parrot/pmc_freeze.h Wed Dec 16 03:41:06 2009 (r43081)
@@ -11,7 +11,7 @@
*/
#ifndef PARROT_PMC_FREEZE_H_GUARD
-#define PARROT_PMC_FREEZE_H_GUARD
+#define PARROT_PMC_FREEZE_H_GUARD
struct _visit_info;
typedef void (*visit_f)(PARROT_INTERP, ARGIN_NULLOK(PMC*), ARGIN(struct _visit_info*));
@@ -27,22 +27,26 @@
} visit_enum_type;
struct _visit_info;
-typedef INTVAL (*get_integer_f) (PARROT_INTERP, struct _visit_info*);
-typedef void (*push_integer_f) (PARROT_INTERP, struct _visit_info*, INTVAL);
-typedef void (*push_string_f) (PARROT_INTERP, struct _visit_info*, STRING*);
-typedef void (*push_number_f) (PARROT_INTERP, struct _visit_info*, FLOATVAL);
-typedef INTVAL (*shift_integer_f) (PARROT_INTERP, struct _visit_info*);
-typedef STRING* (*shift_string_f) (PARROT_INTERP, struct _visit_info*);
-typedef FLOATVAL (*shift_number_f) (PARROT_INTERP, struct _visit_info*);
+typedef INTVAL (*get_integer_f) (PARROT_INTERP, struct _visit_info*);
+typedef void (*push_integer_f) (PARROT_INTERP, struct _visit_info*, INTVAL);
+typedef void (*push_string_f) (PARROT_INTERP, struct _visit_info*, STRING*);
+typedef void (*push_number_f) (PARROT_INTERP, struct _visit_info*, FLOATVAL);
+typedef void (*push_pmc_f) (PARROT_INTERP, struct _visit_info*, PMC*);
+typedef INTVAL (*shift_integer_f) (PARROT_INTERP, struct _visit_info*);
+typedef STRING* (*shift_string_f) (PARROT_INTERP, struct _visit_info*);
+typedef FLOATVAL (*shift_number_f) (PARROT_INTERP, struct _visit_info*);
+typedef PMC* (*shift_pmc_f) (PARROT_INTERP, struct _visit_info*);
typedef struct _image_funcs {
get_integer_f get_integer;
push_integer_f push_integer;
push_string_f push_string;
push_number_f push_float;
+ push_pmc_f push_pmc;
shift_integer_f shift_integer;
shift_string_f shift_string;
shift_number_f shift_float;
+ shift_pmc_f shift_pmc;
} image_funcs;
typedef enum {
Modified: branches/pmc_freeze_cleanup/src/hash.c
==============================================================================
--- branches/pmc_freeze_cleanup/src/hash.c Wed Dec 16 03:37:48 2009 (r43080)
+++ branches/pmc_freeze_cleanup/src/hash.c Wed Dec 16 03:41:06 2009 (r43081)
@@ -587,10 +587,8 @@
switch (hash->entry_type) {
case enum_hash_pmc:
{
- /* this looks awful, but it avoids type-punning warnings */
- void **ptr = &b->value;
- info->thaw_ptr = (PMC **)ptr;
- (info->visit_pmc_now)(interp, NULL, info);
+ const PMC *p = (void *)VTABLE_shift_pmc(interp, info);
+ b->value = (void *)p;
break;
}
case enum_hash_int:
@@ -648,7 +646,7 @@
switch (hash->entry_type) {
case enum_hash_pmc:
- (info->visit_pmc_now)(interp, (PMC *)b->value, info);
+ VTABLE_push_pmc(interp, info, (PMC *)b->value);
break;
case enum_hash_int:
VTABLE_push_integer(interp, info, (INTVAL)b->value);
Modified: branches/pmc_freeze_cleanup/src/pmc_freeze.c
==============================================================================
--- branches/pmc_freeze_cleanup/src/pmc_freeze.c Wed Dec 16 03:37:48 2009 (r43080)
+++ branches/pmc_freeze_cleanup/src/pmc_freeze.c Wed Dec 16 03:41:06 2009 (r43081)
@@ -376,6 +376,23 @@
io->pos = (char *)PF_store_string((opcode_t *)io->pos, v);
}
+/*
+
+=item C<static void push_opcode_pmc(PARROT_INTERP, visit_info *io, PMC *v)>
+
+Pushes a reference to pmc C<*v> onto the end of the C<*io> "stream". If C<*v>
+hasn't been seen yet, it is also pushed onto the todo list.
+
+=cut
+
+*/
+
+static void
+push_opcode_pmc(PARROT_INTERP, ARGIN(visit_info *io), ARGIN(PMC *v)) {
+ ASSERT_ARGS(push_opcode_pmc)
+ io->thaw_ptr = &v;
+ (io->visit_pmc_now)(interp, v, io);
+}
/*
@@ -447,6 +464,26 @@
return s;
}
+/*
+
+=item C<static PMC *shift_opcode_pmc(PARROT_INTERP, visit_info *io)>
+
+Removes and returns a reference to a pmc from the start of the C<*io> "stream".
+
+=cut
+
+*/
+
+PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
+static PMC *
+shift_opcode_pmc(PARROT_INTERP, ARGIN(visit_info *io)) {
+ ASSERT_ARGS(shift_opcode_pmc)
+ PMC *result;
+ io->thaw_ptr = &result;
+ (io->visit_pmc_now)(interp, NULL, io);
+ return result;
+}
/*
@@ -471,9 +508,11 @@
push_opcode_integer,
push_opcode_string,
push_opcode_number,
+ push_opcode_pmc,
shift_opcode_integer,
shift_opcode_string,
- shift_opcode_number
+ shift_opcode_number,
+ shift_opcode_pmc
};
/*
More information about the parrot-commits
mailing list