Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

145 lines (97 sloc) 2.609 kB
/*
Copyright (C) 2001-2014, Parrot Foundation.
=head1 NAME
src/pmc/null.pmc - Null PMC
=head1 DESCRIPTION
This singleton simply creates a way of catching C<NULL> register accesses without
really slowing down the bytecode execution.
=cut
*/
/* HEADERIZER HFILE: none */
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
PARROT_DOES_NOT_RETURN
static void null_pmc_access(PARROT_INTERP, int index)
__attribute__nonnull__(1);
#define ASSERT_ARGS_null_pmc_access __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
pmclass Null singleton {
/*
=head2 Vtable functions
=over 4
=item C<void init()>
Overrides the default to do nothing.
=cut
*/
VTABLE void init() :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
}
VTABLE void *get_pointer() :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
return PMCNULL;
}
VTABLE void set_pointer(void *p) :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
PMCNULL = (PMC *)p;
}
VTABLE INTVAL does(STRING *what) :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
UNUSED(what)
/* XXX maybe a hack to get TGE running again */
return 0;
}
/*
=item C<INTVAL is_same(PMC *value)>
Returns true if value is also a null PMC, false otherwise.
=cut
*/
VTABLE INTVAL is_same(PMC *value) :no_wb {
UNUSED(INTERP)
UNUSED(SELF)
return PMC_IS_NULL(value);
}
/*
=item C<PMC *find_method(STRING *method_name)>
Gives a more informative message than the automaticaly generated version.
=cut
*/
VTABLE PMC *find_method(STRING *method_name) :no_wb {
UNUSED(SELF)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_NULL_REG_ACCESS,
"Null PMC access in find_method('%Ss')",
method_name);
}
}
/*
=back
=head2 Auxiliary functions
=over 4
=item C<static void null_pmc_access(PARROT_INTERP, int index)>
Throws the Null PMC access exception.
=cut
*/
PARROT_DOES_NOT_RETURN
static void
null_pmc_access(PARROT_INTERP, int index)
{
ASSERT_ARGS(null_pmc_access)
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_NULL_REG_ACCESS,
"Null PMC access in %s()",
Parrot_get_vtable_name(interp, index));
}
/*
=back
=cut
*/
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/
Jump to Line
Something went wrong with that request. Please try again.