Next: The ``Defined'' Example Up: Internals of perl Previous: perl As a Compiler   Contents

The perl Intermediate Representation

While the tight coupling of the PVM and perl's front-end does cause some problems, there is still a clearly defined intermediate representation (IR) that is generated by perl's front-end. This section discusses that IR.

The perl IR consists of a parse tree. In the context of perl, this IR is commonly referred as the ``OP-tree''. This OP-tree is an acyclic directed graph representing the flow of the Perl program. There are twelve different OP classes, and a total of 346 different OPs.

Each OP has a number of flags and options. These flags and options control the behavior of the OP. Care must be taken when using the IR, as these options and flags can often change the semantics of the OP-tree evaluation.

Certain types of OPs also have additional fields that might refer to other OPs, or to internal perl data structures. For example, the LISTOP, which is used to group other OPs into a list, contains a field for its child OPs. The SVOP, which is used to refer to a scalar variable, contains a field that points to perl's internal representation of that scalar variable.

The next two subsections contain examples of Perl programs, and their equivalent OP-trees.



Subsections
Next: The ``Defined'' Example Up: Internals of perl Previous: perl As a Compiler   Contents

Copyright © 2000, 2001 Bradley M. Kuhn.

Verbatim copying and distribution of this entire thesis is permitted in any medium, provided this notice is preserved.