GSoC/GCI Archive
Google Code-in 2010 Parrot Foundation and The Perl Foundation

Sanify STRING->PMC Conversions

completed by: Matt Rajca

mentors: whiteknight

Task description: Parrot has 4 primary data types: PMC, STRING, INTVAL, and FLOATVAL. Parrot allows automatic conversions between these 4 types as necessary. Converting low-level type (STRING, INTVAL, and FLOATVAL) to a PMC is called "boxing". Boxing happens in many places.

Several places box a STRING, and this creates lots of duplicate code. Implement a new function, Parrot_pmc_box_string in src/pmc.c to perform this logic. The function should take the interp and a STRING*, and return a PMC*. It should follow HLL mapping rules (See examples for details).

Steps for Completion:

  1. Create a fork of parrot/parrot on Github
  2. Create a new function, Parrot_pmc_box_string in src/pmc.c. Do not mark it PARROT_EXPORT. Do mark it PARROT_HOT and PARROT_INLINE.
  3. Update src/pmc/callcontext.pmc:autobox_pmc() to use the new function for STRINGs
  4. Delete the function make_string_pmc from src/dynext.c. Replace all calls to it with your new function.
  5. Update the definition for the box opcode in src/ops/pmc.ops to use the new function (ask for help if you don't understand ops)
  6. Update the function Parrot_api_pmc_box_string in src/embed/api.c to use your new function
  7. Build parrot and run all tests to verify
  8. Open a pull request on github to have your changes merged in.