SIMPL Code Generation
The target machine for the SIMPL compiler is the JVM. Code is generated from the syntax tree, using the templates given below. (Note: the BANNER is a comment string identifying the compiler and version.)
Node Type |
Template |
PROG |
; BANNER |
PROG |
; BANNER |
ID |
ldc
"name" |
ID |
ldc
"name" |
ID |
ldc
"name" |
ID |
ldc
"name" |
ID |
sipush
0 |
ID |
bipush
0 |
ID |
iload
varNum |
SPACE |
p1.generateCode |
NULL |
|
! |
p1.generateCode |
IF |
p1.generateCode |
WHILE |
lab1: |
<- |
p2.generateCode |
> |
p1.generateCode |
= |
p1.generateCode |
+ |
p1.generateCode |
+ |
p1.generateCode |
- |
p1.generateCode |
* |
p1.generateCode |
* |
p1.generateCode |
/ |
p1.generateCode |
NEG |
p1.generateCode ineg |
NEG |
bipush
1 |
NUM |
sipush
name |
BOOL |
bipush
value |