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: 3163f81)
raw | patch | inline | side by side (parent: 3163f81)
author | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 22:45:41 +0000 (00:45 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 22:45:41 +0000 (00:45 +0200) |
src/mjc2wsl.java | patch | blob | history |
diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java
index 87177112908a7923d7a282be0825afdec10b0659..52c75422b7b7a6bd6ecc6a044830c69da686dbce 100644 (file)
--- a/src/mjc2wsl.java
+++ b/src/mjc2wsl.java
private boolean genPauseAfterEachAddress=false,
genPrintForEachAddress = false,
genPrintEStackOnChange = false;
+
+ private boolean genPopPush=false;
/** Constant used for marking a regular comment from the original file */
public static final char C_REG = ' ';
// generalised stack operations
private String createToStack(String stack, String var){
- return stack + " := <" + var + " > ++ " + stack +";";
+ if (genPopPush)
+ return "PUSH("+stack+"," + var + ");";
+ else
+ return stack + " := <" + var + " > ++ " + stack +";";
}
private String createFromStack(String stack, String var){
+ if (genPopPush)
+ return "POP("+ var + ", "+stack+");";
+ else
return var + ":= HEAD("+stack+"); "+stack+" := TAIL("+stack+");";
}
//Expression stack
case load_1:
case load_2:
case load_3: {
- prl(createToEStack(createLocal(op - load_0)));
+ prl(createStartVar("tempa"));
+ prl("tempa :="+createLocal(op - load_0)+";");
+ prl(createToEStack("tempa"));
+ prl(createEndVar());
break;
}
case store: {
case store_1:
case store_2:
case store_3: {
- prl(createFromEStack(createLocal(op - store_0)));
+ prl(createStartVar("tempa"));
+ prl(createFromEStack("tempa"));
+ prl(createLocal(op - store_0)+" := tempa;");
+ prl(createEndVar());
break;
}
System.out.println();
printHelpOutput();
System.out.println();
+ printHelpDirectives();
+ System.out.println();
printHelpGenerating();
System.out.println();
printHelpHelp();
System.out.println(" --genAll short for applying all code generation");
}
+ public void printHelpDirectives(){
+ System.out.println("Alternatives for code generation:");
+ System.out.println(" --genPopPush generate POP/PUSH instead of TAIL/HEAD");
+ }
+
public void printHelpHelp() {
System.out.println("Help and info options");
System.out.println(" -h basic help");
genPrintEStackOnChange = true;
genPrintForEachAddress = true;
genPauseAfterEachAddress = true;
+ } else if (args[i].compareToIgnoreCase("--genPopPush") == 0) {
+ genPopPush = true;
}
i++;
}