O'Reilly logo

Perl 6 Essentials by Leopold Tötsch, Dan Sugalski, Allison Randal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. The Intermediate Code Compiler

Gentlemen, we can rebuild him. We have the technology. [ . . . ]

Better than he was before. Better . . . stronger . . . faster.

Oscar Goldman, The Six Million Dollar Man

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required