2 Copyright (C) 2004 - 2008, The Perl Foundation.
7 src/pmc/undef.pmc - Generic undefined value
11 This is Parrot's generic undef type. This PMC has no defined value.
12 It returns a numeric value of 0, a boolean of false, and an empty string.
13 When assigned a number, integer, or string it morphs to a Number,
14 Integer, or String PMC respectively, and when assigned a generic PMC
15 it morphs into a PMC of the passed-in type and does a same-type assignment
26 #include "parrot/parrot.h"
27 #define UNDEF_STRING_CLASS enum_class_String
29 pmclass Undef extends default no_ro {
33 =item C<void set_pmc(PMC *other)>
35 Sets the current PMC to C<*other> by first changing the current PMC to the
42 VTABLE void set_pmc(PMC *other) {
43 VTABLE_morph(INTERP, SELF, enum_class_Ref);
44 VTABLE_set_pmc(INTERP, SELF, other);
49 =item C<void assign_pmc(PMC *other)>
51 Assigns the PMC to the value of C<*other> by first changing the PMC to the
58 VTABLE void assign_pmc(PMC *other) {
59 if (!PObj_is_object_TEST(other))
60 VTABLE_morph(INTERP, SELF, other->vtable->base_type);
62 /* don't want to call set_pmc if we're assigning an Undef to an Undef */
63 if (other->vtable->base_type != enum_class_Undef)
64 VTABLE_set_pmc(INTERP, SELF, other);
70 =item C<INTVAL get_integer()>
78 VTABLE INTVAL get_integer() {
84 =item C<INTVAL defined()>
92 VTABLE INTVAL defined() {
98 =item C<void set_integer_native(INTVAL value)>
100 Morphs the current PMC to an C<Integer> and sets the value from C<value>.
106 VTABLE void set_integer_native(INTVAL value) {
107 VTABLE_morph(INTERP, SELF, enum_class_Integer);
108 VTABLE_set_integer_native(INTERP, SELF, value);
113 =item C<FLOATVAL get_number()>
121 VTABLE FLOATVAL get_number() {
127 =item C<void set_number_native(FLOATVAL value)>
129 Morphs the current PMC to a C<Float> and sets the value from C<value>.
135 VTABLE void set_number_native(FLOATVAL value) {
136 VTABLE_morph(INTERP, SELF, enum_class_Float);
137 VTABLE_set_number_native(INTERP, SELF, value);
142 =item C<STRING *get_string()>
144 Returns an empty string.
150 VTABLE STRING *get_string() {
151 return string_make_empty(INTERP, enum_stringrep_one, 0);
156 =item C<void set_string_native(STRING *value)>
158 Morphs the current PMC to a C<String> and sets the value from C<value>.
164 VTABLE void set_string_native(STRING *value) {
165 VTABLE_morph(INTERP, SELF, UNDEF_STRING_CLASS);
166 VTABLE_set_string_native(INTERP, SELF, value);
171 =item C<INTVAL get_bool()>
179 VTABLE INTVAL get_bool() {
185 =item C<void share()>
193 VTABLE void share() {
194 /* see src/pmc/integer.pmc */
199 =item C<PMC *share_ro()>
207 VTABLE PMC *share_ro() {
208 if (PObj_is_PMC_shared_TEST(SELF))
211 return pt_shared_fixup(INTERP, SELF);
216 =item C<PMC *clone()>
218 Clones the current Undef PMC.
224 VTABLE PMC *clone() {
225 return pmc_new(INTERP, SELF->vtable->base_type);
230 =item C<INTVAL is_equal(PMC *value)>
232 Returns 1 if the C<*value> is an Undef PMC, 0 otherwise.
238 VTABLE INTVAL is_equal(PMC *value) {
259 * c-file-style: "parrot"
261 * vim: expandtab shiftwidth=4: