The Interpreter
Virgil is designed for developing systems-level software for microcontrollers, which leads to an emphasis on static checking and static compilation, where a program is compiled to machine code by a cross compiler running on a desktop or server class machine and then deployed onto the device. However, the core of the Virgil language, including the primitive values and operators as well as the object concepts have semantics that are independent of any particular machine. Thus, a Virgil program that does not directly access specific hardware state of particular devices or service hardware interrupts will compute the same results on any machine.
The core portability of Virgil allows us to write programs that run anywhere; in fact, we can run these programs on an interpreter, which allows rapid feedback, testing, and debugging. The Virgil compiler, in addition to the normal tasks of parsing, typechecking, optimizing and transforming Virgil code into C or machine code, also contains an interpreter for the complete language. This interpreter is what allows an application to allocate and initialize its data structures during compilation. But we can also use this interpreter to test and debug our programs before we run them on the hardware. We will use the built-in interpreter throughout this introduction to gain familiarity with the language and its constructs before we attempt to target specific hardware.
Let's try running a simple program in the Virgil interpreter. After downloading the
source distribution and compiling the compiler
(and assuming that you set your $CLASSPATH
variable correctly), go to the
virgil/doc/intro/
directory. You find in that directory a number of example
programs that are used in this introduction. We can run the HelloWorld
program with the following command:
% java vpc.Interpreter HelloWorld.v Hello World! % _
Go back to the tutorial.