There are three test case set in this homework.
You can use make example
, make test
, make bonus
to run them.
We provide simple argument parser in parser.y
, if output
is not NULL
, please use it as assembly filename, otherwise you can use the PROGRAM name as filename.
It would be something like:
PASS_HANDLE(codegen, ProgNode , node){
char fn[128];
prog = node->name;
sprintf(fn, "%s.s", node->name);
fd = fopen(output ? output : fn, "w");
gen(";gen code into the file\n");
fclose(fd);
}
- Use float to implement real type.
Bonus:
- nested (pure) function
- string operation
- array assignment
Material:
Note the example of x := y + z (strings)
in mapping:
java/lang/StringBuffer/append(java/lang/String;)Ljava/lang/StringBuffer;
should be:
java/lang/StringBuffer/append(Ljava/lang/String;)Ljava/lang/StringBuffer;
Hints:
- you may initialize the variables manually