rgravina wrote
So, I found if I ran the supplied compiler against the first/simplest test program listed in the project (Seven), the results showed a function definition, pushing some constants and calling Math.multiply on them (expression parsing), calling Output.printInt ('do' statement, returning void and throwing away return value) etc.
It can also help to write your own even simpler test programs to compare between the compilers. For example, if method calls are causing trouble you could try this
class Test {
method int test(int x) {
var Test t;
var int y;
let y = test(x);
let y = t.test(x);
return y;
}
}
Another thing that can be quite helpful is to write the source code as comments in the generated vm. You probably want to make writing the comments an option.
Here's what my compiler generates with the -d option is set.
/// 1: class Test {
/// 2: method int test(int x) {
/// 3: var Test t;
/// 4: var int y;
function Test.test 2 // 0
push argument 0 // 1 this
pop pointer 0 // 2 this
/// 5: let y = test(x);
push pointer 0 // 3 this
push argument 1 // 4 x
call Test.test 2 // 5
pop local 1 // 6 y
/// 6: let y = t.test(x);
push local 0 // 7 t
push argument 1 // 8 x
call Test.test 2 // 9
pop local 1 // 10 y
/// 7: return y;
push local 1 // 11 y
return // 12
/// 8: }
/// 9: }
(The numbers to the right are the vm line numbers displayed in the VMEmulator—every vm command gets a number except for
label.)
--Mark