gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 16b6eee)
raw | patch | inline | side by side (parent: 16b6eee)
author | Doni Pracner <quinnuendo@gmail.com> | |
Mon, 13 Jan 2014 19:12:32 +0000 (20:12 +0100) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Mon, 13 Jan 2014 19:12:32 +0000 (20:12 +0100) |
src/mjc2wsl.java | patch | blob | history |
diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java
index c8da105e4bff4a081b92d20fd690f4a16f6fbc64..f27f255ec77b2df8cb983f757cc8203b6c4e0dde 100644 (file)
--- a/src/mjc2wsl.java
+++ b/src/mjc2wsl.java
trap = 57;
public String getStandardStart(){
+ return getStandardStart(10);
+ }
+
+ public String getStandardStart(int numWords){
StringBuilder ret = new StringBuilder(
"C:\" This file automatically converted from microjava bytecode\";\n"
+"C:\" with mjc2wsl v "+versionN+"\";\n");
ret.append("VAR < tempa := 0, tempb := 0, tempres :=0,\n\t");
ret.append("mjvm_locals := ARRAY(1,0), ");
+ ret.append("\n\tmjvm_statics := ARRAY("+numWords+",0), ");
ret.append("\n mjvm_estack := < >, mjvm_mstack := < >, ");
ret.append("\n mjvm_fp := 0, mjvm_sp := 0,");
ret.append("\n t_e_m_p := 0 > :");
return "mjvm_locals[" + (i+1)+"]";
}
+ private String genStatic(int i){
+ return "mjvm_statics[" + (i+1)+"]";
+ }
+
/**
* Creates a WSL comment with care to quote chars.
*/
int numberOfWords = get4();
int mainAdr = get4();
- prl(getStandardStart());
+ prl(getStandardStart(numberOfWords));
prl("SKIP;\n ACTIONS A_S_start:\n A_S_start == CALL a"+(14+mainAdr)+" END");
int op = get();
while (op >= 0) {
break;
}
- //TODO getstatic, putstatic
+ case getstatic:{
+ prl(cmdToEStack(genStatic(get2())));
+ break;
+ }
+ case putstatic: {
+ prl(cmdFromEStack(genStatic(get2())));
+ break;
+ }
//TODO getfield, putfield
case const_: {