This is a build directory for custom PMCs with a sample foo.pmc providing the Foo PMC class.
Edit/create your foo.pmc source - For details on creating PMCs, see "classes/genclass.pl" in ..
There are some differences you have to be aware of when creating dynamic PMCs.
When declaring the dynamic PMC, you must specify the dynpmc flag, as in:
dynpmc
pmclass TclString extends TclObject dynpmc ... { ... }
Note that regular (non-dynamic) PMCs have a type id enum_class_PMCNAME, but dynamic PMCs obviously cannot use the same thing. Instead, a dynamically-chosen value is assigned at runtime - so, when you refer to the type of the class , you must dynamically determine the PMC type. So, while scalar (a builtin) has the luxury of knowing at compile time what the class number of its child String is -- for example:
enum_class_PMCNAME
scalar
String
if (type == enum_class_String) { ...
a dynamic PMC such as TclInt must instead perform a runtime lookup of its corresponding TclString PMC, resulting in the more complicated:
TclInt
TclString
static INTVAL dynclass_TclString; pmclass TclInt extends TclObject extends Integer dynpmc group tcl_group { void class_init() { if (pass) { dynclass_TclString = Parrot_PMC_typenum(INTERP,"TclString"); } } }
Finally, if you have a group of PMCs that are interdependent, use the group GROUPNAME syntax to trigger a group library to be built. You will use the group name as the name of the library to load using the PASM op loadlib.
group GROUPNAME
loadlib
pmclass Match extends Hash dynpmc group match_group { ... }
and then in your .imc or .pasm file:
loadlib $P0, "match_group"
Edit ../config/gen/makefiles/dynclasses.in and append your PMC(s) to the build target. The dynclasses.in file is processed by Configure.pl to create the real makefiles. So, invoke the configure script, then make:
../config/gen/makefiles/dynclasses.in
$ perl Configure.pl $ make
If anything changes inside parrot, be sure to:
$ make dynclasses-clean
To install Ruby, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ruby
CPAN shell
perl -MCPAN -e shell install Ruby
For more information on module installation, please visit the detailed CPAN module installation guide.