lib/Parrot/Pmc2c/PCCMETHOD.pm contains a number of constants, defined
for use in the package. these constants should be generated during the
configure process and included, following the DRY principle (don't
repeat yourself.)
~jerry
use constant REGNO_INT => 0;
use constant REGNO_NUM => 1;
use constant REGNO_STR => 2;
use constant REGNO_PMC => 3;
#/* 4 low bits are argument types */
use constant PARROT_ARG_INTVAL => 0x000;
use constant PARROT_ARG_STRING => 0x001;
use constant PARROT_ARG_PMC => 0x002;
use constant PARROT_ARG_FLOATVAL => 0x003;
use constant PARROT_ARG_TYPE_MASK => 0x00f;
#/* argument meaning and conversion bits */
use constant PARROT_ARG_CONSTANT => 0x010;
#/* bits a user has to define */
use constant PARROT_ARG_FLATTEN => 0x020; # /*
.flatten_arg */
use constant PARROT_ARG_SLURPY_ARRAY => PARROT_ARG_FLATTEN; # /*
i.e. foldup */
use constant PARROT_ARG_OPTIONAL => 0x080;
use constant PARROT_ARG_OPT_FLAG => 0x100; # /*
prev optional was set */
use constant PARROT_ARG_NAME => 0x200; # /*
this String is an arg name */
In r20917, I committed a patch from Lukas Mai at the YAPC::EU hackathon,
to solve this. It refactors config/gen/parrot_include.pm, to generate
not just the .pasm versions of the constants files, but also Perl versions.
I would like to see this refactored further, so it generates .pm files
in lib/Parrot/Constants, and so lib/Parrot/Pmc2c/PCCMETHOD.pm uses the
constants as standard modules with a standard import.
The patch is a huge improvement over the existing code in modularity and
maintainability.
Allison