Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 142 lines (94 sloc) 2.504 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
/*
Copyright (C) 2001-2012, Parrot Foundation.

=head1 NAME

src/pmc/null.pmc - NULL

=head1 DESCRIPTION

This 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() {}

    VTABLE void *get_pointer() {
        UNUSED(INTERP)
        UNUSED(SELF)
        return PMCNULL;
    }

    VTABLE void set_pointer(void *p) {
        UNUSED(INTERP)
        UNUSED(SELF)
        PMCNULL = (PMC *)p;
    }

    VTABLE INTVAL does(STRING *what) {
        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) {
        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) {
        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' :
 */
Something went wrong with that request. Please try again.