Source

parvik / src / ops / parvik.ops

Full commit
/*
 * Copyright (C) 2011, Parrot Foundation.
 */

BEGIN_OPS_PREAMBLE

#include "parrot/dynext.h"

END_OPS_PREAMBLE

/* Op to get the address of a PMC. */
inline op parvik_pmc_addr(out INT, invar PMC) :base_core {
    $1 = (int) $2;
    goto NEXT();
}

inline op move(out INT, invar INT) :base_core {
    $1 = $2;
}

inline op move(out NUM, invar NUM) :base_core {
    $1 = $2;
}

inline op move(out STR, invar STR) :base_core {
    $1 = $2;
}

inline op move_object(out PMC, invar PMC) :base_core {
    $1 = $2;
}

inline op const(out INT, inconst INT) :base_core {
    $1 = $2;
}

inline op const_string(out STR, inconst STR) :base_core {
    $1 = $2;
}

inline op const_class(out PMC, in INT) :base_core {
    INTVAL base_type = $2;
    PMC *classobj = interp->vtables[base_type]->pmc_class;

    if (PMC_IS_NULL(classobj) || !PObj_is_class_TEST(classobj))
      classobj = Parrot_pmc_new_init_int(interp, enum_class_PMCProxy, base_type);

    $1 = classobj;
}

inline op instance_of(out INT, invar PMC, in INT) :base_core {
    PMC *classobj = Parrot_oo_get_class(interp, $2);

    if (classobj->vtable->base_type == $3)
        $1 = 1;
    else
        $1 = 0;
}

inline op instance_of(out INT, invar INT, in INT) :base_core {
    $1 = 0;
}

inline op instance_of(out INT, invar NUM, in INT) :base_core {
    $1 = 0;
}

inline op instance_of(out INT, invar STR, in INT) :base_core {
    $1 = 0;
}

inline op array_length(out INT, invar PMC) :base_core {
    $1 = VTABLE_elements(interp, $2);
}

inline op new_instance(out PMC, in INT) :base_core {
    $1 = Parrot_pmc_new(interp, $2);
}

inline op new_array(out PMC, int INT, in INT) :base_core {
    if (Parrot_pmc_type_does(interp, "array", $3))
        $1 = Parrot_pmc_new_init_int(interp, $3, $2);
}

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