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: 94dbae2)
raw | patch | inline | side by side (parent: 94dbae2)
author | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 18:48:46 +0000 (20:48 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 22 Apr 2014 18:48:46 +0000 (20:48 +0200) |
src/mjc2wsl.java | patch | blob | history |
diff --git a/src/mjc2wsl.java b/src/mjc2wsl.java
index 858cae30017462a3e99346d55bb7e958db7230f6..bc6f4656427485f057a9bfe8e4b4676113b3d616 100644 (file)
--- a/src/mjc2wsl.java
+++ b/src/mjc2wsl.java
return ret.toString();
}
+ 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();
+ }
+
+ private String createEndVar(){
+ return "ENDVAR;";
+ }
+
private String createLocal(int i) {
// arrays start at 1 in WSL, so we need an offset
return "mjvm_locals[" + (i + 1) + "]";
break;
}
case div: {
+ prl(createStartVar("tempa", "tempb", "tempres"));
prl(createTopTwoEStack());
prl("IF tempa = 0 THEN ERROR(\"division by zero\") FI;");
prl("tempres := tempb DIV tempa;");
prl(createToEStack("tempres"));
+ prl(createEndVar());
break;
}
case rem: {
+ prl(createStartVar("tempa", "tempb", "tempres"));
prl(createTopTwoEStack());
prl("IF tempa = 0 THEN ERROR(\"division by zero\") FI;");
prl("tempres := tempb MOD tempa;");
prl(createToEStack("tempres"));
+ prl(createEndVar());
break;
}