/*
Copyright (C) 2001-2006, The Perl Foundation.
$Id: perlscalar.pmc 16836 2007-01-30 04:30:52Z coke $

=head1 NAME

src/dynpmc/perlscalar.pmc - Perl Scalar

=head1 DESCRIPTION

Abstract base class for perl scalars.

This class implements common perl scalar functionality: e.g morphing to
another scalar type. The morph method replaces the CHANGE_TYPE macro.

=head2 Methods

=over 4

=cut

*/

#include "parrot/parrot.h"


pmclass perlscalar
    abstract
    noinit
    dynpmc
    group perl_group
    extends scalar {

/*

=item C<void morph(INTVAL type)>

Morphs the scalar to the specified type.

=cut

*/

    void morph(INTVAL type) {
        if (SELF->vtable->base_type == type)
            return;

        switch (type) {
            case enum_class_Integer:
                type = pmc_type(interp,
                    string_from_const_cstring(interp, "PerlInt", 0));
                break;
            case enum_class_Float:
                type = pmc_type(interp,
                    string_from_const_cstring(interp, "PerlNum", 0));
                break;
            case enum_class_String:
                type = pmc_type(interp,
                    string_from_const_cstring(interp, "PerlString", 0));
                break;
            case enum_class_Undef:
                type = pmc_type(interp,
                    string_from_const_cstring(interp, "PerlUndef", 0));
                break;
        }
        pmc_reuse(INTERP, SELF, type, 0);
    }

}

/*

=back

=cut

*/

/*
 * Local variables:
 *   c-file-style: "parrot"
 * End:
 * vim: expandtab shiftwidth=4:
 */
