2 * Copyright (C) 2001-2008, The Perl Foundation.
6 * These are the vtable functions for the TclInt base class
7 * Data Structure and Algorithms:
12 #include "parrot/embed.h"
24 void assign_pmc(PMC* value) {
25 STRING * const undef = string_from_cstring(INTERP, "Undef", 5);
27 if (VTABLE_isa(INTERP, value, undef))
28 pmc_reuse(INTERP, SELF, value->vtable->base_type, 0);
30 SELF.set_integer_native(VTABLE_get_integer(INTERP, value));
36 * TclInt shouldn't automatically promote division to float.
38 PMC* divide(PMC* value, PMC* dest) {
40 INTVAL n = PMC_int_val(SELF);
41 INTVAL d = PMC_int_val(value);
44 real_exception(INTERP, NULL, E_ZeroDivisionError, "divide by zero");
47 dest = pmc_new(INTERP, SELF->vtable->base_type);
49 VTABLE_set_integer_native(INTERP, dest, n / d);
53 FLOATVAL d = VTABLE_get_number(INTERP, value);
56 real_exception(INTERP, NULL, E_ZeroDivisionError,
57 "float division by zero");
60 dest = pmc_new(INTERP, SELF->vtable->base_type);
61 VTABLE_set_number_native(INTERP, dest, SELF.get_number() / d);
70 * c-file-style: "parrot"
72 * vim: expandtab shiftwidth=4: