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: efe68ac)
raw | patch | inline | side by side (parent: efe68ac)
author | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 21:24:45 +0000 (23:24 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 21:24:45 +0000 (23:24 +0200) |
src/mjc2wsl.java | patch | blob | history |
diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java
index 388f1ad39b965402297e05535b2a157482c3cd27..87177112908a7923d7a282be0825afdec10b0659 100644 (file)
--- a/src/mjc2wsl.java
+++ b/src/mjc2wsl.java
public static String createComment(String str, char type) {
return "C:\"" + type + str.replace("\"", "''") + "\";";
}
+
+ // generalised stack operations
+
+ private String createToStack(String stack, String var){
+ return stack + " := <" + var + " > ++ " + stack +";";
+ }
- //Expression stack
+ private String createFromStack(String stack, String var){
+ return var + ":= HEAD("+stack+"); "+stack+" := TAIL("+stack+");";
+ }
+//Expression stack
private String createToEStack(int i) {
- String res = "mjvm_estack := <" + i + " > ++ mjvm_estack;";
- if (genPrintEStackOnChange)
- res += "PRINT(\"eStack\",mjvm_estack);";
- return res;
+ return createToEStack(i+"");
}
private String createToEStack(String i) {
- String res = "mjvm_estack := <" + i + " > ++ mjvm_estack;";
+ String res = createToStack("mjvm_estack", i);
if (genPrintEStackOnChange)
res += "PRINT(\"eStack\",mjvm_estack);";
return res;
}
private String createFromEStack(String st) {
- String res = st
- + " := HEAD(mjvm_estack); mjvm_estack := TAIL(mjvm_estack);";
+ String res = createFromStack("mjvm_estack",st);
if (genPrintEStackOnChange)
res += "PRINT(\"eStack\",mjvm_estack);";
return res;
//Method stack
private String createToMStack(int i) {
- return "mjvm_mstack := <" + i + " > ++ mjvm_mstack;";
+ return createToMStack(i+"");
}
private String createToMStack(String i) {
- return "mjvm_mstack := <" + i + " > ++ mjvm_mstack;";
+ return createToStack("mjvm_mstack", i);
}
private String createFromMStack(String st) {
- return st + " := HEAD(mjvm_mstack); mjvm_mstack := TAIL(mjvm_mstack);";
+ return createFromStack("mjvm_mstack", st);
}
private String getRelationFor(int opcode) throws Exception {