Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Detect attempts to access attributes of a type object and throw an ex…
…ception, rather than letting them be Null PMC Accesses.
  • Loading branch information
jnthn committed Aug 25, 2009
1 parent 8b525f1 commit bd51ce2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/pmc/p6opaque.pmc
Expand Up @@ -369,6 +369,33 @@ back some kind of iterator to let us get all of the possible candidates.

/*

=item C<PMC *get_attr_str(STRING *name)>

Gets an attribute from the instance storage.

=cut

*/
PMC *get_attr_str(STRING *name) {
/* Do a lookup as normal; if we get something non-null, we're done. */
PMC *result = SUPER(name);
if (!PMC_IS_NULL(result))
return result;

/* Otherwise, check if this is a proto-object, in which case we should
* never be accessing state. */
if (VTABLE_isa(interp, SELF, CONST_STRING(interp, "P6protoobject")))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Type objects do not have state, but you tried to access attribute %Ss",
name);

/* Otherwise, for now we'll just allow the Null PMC Access to happen (yes sucks
* somewhat, but probably points to other bugs. */
return result;
}

/*

=item C<opcode_t *invoke(void *next)>

Invokes the object (if this vtable function is overridden).
Expand Down

0 comments on commit bd51ce2

Please sign in to comment.