Chapter 7. The Intermediate Code Compiler
Gentlemen, we can rebuild him. We have the technology. [ . . . ]
Better than he was before. Better . . . stronger . . . faster.
The Intermediate Code Compiler (IMCC) is an alternate tool for creating and running Parrot bytecode. It has several advantages over the method introduced in the previous chapter. It’s a Parrot assembler and embeds the Parrot runtime engine, so it can compile a PASM file to bytecode and immediately run the bytecode with a single command. IMCC can also perform code optimizations, though it doesn’t by default.
IMCC includes its own language, which is commonly called
Parrot Intermediate
Language (PIR). PIR is an overlay on top of Parrot assembly language
and has many higher-level features, though it still
isn’t a high-level language. Assembly files
containing PIR code end with an
.imc
extension.
Getting Started
The first step to working with IMCC
is to compile it. First, build Parrot following the steps in the
previous chapter. Then, from within the
languages/imcc
directory in the
parrot
repository, type:
$ make $ make test
It’s likely that by the time you read this, you
won’t have to compile IMCC at all. One of the
planned tasks is to include these steps in Parrot’s
Makefile
, so it will be done when you compile
Parrot.
After compiling IMCC, create a file fjords.pasm
in the languages/imcc
directory with these two
lines (or reuse the file from Chapter 6):
print "He's pining for the ...
Get Perl 6 Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.