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: 3e8d151)
raw | patch | inline | side by side (parent: 3e8d151)
author | Doni Pracner <quinnuendo@gmail.com> | |
Sun, 27 Jul 2014 23:47:53 +0000 (01:47 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Sun, 27 Jul 2014 23:57:44 +0000 (01:57 +0200) |
src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java | patch | blob | history |
diff --git a/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java b/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java
index 68fd2a108c4c2efde206cb26696852636ee32f4d..26452e802f4b3afb5c92775d9316b322f187af5a 100644 (file)
//default version name, used if the file is not found
private static String versionN = "0.1.x";
- private String versionFile = "version.properties";
+ private String versionFile = "/version.properties";
private TransMessages messages = new TransMessages();
private boolean genPopPush=false;
- private boolean genInlinePrint=false;
+ private boolean genInlinePrint = false;
+
+ private boolean genLocalVars = true;
/** Constant used for marking a regular comment from the original file */
public static final char C_REG = ' ';
ret.append("\nBEGIN");
ret.append("\nVAR <\n\t");
+ if (!genLocalVars){
+ ret.append("\n\ttempa := 0, tempb :=0, tempres := 0,");
+ }
ret.append("mjvm_locals := ARRAY(1,0),");
ret.append("\n\tmjvm_statics := ARRAY("+numWords+",0),");
ret.append("\n\tmjvm_arrays := < >,");
}
private String createStartVar(String... vars){
- StringBuilder ret = new StringBuilder("VAR < ");
- ret.append(vars[0] + " := 0");
- for (int i=1; i<vars.length; i++)
- ret.append(", "+ vars[i] +" := 0");
- ret.append(" > : ");
-
- return ret.toString();
+ if (genLocalVars) {
+ StringBuilder ret = new StringBuilder("VAR < ");
+ ret.append(vars[0] + " := 0");
+ for (int i = 1; i < vars.length; i++)
+ ret.append(", " + vars[i] + " := 0");
+ ret.append(" > : ");
+
+ return ret.toString();
+ }
+ return "";
}
private String createEndVar(){
- return "ENDVAR;";
+ if (genLocalVars)
+ return "ENDVAR;";
+ else
+ return "";
}
private String createLocal(int i) {
}
public void printHelpDirectives(){
- System.out.println("Alternatives for code generation:");
- System.out.println(" --genPopPush generate POP/PUSH instead of TAIL/HEAD");
- System.out.println(" --genHeadTail generate TAIL/HEAD instead of POP/PUSH ");
+ System.out.println("Alternatives for code generation (* are the defaults):");
+ System.out.print(genPopPush?'*':' ');
+ System.out.println(" --genPopPush generate POP/PUSH instead of TAIL/HEAD");
+ System.out.print(!genPopPush?'*':' ');
+ System.out.println(" --genHeadTail generate TAIL/HEAD instead of POP/PUSH ");
+ System.out.println();
+ System.out.print(genInlinePrint?'*':' ');
+ System.out.println(" --genInlinePrint generate prints directly instead of procedure calls");
+ System.out.print(!genInlinePrint?'*':' ');
+ System.out.println(" --genProcedurePrint generate prints as custom procedure calls");
System.out.println();
- System.out.println(" --genInlinePrint generate prints directly instead of procedure calls");
- System.out.println(" --genProcedurePrint generate prints as custom procedure calls");
+ System.out.print(genLocalVars?'*':' ');
+ System.out.println(" --genLocalVars generate local VAR block for temp variables");
+ System.out.print(!genLocalVars?'*':' ');
+ System.out.println(" --genGlobalVars do NOT generate local VAR block for temp variables");
}
public void printHelpHelp() {
genPopPush = false;
} else if (args[i].compareToIgnoreCase("--genProcedurePrint") == 0) {
genInlinePrint = false;
+ } else if (args[i].compareToIgnoreCase("--genLocalVars") == 0) {
+ genLocalVars = true;
+ } else if (args[i].compareToIgnoreCase("--genGlobalVars") == 0) {
+ genLocalVars = false;
}
i++;
}