Next: The ``Add and Print'' Up: Second Approach Kawa Integration Previous: A New Layer of   Contents

The Kawa IR

The Kawa IR is provided by the Java package, gnu.expr.*. This package, described in [4,5], provides classes that represent nodes in a parse tree. Each node in that tree is a subclass of the abstract base class Expression.

Each Expression has two key methods: eval and compile. The former is used when the program is run interactively. When invoked, eval evaluates the current expression (and often subexpressions) in the context of the current run-time environment. The compile method is used to compile the expression (and often subexpressions) to a JVM class file for later use.

One of the most important subclasses of Expression is the LambdaExp, which provides the basic semantics of a lambda expression in Scheme. However, the LambdaExp class is an abstraction of lambda, and thus does not contain anything specific to Scheme. The LambdaExp can be used to enclose functions as well as objects, including handling of parameters, localized lexically scoped variables and variables internally captured by a closure.

The ModuleExp is a subclass of LambdaExp. A ModuleExp maps onto a JVM class, and can include declarations of both static and instance variables, and static and instance methods. When translating perl's IR to Kawa's IR, a ModuleExp is used to represent each Perl package.


Next: The ``Add and Print'' Up: Second Approach Kawa Integration Previous: A New Layer of   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.