Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Transform a segfault into an exception (moritz++ for reporting).
  • Loading branch information
jnthn committed Aug 3, 2011
1 parent 21977e8 commit 07c976f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/binder/bind.c
Expand Up @@ -64,6 +64,10 @@ static void setup_binder_statics(PARROT_INTERP) {
}


/* Gets the ID of a 6model object PMC. */
INTVAL Rakudo_smo_id(void) { return smo_id; }


/* Creates a Parcel from a RPA, filling PMCNULL elements if needed. */
/* This function gets shared with perl6.ops for the perl6_parcel_from_rpa op. */
PMC *
Expand Down
2 changes: 2 additions & 0 deletions src/binder/bind.h
Expand Up @@ -70,6 +70,8 @@ typedef struct {
#define PObj_P6S_ALREADY_CHECKED_FLAG PObj_private0_FLAG
#define PObj_P6S_ALREADY_BOUND_FLAG PObj_private1_FLAG

/* Gets the ID of a 6model object PMC. */
INTVAL Rakudo_smo_id(void);

/* Functions we want to share to provide the interface to the binder. */
INTVAL Rakudo_binding_bind(PARROT_INTERP, PMC *lexpad, PMC *sig_pmc,
Expand Down
6 changes: 6 additions & 0 deletions src/binder/container.c
Expand Up @@ -3,6 +3,7 @@
#include "parrot/extend.h"
#include "container.h"
#include "sixmodelobject.h"
#include "bind.h"

static PMC *scalar_type = NULL;
void Rakudo_cont_set_scalar_type(PMC *type) { scalar_type = type; }
Expand Down Expand Up @@ -51,6 +52,11 @@ static STRING * typename(PARROT_INTERP, PMC *obj) {
* it only really skips them if it's Scalar. */
void Rakudo_cont_store(PARROT_INTERP, PMC *cont, PMC *value,
INTVAL type_check, INTVAL rw_check) {
/* Ensure the value we're storing is a 6model type. */
if (value->vtable->base_type != Rakudo_smo_id())
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Cannot assign a non-Perl 6 value to a Perl 6 container");

/* If it's a scalar container, optimized path. */
if (STABLE(cont)->WHAT == scalar_type) {
Rakudo_Scalar *scalar = (Rakudo_Scalar *)PMC_data(cont);
Expand Down

0 comments on commit 07c976f

Please sign in to comment.