Permalink
Browse files

Eliminate the now-unused DispatcherSub PMC.

  • Loading branch information...
1 parent 132adc6 commit b8e94a85ca49751c2c9d8e0b3ef01dd1b9e30caf @jnthn jnthn committed Aug 29, 2012
Showing with 8 additions and 70 deletions.
  1. +4 −12 src/guts/multi_dispatch.c
  2. +1 −4 src/ops/nqp.ops
  3. +0 −50 src/pmc/dispatchersub.pmc
  4. +3 −4 tools/build/Makefile.in
View
16 src/guts/multi_dispatch.c
@@ -2,7 +2,6 @@
#include "parrot/parrot.h"
#include "parrot/extend.h"
#include "../6model/sixmodelobject.h"
-#include "../pmc/pmc_dispatchersub.h"
#include "pmc_sub.h"
#include "multi_dispatch.h"
@@ -270,7 +269,8 @@ static PMC *get_dispatchees(PARROT_INTERP, PMC *dispatcher) {
return r->dispatchees;
}
else {
- return PARROT_DISPATCHERSUB(dispatcher)->dispatchees;
+ Parrot_ex_throw_from_c_args(interp, 0, 1,
+ "Could not find multi-dispatch list");
}
}
@@ -293,16 +293,8 @@ static NQP_md_cache *get_dispatch_cache(PARROT_INTERP, PMC *dispatcher) {
}
}
else {
- if (PMC_IS_NULL(PARROT_DISPATCHERSUB(dispatcher)->dispatch_cache)) {
- NQP_md_cache *c = mem_sys_allocate_zeroed(sizeof(NQP_md_cache));
- cache_ptr = Parrot_pmc_new(interp, enum_class_Pointer);
- VTABLE_set_pointer(interp, cache_ptr, c);
- PARROT_DISPATCHERSUB(dispatcher)->dispatch_cache = cache_ptr;
- PARROT_GC_WRITE_BARRIER(interp, dispatcher);
- }
- else {
- cache_ptr = PARROT_DISPATCHERSUB(dispatcher)->dispatch_cache;
- }
+ Parrot_ex_throw_from_c_args(interp, 0, 1,
+ "Could not find multi-dispatch list");
}
return (NQP_md_cache *)VTABLE_get_pointer(interp, cache_ptr);
}
View
5 src/ops/nqp.ops
@@ -10,7 +10,6 @@ BEGIN_OPS_PREAMBLE
#include "../6model/repr_registry.h"
#include "../6model/serialization_context.h"
#include "../guts/multi_dispatch.h"
-#include "../pmc/pmc_dispatchersub.h"
#include "../pmc/pmc_nqplexinfo.h"
#include "pmc_sub.h"
@@ -294,7 +293,6 @@ inline op nqp_dynop_setup() :base_core {
/* Look up and cache some type IDs. */
stable_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "STable", 0));
smo_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "SixModelObject", 0));
- disp_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "DispatcherSub", 0));
qrpa_id = Parrot_pmc_get_type_str(interp, Parrot_str_new(interp, "QRPA", 0));
/* Initialize the object model. */
@@ -1430,8 +1428,7 @@ inline op multi_dispatch_over_lexical_candidates(out PMC) :base_core {
PMC *cur_ctx = CURRENT_CONTEXT(interp);
while (!PMC_IS_NULL(cur_ctx)) {
Parrot_Context *ctx_struct = CONTEXT_STRUCT(cur_ctx);
- if (ctx_struct->current_sub->vtable->base_type == disp_id ||
- ctx_struct->current_sub->vtable->base_type == enum_class_Sub &&
+ if (ctx_struct->current_sub->vtable->base_type == enum_class_Sub &&
PARROT_SUB(ctx_struct->current_sub)->multi_signature->vtable->base_type == smo_id &&
!PMC_IS_NULL(((NQP_Routine *)PMC_data(PARROT_SUB(ctx_struct->current_sub)->multi_signature))->dispatchees)) {
/* Found a dispatcher. Enter the multi-dispatcher to find a the
View
50 src/pmc/dispatchersub.pmc
@@ -1,50 +0,0 @@
-/* This extends the Parrot Sub PMC to add various pieces needed for
- * multiple dispatch. */
-#include "pmc_sub.h"
-pmclass DispatcherSub extends Sub auto_attrs dynpmc group nqp {
- ATTR PMC *dispatchees; /* Used if this code object is a dispatcher. */
- ATTR PMC *dispatch_cache; /* Holds a (multi-)dispatch cache if needed. */
-
- VTABLE void init() {
- SUPER();
- SET_ATTR_dispatchees(interp, SELF, PMCNULL);
- SET_ATTR_dispatch_cache(interp, SELF, PMCNULL);
- }
-
- VTABLE void mark() {
- PMC *dispatchees, *dispatch_cache;
- SUPER();
- GET_ATTR_dispatchees(interp, SELF, dispatchees);
- Parrot_gc_mark_PMC_alive(INTERP, dispatchees);
- GET_ATTR_dispatch_cache(interp, SELF, dispatch_cache);
- Parrot_gc_mark_PMC_alive(INTERP, dispatch_cache);
- }
-
- VTABLE PMC * clone() {
- PMC *dispatchees, *dispatch_cache;
- PMC *cloned = SUPER();
- GET_ATTR_dispatchees(interp, SELF, dispatchees);
- SET_ATTR_dispatchees(interp, cloned, dispatchees);
- return cloned;
- }
-
- VTABLE void assign_pmc(PMC *other) {
- /* It's OK to assign another DispatcherSub or alternatively to
- * assign a Parrot Sub (our immediate parent). */
- if (other->vtable->base_type == SELF->vtable->base_type ||
- other->vtable->base_type == enum_class_Sub) {
- Parrot_Sub_attributes *my_sub;
- Parrot_Sub_attributes *other_sub;
-
- PMC_get_sub(INTERP, SELF, my_sub);
- PMC_get_sub(INTERP, other, other_sub);
-
- /* copy the sub struct */
- memmove(my_sub, other_sub, sizeof (Parrot_Sub_attributes));
- }
- else
- Parrot_ex_throw_from_c_args(INTERP, NULL,
- EXCEPTION_INVALID_OPERATION,
- "Can't assign a non-Sub type to a Sub");
- }
-}
View
7 tools/build/Makefile.in
@@ -203,10 +203,9 @@ DYNPMC = $(PMC_DIR)/$(GROUP)$(LOAD_EXT)
DYNOPS = $(OPS_DIR)/$(OPS)$(LOAD_EXT)
PMC_SOURCES = $(PMC_DIR)/stable.pmc $(PMC_DIR)/sixmodelobject.pmc \
- $(PMC_DIR)/dispatchersub.pmc $(PMC_DIR)/nqplexinfo.pmc \
- $(PMC_DIR)/nqplexpad.pmc $(PMC_DIR)/serializationcontext.pmc \
- $(PMC_DIR)/ownedhash.pmc $(PMC_DIR)/ownedresizablepmcarray.pmc \
- $(PMC_DIR)/qrpa.pmc \
+ $(PMC_DIR)/nqplexinfo.pmc $(PMC_DIR)/nqplexpad.pmc \
+ $(PMC_DIR)/serializationcontext.pmc $(PMC_DIR)/ownedhash.pmc \
+ $(PMC_DIR)/ownedresizablepmcarray.pmc $(PMC_DIR)/qrpa.pmc \
OPS_SOURCE = nqp.ops

0 comments on commit b8e94a8

Please sign in to comment.