fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / pmc / null.pmc
blobe645b1d86a6f28da98bbf9ad938832a99a4d7723
1 /*
2 Copyright (C) 2001-2010, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/pmc/null.pmc - NULL
9 =head1 DESCRIPTION
11 This simply creates a way of catching C<NULL> register accesses without
12 really slowing down the bytecode execution.
14 =cut
18 /* HEADERIZER HFILE: none */
19 /* HEADERIZER BEGIN: static */
20 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
22 PARROT_DOES_NOT_RETURN
23 static void null_pmc_access(PARROT_INTERP, int index)
24         __attribute__nonnull__(1);
26 #define ASSERT_ARGS_null_pmc_access __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
27        PARROT_ASSERT_ARG(interp))
28 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
29 /* HEADERIZER END: static */
31 pmclass Null singleton {
35 =head2 Vtable functions
37 =over 4
39 =item C<void init()>
41 Overrides the default to do nothing.
43 =cut
47     VTABLE void init() {
48         UNUSED(INTERP)
49     }
51     VTABLE void *get_pointer() {
52         UNUSED(INTERP)
53         return PMCNULL;
54     }
56     VTABLE void set_pointer(void *p) {
57         UNUSED(INTERP)
58         PMCNULL = (PMC *)p;
59     }
61     VTABLE INTVAL does(STRING *what) {
62         UNUSED(INTERP)
63         UNUSED(what)
64         /* XXX maybe a hack to get TGE running again */
65         return 0;
66     }
70 =item C<INTVAL is_same(PMC *value)>
72 Returns true if value is also a null PMC, false otherwise.
74 =cut
77     VTABLE INTVAL is_same(PMC *value) {
78         return PMC_IS_NULL(value);
79     }
83 =item C<PMC *find_method(STRING *method_name)>
85 Gives a more informative message than the automaticaly generated version.
87 =cut
91     VTABLE PMC *find_method(STRING *method_name) {
92         Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_NULL_REG_ACCESS,
93                 "Null PMC access in find_method('%Ss')",
94                 method_name);
95     }
101 =back
103 =head2 Auxiliar functions
105 =over 4
107 =item C<static void null_pmc_access(PARROT_INTERP, int index)>
109 Throws the Null PMC access exception.
111 =cut
115 PARROT_DOES_NOT_RETURN
116 static void
117 null_pmc_access(PARROT_INTERP, int index)
119     ASSERT_ARGS(null_pmc_access)
120     Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_NULL_REG_ACCESS,
121             "Null PMC access in %s()",
122             Parrot_get_vtable_name(interp, index));
127 =back
129 =cut
134  * Local variables:
135  *   c-file-style: "parrot"
136  * End:
137  * vim: expandtab shiftwidth=4:
138  */