├── .github └── workflows │ └── main.yml ├── .gitignore ├── Makefile ├── README.assets └── image-20200612234843059.png ├── README.md ├── assets ├── SSA_example1.3.png ├── image-20200322185846797.png ├── image-20200511135217105.png ├── image-20200511135228135.png ├── image-20200511135235202.png └── image-20200511141736110.png ├── configure ├── configure.ac ├── deps ├── javacc-7.0.5.jar ├── jtb132.jar ├── kgi.jar ├── minijava-parser.jar ├── pgi.jar └── spp.jar ├── src ├── HelloWorld.java ├── Info.java ├── J2P.java ├── K2M.java ├── P2S.java ├── S2K.java ├── Type.java ├── TypeCheck.java ├── kanga.jj ├── minijava.jj ├── mips.jj ├── piglet.jj └── spiglet.jj └── testcases ├── kanga ├── BinaryTree.kg ├── BubbleSort.kg ├── Factorial.kg ├── LinearSearch.kg ├── LinkedList.kg ├── MoreThan4.kg ├── QuickSort.kg └── TreeVisitor.kg ├── minijava ├── ArgOrd.java ├── BinaryTree-error.java ├── BinaryTree.java ├── BubbleSort-error.java ├── BubbleSort.java ├── ErrorNull.java ├── ErrorOutBound.java ├── Factorial-error.java ├── Factorial.java ├── LinearSearch-error.java ├── LinearSearch.java ├── LinkedList-error.java ├── LinkedList.java ├── MoreThan20Parameters.java ├── MoreThan4-error.java ├── MoreThan4.java ├── Overload-error.java ├── QuickSort-error.java ├── QuickSort.java ├── RecursiveExtend.java ├── TreeVisitor-error.java ├── TreeVisitor.java ├── priv.test01.java ├── priv.test02.java ├── priv.test03.java ├── priv.test04.java ├── priv.test05.java ├── priv.test06.java ├── priv.test07.java ├── priv.test08.java ├── priv.test09.java ├── priv.test10.java ├── priv.test11.java ├── priv.test12.java ├── priv.test13.java ├── priv.test14.java ├── priv.test15.java ├── priv.test16.java ├── priv.test17.java ├── priv.test18.java ├── priv.test19.java ├── priv.test20.java ├── priv.test21.java ├── priv.test22.java ├── priv.test23.java ├── test00.java ├── test01.java ├── test02.java ├── test03.java ├── test04.java ├── test05.java ├── test06.java ├── test07.java ├── test08.java ├── test09.java ├── test10.java ├── test11.java ├── test12.java ├── test13.java ├── test14.java ├── test15.java ├── test16.java ├── test17.java ├── test18.java ├── test19.java ├── test20.java ├── test21.java ├── test22.java ├── test23.java ├── test24.java ├── test25.java ├── test26.java ├── test27.java ├── test28.java ├── test29.java ├── test30.java ├── test31.java ├── test32.java ├── test33.java ├── test34.java ├── test35.java ├── test36.java ├── test37.java ├── test38.java ├── test39.java ├── test40.java ├── test41.java ├── test42.java ├── test43.java ├── test44.java ├── test45.java ├── test46.java ├── test47.java ├── test48.java ├── test49.java ├── test50.java ├── test51.java ├── test52.java ├── test53.java ├── test54.java ├── test55.java ├── test56.java ├── test57.java ├── test58.java ├── test59.java ├── test60.java ├── test61.java ├── test62.java ├── test63.java ├── test64.java ├── test65.java ├── test66.java ├── test67.java ├── test68.java ├── test69.java ├── test70.java ├── test71.java ├── test72.java ├── test73.java ├── test74.java ├── test75.java ├── test76.java ├── test77.java ├── test78.java ├── test79.java ├── test80.java ├── test81.java ├── test82.java ├── test83.java ├── test84.java ├── test85.java ├── test86.java ├── test87.java ├── test88.java ├── test89.java ├── test90.java ├── test91.java ├── test92.java ├── test93.java ├── test94.java ├── test95.java ├── test96.java ├── test97.java ├── test98.java └── test99.java ├── mips ├── BinaryTree.s ├── BubbleSort.s ├── Factorial.s ├── LinearSearch.s ├── LinkedList.s ├── MoreThan4.s ├── QuickSort.s └── TreeVisitor.s ├── piglet ├── BinaryTree.pg ├── BubbleSort.pg ├── Factorial.pg ├── LinearSearch.pg ├── LinkedList.pg ├── MoreThan4.pg ├── QuickSort.pg ├── TreeVisitor.pg ├── priv.test01.pg ├── priv.test02.pg ├── priv.test03.pg ├── priv.test04.pg ├── priv.test05.pg ├── priv.test06.pg ├── priv.test07.pg ├── priv.test08.pg ├── priv.test09.pg ├── priv.test10.pg ├── priv.test11.pg ├── priv.test12.pg ├── priv.test13.pg ├── priv.test14.pg ├── priv.test15.pg ├── priv.test16.pg ├── priv.test17.pg ├── priv.test18.pg ├── priv.test19.pg ├── priv.test20.pg ├── priv.test21.pg ├── priv.test22.pg └── priv.test23.pg └── spiglet ├── BinaryTree.spg ├── BubbleSort.spg ├── Factorial.spg ├── LinearSearch.spg ├── LinkedList.spg ├── MoreThan4.spg ├── QuickSort.spg └── TreeVisitor.spg /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Set up Prequisites 16 | run: sudo apt install -y spim 17 | - name: Set up Java 18 | uses: actions/setup-java@v1.3.0 19 | with: 20 | java-version: '11' 21 | java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk 22 | architecture: x64 # (x64 or x86) - defaults to x64 23 | - name: Build the Targets 24 | run: | 25 | make 26 | make build 27 | - name: Run Test 28 | run: make test -j8 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ IDEA 2 | .idea/ 3 | 4 | # vscode 5 | .vscode/ 6 | 7 | # configure 8 | config.* 9 | autom4te.cache/ 10 | 11 | out/ 12 | temp/ 13 | src/minijava 14 | src/piglet 15 | src/spiglet 16 | src/kanga 17 | src/mips 18 | 19 | # Mac OS 20 | .DS_Store 21 | 22 | -------------------------------------------------------------------------------- /README.assets/image-20200612234843059.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/README.assets/image-20200612234843059.png -------------------------------------------------------------------------------- /assets/SSA_example1.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/SSA_example1.3.png -------------------------------------------------------------------------------- /assets/image-20200322185846797.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/image-20200322185846797.png -------------------------------------------------------------------------------- /assets/image-20200511135217105.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/image-20200511135217105.png -------------------------------------------------------------------------------- /assets/image-20200511135228135.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/image-20200511135228135.png -------------------------------------------------------------------------------- /assets/image-20200511135235202.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/image-20200511135235202.png -------------------------------------------------------------------------------- /assets/image-20200511141736110.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/assets/image-20200511141736110.png -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT(MiniJava-Compiler, 1.0) 2 | 3 | AC_CHECK_PROGS([SPIM], [spim], [:]) 4 | if test "$SPIM" = :; then 5 | AC_MSG_ERROR([This package needs spim.]) 6 | fi 7 | 8 | AC_OUTPUT -------------------------------------------------------------------------------- /deps/javacc-7.0.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/javacc-7.0.5.jar -------------------------------------------------------------------------------- /deps/jtb132.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/jtb132.jar -------------------------------------------------------------------------------- /deps/kgi.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/kgi.jar -------------------------------------------------------------------------------- /deps/minijava-parser.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/minijava-parser.jar -------------------------------------------------------------------------------- /deps/pgi.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/pgi.jar -------------------------------------------------------------------------------- /deps/spp.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magic3007/MiniJava-Compiler/50aac0fc192d2c6effa9b503f61caed8658a3a9b/deps/spp.jar -------------------------------------------------------------------------------- /src/HelloWorld.java: -------------------------------------------------------------------------------- 1 | import minijava.parser.*; 2 | import minijava.visitor.GJNoArguDepthFirst; 3 | import minijava.syntaxtree.*; 4 | 5 | class Print extends GJNoArguDepthFirst { 6 | public void MinusExpression(Expression n) { 7 | System.out.println("-"); 8 | } 9 | } 10 | 11 | public class HelloWorld { 12 | public static void main(String []args) throws Exception { 13 | MiniJavaParser parser = new MiniJavaParser(System.in); 14 | Node root = parser.Goal(); 15 | root.accept(new Print()); 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Info.java: -------------------------------------------------------------------------------- 1 | import java.io.PrintStream; 2 | import java.util.*; 3 | 4 | class Info { 5 | static final boolean DEBUG = false; 6 | 7 | static void dd(String s) { 8 | if (!DEBUG) { 9 | // pass 10 | } else { 11 | System.out.print(s); 12 | } 13 | } 14 | 15 | static void dln() { 16 | if (!DEBUG) { 17 | // pass 18 | } else { 19 | System.out.println(); 20 | } 21 | } 22 | 23 | static void dump(String... msg) { 24 | if (!DEBUG) { 25 | // pass 26 | } else { 27 | for (String m : msg) { 28 | dd(m); 29 | dd(" "); 30 | } 31 | dln(); 32 | } 33 | } 34 | 35 | static void panic(String... msg) { 36 | dump(msg); 37 | throw new RuntimeException("DEBUG"); 38 | } 39 | 40 | static void debug(String... msg) { 41 | dump(msg); 42 | } 43 | } 44 | 45 | class Emitter { 46 | private int indentNum = 0; 47 | private List buf = new LinkedList(); 48 | boolean mute = true; 49 | 50 | java.io.PrintStream out = System.out; 51 | 52 | Emitter() { 53 | } 54 | 55 | Emitter(boolean mute) { 56 | this.mute = mute; 57 | } 58 | 59 | void emitBuf(String... msg) { 60 | for (String m : msg) { 61 | buf.add(m); 62 | } 63 | } 64 | 65 | void emitFlush() { 66 | if (buf.size() == 0) { 67 | return; 68 | } 69 | String[] args = buf.toArray(new String[0]); 70 | buf.clear(); 71 | emit(args); 72 | } 73 | 74 | String numToOffset(int num) { 75 | return Integer.toString(num * 4); 76 | } 77 | 78 | void emitOpen(String... msg) { 79 | emitFlush(); 80 | emit(msg); 81 | indentNum += 1; 82 | } 83 | 84 | void emitClose(String... msg) { 85 | emitFlush(); 86 | indentNum -= 1; 87 | emit(msg); 88 | } 89 | 90 | void emit(String... msg) { 91 | if (mute) { 92 | return; 93 | } 94 | if (msg.length == 0) { 95 | return; 96 | } 97 | if (buf.size() != 0) { 98 | this.emitFlush(); 99 | } 100 | for (int i = 0; i < indentNum; i++) { 101 | out.print("\t"); 102 | } 103 | for (String m : msg) { 104 | out.print(m); 105 | out.print(" "); 106 | } 107 | out.println(); 108 | } 109 | 110 | private int labelNum = 100; 111 | 112 | String newLabel() { 113 | labelNum += 1; 114 | return "L" + labelNum; 115 | } 116 | 117 | private int tempNum = 200; 118 | 119 | String newTemp() { 120 | tempNum += 1; 121 | return "TEMP " + tempNum; 122 | } 123 | 124 | void setTempNum(int tempNum){ 125 | this.tempNum = tempNum; 126 | } 127 | } 128 | 129 | class StringBuffer{ 130 | private Deque buf; 131 | private String delimiter; 132 | 133 | StringBuffer() { 134 | buf = new LinkedList(); 135 | delimiter = " "; 136 | } 137 | 138 | void append(String... msg){ 139 | for (String m : msg) { 140 | buf.add(m); 141 | } 142 | } 143 | 144 | void prepend(String msg){ 145 | buf.addFirst(msg); 146 | } 147 | 148 | public String toString(){ 149 | return String.join(delimiter, buf); 150 | } 151 | } -------------------------------------------------------------------------------- /src/J2P.java: -------------------------------------------------------------------------------- 1 | import minijava.parser.*; 2 | import minijava.visitor.*; 3 | import minijava.syntaxtree.*; 4 | import java.util.*; 5 | 6 | 7 | public class J2P { 8 | 9 | public static void main(String []args) throws Exception { 10 | Emitter e = new Emitter(false); 11 | TypeCheck.TypeCheck(e, args.length > 0 ? args[0] : null); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/kanga.jj: -------------------------------------------------------------------------------- 1 | options { 2 | JAVA_UNICODE_ESCAPE = true; 3 | } 4 | 5 | PARSER_BEGIN(KangaParser) 6 | public class KangaParser {} 7 | PARSER_END(KangaParser) 8 | 9 | SKIP : /* WHITE SPACE */ 10 | { 11 | " " 12 | | "\t" 13 | | "\n" 14 | | "\r" 15 | | "\f" 16 | } 17 | 18 | SPECIAL_TOKEN : /* COMMENTS */ 19 | { 20 | 21 | | 22 | | 23 | } 24 | 25 | TOKEN : 26 | { 27 | < LPAREN: "(" > 28 | | < RPAREN: ")" > 29 | | < LBRACE: "{" > 30 | | < RBRACE: "}" > 31 | | < LSQPAREN: "[" > 32 | | < RSQPAREN: "]" > 33 | | < DOT: "." > 34 | | < LT: "LT" > 35 | | < LE: "LE" > 36 | | < GT: "GT" > 37 | | < GE: "GE" > 38 | | < NE: "NE" > 39 | | < EQ: "EQ" > 40 | | < PLUS: "PLUS" > 41 | | < MINUS: "MINUS" > 42 | | < AND : "AND" > 43 | | < OR : "OR" > 44 | | < NOT : "NOT" > 45 | | < TIMES : "TIMES" > 46 | | < MAIN: "MAIN" > 47 | | < CODE: "CODE" > 48 | | < HALLOCATE: "HALLOCATE" > 49 | | < SPILLEDARG: "SPILLEDARG" > 50 | | < END: "END" > 51 | | < NOOP: "NOOP" > 52 | | < MOVE : "MOVE" > 53 | | < CALL : "CALL" > 54 | | < ERROR : "ERROR" > 55 | | < PRINT: "PRINT" > 56 | | < BEGIN: "BEGIN" > 57 | | < RETURN: "RETURN" > 58 | | < JUMP : "JUMP" > 59 | | < CJUMP : "CJUMP" > 60 | | < HSTORE: "HSTORE" > 61 | | < HLOAD : "HLOAD" > 62 | | < ALOAD : "ALOAD" > 63 | | < ASTORE : "ASTORE" > 64 | | < PASSARG : "PASSARG" > 65 | | < MEM: "MEM" > 66 | | < TEMP: "TEMP" > 67 | | < ARG: "ARG" > 68 | | < ZERO: "zero" > 69 | | < at: "at" > 70 | | < v0: "v0" > 71 | | < v1: "v1" > 72 | | < a0: "a0" > 73 | | < a1: "a1" > 74 | | < a2: "a2" > 75 | | < a3: "a3" > 76 | | < t0: "t0" > 77 | | < t1: "t1" > 78 | | < t2: "t2" > 79 | | < t3: "t3" > 80 | | < t4: "t4" > 81 | | < t5: "t5" > 82 | | < t6: "t6" > 83 | | < t7: "t7" > 84 | | < s0: "s0" > 85 | | < s1: "s1" > 86 | | < s2: "s2" > 87 | | < s3: "s3" > 88 | | < s4: "s4" > 89 | | < s5: "s5" > 90 | | < s6: "s6" > 91 | | < s7: "s7" > 92 | | < t8: "t8" > 93 | | < t9: "t9" > 94 | | < k0: "k0" > 95 | | < k1: "k1" > 96 | | < gp: "gp" > 97 | | < sp: "sp" > 98 | | < fp: "fp" > 99 | | < ra: "ra" > 100 | } 101 | 102 | TOKEN : /* LITERALS */ 103 | { 104 | < INTEGER_LITERAL: ( ["1"-"9"] (["0"-"9"])* | "0" ) > 105 | } 106 | 107 | TOKEN : /* IDENTIFIERS */ 108 | { 109 | < IDENTIFIER: (|)* > 110 | | 111 | < #LETTER: 112 | [ 113 | "\u0024", 114 | "\u0041"-"\u005a", 115 | "\u005f", 116 | "\u0061"-"\u007a", 117 | "\u00c0"-"\u00d6", 118 | "\u00d8"-"\u00f6", 119 | "\u00f8"-"\u00ff", 120 | "\u0100"-"\u1fff", 121 | "\u3040"-"\u318f", 122 | "\u3300"-"\u337f", 123 | "\u3400"-"\u3d2d", 124 | "\u4e00"-"\u9fff", 125 | "\uf900"-"\ufaff" 126 | ] 127 | > 128 | | 129 | < #DIGIT: 130 | [ 131 | "\u0030"-"\u0039", 132 | "\u0660"-"\u0669", 133 | "\u06f0"-"\u06f9", 134 | "\u0966"-"\u096f", 135 | "\u09e6"-"\u09ef", 136 | "\u0a66"-"\u0a6f", 137 | "\u0ae6"-"\u0aef", 138 | "\u0b66"-"\u0b6f", 139 | "\u0be7"-"\u0bef", 140 | "\u0c66"-"\u0c6f", 141 | "\u0ce6"-"\u0cef", 142 | "\u0d66"-"\u0d6f", 143 | "\u0e50"-"\u0e59", 144 | "\u0ed0"-"\u0ed9", 145 | "\u1040"-"\u1049" 146 | ] 147 | > 148 | } 149 | 150 | /********************************* 151 | * The Kanga Grammar Starts Here * 152 | *********************************/ 153 | 154 | 155 | void Goal() : 156 | {} 157 | { 158 | "MAIN" "[" IntegerLiteral() "]" "[" IntegerLiteral() "]" "[" IntegerLiteral() "]" StmtList() "END" ( Procedure() )* 159 | } 160 | 161 | void StmtList() : 162 | {} 163 | { 164 | ( ( Label() )? Stmt() )* 165 | } 166 | 167 | void Procedure() : 168 | {} 169 | { 170 | Label() "[" IntegerLiteral() "]" "[" IntegerLiteral() "]" "[" IntegerLiteral() "]" StmtList() "END" 171 | } 172 | 173 | void Stmt() : 174 | {} 175 | { 176 | NoOpStmt() 177 | | 178 | ErrorStmt() 179 | | 180 | CJumpStmt() 181 | | 182 | JumpStmt() 183 | | 184 | HStoreStmt() 185 | | 186 | HLoadStmt() 187 | | 188 | MoveStmt() 189 | | 190 | PrintStmt() 191 | | 192 | ALoadStmt() 193 | | 194 | AStoreStmt() 195 | | 196 | PassArgStmt() 197 | | 198 | CallStmt() 199 | } 200 | 201 | void NoOpStmt() : 202 | {} 203 | { 204 | "NOOP" 205 | } 206 | 207 | void ErrorStmt() : 208 | {} 209 | { 210 | "ERROR" 211 | } 212 | 213 | void CJumpStmt() : 214 | {} 215 | { 216 | "CJUMP" Reg() Label() 217 | } 218 | 219 | void JumpStmt() : 220 | {} 221 | { 222 | "JUMP" Label() 223 | } 224 | 225 | void HStoreStmt() : 226 | {} 227 | { 228 | "HSTORE" Reg() IntegerLiteral() Reg() 229 | } 230 | 231 | void HLoadStmt() : 232 | {} 233 | { 234 | "HLOAD" Reg() Reg() IntegerLiteral() 235 | } 236 | 237 | void MoveStmt() : 238 | {} 239 | { 240 | "MOVE" Reg() Exp() 241 | } 242 | 243 | void PrintStmt() : 244 | {} 245 | { 246 | "PRINT" SimpleExp() 247 | } 248 | 249 | 250 | void ALoadStmt() : 251 | {} 252 | { 253 | "ALOAD" Reg() SpilledArg() 254 | } 255 | 256 | void AStoreStmt() : 257 | {} 258 | { 259 | "ASTORE" SpilledArg() Reg() 260 | } 261 | 262 | void PassArgStmt() : 263 | {} 264 | { 265 | "PASSARG" IntegerLiteral() Reg() 266 | } 267 | 268 | void CallStmt() : 269 | {} 270 | { 271 | "CALL" SimpleExp() 272 | } 273 | 274 | 275 | void Exp(): 276 | {} 277 | { 278 | HAllocate() 279 | | 280 | BinOp() 281 | | 282 | SimpleExp() 283 | } 284 | 285 | 286 | void HAllocate() : 287 | {} 288 | { 289 | "HALLOCATE" SimpleExp() 290 | } 291 | 292 | void BinOp() : 293 | {} 294 | { 295 | Operator() Reg() SimpleExp() 296 | } 297 | 298 | void Operator() : 299 | {} 300 | { 301 | "LT" 302 | | 303 | "PLUS" 304 | | 305 | "MINUS" 306 | | 307 | "TIMES" 308 | } 309 | 310 | void SpilledArg() : 311 | {} 312 | { 313 | "SPILLEDARG" IntegerLiteral() 314 | } 315 | 316 | void SimpleExp() : 317 | {} 318 | { 319 | Reg() 320 | | 321 | IntegerLiteral() 322 | | 323 | Label() 324 | } 325 | 326 | void Reg() : 327 | {} 328 | { 329 | "a0" 330 | | 331 | "a1" 332 | | 333 | "a2" 334 | | 335 | "a3" 336 | | 337 | "t0" 338 | | 339 | "t1" 340 | | 341 | "t2" 342 | | 343 | "t3" 344 | | 345 | "t4" 346 | | 347 | "t5" 348 | | 349 | "t6" 350 | | 351 | "t7" 352 | | 353 | "s0" 354 | | 355 | "s1" 356 | | 357 | "s2" 358 | | 359 | "s3" 360 | | 361 | "s4" 362 | | 363 | "s5" 364 | | 365 | "s6" 366 | | 367 | "s7" 368 | | 369 | "t8" 370 | | 371 | "t9" 372 | | 373 | "v0" 374 | | 375 | "v1" 376 | } 377 | 378 | void IntegerLiteral() : 379 | {} 380 | { 381 | 382 | } 383 | 384 | void Label() : 385 | {} 386 | { 387 | 388 | } 389 | 390 | 391 | 392 | 393 | 394 | -------------------------------------------------------------------------------- /src/minijava.jj: -------------------------------------------------------------------------------- 1 | options { 2 | JAVA_UNICODE_ESCAPE = true; 3 | } 4 | 5 | PARSER_BEGIN(MiniJavaParser) 6 | public class MiniJavaParser {} 7 | PARSER_END(MiniJavaParser) 8 | 9 | SKIP : /* WHITE SPACE */ 10 | { 11 | " " 12 | | "\t" 13 | | "\n" 14 | | "\r" 15 | | "\f" 16 | } 17 | 18 | SPECIAL_TOKEN : /* COMMENTS */ 19 | { 20 | 21 | | 22 | | 23 | } 24 | 25 | TOKEN : 26 | { 27 | < LPAREN: "(" > 28 | | < RPAREN: ")" > 29 | | < LSQPAREN: "[" > 30 | | < RSQPAREN: "]" > 31 | | < LBRACE: "{" > 32 | | < RBRACE: "}" > 33 | | < SEMICOLON: ";" > 34 | | < DOT: "." > 35 | | < ASSIGN: "=" > 36 | | < LT: "<" > 37 | | < PLUS: "+" > 38 | | < MINUS: "-" > 39 | | < AND : "&&" > 40 | | < NOT : "!" > 41 | | < BOOLEAN: "boolean" > 42 | | < CLASS: "class" > 43 | | < INTERFACE: "interface" > 44 | | < ELSE: "else" > 45 | | < EXTENDS: "extends" > 46 | | < FALSE: "false" > 47 | | < IF: "if" > 48 | | < WHILE: "while" > 49 | | < INTEGER: "int" > 50 | | < LENGTH: "length" > 51 | | < MAIN: "main" > 52 | | < NEW: "new" > 53 | | < PUBLIC: "public" > 54 | | < RETURN: "return" > 55 | | < STATIC: "static" > 56 | | < STRING: "String" > 57 | | < THIS: "this" > 58 | | < TRUE: "true" > 59 | | < PRINT: "System.out.println" > 60 | | < VOID: "void" > 61 | } 62 | 63 | TOKEN : /* LITERALS */ 64 | { 65 | < INTEGER_LITERAL: ( ["1"-"9"] (["0"-"9"])* | "0" ) > 66 | } 67 | 68 | TOKEN : /* IDENTIFIERS */ 69 | { 70 | < IDENTIFIER: (|)* > 71 | | 72 | < #LETTER: 73 | [ 74 | "\u0024", 75 | "\u0041"-"\u005a", 76 | "\u005f", 77 | "\u0061"-"\u007a", 78 | "\u00c0"-"\u00d6", 79 | "\u00d8"-"\u00f6", 80 | "\u00f8"-"\u00ff", 81 | "\u0100"-"\u1fff", 82 | "\u3040"-"\u318f", 83 | "\u3300"-"\u337f", 84 | "\u3400"-"\u3d2d", 85 | "\u4e00"-"\u9fff", 86 | "\uf900"-"\ufaff" 87 | ] 88 | > 89 | | 90 | < #DIGIT: 91 | [ 92 | "\u0030"-"\u0039", 93 | "\u0660"-"\u0669", 94 | "\u06f0"-"\u06f9", 95 | "\u0966"-"\u096f", 96 | "\u09e6"-"\u09ef", 97 | "\u0a66"-"\u0a6f", 98 | "\u0ae6"-"\u0aef", 99 | "\u0b66"-"\u0b6f", 100 | "\u0be7"-"\u0bef", 101 | "\u0c66"-"\u0c6f", 102 | "\u0ce6"-"\u0cef", 103 | "\u0d66"-"\u0d6f", 104 | "\u0e50"-"\u0e59", 105 | "\u0ed0"-"\u0ed9", 106 | "\u1040"-"\u1049" 107 | ] 108 | > 109 | } 110 | 111 | 112 | /************************************ 113 | * The MiniJava Grammar Starts Here * 114 | ************************************/ 115 | 116 | 117 | void Goal() : 118 | {} 119 | { 120 | MainClass() 121 | ( TypeDeclaration() )* 122 | 123 | } 124 | 125 | void MainClass() : 126 | {} 127 | { 128 | "class" Identifier() "{" 129 | "public" "static" "void" "main" "(" "String" "[" "]" Identifier() ")" 130 | "{" ( LOOKAHEAD(2) VarDeclaration() )* ( Statement() )* "}" 131 | "}" 132 | } 133 | 134 | void TypeDeclaration() : 135 | {} 136 | { 137 | LOOKAHEAD(3) 138 | ClassDeclaration() 139 | | 140 | ClassExtendsDeclaration() 141 | } 142 | 143 | void ClassDeclaration() : 144 | {} 145 | { 146 | "class" Identifier() "{" ( VarDeclaration() )* 147 | ( MethodDeclaration() )* 148 | "}" 149 | } 150 | 151 | void ClassExtendsDeclaration() : 152 | {} 153 | { 154 | "class" Identifier() "extends" Identifier() 155 | "{" ( VarDeclaration() )* 156 | ( MethodDeclaration() )* 157 | "}" 158 | } 159 | 160 | void VarDeclaration() : 161 | {} 162 | { 163 | Type() Identifier() ";" 164 | } 165 | 166 | void MethodDeclaration() : 167 | {} 168 | { 169 | "public" Type() Identifier() 170 | "(" ( FormalParameterList() )? ")" 171 | "{" ( LOOKAHEAD(2) VarDeclaration() )* 172 | ( Statement() )* "return" Expression() ";" "}" 173 | } 174 | 175 | void FormalParameterList() : 176 | {} 177 | { 178 | FormalParameter() ( FormalParameterRest() )* 179 | } 180 | 181 | void FormalParameter() : 182 | {} 183 | { 184 | Type() Identifier() 185 | } 186 | 187 | void FormalParameterRest() : 188 | {} 189 | { 190 | "," FormalParameter() 191 | } 192 | 193 | void Type() : 194 | {} 195 | { 196 | LOOKAHEAD(3) 197 | ArrayType() 198 | | 199 | BooleanType() 200 | | 201 | IntegerType() 202 | | 203 | Identifier() 204 | } 205 | 206 | void ArrayType() : 207 | {} 208 | { 209 | "int" "[" "]" 210 | } 211 | 212 | void BooleanType() : 213 | {} 214 | { 215 | "boolean" 216 | } 217 | 218 | void IntegerType() : 219 | {} 220 | { 221 | "int" 222 | } 223 | 224 | void Statement() : 225 | {} 226 | { 227 | Block() 228 | | 229 | LOOKAHEAD(2) 230 | AssignmentStatement() 231 | | 232 | LOOKAHEAD(2) 233 | ArrayAssignmentStatement() 234 | | 235 | IfStatement() 236 | | 237 | WhileStatement() 238 | | 239 | PrintStatement() 240 | } 241 | 242 | void Block() : 243 | {} 244 | { 245 | "{" ( Statement() )* "}" 246 | } 247 | 248 | void AssignmentStatement() : 249 | {} 250 | { 251 | Identifier() "=" Expression() ";" 252 | } 253 | 254 | void ArrayAssignmentStatement() : 255 | {} 256 | { 257 | Identifier() "[" Expression() "]" "=" Expression() ";" 258 | } 259 | 260 | void IfStatement() : 261 | {} 262 | { 263 | "if" "(" Expression() ")" Statement() "else" Statement() 264 | } 265 | 266 | void WhileStatement() : 267 | {} 268 | { 269 | "while" "(" Expression() ")" Statement() 270 | } 271 | 272 | void PrintStatement() : 273 | {} 274 | { 275 | "System.out.println" "(" Expression() ")" ";" 276 | } 277 | 278 | void Expression() : 279 | {} 280 | { 281 | LOOKAHEAD( PrimaryExpression() "&&" ) 282 | AndExpression() 283 | | 284 | LOOKAHEAD( PrimaryExpression() "<" ) 285 | CompareExpression() 286 | | 287 | LOOKAHEAD( PrimaryExpression() "+" ) 288 | PlusExpression() 289 | | 290 | LOOKAHEAD( PrimaryExpression() "-" ) 291 | MinusExpression() 292 | | 293 | LOOKAHEAD( PrimaryExpression() "*" ) 294 | TimesExpression() 295 | | 296 | LOOKAHEAD( PrimaryExpression() "[" ) 297 | ArrayLookup() 298 | | 299 | LOOKAHEAD( PrimaryExpression() "." "length" ) 300 | ArrayLength() 301 | | 302 | LOOKAHEAD( PrimaryExpression() "." Identifier() "(" ) 303 | MessageSend() 304 | | 305 | PrimaryExpression() 306 | } 307 | 308 | void AndExpression() : 309 | {} 310 | { 311 | PrimaryExpression() "&&" PrimaryExpression() 312 | } 313 | 314 | void CompareExpression() : 315 | {} 316 | { 317 | PrimaryExpression() "<" PrimaryExpression() 318 | } 319 | 320 | void PlusExpression() : 321 | {} 322 | { 323 | PrimaryExpression() "+" PrimaryExpression() 324 | } 325 | 326 | void MinusExpression() : 327 | {} 328 | { 329 | PrimaryExpression() "-" PrimaryExpression() 330 | } 331 | 332 | void TimesExpression() : 333 | {} 334 | { 335 | PrimaryExpression() "*" PrimaryExpression() 336 | } 337 | 338 | void ArrayLookup() : 339 | {} 340 | { 341 | PrimaryExpression() "[" PrimaryExpression() "]" 342 | } 343 | 344 | void ArrayLength() : 345 | {} 346 | { 347 | PrimaryExpression() "." "length" 348 | } 349 | 350 | void MessageSend() : 351 | {} 352 | { 353 | PrimaryExpression() "." Identifier() 354 | "(" ( ExpressionList() )? ")" 355 | } 356 | 357 | void ExpressionList() : 358 | {} 359 | { 360 | Expression() ( ExpressionRest() )* 361 | } 362 | 363 | void ExpressionRest() : 364 | {} 365 | { 366 | "," Expression() 367 | } 368 | 369 | void PrimaryExpression() : 370 | {} 371 | { 372 | IntegerLiteral() 373 | | 374 | TrueLiteral() 375 | | 376 | FalseLiteral() 377 | | 378 | Identifier() 379 | | 380 | ThisExpression() 381 | | 382 | LOOKAHEAD(3) 383 | ArrayAllocationExpression() 384 | | 385 | AllocationExpression() 386 | | 387 | NotExpression() 388 | | 389 | BracketExpression() 390 | } 391 | 392 | void IntegerLiteral() : 393 | {} 394 | { 395 | 396 | } 397 | 398 | 399 | void TrueLiteral() : 400 | {} 401 | { 402 | "true" 403 | } 404 | 405 | void FalseLiteral() : 406 | {} 407 | { 408 | "false" 409 | } 410 | 411 | void Identifier() : 412 | {} 413 | { 414 | 415 | } 416 | 417 | void ThisExpression() : 418 | {} 419 | { 420 | "this" 421 | } 422 | 423 | void ArrayAllocationExpression() : 424 | {} 425 | { 426 | "new" "int" "[" Expression() "]" 427 | } 428 | 429 | void AllocationExpression() : 430 | {} 431 | { 432 | "new" Identifier() "(" ")" 433 | } 434 | 435 | void NotExpression() : 436 | {} 437 | { 438 | "!" Expression() 439 | } 440 | 441 | void BracketExpression() : 442 | {} 443 | { 444 | "(" Expression() ")" 445 | } 446 | -------------------------------------------------------------------------------- /src/piglet.jj: -------------------------------------------------------------------------------- 1 | options { 2 | JAVA_UNICODE_ESCAPE = true; 3 | } 4 | 5 | PARSER_BEGIN(PigletParser) 6 | public class PigletParser {} 7 | PARSER_END(PigletParser) 8 | 9 | SKIP : /* WHITE SPACE */ 10 | { 11 | " " 12 | | "\t" 13 | | "\n" 14 | | "\r" 15 | | "\f" 16 | } 17 | 18 | SPECIAL_TOKEN : /* COMMENTS */ 19 | { 20 | 21 | | 22 | | 23 | } 24 | 25 | TOKEN : 26 | { 27 | < LPAREN: "(" > 28 | | < RPAREN: ")" > 29 | | < LBRACE: "{" > 30 | | < RBRACE: "}" > 31 | | < LSQPAREN: "[" > 32 | | < RSQPAREN: "]" > 33 | | < DOT: "." > 34 | | < LT: "LT" > 35 | | < LE: "LE" > 36 | | < GT: "GT" > 37 | | < GE: "GE" > 38 | | < NE: "NE" > 39 | | < EQ: "EQ" > 40 | | < PLUS: "PLUS" > 41 | | < MINUS: "MINUS" > 42 | | < AND : "AND" > 43 | | < OR : "OR" > 44 | | < NOT : "NOT" > 45 | | < TIMES : "TIMES" > 46 | | < MAIN: "MAIN" > 47 | | < CODE: "CODE" > 48 | | < HALLOCATE: "HALLOCATE" > 49 | | < END: "END" > 50 | | < NOOP: "NOOP" > 51 | | < MOVE : "MOVE" > 52 | | < CALL : "CALL" > 53 | | < ERROR : "ERROR" > 54 | | < PRINT: "PRINT" > 55 | | < BEGIN: "BEGIN" > 56 | | < RETURN: "RETURN" > 57 | | < JUMP : "JUMP" > 58 | | < CJUMP : "CJUMP" > 59 | | < HSTORE: "HSTORE" > 60 | | < HLOAD : "HLOAD" > 61 | | < MEM: "MEM" > 62 | | < TEMP: "TEMP" > 63 | | < ARG: "ARG" > 64 | } 65 | 66 | TOKEN : /* LITERALS */ 67 | { 68 | < INTEGER_LITERAL: ( ["1"-"9"] (["0"-"9"])* | "0" ) > 69 | } 70 | 71 | TOKEN : /* IDENTIFIERS */ 72 | { 73 | < IDENTIFIER: (|)* > 74 | | 75 | < #LETTER: 76 | [ 77 | "\u0024", 78 | "\u0041"-"\u005a", 79 | "\u005f", 80 | "\u0061"-"\u007a", 81 | "\u00c0"-"\u00d6", 82 | "\u00d8"-"\u00f6", 83 | "\u00f8"-"\u00ff", 84 | "\u0100"-"\u1fff", 85 | "\u3040"-"\u318f", 86 | "\u3300"-"\u337f", 87 | "\u3400"-"\u3d2d", 88 | "\u4e00"-"\u9fff", 89 | "\uf900"-"\ufaff" 90 | ] 91 | > 92 | | 93 | < #DIGIT: 94 | [ 95 | "\u0030"-"\u0039", 96 | "\u0660"-"\u0669", 97 | "\u06f0"-"\u06f9", 98 | "\u0966"-"\u096f", 99 | "\u09e6"-"\u09ef", 100 | "\u0a66"-"\u0a6f", 101 | "\u0ae6"-"\u0aef", 102 | "\u0b66"-"\u0b6f", 103 | "\u0be7"-"\u0bef", 104 | "\u0c66"-"\u0c6f", 105 | "\u0ce6"-"\u0cef", 106 | "\u0d66"-"\u0d6f", 107 | "\u0e50"-"\u0e59", 108 | "\u0ed0"-"\u0ed9", 109 | "\u1040"-"\u1049" 110 | ] 111 | > 112 | } 113 | 114 | /********************************** 115 | * The Piglet Grammar Starts Here * 116 | **********************************/ 117 | 118 | 119 | void Goal() : 120 | {} 121 | { 122 | "MAIN" StmtList() "END" ( Procedure() )* 123 | } 124 | 125 | void StmtList() : 126 | {} 127 | { 128 | ( ( Label() )? Stmt() )* 129 | } 130 | 131 | void Procedure() : 132 | {} 133 | { 134 | Label() "[" IntegerLiteral() "]" StmtExp() 135 | } 136 | 137 | void Stmt() : 138 | {} 139 | { 140 | NoOpStmt() 141 | | 142 | ErrorStmt() 143 | | 144 | CJumpStmt() 145 | | 146 | JumpStmt() 147 | | 148 | HStoreStmt() 149 | | 150 | HLoadStmt() 151 | | 152 | MoveStmt() 153 | | 154 | PrintStmt() 155 | } 156 | 157 | void NoOpStmt() : 158 | {} 159 | { 160 | "NOOP" 161 | } 162 | 163 | void ErrorStmt() : 164 | {} 165 | { 166 | "ERROR" 167 | } 168 | 169 | void CJumpStmt() : 170 | {} 171 | { 172 | "CJUMP" Exp() Label() 173 | } 174 | 175 | void JumpStmt() : 176 | {} 177 | { 178 | "JUMP" Label() 179 | } 180 | 181 | void HStoreStmt() : 182 | {} 183 | { 184 | "HSTORE" Exp() IntegerLiteral() Exp() 185 | } 186 | 187 | void HLoadStmt() : 188 | {} 189 | { 190 | "HLOAD" Temp() Exp() IntegerLiteral() 191 | } 192 | 193 | void MoveStmt() : 194 | {} 195 | { 196 | "MOVE" Temp() Exp() 197 | } 198 | 199 | void PrintStmt() : 200 | {} 201 | { 202 | "PRINT" Exp() 203 | } 204 | 205 | void Exp(): 206 | {} 207 | { 208 | StmtExp() 209 | | 210 | Call() 211 | | 212 | HAllocate() 213 | | 214 | BinOp() 215 | | 216 | Temp() 217 | | 218 | IntegerLiteral() 219 | | 220 | Label() 221 | } 222 | 223 | void StmtExp() : 224 | {} 225 | { 226 | "BEGIN" StmtList() "RETURN" Exp() "END" 227 | } 228 | 229 | void Call() : 230 | {} 231 | { 232 | "CALL" Exp() "(" ( Exp() )* ")" 233 | } 234 | 235 | void HAllocate() : 236 | {} 237 | { 238 | "HALLOCATE" Exp() 239 | } 240 | 241 | void BinOp() : 242 | {} 243 | { 244 | Operator() Exp() Exp() 245 | } 246 | 247 | void Operator() : 248 | {} 249 | { 250 | "LT" 251 | | 252 | "PLUS" 253 | | 254 | "MINUS" 255 | | 256 | "TIMES" 257 | } 258 | 259 | void Temp() : 260 | {} 261 | { 262 | "TEMP" IntegerLiteral() 263 | } 264 | 265 | void IntegerLiteral() : 266 | {} 267 | { 268 | 269 | } 270 | 271 | void Label() : 272 | {} 273 | { 274 | 275 | } 276 | 277 | -------------------------------------------------------------------------------- /src/spiglet.jj: -------------------------------------------------------------------------------- 1 | options { 2 | JAVA_UNICODE_ESCAPE = true; 3 | } 4 | 5 | PARSER_BEGIN(SpigletParser) 6 | public class SpigletParser {} 7 | PARSER_END(SpigletParser) 8 | 9 | SKIP : /* WHITE SPACE */ 10 | { 11 | " " 12 | | "\t" 13 | | "\n" 14 | | "\r" 15 | | "\f" 16 | } 17 | 18 | SPECIAL_TOKEN : /* COMMENTS */ 19 | { 20 | 21 | | 22 | | 23 | } 24 | 25 | 26 | TOKEN : 27 | { 28 | < LPAREN: "(" > 29 | | < RPAREN: ")" > 30 | | < LBRACE: "{" > 31 | | < RBRACE: "}" > 32 | | < LSQPAREN: "[" > 33 | | < RSQPAREN: "]" > 34 | | < DOT: "." > 35 | | < LT: "LT" > 36 | | < LE: "LE" > 37 | | < GT: "GT" > 38 | | < GE: "GE" > 39 | | < NE: "NE" > 40 | | < EQ: "EQ" > 41 | | < PLUS: "PLUS" > 42 | | < MINUS: "MINUS" > 43 | | < AND : "AND" > 44 | | < OR : "OR" > 45 | | < NOT : "NOT" > 46 | | < TIMES : "TIMES" > 47 | | < MAIN: "MAIN" > 48 | | < CODE: "CODE" > 49 | | < HALLOCATE: "HALLOCATE" > 50 | | < END: "END" > 51 | | < NOOP: "NOOP" > 52 | | < MOVE : "MOVE" > 53 | | < CALL : "CALL" > 54 | | < ERROR : "ERROR" > 55 | | < PRINT: "PRINT" > 56 | | < BEGIN: "BEGIN" > 57 | | < RETURN: "RETURN" > 58 | | < JUMP : "JUMP" > 59 | | < CJUMP : "CJUMP" > 60 | | < HSTORE: "HSTORE" > 61 | | < HLOAD : "HLOAD" > 62 | | < MEM: "MEM" > 63 | | < TEMP: "TEMP" > 64 | | < ARG: "ARG" > 65 | } 66 | 67 | TOKEN : /* LITERALS */ 68 | { 69 | < INTEGER_LITERAL: ( ["1"-"9"] (["0"-"9"])* | "0" ) > 70 | } 71 | 72 | TOKEN : /* IDENTIFIERS */ 73 | { 74 | < IDENTIFIER: (|)* > 75 | | 76 | < #LETTER: 77 | [ 78 | "\u0024", 79 | "\u0041"-"\u005a", 80 | "\u005f", 81 | "\u0061"-"\u007a", 82 | "\u00c0"-"\u00d6", 83 | "\u00d8"-"\u00f6", 84 | "\u00f8"-"\u00ff", 85 | "\u0100"-"\u1fff", 86 | "\u3040"-"\u318f", 87 | "\u3300"-"\u337f", 88 | "\u3400"-"\u3d2d", 89 | "\u4e00"-"\u9fff", 90 | "\uf900"-"\ufaff" 91 | ] 92 | > 93 | | 94 | < #DIGIT: 95 | [ 96 | "\u0030"-"\u0039", 97 | "\u0660"-"\u0669", 98 | "\u06f0"-"\u06f9", 99 | "\u0966"-"\u096f", 100 | "\u09e6"-"\u09ef", 101 | "\u0a66"-"\u0a6f", 102 | "\u0ae6"-"\u0aef", 103 | "\u0b66"-"\u0b6f", 104 | "\u0be7"-"\u0bef", 105 | "\u0c66"-"\u0c6f", 106 | "\u0ce6"-"\u0cef", 107 | "\u0d66"-"\u0d6f", 108 | "\u0e50"-"\u0e59", 109 | "\u0ed0"-"\u0ed9", 110 | "\u1040"-"\u1049" 111 | ] 112 | > 113 | } 114 | 115 | /*********************************** 116 | * The Spiglet Grammar Starts Here * 117 | ***********************************/ 118 | 119 | 120 | void Goal() : 121 | {} 122 | { 123 | "MAIN" StmtList() "END" ( Procedure() )* 124 | } 125 | 126 | void StmtList() : 127 | {} 128 | { 129 | ( ( Label() )? Stmt() )* 130 | } 131 | 132 | void Procedure() : 133 | {} 134 | { 135 | Label() "[" IntegerLiteral() "]" StmtExp() 136 | } 137 | 138 | void Stmt() : 139 | {} 140 | { 141 | NoOpStmt() 142 | | 143 | ErrorStmt() 144 | | 145 | CJumpStmt() 146 | | 147 | JumpStmt() 148 | | 149 | HStoreStmt() 150 | | 151 | HLoadStmt() 152 | | 153 | MoveStmt() 154 | | 155 | PrintStmt() 156 | } 157 | 158 | void NoOpStmt() : 159 | {} 160 | { 161 | "NOOP" 162 | } 163 | 164 | void ErrorStmt() : 165 | {} 166 | { 167 | "ERROR" 168 | } 169 | 170 | void CJumpStmt() : 171 | {} 172 | { 173 | "CJUMP" Temp() Label() 174 | } 175 | 176 | void JumpStmt() : 177 | {} 178 | { 179 | "JUMP" Label() 180 | } 181 | 182 | void HStoreStmt() : 183 | {} 184 | { 185 | "HSTORE" Temp() IntegerLiteral() Temp() 186 | } 187 | 188 | void HLoadStmt() : 189 | {} 190 | { 191 | "HLOAD" Temp() Temp() IntegerLiteral() 192 | } 193 | 194 | void MoveStmt() : 195 | {} 196 | { 197 | "MOVE" Temp() Exp() 198 | } 199 | 200 | void PrintStmt() : 201 | {} 202 | { 203 | "PRINT" SimpleExp() 204 | } 205 | 206 | void Exp(): 207 | {} 208 | { 209 | Call() 210 | | 211 | HAllocate() 212 | | 213 | BinOp() 214 | | 215 | SimpleExp() 216 | } 217 | 218 | void StmtExp() : 219 | {} 220 | { 221 | "BEGIN" StmtList() "RETURN" SimpleExp() "END" 222 | } 223 | 224 | void Call() : 225 | {} 226 | { 227 | "CALL" SimpleExp() "(" ( Temp() )* ")" 228 | } 229 | 230 | void HAllocate() : 231 | {} 232 | { 233 | "HALLOCATE" SimpleExp() 234 | } 235 | 236 | void BinOp() : 237 | {} 238 | { 239 | Operator() Temp() SimpleExp() 240 | } 241 | 242 | void Operator() : 243 | {} 244 | { 245 | "LT" 246 | | 247 | "PLUS" 248 | | 249 | "MINUS" 250 | | 251 | "TIMES" 252 | } 253 | 254 | void SimpleExp() : 255 | {} 256 | { 257 | Temp() 258 | | 259 | IntegerLiteral() 260 | | 261 | Label() 262 | } 263 | 264 | void Temp() : 265 | {} 266 | { 267 | "TEMP" IntegerLiteral() 268 | } 269 | 270 | void IntegerLiteral() : 271 | {} 272 | { 273 | 274 | } 275 | 276 | void Label() : 277 | {} 278 | { 279 | 280 | } 281 | 282 | -------------------------------------------------------------------------------- /testcases/kanga/Factorial.kg: -------------------------------------------------------------------------------- 1 | MAIN [0][0][2] 2 | MOVE t0 HALLOCATE 4 3 | MOVE t1 HALLOCATE 4 4 | MOVE t2 Fac_ComputeFac 5 | HSTORE t0 0 t2 6 | HSTORE t1 0 t0 7 | MOVE t0 t1 8 | HLOAD t1 t0 0 9 | HLOAD t2 t1 0 10 | MOVE t1 10 11 | MOVE a0 t0 12 | MOVE a1 t1 13 | CALL t2 14 | MOVE t3 v0 15 | PRINT t3 16 | END 17 | Fac_ComputeFac [2][3][2] 18 | ASTORE SPILLEDARG 0 s0 19 | ASTORE SPILLEDARG 1 s1 20 | ASTORE SPILLEDARG 2 s2 21 | MOVE s0 a0 22 | MOVE s1 a1 23 | MOVE t0 1 24 | MOVE t1 LT s1 t0 25 | CJUMP t1 L2 26 | MOVE s2 1 27 | JUMP L3 28 | L2 NOOP 29 | MOVE t0 s0 30 | HLOAD t1 t0 0 31 | HLOAD t2 t1 0 32 | MOVE t1 1 33 | MOVE t3 MINUS s1 t1 34 | MOVE a0 t0 35 | MOVE a1 t3 36 | CALL t2 37 | MOVE t1 v0 38 | MOVE t0 TIMES s1 t1 39 | MOVE s2 t0 40 | L3 NOOP 41 | MOVE v0 s2 42 | ALOAD s0 SPILLEDARG 0 43 | ALOAD s1 SPILLEDARG 1 44 | ALOAD s2 SPILLEDARG 2 45 | END 46 | -------------------------------------------------------------------------------- /testcases/kanga/LinearSearch.kg: -------------------------------------------------------------------------------- 1 | MAIN [0][0][2] 2 | MOVE t0 HALLOCATE 16 3 | MOVE t1 HALLOCATE 12 4 | MOVE t2 LS_Init 5 | HSTORE t0 12 t2 6 | MOVE t2 LS_Search 7 | HSTORE t0 8 t2 8 | MOVE t2 LS_Print 9 | HSTORE t0 4 t2 10 | MOVE t2 LS_Start 11 | HSTORE t0 0 t2 12 | MOVE t2 4 13 | L0 NOOP 14 | MOVE t3 12 15 | MOVE t4 LT t2 t3 16 | CJUMP t4 L1 17 | MOVE t3 PLUS t1 t2 18 | MOVE t4 0 19 | HSTORE t3 0 t4 20 | MOVE t2 PLUS t2 4 21 | JUMP L0 22 | L1 NOOP 23 | HSTORE t1 0 t0 24 | MOVE t0 t1 25 | HLOAD t1 t0 0 26 | HLOAD t2 t1 0 27 | MOVE t1 10 28 | MOVE a0 t0 29 | MOVE a1 t1 30 | CALL t2 31 | MOVE t3 v0 32 | PRINT t3 33 | END 34 | LS_Start [2][2][2] 35 | ASTORE SPILLEDARG 0 s0 36 | ASTORE SPILLEDARG 1 s1 37 | MOVE s0 a0 38 | MOVE s1 a1 39 | MOVE t0 s0 40 | HLOAD t1 t0 0 41 | HLOAD t2 t1 12 42 | MOVE a0 t0 43 | MOVE a1 s1 44 | CALL t2 45 | MOVE t1 v0 46 | MOVE t0 s0 47 | HLOAD t1 t0 0 48 | HLOAD t2 t1 4 49 | MOVE a0 t0 50 | CALL t2 51 | MOVE t1 v0 52 | MOVE t0 9999 53 | PRINT t0 54 | MOVE t0 s0 55 | HLOAD t1 t0 0 56 | HLOAD t2 t1 8 57 | MOVE t1 8 58 | MOVE a0 t0 59 | MOVE a1 t1 60 | CALL t2 61 | MOVE t3 v0 62 | PRINT t3 63 | MOVE t0 s0 64 | HLOAD t1 t0 0 65 | HLOAD t2 t1 8 66 | MOVE t1 12 67 | MOVE a0 t0 68 | MOVE a1 t1 69 | CALL t2 70 | MOVE t3 v0 71 | PRINT t3 72 | MOVE t0 s0 73 | HLOAD t1 t0 0 74 | HLOAD t2 t1 8 75 | MOVE t1 17 76 | MOVE a0 t0 77 | MOVE a1 t1 78 | CALL t2 79 | MOVE t3 v0 80 | PRINT t3 81 | MOVE t0 s0 82 | HLOAD t1 t0 0 83 | HLOAD t2 t1 8 84 | MOVE t1 50 85 | MOVE a0 t0 86 | MOVE a1 t1 87 | CALL t2 88 | MOVE t3 v0 89 | PRINT t3 90 | MOVE t0 55 91 | MOVE v0 t0 92 | ALOAD s0 SPILLEDARG 0 93 | ALOAD s1 SPILLEDARG 1 94 | END 95 | LS_Print [1][1][0] 96 | ASTORE SPILLEDARG 0 s0 97 | MOVE s0 a0 98 | MOVE t0 1 99 | L2 NOOP 100 | HLOAD t1 s0 8 101 | MOVE t2 LT t0 t1 102 | CJUMP t2 L3 103 | HLOAD t1 s0 4 104 | MOVE t2 TIMES t0 4 105 | HLOAD t1 s0 4 106 | HLOAD t3 t1 0 107 | MOVE t4 1 108 | MOVE t5 LT t2 t3 109 | MOVE t3 MINUS t4 t5 110 | CJUMP t3 L4 111 | ERROR 112 | L4 NOOP 113 | MOVE t3 4 114 | MOVE t4 t3 115 | MOVE t3 PLUS t2 t4 116 | MOVE t2 t3 117 | MOVE t3 PLUS t1 t2 118 | HLOAD t1 t3 0 119 | PRINT t1 120 | MOVE t0 PLUS t0 1 121 | JUMP L2 122 | L3 NOOP 123 | MOVE t0 0 124 | MOVE v0 t0 125 | ALOAD s0 SPILLEDARG 0 126 | END 127 | LS_Search [2][2][0] 128 | ASTORE SPILLEDARG 0 s0 129 | ASTORE SPILLEDARG 1 s1 130 | MOVE s0 a0 131 | MOVE s1 a1 132 | MOVE t0 1 133 | MOVE t1 0 134 | L5 NOOP 135 | HLOAD t2 s0 8 136 | MOVE t3 LT t0 t2 137 | CJUMP t3 L6 138 | HLOAD t2 s0 4 139 | MOVE t3 TIMES t0 4 140 | HLOAD t2 s0 4 141 | HLOAD t4 t2 0 142 | MOVE t5 1 143 | MOVE t6 LT t3 t4 144 | MOVE t4 MINUS t5 t6 145 | CJUMP t4 L7 146 | ERROR 147 | L7 NOOP 148 | MOVE t4 4 149 | MOVE t5 t4 150 | MOVE t4 PLUS t3 t5 151 | MOVE t3 t4 152 | MOVE t4 PLUS t2 t3 153 | HLOAD t2 t4 0 154 | MOVE t3 t2 155 | MOVE t2 PLUS s1 1 156 | MOVE t4 LT t3 s1 157 | CJUMP t4 L8 158 | JUMP L9 159 | L8 NOOP 160 | MOVE t4 1 161 | MOVE t5 LT t3 t2 162 | MOVE t2 MINUS t4 t5 163 | CJUMP t2 L10 164 | JUMP L11 165 | L10 NOOP 166 | MOVE t1 1 167 | HLOAD t2 s0 8 168 | MOVE t0 t2 169 | L11 NOOP 170 | L9 NOOP 171 | MOVE t0 PLUS t0 1 172 | JUMP L5 173 | L6 NOOP 174 | MOVE v0 t1 175 | ALOAD s0 SPILLEDARG 0 176 | ALOAD s1 SPILLEDARG 1 177 | END 178 | LS_Init [2][2][0] 179 | ASTORE SPILLEDARG 0 s0 180 | ASTORE SPILLEDARG 1 s1 181 | MOVE s0 a0 182 | MOVE s1 a1 183 | HSTORE s0 8 s1 184 | MOVE t0 PLUS s1 1 185 | MOVE t1 4 186 | MOVE t2 TIMES t0 t1 187 | MOVE t0 HALLOCATE t2 188 | MOVE t1 4 189 | L12 NOOP 190 | MOVE t2 1 191 | MOVE t3 PLUS s1 t2 192 | MOVE t2 4 193 | MOVE t4 t2 194 | MOVE t2 TIMES t3 t4 195 | MOVE t3 LT t1 t2 196 | CJUMP t3 L13 197 | MOVE t2 PLUS t0 t1 198 | MOVE t3 0 199 | HSTORE t2 0 t3 200 | MOVE t1 PLUS t1 4 201 | JUMP L12 202 | L13 NOOP 203 | MOVE t1 4 204 | MOVE t2 TIMES s1 t1 205 | HSTORE t0 0 t2 206 | HSTORE s0 4 t0 207 | MOVE t0 1 208 | HLOAD t1 s0 8 209 | MOVE t2 1 210 | MOVE t3 PLUS t1 t2 211 | L14 NOOP 212 | HLOAD t1 s0 8 213 | MOVE t2 LT t0 t1 214 | CJUMP t2 L15 215 | MOVE t1 2 216 | MOVE t2 TIMES t1 t0 217 | MOVE t1 MINUS t3 3 218 | MOVE t4 1 219 | MOVE t5 TIMES t4 4 220 | MOVE t4 PLUS s0 t5 221 | HLOAD t6 t4 0 222 | MOVE t4 TIMES t0 4 223 | MOVE t7 1 224 | MOVE t5 TIMES t7 4 225 | MOVE t7 PLUS s0 t5 226 | HLOAD t6 t7 0 227 | HLOAD t5 t6 0 228 | MOVE t7 1 229 | MOVE t8 LT t4 t5 230 | MOVE t5 MINUS t7 t8 231 | CJUMP t5 L16 232 | ERROR 233 | L16 NOOP 234 | MOVE t5 4 235 | MOVE t7 t5 236 | MOVE t5 PLUS t4 t7 237 | MOVE t4 t5 238 | MOVE t5 PLUS t6 t4 239 | MOVE t4 PLUS t2 t1 240 | HSTORE t5 0 t4 241 | MOVE t0 PLUS t0 1 242 | MOVE t3 MINUS t3 1 243 | JUMP L14 244 | L15 NOOP 245 | MOVE t0 0 246 | MOVE v0 t0 247 | ALOAD s0 SPILLEDARG 0 248 | ALOAD s1 SPILLEDARG 1 249 | END 250 | -------------------------------------------------------------------------------- /testcases/kanga/MoreThan4.kg: -------------------------------------------------------------------------------- 1 | MAIN [0][0][7] 2 | MOVE t0 HALLOCATE 8 3 | MOVE t1 HALLOCATE 4 4 | MOVE t2 MT4_Change 5 | HSTORE t0 4 t2 6 | MOVE t2 MT4_Start 7 | HSTORE t0 0 t2 8 | HSTORE t1 0 t0 9 | MOVE t0 t1 10 | HLOAD t1 t0 0 11 | HLOAD t2 t1 0 12 | MOVE t1 1 13 | MOVE t3 2 14 | MOVE t4 3 15 | MOVE t5 4 16 | MOVE t6 5 17 | MOVE t7 6 18 | MOVE a0 t0 19 | MOVE a1 t1 20 | MOVE a2 t3 21 | MOVE a3 t4 22 | PASSARG 1 t5 23 | PASSARG 2 t6 24 | PASSARG 3 t7 25 | CALL t2 26 | MOVE t8 v0 27 | PRINT t8 28 | END 29 | MT4_Start [7][7][7] 30 | ASTORE SPILLEDARG 3 s0 31 | ASTORE SPILLEDARG 4 s1 32 | ASTORE SPILLEDARG 5 s2 33 | ASTORE SPILLEDARG 6 s3 34 | MOVE s0 a0 35 | MOVE s1 a1 36 | MOVE s2 a2 37 | MOVE s3 a3 38 | PRINT s1 39 | PRINT s2 40 | PRINT s3 41 | ALOAD v1 SPILLEDARG 0 42 | PRINT v1 43 | ALOAD v1 SPILLEDARG 1 44 | PRINT v1 45 | ALOAD v1 SPILLEDARG 2 46 | PRINT v1 47 | MOVE t0 s0 48 | HLOAD t1 t0 0 49 | HLOAD t2 t1 4 50 | MOVE a0 t0 51 | ALOAD v1 SPILLEDARG 2 52 | MOVE a1 v1 53 | ALOAD v0 SPILLEDARG 1 54 | MOVE a2 v0 55 | ALOAD v0 SPILLEDARG 0 56 | MOVE a3 v0 57 | PASSARG 1 s3 58 | PASSARG 2 s2 59 | PASSARG 3 s1 60 | CALL t2 61 | MOVE t1 v0 62 | MOVE t0 t1 63 | MOVE v0 t0 64 | ALOAD s0 SPILLEDARG 3 65 | ALOAD s1 SPILLEDARG 4 66 | ALOAD s2 SPILLEDARG 5 67 | ALOAD s3 SPILLEDARG 6 68 | END 69 | MT4_Change [7][7][0] 70 | ASTORE SPILLEDARG 3 s0 71 | ASTORE SPILLEDARG 4 s1 72 | ASTORE SPILLEDARG 5 s2 73 | ASTORE SPILLEDARG 6 s3 74 | MOVE s0 a0 75 | MOVE s1 a1 76 | MOVE s2 a2 77 | MOVE s3 a3 78 | PRINT s1 79 | PRINT s2 80 | PRINT s3 81 | ALOAD v1 SPILLEDARG 0 82 | PRINT v1 83 | ALOAD v1 SPILLEDARG 1 84 | PRINT v1 85 | ALOAD v1 SPILLEDARG 2 86 | PRINT v1 87 | MOVE t0 0 88 | MOVE v0 t0 89 | ALOAD s0 SPILLEDARG 3 90 | ALOAD s1 SPILLEDARG 4 91 | ALOAD s2 SPILLEDARG 5 92 | ALOAD s3 SPILLEDARG 6 93 | END 94 | -------------------------------------------------------------------------------- /testcases/minijava/ArgOrd.java: -------------------------------------------------------------------------------- 1 | class argg { 2 | public static void main(String[] a){ 3 | Test t; 4 | t = new Test(); 5 | System.out.println(t.start(t.f0(), t.f1())); 6 | } 7 | } 8 | 9 | class Test { 10 | 11 | public int f0() { 12 | System.out.println(12); 13 | return 1; 14 | } 15 | public int f1() { 16 | System.out.println(6); 17 | return 2; 18 | } 19 | 20 | public int start(int a, int b) { 21 | return 3; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/BinaryTree-error.java: -------------------------------------------------------------------------------- 1 | class BubbleSort{ 2 | public static void main(String[] a){ 3 | System.out.println(new BBS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains the array of integers and 9 | // methods to initialize, print and sort the array 10 | // using Bublesort 11 | class BBS{ 12 | 13 | int[] number ; 14 | int size ; 15 | 16 | // Invoke the Initialization, Sort and Printing 17 | // Methods 18 | public int Start(int sz){ 19 | int aux01 ; 20 | aux01 = this.Init(sz); 21 | aux01 = this.Print(); 22 | System.out.println(99999); 23 | aux01 = this.Sort(); 24 | aux01 = this.Print(); 25 | return 0 ; 26 | } 27 | 28 | 29 | // Sort array of integers using Bublesort method 30 | public int Sort(){ 31 | int nt ; 32 | int i ; 33 | int aux02 ; 34 | int aux04 ; 35 | int aux05 ; 36 | int aux06 ; 37 | int aux07 ; 38 | int j ; 39 | int t ; 40 | i = size - 1 ; 41 | aux02 = 0 - 1 ; 42 | while (aux02 < i) { 43 | j = 1 ; 44 | //aux03 = i+1 ; 45 | while (j < (i+1)){ 46 | aux07 = j - 1 ; 47 | aux04 = number[aux07] ; 48 | aux05 = number[j] ; 49 | if (aux05 < aux04) { 50 | aux06 = j - 1 ; 51 | t = number[aux06] ; 52 | number[aux06] = number[j] ; 53 | number[j] = t; 54 | } 55 | else nt = 0 ; 56 | j = j + 1 ; 57 | } 58 | i = i - 1 ; 59 | } 60 | return 0 ; 61 | } 62 | 63 | // Printing method 64 | public int Print(){ 65 | int j ; 66 | j = 0 ; 67 | while (j < (size)) { 68 | System.out.println(number[j]); 69 | j = j + 1 ; 70 | } 71 | return 0 ; 72 | } 73 | 74 | // Initialize array of integers 75 | public int Init(int sz){ 76 | size = sz ; 77 | number = new int[sz] ; 78 | 79 | number[0] = 20 ; 80 | number[1] = 7 ; 81 | number[2] = 12 ; 82 | number[3] = 18 ; 83 | number[4] = 2 ; 84 | number[5] = 11 ; 85 | number[6] = 6 ; 86 | number[7] = 9 ; 87 | number[8] = 19 ; 88 | number[9] = 5 ; 89 | 90 | return false ; //TE 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /testcases/minijava/BinaryTree.java: -------------------------------------------------------------------------------- 1 | class BinaryTree{ 2 | public static void main(String[] a){ 3 | System.out.println(new BT().Start()); 4 | } 5 | } 6 | 7 | 8 | // This class invokes the methods to create a tree, 9 | // insert, delete and serach for elements on it 10 | class BT { 11 | 12 | public int Start(){ 13 | Tree root ; 14 | boolean ntb ; 15 | int nti ; 16 | 17 | root = new Tree(); 18 | ntb = root.Init(16); 19 | ntb = root.Print(); 20 | System.out.println(100000000); 21 | ntb = root.Insert(8) ; 22 | ntb = root.Print(); 23 | ntb = root.Insert(24) ; 24 | ntb = root.Insert(4) ; 25 | ntb = root.Insert(12) ; 26 | ntb = root.Insert(20) ; 27 | ntb = root.Insert(28) ; 28 | ntb = root.Insert(14) ; 29 | ntb = root.Print(); 30 | System.out.println(root.Search(24)); 31 | System.out.println(root.Search(12)); 32 | System.out.println(root.Search(16)); 33 | System.out.println(root.Search(50)); 34 | System.out.println(root.Search(12)); 35 | ntb = root.Delete(12); 36 | ntb = root.Print(); 37 | System.out.println(root.Search(12)); 38 | 39 | return 0 ; 40 | } 41 | 42 | } 43 | 44 | class Tree{ 45 | Tree left ; 46 | Tree right; 47 | int key ; 48 | boolean has_left ; 49 | boolean has_right ; 50 | Tree my_null ; 51 | 52 | // Initialize a node with a key value and no children 53 | public boolean Init(int v_key){ 54 | key = v_key ; 55 | has_left = false ; 56 | has_right = false ; 57 | return true ; 58 | } 59 | 60 | // Update the right child with rn 61 | public boolean SetRight(Tree rn){ 62 | right = rn ; 63 | return true ; 64 | } 65 | 66 | // Update the left child with ln 67 | public boolean SetLeft(Tree ln){ 68 | left = ln ; 69 | return true ; 70 | } 71 | 72 | public Tree GetRight(){ 73 | return right ; 74 | } 75 | 76 | public Tree GetLeft(){ 77 | return left; 78 | } 79 | 80 | public int GetKey(){ 81 | return key ; 82 | } 83 | 84 | public boolean SetKey(int v_key){ 85 | key = v_key ; 86 | return true ; 87 | } 88 | 89 | public boolean GetHas_Right(){ 90 | return has_right ; 91 | } 92 | 93 | public boolean GetHas_Left(){ 94 | return has_left ; 95 | } 96 | 97 | public boolean SetHas_Left(boolean val){ 98 | has_left = val ; 99 | return true ; 100 | } 101 | 102 | public boolean SetHas_Right(boolean val){ 103 | has_right = val ; 104 | return true ; 105 | } 106 | 107 | // This method compares two integers and 108 | // returns true if they are equal and false 109 | // otherwise 110 | public boolean Compare(int num1 , int num2){ 111 | boolean ntb ; 112 | int nti ; 113 | 114 | ntb = false ; 115 | nti = num2 + 1 ; 116 | if (num1 < num2) ntb = false ; 117 | else if (!(num1 < nti)) ntb = false ; 118 | else ntb = true ; 119 | return ntb ; 120 | } 121 | 122 | 123 | // Insert a new element in the tree 124 | public boolean Insert(int v_key){ 125 | Tree new_node ; 126 | boolean ntb ; 127 | boolean cont ; 128 | int key_aux ; 129 | Tree current_node ; 130 | 131 | new_node = new Tree(); 132 | ntb = new_node.Init(v_key) ; 133 | current_node = this ; 134 | cont = true ; 135 | while (cont){ 136 | key_aux = current_node.GetKey(); 137 | if (v_key < key_aux){ 138 | if (current_node.GetHas_Left()) 139 | current_node = current_node.GetLeft() ; 140 | else { 141 | cont = false ; 142 | ntb = current_node.SetHas_Left(true); 143 | ntb = current_node.SetLeft(new_node); 144 | } 145 | } 146 | else{ 147 | if (current_node.GetHas_Right()) 148 | current_node = current_node.GetRight() ; 149 | else { 150 | cont = false ; 151 | ntb = current_node.SetHas_Right(true); 152 | ntb = current_node.SetRight(new_node); 153 | } 154 | } 155 | } 156 | return true ; 157 | } 158 | 159 | 160 | // Delete an element from the tree 161 | public boolean Delete(int v_key){ 162 | Tree current_node ; 163 | Tree parent_node ; 164 | boolean cont ; 165 | boolean found ; 166 | boolean is_root ; 167 | int key_aux ; 168 | boolean ntb ; 169 | 170 | current_node = this ; 171 | parent_node = this ; 172 | cont = true ; 173 | found = false ; 174 | is_root = true ; 175 | while (cont){ 176 | key_aux = current_node.GetKey(); 177 | if (v_key < key_aux) 178 | if (current_node.GetHas_Left()){ 179 | parent_node = current_node ; 180 | current_node = current_node.GetLeft() ; 181 | } 182 | else cont = false ; 183 | else 184 | if (key_aux < v_key) 185 | if (current_node.GetHas_Right()){ 186 | parent_node = current_node ; 187 | current_node = current_node.GetRight() ; 188 | } 189 | else cont = false ; 190 | else { 191 | if (is_root) 192 | if ((!current_node.GetHas_Right()) && 193 | (!current_node.GetHas_Left()) ) 194 | ntb = true ; 195 | else 196 | ntb = this.Remove(parent_node,current_node); 197 | else ntb = this.Remove(parent_node,current_node); 198 | found = true ; 199 | cont = false ; 200 | } 201 | is_root = false ; 202 | } 203 | return found ; 204 | } 205 | 206 | 207 | // Check if the element to be removed will use the 208 | // righ or left subtree if one exists 209 | public boolean Remove(Tree p_node, Tree c_node){ 210 | boolean ntb ; 211 | int auxkey1 ; 212 | int auxkey2 ; 213 | 214 | if (c_node.GetHas_Left()) 215 | ntb = this.RemoveLeft(p_node,c_node) ; 216 | else 217 | if (c_node.GetHas_Right()) 218 | ntb = this.RemoveRight(p_node,c_node) ; 219 | else { 220 | auxkey1 = c_node.GetKey(); 221 | //auxtree01 = p_node.GetLeft() ; 222 | //auxkey2 = auxtree01.GetKey() ; 223 | auxkey2 = (p_node.GetLeft()).GetKey() ; 224 | if (this.Compare(auxkey1,auxkey2)) { 225 | ntb = p_node.SetLeft(my_null); 226 | ntb = p_node.SetHas_Left(false); 227 | } 228 | else { 229 | ntb = p_node.SetRight(my_null); 230 | ntb = p_node.SetHas_Right(false); 231 | } 232 | } 233 | return true ; 234 | } 235 | 236 | 237 | // Copy the child key to the parent until a leaf is 238 | // found and remove the leaf. This is done with the 239 | // right subtree 240 | public boolean RemoveRight(Tree p_node, Tree c_node){ 241 | boolean ntb ; 242 | 243 | while (c_node.GetHas_Right()){ 244 | //auxtree01 = c_node.GetRight() ; 245 | //auxint02 = auxtree01.GetKey(); 246 | //ntb = c_node.SetKey(auxint02); 247 | ntb = c_node.SetKey((c_node.GetRight()).GetKey()); 248 | p_node = c_node ; 249 | c_node = c_node.GetRight() ; 250 | } 251 | ntb = p_node.SetRight(my_null); 252 | ntb = p_node.SetHas_Right(false); 253 | return true ; 254 | } 255 | 256 | 257 | // Copy the child key to the parent until a leaf is 258 | // found and remove the leaf. This is done with the 259 | // left subtree 260 | public boolean RemoveLeft(Tree p_node, Tree c_node){ 261 | boolean ntb ; 262 | 263 | while (c_node.GetHas_Left()){ 264 | //auxtree01 = c_node.GetLeft() ; 265 | //auxint02 = auxtree01.GetKey(); 266 | //ntb = c_node.SetKey(auxint02); 267 | ntb = c_node.SetKey((c_node.GetLeft()).GetKey()); 268 | p_node = c_node ; 269 | c_node = c_node.GetLeft() ; 270 | } 271 | ntb = p_node.SetLeft(my_null); 272 | ntb = p_node.SetHas_Left(false); 273 | return true ; 274 | } 275 | 276 | // Search for an elemnt in the tree 277 | public int Search(int v_key){ 278 | boolean cont ; 279 | int ifound ; 280 | Tree current_node; 281 | int key_aux ; 282 | 283 | current_node = this ; 284 | cont = true ; 285 | ifound = 0 ; 286 | while (cont){ 287 | key_aux = current_node.GetKey(); 288 | if (v_key < key_aux) 289 | if (current_node.GetHas_Left()) 290 | current_node = current_node.GetLeft() ; 291 | else cont = false ; 292 | else 293 | if (key_aux < v_key) 294 | if (current_node.GetHas_Right()) 295 | current_node = current_node.GetRight() ; 296 | else cont = false ; 297 | else { 298 | ifound = 1 ; 299 | cont = false ; 300 | } 301 | } 302 | return ifound ; 303 | } 304 | 305 | // Invoke the method to really print the tree elements 306 | public boolean Print(){ 307 | Tree current_node; 308 | boolean ntb ; 309 | 310 | current_node = this ; 311 | ntb = this.RecPrint(current_node); 312 | return true ; 313 | } 314 | 315 | // Print the elements of the tree 316 | public boolean RecPrint(Tree node){ 317 | boolean ntb ; 318 | 319 | if (node.GetHas_Left()){ 320 | //auxtree01 = node.GetLeft() ; 321 | //ntb = this.RecPrint(auxtree01); 322 | ntb = this.RecPrint(node.GetLeft()); 323 | } else ntb = true ; 324 | System.out.println(node.GetKey()); 325 | if (node.GetHas_Right()){ 326 | //auxtree01 = node.GetRight() ; 327 | //ntb = this.RecPrint(auxtree01); 328 | ntb = this.RecPrint(node.GetRight()); 329 | } else ntb = true ; 330 | return true ; 331 | } 332 | 333 | } 334 | 335 | -------------------------------------------------------------------------------- /testcases/minijava/BubbleSort-error.java: -------------------------------------------------------------------------------- 1 | class BubbleSort{ 2 | public static void main(String[] a){ 3 | System.out.println(new BBS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains the array of integers and 9 | // methods to initialize, print and sort the array 10 | // using Bublesort 11 | class BBS{ 12 | 13 | int[] number ; 14 | int size ; 15 | 16 | // Invoke the Initialization, Sort and Printing 17 | // Methods 18 | public int Start(int sz){ 19 | int aux01 ; 20 | aux01 = this.Init(sz); 21 | aux01 = this.Print(); 22 | System.out.println(99999); 23 | aux01 = this.Sort(); 24 | aux01 = this.Print(); 25 | return 0 ; 26 | } 27 | 28 | 29 | // Sort array of integers using Bublesort method 30 | public int Sort(){ 31 | int nt ; 32 | int i ; 33 | int aux02 ; 34 | int aux04 ; 35 | int aux05 ; 36 | int aux06 ; 37 | int aux07 ; 38 | int j ; 39 | int t ; 40 | i = size - 1 ; 41 | aux02 = 0 - 1 ; 42 | while (aux02 < i) { 43 | j = 1 ; 44 | //aux03 = i+1 ; 45 | while (j < (i+1)){ 46 | aux07 = j - 1 ; 47 | aux04 = number[aux07] ; 48 | aux05 = number[j] ; 49 | if (aux05 < aux04) { 50 | aux06 = j - 1 ; 51 | t = number[aux06] ; 52 | number[aux06] = number[j] ; 53 | number[j] = t; 54 | } 55 | else nt = 0 ; 56 | j = j + 1 ; 57 | } 58 | i = i - 1 ; 59 | } 60 | return 0 ; 61 | } 62 | 63 | // Printing method 64 | public int Print(){ 65 | int j ; 66 | j = 0 ; 67 | while (j < (size)) { 68 | System.out.println(number[j]); 69 | j = j + 1 ; 70 | } 71 | return 0 ; 72 | } 73 | 74 | // Initialize array of integers 75 | public int Init(int sz){ 76 | size = sz1 ; //TE 77 | number = new int[sz] ; 78 | 79 | number[0] = 20 ; 80 | number[1] = 7 ; 81 | number[2] = 12 ; 82 | number[3] = 18 ; 83 | number[4] = 2 ; 84 | number[5] = 11 ; 85 | number[6] = 6 ; 86 | number[7] = 9 ; 87 | number[8] = 19 ; 88 | number[9] = 5 ; 89 | 90 | return 0 ; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /testcases/minijava/BubbleSort.java: -------------------------------------------------------------------------------- 1 | class BubbleSort{ 2 | public static void main(String[] a){ 3 | System.out.println(new BBS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains the array of integers and 9 | // methods to initialize, print and sort the array 10 | // using Bublesort 11 | class BBS{ 12 | 13 | int[] number ; 14 | int size ; 15 | 16 | // Invoke the Initialization, Sort and Printing 17 | // Methods 18 | public int Start(int sz){ 19 | int aux01 ; 20 | aux01 = this.Init(sz); 21 | aux01 = this.Print(); 22 | System.out.println(99999); 23 | aux01 = this.Sort(); 24 | aux01 = this.Print(); 25 | return 0 ; 26 | } 27 | 28 | 29 | // Sort array of integers using Bublesort method 30 | public int Sort(){ 31 | int nt ; 32 | int i ; 33 | int aux02 ; 34 | int aux04 ; 35 | int aux05 ; 36 | int aux06 ; 37 | int aux07 ; 38 | int j ; 39 | int t ; 40 | i = size - 1 ; 41 | aux02 = 0 - 1 ; 42 | while (aux02 < i) { 43 | j = 1 ; 44 | //aux03 = i+1 ; 45 | while (j < (i+1)){ 46 | aux07 = j - 1 ; 47 | aux04 = number[aux07] ; 48 | aux05 = number[j] ; 49 | if (aux05 < aux04) { 50 | aux06 = j - 1 ; 51 | t = number[aux06] ; 52 | number[aux06] = number[j] ; 53 | number[j] = t; 54 | } 55 | else nt = 0 ; 56 | j = j + 1 ; 57 | } 58 | i = i - 1 ; 59 | } 60 | return 0 ; 61 | } 62 | 63 | // Printing method 64 | public int Print(){ 65 | int j ; 66 | j = 0 ; 67 | while (j < (size)) { 68 | System.out.println(number[j]); 69 | j = j + 1 ; 70 | } 71 | return 0 ; 72 | } 73 | 74 | // Initialize array of integers 75 | public int Init(int sz){ 76 | size = sz ; 77 | number = new int[sz] ; 78 | 79 | number[0] = 20 ; 80 | number[1] = 7 ; 81 | number[2] = 12 ; 82 | number[3] = 18 ; 83 | number[4] = 2 ; 84 | number[5] = 11 ; 85 | number[6] = 6 ; 86 | number[7] = 9 ; 87 | number[8] = 19 ; 88 | number[9] = 5 ; 89 | 90 | return 0 ; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /testcases/minijava/ErrorNull.java: -------------------------------------------------------------------------------- 1 | class ErrorNull{ 2 | public static void main(String[] a){ 3 | A x; A y; 4 | int ret; 5 | x = new A(); 6 | // y = x.haha(); 7 | // ret = y.foo(); 8 | } 9 | } 10 | 11 | class A { 12 | A n; 13 | public A haha() { 14 | return n; 15 | } 16 | public int foo() { return 1; } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /testcases/minijava/ErrorOutBound.java: -------------------------------------------------------------------------------- 1 | class ErrorOutBound{ 2 | public static void main(String[] a){ 3 | int[] arr; 4 | int i; 5 | System.out.println(1); 6 | i = 1000; 7 | i = i - 99; 8 | arr = new int[1]; 9 | arr[i]=1; 10 | arr[0] = 1; 11 | } 12 | } -------------------------------------------------------------------------------- /testcases/minijava/Factorial-error.java: -------------------------------------------------------------------------------- 1 | class Factorial{ 2 | public static void main(String[] a){ 3 | System.out.println(new Fac().ComputeFac(10)); 4 | } 5 | } 6 | 7 | class Fac { 8 | public boolean ComputeFac(int num){ //TE 9 | int num_aux ; 10 | if (num < 1) 11 | num_aux = 1 ; 12 | else 13 | num_aux = num * (this.ComputeFac(num-1)) ; 14 | return num_aux ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testcases/minijava/Factorial.java: -------------------------------------------------------------------------------- 1 | class Factorial{ 2 | public static void main(String[] a){ 3 | System.out.println(new Fac().ComputeFac(10)); 4 | } 5 | } 6 | 7 | class Fac { 8 | public int ComputeFac(int num){ 9 | int num_aux ; 10 | if (num < 1) 11 | num_aux = 1 ; 12 | else 13 | num_aux = num * (this.ComputeFac(num-1)) ; 14 | return num_aux ; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testcases/minijava/LinearSearch-error.java: -------------------------------------------------------------------------------- 1 | class LinearSearch{ 2 | public static void main(String[] a){ 3 | System.out.println(new LS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains an array of integers and 9 | // methods to initialize, print and search the array 10 | // using Linear Search 11 | class LS { 12 | int number ; //TE 13 | int size ; 14 | 15 | // Invoke methods to initialize, print and search 16 | // for elements on the array 17 | public int Start(int sz){ 18 | int aux01 ; 19 | int aux02 ; 20 | 21 | aux01 = this.Init(sz); 22 | aux02 = this.Print(); 23 | System.out.println(9999); 24 | System.out.println(this.Search(8)); 25 | System.out.println(this.Search(12)) ; 26 | System.out.println(this.Search(17)) ; 27 | System.out.println(this.Search(50)) ; 28 | return 55 ; 29 | } 30 | 31 | // Print array of integers 32 | public int Print(){ 33 | int j ; 34 | 35 | j = 1 ; 36 | while (j < (size)) { 37 | System.out.println(number[j]); 38 | j = j + 1 ; 39 | } 40 | return 0 ; 41 | } 42 | 43 | // Search for a specific value (num) using 44 | // linear search 45 | public int Search(int num){ 46 | int j ; 47 | boolean ls01 ; 48 | int ifound ; 49 | int aux01 ; 50 | int aux02 ; 51 | int nt ; 52 | 53 | j = 1 ; 54 | ls01 = false ; 55 | ifound = 0 ; 56 | 57 | //System.out.println(num); 58 | while (j < (size)) { 59 | aux01 = number[j] ; 60 | aux02 = num + 1 ; 61 | if (aux01 < num) nt = 0 ; 62 | else if (!(aux01 < aux02)) nt = 0 ; 63 | else { 64 | ls01 = true ; 65 | ifound = 1 ; 66 | j = size ; 67 | } 68 | j = j + 1 ; 69 | } 70 | 71 | return ifound ; 72 | } 73 | 74 | 75 | 76 | // initialize array of integers with some 77 | // some sequence 78 | public int Init(int sz){ 79 | int j ; 80 | int k ; 81 | int aux01 ; 82 | int aux02 ; 83 | 84 | size = sz ; 85 | number = new int[sz] ; 86 | 87 | j = 1 ; 88 | k = size + 1 ; 89 | while (j < (size)) { 90 | aux01 = 2 * j ; 91 | aux02 = k - 3 ; 92 | number[j] = aux01 + aux02 ; 93 | j = j + 1 ; 94 | k = k - 1 ; 95 | } 96 | return 0 ; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /testcases/minijava/LinearSearch.java: -------------------------------------------------------------------------------- 1 | class LinearSearch{ 2 | public static void main(String[] a){ 3 | System.out.println(new LS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains an array of integers and 9 | // methods to initialize, print and search the array 10 | // using Linear Search 11 | class LS { 12 | int[] number ; 13 | int size ; 14 | 15 | // Invoke methods to initialize, print and search 16 | // for elements on the array 17 | public int Start(int sz){ 18 | int aux01 ; 19 | int aux02 ; 20 | 21 | aux01 = this.Init(sz); 22 | aux02 = this.Print(); 23 | System.out.println(9999); 24 | System.out.println(this.Search(8)); 25 | System.out.println(this.Search(12)) ; 26 | System.out.println(this.Search(17)) ; 27 | System.out.println(this.Search(50)) ; 28 | return 55 ; 29 | } 30 | 31 | // Print array of integers 32 | public int Print(){ 33 | int j ; 34 | 35 | j = 1 ; 36 | while (j < (size)) { 37 | System.out.println(number[j]); 38 | j = j + 1 ; 39 | } 40 | return 0 ; 41 | } 42 | 43 | // Search for a specific value (num) using 44 | // linear search 45 | public int Search(int num){ 46 | int j ; 47 | boolean ls01 ; 48 | int ifound ; 49 | int aux01 ; 50 | int aux02 ; 51 | int nt ; 52 | 53 | j = 1 ; 54 | ls01 = false ; 55 | ifound = 0 ; 56 | 57 | //System.out.println(num); 58 | while (j < (size)) { 59 | aux01 = number[j] ; 60 | aux02 = num + 1 ; 61 | if (aux01 < num) nt = 0 ; 62 | else if (!(aux01 < aux02)) nt = 0 ; 63 | else { 64 | ls01 = true ; 65 | ifound = 1 ; 66 | j = size ; 67 | } 68 | j = j + 1 ; 69 | } 70 | 71 | return ifound ; 72 | } 73 | 74 | 75 | 76 | // initialize array of integers with some 77 | // some sequence 78 | public int Init(int sz){ 79 | int j ; 80 | int k ; 81 | int aux01 ; 82 | int aux02 ; 83 | 84 | size = sz ; 85 | number = new int[sz] ; 86 | 87 | j = 1 ; 88 | k = size + 1 ; 89 | while (j < (size)) { 90 | aux01 = 2 * j ; 91 | aux02 = k - 3 ; 92 | number[j] = aux01 + aux02 ; 93 | j = j + 1 ; 94 | k = k - 1 ; 95 | } 96 | return 0 ; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /testcases/minijava/LinkedList-error.java: -------------------------------------------------------------------------------- 1 | class LinkedList{ 2 | public static void main(String[] a){ 3 | System.out.println(new LL().Start()); 4 | } 5 | } 6 | 7 | class Element { 8 | int Age ; 9 | int Salary ; 10 | boolean Married ; 11 | 12 | // Initialize some class variables 13 | public boolean Init(int v_Age, int v_Salary, boolean v_Married){ 14 | Age = v_Age ; 15 | Salary = v_Salary ; 16 | Married = v_Married ; 17 | return true ; 18 | } 19 | 20 | public int GetAge(){ 21 | return Age ; 22 | } 23 | 24 | public int GetSalary(){ 25 | return Salary ; 26 | } 27 | 28 | public boolean GetMarried(){ 29 | return Married ; 30 | } 31 | 32 | // This method returns true if the object "other" 33 | // has the same values for age, salary and 34 | public boolean Equal(Element other){ 35 | boolean ret_val ; 36 | int aux01 ; 37 | int aux02 ; 38 | int nt ; 39 | ret_val = true ; 40 | 41 | aux01 = other.GetAge(); 42 | if (!this.Compare(aux01,Age)) ret_val = false ; 43 | else { 44 | aux02 = other.GetSalary(); 45 | if (!this.Compare(aux02,Salary)) ret_val = false ; 46 | else 47 | if (Married) 48 | if (!other.GetMarried()) ret_val = false; 49 | else nt = 0 ; 50 | else 51 | if (other.GetMarried()) ret_val = false; 52 | else nt = 0 ; 53 | } 54 | 55 | return ret_val ; 56 | } 57 | 58 | // This method compares two integers and 59 | // returns true if they are equal and false 60 | // otherwise 61 | public boolean Compare(int num1 , int num2){ 62 | boolean retval ; 63 | int aux02 ; 64 | retval = false ; 65 | aux02 = num2 + 1 ; 66 | if (num1 < num2) retval = false ; 67 | else if (!(num1 < aux02)) retval = false ; 68 | else retval = true ; 69 | return retval ; 70 | } 71 | 72 | } 73 | 74 | class List{ 75 | Element elem ; 76 | List next ; 77 | boolean end ; 78 | 79 | // Initialize the node list as the last node 80 | public boolean Init(){ 81 | end = true ; 82 | return true ; 83 | } 84 | 85 | // Initialize the values of a new node 86 | public boolean InitNew(Element v_elem, List v_next, boolean v_end){ 87 | end = v_end ; 88 | elem = v_elem ; 89 | next = v_next ; 90 | return true ; 91 | } 92 | 93 | // Insert a new node at the beginning of the list 94 | public List Insert(Element new_elem){ 95 | boolean ret_val ; 96 | List aux03 ; 97 | List aux02 ; 98 | aux03 = this ; 99 | aux02 = new List(); 100 | ret_val = aux02.InitNew(new_elem,aux03,false); 101 | return aux02 ; 102 | } 103 | 104 | 105 | // Update the the pointer to the next node 106 | public boolean SetNext(List v_next){ 107 | next = v_next ; 108 | return 0 ; //TE 109 | } 110 | 111 | // Delete an element e from the list 112 | public List Delete(Element e){ 113 | List my_head ; 114 | boolean ret_val ; 115 | boolean aux05; 116 | List aux01 ; 117 | List prev ; 118 | boolean var_end ; 119 | Element var_elem ; 120 | int aux04 ; 121 | int nt ; 122 | 123 | 124 | my_head = this ; 125 | ret_val = false ; 126 | aux04 = 0 - 1 ; 127 | aux01 = this ; 128 | prev = this ; 129 | var_end = end; 130 | var_elem = elem ; 131 | while ((!var_end) && (!ret_val)){ 132 | if (e.Equal(var_elem)){ 133 | ret_val = true ; 134 | if (aux04 < 0) { 135 | // delete first element 136 | my_head = aux01.GetNext() ; 137 | } 138 | else{ // delete a non first element 139 | System.out.println(0-555); 140 | aux05 = prev.SetNext(aux01.GetNext()); 141 | System.out.println(0-555); 142 | 143 | } 144 | } else nt = 0 ; 145 | if (!ret_val){ 146 | prev = aux01 ; 147 | aux01 = aux01.GetNext() ; 148 | var_end = aux01.GetEnd(); 149 | var_elem = aux01.GetElem(); 150 | aux04 = 1 ; 151 | } else nt = 0 ; 152 | } 153 | return my_head ; 154 | } 155 | 156 | 157 | // Search for an element e on the list 158 | public int Search(Element e){ 159 | int int_ret_val ; 160 | List aux01 ; 161 | Element var_elem ; 162 | boolean var_end ; 163 | int nt ; 164 | 165 | int_ret_val = 0 ; 166 | aux01 = this ; 167 | var_end = end; 168 | var_elem = elem ; 169 | while (!var_end){ 170 | if (e.Equal(var_elem)){ 171 | int_ret_val = 1 ; 172 | } 173 | else nt = 0 ; 174 | aux01 = aux01.GetNext() ; 175 | var_end = aux01.GetEnd(); 176 | var_elem = aux01.GetElem(); 177 | } 178 | return int_ret_val ; 179 | } 180 | 181 | public boolean GetEnd(){ 182 | return end ; 183 | } 184 | 185 | public Element GetElem(){ 186 | return elem ; 187 | } 188 | 189 | public List GetNext(){ 190 | return next ; 191 | } 192 | 193 | 194 | // Print the linked list 195 | public boolean Print(){ 196 | List aux01 ; 197 | boolean var_end ; 198 | Element var_elem ; 199 | 200 | aux01 = this ; 201 | var_end = end ; 202 | var_elem = elem ; 203 | while (!var_end){ 204 | System.out.println(var_elem.GetAge()); 205 | aux01 = aux01.GetNext() ; 206 | var_end = aux01.GetEnd(); 207 | var_elem = aux01.GetElem(); 208 | } 209 | 210 | return true ; 211 | } 212 | } 213 | 214 | 215 | // this class invokes the methods to insert, delete, 216 | // search and print the linked list 217 | class LL{ 218 | 219 | public int Start(){ 220 | 221 | List head ; 222 | List last_elem ; 223 | boolean aux01 ; 224 | Element el01 ; 225 | Element el02 ; 226 | Element el03 ; 227 | 228 | last_elem = new List(); 229 | aux01 = last_elem.Init(); 230 | head = last_elem ; 231 | aux01 = head.Init(); 232 | aux01 = head.Print(); 233 | 234 | // inserting first element 235 | el01 = new Element(); 236 | aux01 = el01.Init(25,37000,false); 237 | head = head.Insert(el01); 238 | aux01 = head.Print(); 239 | System.out.println(10000000); 240 | // inserting second element 241 | el01 = new Element(); 242 | aux01 = el01.Init(39,42000,true); 243 | el02 = el01 ; 244 | head = head.Insert(el01); 245 | aux01 = head.Print(); 246 | System.out.println(10000000); 247 | // inserting third element 248 | el01 = new Element(); 249 | aux01 = el01.Init(22,34000,false); 250 | head = head.Insert(el01); 251 | aux01 = head.Print(); 252 | el03 = new Element(); 253 | aux01 = el03.Init(27,34000,false); 254 | System.out.println(head.Search(el02)); 255 | System.out.println(head.Search(el03)); 256 | System.out.println(10000000); 257 | // inserting fourth element 258 | el01 = new Element(); 259 | aux01 = el01.Init(28,35000,false); 260 | head = head.Insert(el01); 261 | aux01 = head.Print(); 262 | System.out.println(2220000); 263 | 264 | head = head.Delete(el02); 265 | aux01 = head.Print(); 266 | System.out.println(33300000); 267 | 268 | 269 | head = head.Delete(el01); 270 | aux01 = head.Print(); 271 | System.out.println(44440000); 272 | 273 | return 0 ; 274 | 275 | 276 | } 277 | 278 | } 279 | -------------------------------------------------------------------------------- /testcases/minijava/LinkedList.java: -------------------------------------------------------------------------------- 1 | class LinkedList{ 2 | public static void main(String[] a){ 3 | System.out.println(new LL().Start()); 4 | } 5 | } 6 | 7 | class Element { 8 | int Age ; 9 | int Salary ; 10 | boolean Married ; 11 | 12 | // Initialize some class variables 13 | public boolean Init(int v_Age, int v_Salary, boolean v_Married){ 14 | Age = v_Age ; 15 | Salary = v_Salary ; 16 | Married = v_Married ; 17 | return true ; 18 | } 19 | 20 | public int GetAge(){ 21 | return Age ; 22 | } 23 | 24 | public int GetSalary(){ 25 | return Salary ; 26 | } 27 | 28 | public boolean GetMarried(){ 29 | return Married ; 30 | } 31 | 32 | // This method returns true if the object "other" 33 | // has the same values for age, salary and 34 | public boolean Equal(Element other){ 35 | boolean ret_val ; 36 | int aux01 ; 37 | int aux02 ; 38 | int nt ; 39 | ret_val = true ; 40 | 41 | aux01 = other.GetAge(); 42 | if (!this.Compare(aux01,Age)) ret_val = false ; 43 | else { 44 | aux02 = other.GetSalary(); 45 | if (!this.Compare(aux02,Salary)) ret_val = false ; 46 | else 47 | if (Married) 48 | if (!other.GetMarried()) ret_val = false; 49 | else nt = 0 ; 50 | else 51 | if (other.GetMarried()) ret_val = false; 52 | else nt = 0 ; 53 | } 54 | 55 | return ret_val ; 56 | } 57 | 58 | // This method compares two integers and 59 | // returns true if they are equal and false 60 | // otherwise 61 | public boolean Compare(int num1 , int num2){ 62 | boolean retval ; 63 | int aux02 ; 64 | retval = false ; 65 | aux02 = num2 + 1 ; 66 | if (num1 < num2) retval = false ; 67 | else if (!(num1 < aux02)) retval = false ; 68 | else retval = true ; 69 | return retval ; 70 | } 71 | 72 | } 73 | 74 | class List{ 75 | Element elem ; 76 | List next ; 77 | boolean end ; 78 | 79 | // Initialize the node list as the last node 80 | public boolean Init(){ 81 | end = true ; 82 | return true ; 83 | } 84 | 85 | // Initialize the values of a new node 86 | public boolean InitNew(Element v_elem, List v_next, boolean v_end){ 87 | end = v_end ; 88 | elem = v_elem ; 89 | next = v_next ; 90 | return true ; 91 | } 92 | 93 | // Insert a new node at the beginning of the list 94 | public List Insert(Element new_elem){ 95 | boolean ret_val ; 96 | List aux03 ; 97 | List aux02 ; 98 | aux03 = this ; 99 | aux02 = new List(); 100 | ret_val = aux02.InitNew(new_elem,aux03,false); 101 | return aux02 ; 102 | } 103 | 104 | 105 | // Update the the pointer to the next node 106 | public boolean SetNext(List v_next){ 107 | next = v_next ; 108 | return true ; 109 | } 110 | 111 | // Delete an element e from the list 112 | public List Delete(Element e){ 113 | List my_head ; 114 | boolean ret_val ; 115 | boolean aux05; 116 | List aux01 ; 117 | List prev ; 118 | boolean var_end ; 119 | Element var_elem ; 120 | int aux04 ; 121 | int nt ; 122 | 123 | 124 | my_head = this ; 125 | ret_val = false ; 126 | aux04 = 0 - 1 ; 127 | aux01 = this ; 128 | prev = this ; 129 | var_end = end; 130 | var_elem = elem ; 131 | while ((!var_end) && (!ret_val)){ 132 | if (e.Equal(var_elem)){ 133 | ret_val = true ; 134 | if (aux04 < 0) { 135 | // delete first element 136 | my_head = aux01.GetNext() ; 137 | } 138 | else{ // delete a non first element 139 | System.out.println(0-555); 140 | aux05 = prev.SetNext(aux01.GetNext()); 141 | System.out.println(0-555); 142 | 143 | } 144 | } else nt = 0 ; 145 | if (!ret_val){ 146 | prev = aux01 ; 147 | aux01 = aux01.GetNext() ; 148 | var_end = aux01.GetEnd(); 149 | var_elem = aux01.GetElem(); 150 | aux04 = 1 ; 151 | } else nt = 0 ; 152 | } 153 | return my_head ; 154 | } 155 | 156 | 157 | // Search for an element e on the list 158 | public int Search(Element e){ 159 | int int_ret_val ; 160 | List aux01 ; 161 | Element var_elem ; 162 | boolean var_end ; 163 | int nt ; 164 | 165 | int_ret_val = 0 ; 166 | aux01 = this ; 167 | var_end = end; 168 | var_elem = elem ; 169 | while (!var_end){ 170 | if (e.Equal(var_elem)){ 171 | int_ret_val = 1 ; 172 | } 173 | else nt = 0 ; 174 | aux01 = aux01.GetNext() ; 175 | var_end = aux01.GetEnd(); 176 | var_elem = aux01.GetElem(); 177 | } 178 | return int_ret_val ; 179 | } 180 | 181 | public boolean GetEnd(){ 182 | return end ; 183 | } 184 | 185 | public Element GetElem(){ 186 | return elem ; 187 | } 188 | 189 | public List GetNext(){ 190 | return next ; 191 | } 192 | 193 | 194 | // Print the linked list 195 | public boolean Print(){ 196 | List aux01 ; 197 | boolean var_end ; 198 | Element var_elem ; 199 | 200 | aux01 = this ; 201 | var_end = end ; 202 | var_elem = elem ; 203 | while (!var_end){ 204 | System.out.println(var_elem.GetAge()); 205 | aux01 = aux01.GetNext() ; 206 | var_end = aux01.GetEnd(); 207 | var_elem = aux01.GetElem(); 208 | } 209 | 210 | return true ; 211 | } 212 | } 213 | 214 | 215 | // this class invokes the methods to insert, delete, 216 | // search and print the linked list 217 | class LL{ 218 | 219 | public int Start(){ 220 | 221 | List head ; 222 | List last_elem ; 223 | boolean aux01 ; 224 | Element el01 ; 225 | Element el02 ; 226 | Element el03 ; 227 | 228 | last_elem = new List(); 229 | aux01 = last_elem.Init(); 230 | head = last_elem ; 231 | aux01 = head.Init(); 232 | aux01 = head.Print(); 233 | 234 | // inserting first element 235 | el01 = new Element(); 236 | aux01 = el01.Init(25,37000,false); 237 | head = head.Insert(el01); 238 | aux01 = head.Print(); 239 | System.out.println(10000000); 240 | // inserting second element 241 | el01 = new Element(); 242 | aux01 = el01.Init(39,42000,true); 243 | el02 = el01 ; 244 | head = head.Insert(el01); 245 | aux01 = head.Print(); 246 | System.out.println(10000000); 247 | // inserting third element 248 | el01 = new Element(); 249 | aux01 = el01.Init(22,34000,false); 250 | head = head.Insert(el01); 251 | aux01 = head.Print(); 252 | el03 = new Element(); 253 | aux01 = el03.Init(27,34000,false); 254 | System.out.println(head.Search(el02)); 255 | System.out.println(head.Search(el03)); 256 | System.out.println(10000000); 257 | // inserting fourth element 258 | el01 = new Element(); 259 | aux01 = el01.Init(28,35000,false); 260 | head = head.Insert(el01); 261 | aux01 = head.Print(); 262 | System.out.println(2220000); 263 | 264 | head = head.Delete(el02); 265 | aux01 = head.Print(); 266 | System.out.println(33300000); 267 | 268 | 269 | head = head.Delete(el01); 270 | aux01 = head.Print(); 271 | System.out.println(44440000); 272 | 273 | return 0 ; 274 | 275 | 276 | } 277 | 278 | } 279 | -------------------------------------------------------------------------------- /testcases/minijava/MoreThan20Parameters.java: -------------------------------------------------------------------------------- 1 | 2 | class MoreThan20Parameters { 3 | public static void main(String[] a){ 4 | System.out.println(new Test().Start(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)); 5 | } 6 | } 7 | 8 | class Test { 9 | int aux; 10 | public int Start(int p0, int p1, int p2, int p3 , int p4, int p5, int p6, int p7, int p8, int p9, int p10, 11 | int p11, int p12, int p13, int p14, int p15, int p16, int p17, int p18, int p19, int p20){ 12 | System.out.println(p0); 13 | aux = p19 + p20; 14 | return aux; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /testcases/minijava/MoreThan4-error.java: -------------------------------------------------------------------------------- 1 | class MoreThan4{ 2 | public static void main(String[] a){ 3 | System.out.println(new MT4().Start(1,2,3,4,5,6)); 4 | } 5 | } 6 | 7 | class MT4 { 8 | public int Start(int p1, int p2, int p3 , int p4, int p5, int p6){ 9 | int aux ; 10 | System.out.println(p1); 11 | System.out.println(p2); 12 | System.out.println(p3); 13 | System.out.println(p4); 14 | System.out.println(p5); 15 | System.out.println(p6); 16 | aux = this.Change(p6,p5,p4,p3,p2);//TE 17 | return aux ; 18 | } 19 | 20 | public int Change(int p1, int p2, int p3 , int p4, int p5, int p6){ 21 | System.out.println(p1); 22 | System.out.println(p2); 23 | System.out.println(p3); 24 | System.out.println(p4); 25 | System.out.println(p5); 26 | System.out.println(p6); 27 | return 0 ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testcases/minijava/MoreThan4.java: -------------------------------------------------------------------------------- 1 | class MoreThan4{ 2 | public static void main(String[] a){ 3 | System.out.println(new MT4().Start(1,2,3,4,5,6)); 4 | } 5 | } 6 | 7 | class MT4 { 8 | public int Start(int p1, int p2, int p3 , int p4, int p5, int p6){ 9 | int aux ; 10 | System.out.println(p1); 11 | System.out.println(p2); 12 | System.out.println(p3); 13 | System.out.println(p4); 14 | System.out.println(p5); 15 | System.out.println(p6); 16 | aux = this.Change(p6,p5,p4,p3,p2,p1); 17 | return aux ; 18 | } 19 | 20 | public int Change(int p1, int p2, int p3 , int p4, int p5, int p6){ 21 | System.out.println(p1); 22 | System.out.println(p2); 23 | System.out.println(p3); 24 | System.out.println(p4); 25 | System.out.println(p5); 26 | System.out.println(p6); 27 | return 0 ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testcases/minijava/Overload-error.java: -------------------------------------------------------------------------------- 1 | class testOverload{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test2 test2; 10 | int b; 11 | 12 | public int start(){ 13 | 14 | b = test2.next(1); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(){ 20 | 21 | return 0; 22 | } 23 | } 24 | 25 | 26 | class Test2 extends Test { 27 | 28 | public int next(int a) { // TE 29 | 30 | return a; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /testcases/minijava/QuickSort-error.java: -------------------------------------------------------------------------------- 1 | class QuickSort{ 2 | public static void main(String[] a){ 3 | System.out.println(new QS().Start(10)); 4 | } 5 | } 6 | 7 | 8 | // This class contains the array of integers and 9 | // methods to initialize, print and sort the array 10 | // using Quicksort 11 | class QS{ 12 | 13 | int number ; //TE 14 | int size ; 15 | 16 | // Invoke the Initialization, Sort and Printing 17 | // Methods 18 | public int Start(int sz){ 19 | int aux01 ; 20 | aux01 = this.Init(sz); 21 | aux01 = this.Print(); 22 | System.out.println(9999); 23 | aux01 = size - 1 ; 24 | aux01 = this.Sort(0,aux01); 25 | aux01 = this.Print(); 26 | return 0 ; 27 | } 28 | 29 | 30 | // Sort array of integers using Quicksort method 31 | public int Sort(int left, int right){ 32 | int v ; 33 | int i ; 34 | int j ; 35 | int nt; 36 | int t ; 37 | boolean cont01; 38 | boolean cont02; 39 | int aux03 ; 40 | t = 0 ; 41 | if (left < right){ 42 | v = number[right] ; 43 | i = left - 1 ; 44 | j = right ; 45 | cont01 = true ; 46 | while (cont01){ 47 | cont02 = true ; 48 | while (cont02){ 49 | i = i + 1 ; 50 | aux03 = number[i] ; 51 | if (!(aux03 13 36 | return a.add(aa, bi); 37 | } 38 | 39 | public int init(int i) { 40 | aa = new B25(); 41 | ai = 2 * i; 42 | bi = 10 + i; 43 | return ai + bi; 44 | } 45 | } 46 | 47 | class C25 extends A25 { 48 | int ci; 49 | 50 | public int add(A25 a, int i) { 51 | System.out.println(this.init(i)); // --> 60 52 | return aa.add(a, ci); 53 | } 54 | 55 | public int init(int i) { 56 | aa = new A25(); 57 | ai = i - 5; 58 | ci = ai * i; 59 | return ci - ai; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /testcases/minijava/priv.test23.java: -------------------------------------------------------------------------------- 1 | class test23{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | int i; 10 | 11 | public int start(){ 12 | 13 | Test test; 14 | 15 | test = new Test(); 16 | 17 | i = 10; 18 | 19 | i = test.first(new Test().second()); 20 | 21 | return i; 22 | } 23 | 24 | public int first(int i){ 25 | 26 | return i; 27 | 28 | } 29 | 30 | public int second(){ 31 | 32 | return 30; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testcases/minijava/test00.java: -------------------------------------------------------------------------------- 1 | class test107{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test2 test2; 10 | boolean b; 11 | 12 | public int start(){ 13 | 14 | b = test2.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(){ // TE 20 | 21 | return 0; 22 | } 23 | } 24 | 25 | 26 | class Test2 extends Test { 27 | 28 | public boolean next() { 29 | 30 | return true; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /testcases/minijava/test01.java: -------------------------------------------------------------------------------- 1 | class test01{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean result; 10 | 11 | public int compute(){ 12 | 13 | result = true && false; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test02.java: -------------------------------------------------------------------------------- 1 | class test02{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean result; 10 | 11 | public int compute(){ 12 | 13 | result = 10 < 20 ; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test03.java: -------------------------------------------------------------------------------- 1 | class test03{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | int result; 10 | 11 | public int compute(){ 12 | 13 | result = 10 + 20 ; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test04.java: -------------------------------------------------------------------------------- 1 | class test04{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | int result; 10 | 11 | public int compute(){ 12 | 13 | result = 10 - 20 ; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test05.java: -------------------------------------------------------------------------------- 1 | class test05{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | int result; 10 | 11 | public int compute(){ 12 | 13 | result = 10 * 20 ; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test06.java: -------------------------------------------------------------------------------- 1 | class test06{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | boolean result; 14 | 15 | public int compute(){ 16 | 17 | op1bool = true; 18 | op2bool = false; 19 | result = op1bool && op2bool; 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test07.java: -------------------------------------------------------------------------------- 1 | class test07{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | boolean result; 14 | 15 | public int compute(){ 16 | 17 | op1int = 10; 18 | op2int = 20; 19 | result = op1int < op2int; 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test08.java: -------------------------------------------------------------------------------- 1 | class test08{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int result; 14 | 15 | public int compute(){ 16 | 17 | op1int = 10; 18 | op2int = 20; 19 | result = op1int + op2int; 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test09.java: -------------------------------------------------------------------------------- 1 | class test09{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int result; 14 | 15 | public int compute(){ 16 | 17 | op1int = 10; 18 | op2int = 20; 19 | result = op1int - op2int; 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test10.java: -------------------------------------------------------------------------------- 1 | class test10{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int result; 14 | 15 | public int compute(){ 16 | 17 | op1int = 10; 18 | op2int = 20; 19 | result = op1int * op2int; 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test11.java: -------------------------------------------------------------------------------- 1 | class test11{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int resultint; 14 | boolean resultbool; 15 | 16 | public int compute(){ 17 | 18 | op1bool = true; 19 | op2bool = false; 20 | resultint = op1bool && op2bool; // TE 21 | 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test12.java: -------------------------------------------------------------------------------- 1 | class test12{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int resultint; 14 | boolean resultbool; 15 | 16 | public int compute(){ 17 | 18 | op1int = 10; 19 | op2int = 20; 20 | resultint = op1int < op2int; // TE 21 | 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test13.java: -------------------------------------------------------------------------------- 1 | class test13{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int resultint; 14 | boolean resultbool; 15 | 16 | public int compute(){ 17 | 18 | op1int = 10; 19 | op2int = 20; 20 | resultbool = op1int + op2int; // TE 21 | 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test14.java: -------------------------------------------------------------------------------- 1 | class test14{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int resultint; 14 | boolean resultbool; 15 | 16 | public int compute(){ 17 | 18 | op1int = 10; 19 | op2int = 20; 20 | resultbool = op1int - op2int; // TE 21 | 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test15.java: -------------------------------------------------------------------------------- 1 | class test15{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | boolean op1bool; 10 | boolean op2bool; 11 | int op1int; 12 | int op2int; 13 | int resultint; 14 | boolean resultbool; 15 | 16 | public int compute(){ 17 | 18 | op1int = 10; 19 | op2int = 20; 20 | resultbool = op1int * op2int; // TE 21 | 22 | return 0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test16.java: -------------------------------------------------------------------------------- 1 | class test16{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | System.out.println(op); // TE TE 12 | 13 | return 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testcases/minijava/test17.java: -------------------------------------------------------------------------------- 1 | class test17{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().next()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int op; 12 | 13 | return 0; 14 | } 15 | 16 | public int next(){ 17 | int result; 18 | 19 | result = op; // TE TE 20 | 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test18.java: -------------------------------------------------------------------------------- 1 | class test18{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int op; 12 | int result; 13 | 14 | result = op[10]; // TE 15 | 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testcases/minijava/test19.java: -------------------------------------------------------------------------------- 1 | class test19{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | 13 | op = new int[10]; 14 | 15 | op = 5; // TE 16 | 17 | return 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testcases/minijava/test20.java: -------------------------------------------------------------------------------- 1 | class test20{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | int result; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | 15 | op = new int[10]; 16 | 17 | result = op.start(); // TE 18 | 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testcases/minijava/test21.java: -------------------------------------------------------------------------------- 1 | class test21{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | 13 | op = new int[10]; 14 | 15 | op[true] = 20; // TE 16 | 17 | return 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testcases/minijava/test22.java: -------------------------------------------------------------------------------- 1 | class test22{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | Test test; 13 | 14 | op = new int[10]; 15 | 16 | op[test] = 20; // TE 17 | 18 | return 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testcases/minijava/test23.java: -------------------------------------------------------------------------------- 1 | class test23{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | 15 | op = new int[10]; 16 | 17 | op[test.next()] = 20; // TE 18 | 19 | return 0; 20 | } 21 | 22 | public Test next() { 23 | 24 | return test; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test24.java: -------------------------------------------------------------------------------- 1 | class test24{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | boolean result; 10 | 11 | public int start(){ 12 | 13 | result = !1; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test25.java: -------------------------------------------------------------------------------- 1 | class test25{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | boolean result; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | 15 | op = new int[10]; 16 | 17 | result = !op; // TE 18 | 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testcases/minijava/test26.java: -------------------------------------------------------------------------------- 1 | class test26{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | boolean result; 11 | 12 | public int start(){ 13 | 14 | result = !test.next(); // TE 15 | 16 | return 0; 17 | } 18 | 19 | public Test next() { 20 | 21 | return test; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test27.java: -------------------------------------------------------------------------------- 1 | class test27{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | boolean result; 11 | 12 | public int start(){ 13 | 14 | result = !!true; 15 | 16 | return 0; 17 | } 18 | 19 | public Test next() { 20 | 21 | return test; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test28.java: -------------------------------------------------------------------------------- 1 | class test28{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | boolean result; 10 | 11 | public int start(){ 12 | 13 | result = !this; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test29.java: -------------------------------------------------------------------------------- 1 | class test29{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | Test test; 12 | int op; 13 | 14 | test = new op(); // TE TE 15 | 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testcases/minijava/test30.java: -------------------------------------------------------------------------------- 1 | class test30{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | Test test; 12 | 13 | test = new test(); // TE TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test31.java: -------------------------------------------------------------------------------- 1 | class test31{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | 13 | op = new int[true]; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test32.java: -------------------------------------------------------------------------------- 1 | class test32{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | int[] op2; 13 | 14 | op = new int[op2]; // TE 15 | 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testcases/minijava/test33.java: -------------------------------------------------------------------------------- 1 | class test33{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | int[] op2; 15 | 16 | op = new int[test.next()]; // TE 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | return test; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test34.java: -------------------------------------------------------------------------------- 1 | class test34{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | System.out.println(true); // TE 12 | 13 | return 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testcases/minijava/test35.java: -------------------------------------------------------------------------------- 1 | class test35{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | System.out.println(test); // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test36.java: -------------------------------------------------------------------------------- 1 | class test36{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | System.out.println(test.next()); // TE 14 | 15 | return 0; 16 | } 17 | 18 | public Test next(){ 19 | 20 | System.out.println(test.start()); 21 | 22 | return test; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test37.java: -------------------------------------------------------------------------------- 1 | class test37{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | while (1) System.out.println(1); // TE 12 | 13 | return 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testcases/minijava/test38.java: -------------------------------------------------------------------------------- 1 | class test37{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | while (test) System.out.println(1); // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test39.java: -------------------------------------------------------------------------------- 1 | class test39{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | while(test.next()) System.out.println(1); // TE 14 | 15 | return 0; 16 | } 17 | 18 | public Test next(){ 19 | 20 | while (true) System.out.println(1); 21 | 22 | return test; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test40.java: -------------------------------------------------------------------------------- 1 | class test40{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | if (1) System.out.println(1); else System.out.println(0); // TE 12 | 13 | return 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testcases/minijava/test41.java: -------------------------------------------------------------------------------- 1 | class test37{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | if (test) System.out.println(1); else System.out.println(0); // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test42.java: -------------------------------------------------------------------------------- 1 | class test42{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | if (test.next()) System.out.println(1); else System.out.println(0); // TE 14 | 15 | return 0; 16 | } 17 | 18 | public Test next(){ 19 | 20 | if (true) System.out.println(1); else System.out.println(0); // TE 21 | 22 | return test; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test43.java: -------------------------------------------------------------------------------- 1 | class test43{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | boolean op; 12 | 13 | op[10] = 5; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test44.java: -------------------------------------------------------------------------------- 1 | class test44{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | Test op; 12 | 13 | op[10] = 5; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test45.java: -------------------------------------------------------------------------------- 1 | class test45{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | 13 | op = new int[10]; 14 | 15 | op[true] = 5; // TE 16 | 17 | return 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testcases/minijava/test46.java: -------------------------------------------------------------------------------- 1 | class test46{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | 15 | op = new int[10]; 16 | 17 | op[test] = 5; // TE 18 | 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testcases/minijava/test47.java: -------------------------------------------------------------------------------- 1 | class test47{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | int[] op; 11 | 12 | public int start(){ 13 | 14 | op = new int[10]; 15 | 16 | op[test.next()] = 5; // TE 17 | 18 | return 0; 19 | } 20 | 21 | public int[] next(){ 22 | 23 | return op; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test48.java: -------------------------------------------------------------------------------- 1 | class test48{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | int[] op; 12 | 13 | op = new int[10]; 14 | 15 | op[5] = true; // TE 16 | 17 | return 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testcases/minijava/test49.java: -------------------------------------------------------------------------------- 1 | class test49{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | int[] op; 14 | 15 | op = new int[10]; 16 | 17 | op[5] = test; // TE 18 | 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testcases/minijava/test50.java: -------------------------------------------------------------------------------- 1 | class test50{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | int[] op; 11 | 12 | public int start(){ 13 | 14 | op = new int[10]; 15 | 16 | op[5] = test.next(); // TE 17 | 18 | return 0; 19 | } 20 | 21 | public int[] next(){ 22 | 23 | return op; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test51.java: -------------------------------------------------------------------------------- 1 | class test51{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | int result; 11 | 12 | public int start(){ 13 | 14 | result = test; // TE 15 | 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testcases/minijava/test52.java: -------------------------------------------------------------------------------- 1 | class test52{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | int op; 10 | boolean result; 11 | 12 | public int start(){ 13 | 14 | result = op; // TE 15 | 16 | return 0; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testcases/minijava/test53.java: -------------------------------------------------------------------------------- 1 | class test53{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | int[] result; 10 | int op; 11 | 12 | public int start(){ 13 | 14 | result = new int[10]; 15 | 16 | result = op; // TE 17 | 18 | return 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testcases/minijava/test54.java: -------------------------------------------------------------------------------- 1 | class test54{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2{ 8 | } 9 | 10 | class Test{ 11 | 12 | Test test; 13 | Test2 test2; 14 | int result; 15 | 16 | public int start(){ 17 | 18 | test = test2; // TE 19 | 20 | return 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testcases/minijava/test55.java: -------------------------------------------------------------------------------- 1 | class test55{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | int[] result; 10 | int[] op; 11 | 12 | public int start(){ 13 | 14 | result = new int[10]; 15 | 16 | result = op; 17 | 18 | return 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testcases/minijava/test56.java: -------------------------------------------------------------------------------- 1 | class test56{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class B extends A{ 8 | 9 | } 10 | 11 | class A{ 12 | 13 | A a; 14 | B b; 15 | 16 | public int start(){ 17 | 18 | a = b; 19 | 20 | return 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testcases/minijava/test57.java: -------------------------------------------------------------------------------- 1 | class test57{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class C extends B{ 8 | 9 | } 10 | 11 | class B extends A{ 12 | 13 | } 14 | 15 | class A{ 16 | 17 | A a; 18 | C c; 19 | 20 | public int start(){ 21 | 22 | a = c; 23 | 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test58.java: -------------------------------------------------------------------------------- 1 | class test58{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class C extends B{ 8 | 9 | } 10 | 11 | class B extends A{ 12 | 13 | } 14 | 15 | class A{ 16 | 17 | B b; 18 | C c; 19 | 20 | public int start(){ 21 | 22 | b = c; 23 | 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test59.java: -------------------------------------------------------------------------------- 1 | class test59{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class B extends A{ 8 | 9 | } 10 | 11 | class A{ 12 | 13 | A a; 14 | B b; 15 | 16 | public int start(){ 17 | 18 | b = a; // TE 19 | 20 | return 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testcases/minijava/test60.java: -------------------------------------------------------------------------------- 1 | class test60{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class C extends B{ 8 | 9 | } 10 | 11 | class B extends A{ 12 | 13 | } 14 | 15 | class A{ 16 | 17 | B b; 18 | C c; 19 | 20 | public int start(){ 21 | 22 | c = b; // TE 23 | 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test61.java: -------------------------------------------------------------------------------- 1 | class test61{ 2 | public static void main(String[] a){ 3 | System.out.println(new A().start()); 4 | } 5 | } 6 | 7 | class C extends B{ 8 | 9 | } 10 | 11 | class B extends A{ 12 | 13 | } 14 | 15 | class A{ 16 | 17 | A a; 18 | C c; 19 | 20 | public int start(){ 21 | 22 | c = a; // TE 23 | 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test62.java: -------------------------------------------------------------------------------- 1 | class test62{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | test = this; 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test63.java: -------------------------------------------------------------------------------- 1 | class test63{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2{ 8 | 9 | } 10 | 11 | class Test{ 12 | 13 | Test2 test2; 14 | 15 | public int start(){ 16 | 17 | test2 = this; // TE 18 | 19 | return 0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testcases/minijava/test64.java: -------------------------------------------------------------------------------- 1 | class test64{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | public int start(){ 10 | 11 | i = 10; // TE 12 | 13 | return 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testcases/minijava/test65.java: -------------------------------------------------------------------------------- 1 | class test65{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | test = test.next(); 14 | 15 | return 0; 16 | } 17 | 18 | public Test next() { 19 | 20 | return true; // TE 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testcases/minijava/test66.java: -------------------------------------------------------------------------------- 1 | class test66{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test{ 8 | 9 | } 10 | 11 | class Test{ 12 | 13 | Test test; 14 | 15 | public int start(){ 16 | 17 | test = test.next(); 18 | 19 | return 0; 20 | } 21 | 22 | public Test next() { 23 | 24 | Test2 test2; 25 | 26 | return test2; // legal in MiniJava 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testcases/minijava/test67.java: -------------------------------------------------------------------------------- 1 | class test67{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test{ 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | test = test.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public Test next() { 20 | 21 | return i; // TE 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test68.java: -------------------------------------------------------------------------------- 1 | class test68{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 { 8 | 9 | public Test2 start(){ 10 | 11 | Test2 test22; 12 | 13 | return test22; 14 | } 15 | } 16 | 17 | class Test { 18 | 19 | Test test; 20 | int i; 21 | 22 | public int start(){ 23 | 24 | test = test.next(); 25 | 26 | return 0; 27 | } 28 | 29 | public Test next() { 30 | 31 | Test2 test21; 32 | 33 | return test21.start(); // TE 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /testcases/minijava/test69.java: -------------------------------------------------------------------------------- 1 | class test69{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test{ 8 | 9 | public Test2 start(){ //TE 10 | 11 | return this; 12 | } 13 | } 14 | 15 | class Test { 16 | 17 | Test test; 18 | int i; 19 | 20 | public int start(){ 21 | 22 | test = test.next(); 23 | 24 | return 0; 25 | } 26 | 27 | public Test next() { 28 | 29 | Test2 test21; 30 | 31 | return test21.start(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /testcases/minijava/test70.java: -------------------------------------------------------------------------------- 1 | class test70{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | test = test.next(true); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(boolean i) { 20 | 21 | i = false; // TE 22 | 23 | return 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test71.java: -------------------------------------------------------------------------------- 1 | class test71{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int j; 11 | 12 | public int start(){ 13 | 14 | j = test.next(true); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(boolean i) { 20 | 21 | int i; // TE 22 | 23 | return 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test72.java: -------------------------------------------------------------------------------- 1 | class test72{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test extends NotPresent { //TE 8 | 9 | public int start(){ 10 | 11 | return 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testcases/minijava/test73.java: -------------------------------------------------------------------------------- 1 | class test73{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test extends test73 { 8 | 9 | public int start(){ 10 | 11 | return 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testcases/minijava/test74.java: -------------------------------------------------------------------------------- 1 | class test74{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test{ 8 | 9 | public int start(){ 10 | 11 | Test test1; 12 | 13 | test1 = test; 14 | 15 | return 0; 16 | } 17 | } 18 | 19 | class Test { 20 | 21 | Test test; 22 | 23 | public int start(){ 24 | 25 | test = this; 26 | 27 | return 0; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /testcases/minijava/test75.java: -------------------------------------------------------------------------------- 1 | class test75{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test{ 8 | 9 | public int start2(){ 10 | 11 | Test test1; 12 | int j; 13 | 14 | j = test1.start(); //legal in MiniJava 15 | 16 | return 0; 17 | } 18 | } 19 | 20 | class Test { 21 | 22 | Test test; 23 | 24 | public int start(){ 25 | 26 | return 0; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /testcases/minijava/test76.java: -------------------------------------------------------------------------------- 1 | class test76{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(){ 20 | 21 | i = test.start(); 22 | 23 | return i; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /testcases/minijava/test77.java: -------------------------------------------------------------------------------- 1 | class test77{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(){ 20 | 21 | return test.start(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test78.java: -------------------------------------------------------------------------------- 1 | class test78{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | 11 | public int start(){ 12 | 13 | test = test.next(); 14 | 15 | return 0; 16 | } 17 | 18 | public Test next(){ 19 | 20 | return test.next(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test79.java: -------------------------------------------------------------------------------- 1 | class test79{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | int i; 10 | 11 | public int start(){ 12 | 13 | int j; 14 | 15 | i = 10; 16 | j = 10; 17 | 18 | return ((i+((j*5)-8))+23); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testcases/minijava/test80.java: -------------------------------------------------------------------------------- 1 | class test77{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | boolean b; 11 | 12 | public int start(){ 13 | 14 | b = test.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public boolean next(){ 20 | 21 | return ((true && (7<8)) && b); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test81.java: -------------------------------------------------------------------------------- 1 | class test81{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | int i; 10 | 11 | public int start(){ 12 | 13 | int j; 14 | int k; 15 | 16 | i = 10; 17 | j = 10; 18 | 19 | k = ((i+((j*5)-8))+23); 20 | 21 | return k; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test82.java: -------------------------------------------------------------------------------- 1 | class test77{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | boolean b; 11 | 12 | public int start(){ 13 | 14 | b = test.next(); 15 | 16 | return 0; 17 | } 18 | 19 | public boolean next(){ 20 | 21 | boolean b2; 22 | 23 | b2 = ((true && (7<8)) && !b); 24 | return b2; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /testcases/minijava/test83.java: -------------------------------------------------------------------------------- 1 | class test83{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(5, 5); // TE 15 | 16 | return 0; 17 | } 18 | 19 | public int next(int j){ 20 | 21 | return 0; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test84.java: -------------------------------------------------------------------------------- 1 | class test84{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(true); // TE 15 | 16 | return 0; 17 | } 18 | 19 | public int next(boolean b1, boolean b2){ 20 | 21 | return 0; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test85.java: -------------------------------------------------------------------------------- 1 | class test85{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(test, 45, true); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(Test t, int j, boolean b){ 20 | 21 | return 0; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/minijava/test86.java: -------------------------------------------------------------------------------- 1 | class test125{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 { 8 | 9 | } 10 | 11 | class Test { 12 | 13 | Test test; 14 | 15 | public int start(){ 16 | 17 | test = new Test2(); // TE 18 | 19 | return 0; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /testcases/minijava/test87.java: -------------------------------------------------------------------------------- 1 | class test03{ 2 | public static void main(String[] a){ 3 | System.out.println(new Operator().compute()); 4 | } 5 | } 6 | 7 | class Operator{ 8 | 9 | int result; 10 | 11 | public int compute(){ 12 | 13 | result = 10 + false; // TE 14 | 15 | return 0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testcases/minijava/test88.java: -------------------------------------------------------------------------------- 1 | class test88{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | test = test.next(test, i); // TE 15 | 16 | return 0; 17 | } 18 | 19 | public Test next(int i, Test t, boolean b){ 20 | 21 | return test; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testcases/minijava/test89.java: -------------------------------------------------------------------------------- 1 | class test89{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | test = test.next(test.third(i)); 15 | 16 | return 0; 17 | } 18 | 19 | public Test next(Test t){ 20 | 21 | return test; 22 | } 23 | 24 | public Test third(int i){ 25 | 26 | return test; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testcases/minijava/test90.java: -------------------------------------------------------------------------------- 1 | class test90{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = test.next(i); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next(int[] i){ 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test91.java: -------------------------------------------------------------------------------- 1 | class test91{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = test.next(i); // TE TE 17 | 18 | return 0; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testcases/minijava/test92.java: -------------------------------------------------------------------------------- 1 | class test92{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test { 8 | 9 | public int next(int i) { 10 | 11 | return 0; 12 | } 13 | } 14 | 15 | class Test { 16 | 17 | Test test; 18 | int[] i; 19 | 20 | public int start(){ 21 | 22 | i = new int[10]; 23 | 24 | test = test.next(i); // TE TE 25 | 26 | return 0; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testcases/minijava/test93.java: -------------------------------------------------------------------------------- 1 | class test93{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = (test.next()).next(); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test94.java: -------------------------------------------------------------------------------- 1 | class test94{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = (new Test()).next(); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test95.java: -------------------------------------------------------------------------------- 1 | class test95{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = ((new Test()).next()).next(); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test96.java: -------------------------------------------------------------------------------- 1 | class test96{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test2 extends Test{ 8 | 9 | } 10 | 11 | class Test { 12 | 13 | Test test; 14 | int[] i; 15 | 16 | public int start(){ 17 | 18 | i = new int[10]; 19 | 20 | test = ((new Test2()).next()).next(); 21 | 22 | return 0; 23 | } 24 | 25 | public Test next() { 26 | 27 | return test; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testcases/minijava/test97.java: -------------------------------------------------------------------------------- 1 | class test97{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = (this.next()).next(); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test98.java: -------------------------------------------------------------------------------- 1 | class test98{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int[] i; 11 | 12 | public int start(){ 13 | 14 | i = new int[10]; 15 | 16 | test = (this).next(); 17 | 18 | return 0; 19 | } 20 | 21 | public Test next() { 22 | 23 | return test; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testcases/minijava/test99.java: -------------------------------------------------------------------------------- 1 | class test99{ 2 | public static void main(String[] a){ 3 | System.out.println(new Test().start()); 4 | } 5 | } 6 | 7 | class Test { 8 | 9 | Test test; 10 | int i; 11 | 12 | public int start(){ 13 | 14 | i = test.next(this); 15 | 16 | return 0; 17 | } 18 | 19 | public int next(Test t){ 20 | 21 | return 0; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /testcases/mips/Factorial.s: -------------------------------------------------------------------------------- 1 | .text 2 | .globl main 3 | main: 4 | move $fp, $sp 5 | subu $sp, $sp, 4 6 | sw $ra, -4($fp) 7 | li $a0 4 8 | jal _halloc 9 | move $t0 $v0 10 | li $a0 4 11 | jal _halloc 12 | move $t1 $v0 13 | la $t2 Fac_ComputeFac 14 | sw $t2, 0($t0) 15 | sw $t0, 0($t1) 16 | move $t0 $t1 17 | lw $t1 0($t0) 18 | lw $t2 0($t1) 19 | li $t1 10 20 | move $a0 $t0 21 | move $a1 $t1 22 | jalr $t2 23 | move $t3 $v0 24 | move $a0 $t3 25 | jal _print 26 | lw $ra, -4($fp) 27 | addu $sp, $sp, 4 28 | j $ra 29 | 30 | .text 31 | .globl Fac_ComputeFac 32 | Fac_ComputeFac: 33 | sw $fp, -8($sp) 34 | move $fp, $sp 35 | subu $sp, $sp, 20 36 | sw $ra, -4($fp) 37 | sw $s0, 0($sp) 38 | sw $s1, 4($sp) 39 | sw $s2, 8($sp) 40 | move $s0 $a0 41 | move $s1 $a1 42 | li $t0 1 43 | slt $t1, $s1, $t0 44 | beqz $t1 L2 45 | li $s2 1 46 | b L3 47 | L2: nop 48 | move $t0 $s0 49 | lw $t1 0($t0) 50 | lw $t2 0($t1) 51 | li $t1 1 52 | sub $t3, $s1, $t1 53 | move $a0 $t0 54 | move $a1 $t3 55 | jalr $t2 56 | move $t1 $v0 57 | mul $t0, $s1, $t1 58 | move $s2 $t0 59 | L3: nop 60 | move $v0 $s2 61 | lw $s0, 0($sp) 62 | lw $s1, 4($sp) 63 | lw $s2, 8($sp) 64 | lw $ra, -4($fp) 65 | lw $fp, 12($sp) 66 | addu $sp, $sp, 20 67 | j $ra 68 | 69 | .text 70 | .globl _halloc 71 | _halloc: 72 | li $v0, 9 73 | syscall 74 | j $ra 75 | 76 | .text 77 | .globl _print 78 | _print: 79 | li $v0, 1 80 | syscall 81 | la $a0, newl 82 | li $v0, 4 83 | syscall 84 | j $ra 85 | 86 | .data 87 | .align 0 88 | newl: .asciiz "\n" 89 | .data 90 | .align 0 91 | str_er: .asciiz " ERROR: abnormal termination\n" 92 | -------------------------------------------------------------------------------- /testcases/mips/LinearSearch.s: -------------------------------------------------------------------------------- 1 | .text 2 | .globl main 3 | main: 4 | move $fp, $sp 5 | subu $sp, $sp, 4 6 | sw $ra, -4($fp) 7 | li $a0 16 8 | jal _halloc 9 | move $t0 $v0 10 | li $a0 12 11 | jal _halloc 12 | move $t1 $v0 13 | la $t2 LS_Init 14 | sw $t2, 12($t0) 15 | la $t2 LS_Search 16 | sw $t2, 8($t0) 17 | la $t2 LS_Print 18 | sw $t2, 4($t0) 19 | la $t2 LS_Start 20 | sw $t2, 0($t0) 21 | li $t2 4 22 | L0:nop 23 | li $t3 12 24 | slt $t4, $t2, $t3 25 | beqz $t4 L1 26 | add $t3, $t1, $t2 27 | li $t4 0 28 | sw $t4, 0($t3) 29 | add $t2, $t2, 4 30 | b L0 31 | L1: nop 32 | sw $t0, 0($t1) 33 | move $t0 $t1 34 | lw $t1 0($t0) 35 | lw $t2 0($t1) 36 | li $t1 10 37 | move $a0 $t0 38 | move $a1 $t1 39 | jalr $t2 40 | move $t3 $v0 41 | move $a0 $t3 42 | jal _print 43 | lw $ra, -4($fp) 44 | addu $sp, $sp, 4 45 | j $ra 46 | 47 | .text 48 | .globl LS_Start 49 | LS_Start: 50 | sw $fp, -8($sp) 51 | move $fp, $sp 52 | subu $sp, $sp, 16 53 | sw $ra, -4($fp) 54 | sw $s0, 0($sp) 55 | sw $s1, 4($sp) 56 | move $s0 $a0 57 | move $s1 $a1 58 | move $t0 $s0 59 | lw $t1 0($t0) 60 | lw $t2 12($t1) 61 | move $a0 $t0 62 | move $a1 $s1 63 | jalr $t2 64 | move $t1 $v0 65 | move $t0 $s0 66 | lw $t1 0($t0) 67 | lw $t2 4($t1) 68 | move $a0 $t0 69 | jalr $t2 70 | move $t1 $v0 71 | li $t0 9999 72 | move $a0 $t0 73 | jal _print 74 | move $t0 $s0 75 | lw $t1 0($t0) 76 | lw $t2 8($t1) 77 | li $t1 8 78 | move $a0 $t0 79 | move $a1 $t1 80 | jalr $t2 81 | move $t3 $v0 82 | move $a0 $t3 83 | jal _print 84 | move $t0 $s0 85 | lw $t1 0($t0) 86 | lw $t2 8($t1) 87 | li $t1 12 88 | move $a0 $t0 89 | move $a1 $t1 90 | jalr $t2 91 | move $t3 $v0 92 | move $a0 $t3 93 | jal _print 94 | move $t0 $s0 95 | lw $t1 0($t0) 96 | lw $t2 8($t1) 97 | li $t1 17 98 | move $a0 $t0 99 | move $a1 $t1 100 | jalr $t2 101 | move $t3 $v0 102 | move $a0 $t3 103 | jal _print 104 | move $t0 $s0 105 | lw $t1 0($t0) 106 | lw $t2 8($t1) 107 | li $t1 50 108 | move $a0 $t0 109 | move $a1 $t1 110 | jalr $t2 111 | move $t3 $v0 112 | move $a0 $t3 113 | jal _print 114 | li $t0 55 115 | move $v0 $t0 116 | lw $s0, 0($sp) 117 | lw $s1, 4($sp) 118 | lw $ra, -4($fp) 119 | lw $fp, 8($sp) 120 | addu $sp, $sp, 16 121 | j $ra 122 | 123 | .text 124 | .globl LS_Print 125 | LS_Print: 126 | sw $fp, -8($sp) 127 | move $fp, $sp 128 | subu $sp, $sp, 12 129 | sw $ra, -4($fp) 130 | sw $s0, 0($sp) 131 | move $s0 $a0 132 | li $t0 1 133 | L2:nop 134 | lw $t1 8($s0) 135 | slt $t2, $t0, $t1 136 | beqz $t2 L3 137 | lw $t1 4($s0) 138 | mul $t2, $t0, 4 139 | lw $t1 4($s0) 140 | lw $t3 0($t1) 141 | li $t4 1 142 | slt $t5, $t2, $t3 143 | sub $t3, $t4, $t5 144 | beqz $t3 L4 145 | li $v0, 4 146 | la $a0, str_er 147 | syscall 148 | li $v0, 10 149 | syscall 150 | L4: nop 151 | li $t3 4 152 | move $t4 $t3 153 | add $t3, $t2, $t4 154 | move $t2 $t3 155 | add $t3, $t1, $t2 156 | lw $t1 0($t3) 157 | move $a0 $t1 158 | jal _print 159 | add $t0, $t0, 1 160 | b L2 161 | L3: nop 162 | li $t0 0 163 | move $v0 $t0 164 | lw $s0, 0($sp) 165 | lw $ra, -4($fp) 166 | lw $fp, 4($sp) 167 | addu $sp, $sp, 12 168 | j $ra 169 | 170 | .text 171 | .globl LS_Search 172 | LS_Search: 173 | sw $fp, -8($sp) 174 | move $fp, $sp 175 | subu $sp, $sp, 16 176 | sw $ra, -4($fp) 177 | sw $s0, 0($sp) 178 | sw $s1, 4($sp) 179 | move $s0 $a0 180 | move $s1 $a1 181 | li $t0 1 182 | li $t1 0 183 | L5:nop 184 | lw $t2 8($s0) 185 | slt $t3, $t0, $t2 186 | beqz $t3 L6 187 | lw $t2 4($s0) 188 | mul $t3, $t0, 4 189 | lw $t2 4($s0) 190 | lw $t4 0($t2) 191 | li $t5 1 192 | slt $t6, $t3, $t4 193 | sub $t4, $t5, $t6 194 | beqz $t4 L7 195 | li $v0, 4 196 | la $a0, str_er 197 | syscall 198 | li $v0, 10 199 | syscall 200 | L7: nop 201 | li $t4 4 202 | move $t5 $t4 203 | add $t4, $t3, $t5 204 | move $t3 $t4 205 | add $t4, $t2, $t3 206 | lw $t2 0($t4) 207 | move $t3 $t2 208 | add $t2, $s1, 1 209 | slt $t4, $t3, $s1 210 | beqz $t4 L8 211 | b L9 212 | L8: nop 213 | li $t4 1 214 | slt $t5, $t3, $t2 215 | sub $t2, $t4, $t5 216 | beqz $t2 L10 217 | b L11 218 | L10: nop 219 | li $t1 1 220 | lw $t2 8($s0) 221 | move $t0 $t2 222 | L11: nop 223 | L9: nop 224 | add $t0, $t0, 1 225 | b L5 226 | L6: nop 227 | move $v0 $t1 228 | lw $s0, 0($sp) 229 | lw $s1, 4($sp) 230 | lw $ra, -4($fp) 231 | lw $fp, 8($sp) 232 | addu $sp, $sp, 16 233 | j $ra 234 | 235 | .text 236 | .globl LS_Init 237 | LS_Init: 238 | sw $fp, -8($sp) 239 | move $fp, $sp 240 | subu $sp, $sp, 16 241 | sw $ra, -4($fp) 242 | sw $s0, 0($sp) 243 | sw $s1, 4($sp) 244 | move $s0 $a0 245 | move $s1 $a1 246 | sw $s1, 8($s0) 247 | add $t0, $s1, 1 248 | li $t1 4 249 | mul $t2, $t0, $t1 250 | move $a0 $t2 251 | jal _halloc 252 | move $t0 $v0 253 | li $t1 4 254 | L12: nop 255 | li $t2 1 256 | add $t3, $s1, $t2 257 | li $t2 4 258 | move $t4 $t2 259 | mul $t2, $t3, $t4 260 | slt $t3, $t1, $t2 261 | beqz $t3 L13 262 | add $t2, $t0, $t1 263 | li $t3 0 264 | sw $t3, 0($t2) 265 | add $t1, $t1, 4 266 | b L12 267 | L13: nop 268 | li $t1 4 269 | mul $t2, $s1, $t1 270 | sw $t2, 0($t0) 271 | sw $t0, 4($s0) 272 | li $t0 1 273 | lw $t1 8($s0) 274 | li $t2 1 275 | add $t3, $t1, $t2 276 | L14: nop 277 | lw $t1 8($s0) 278 | slt $t2, $t0, $t1 279 | beqz $t2 L15 280 | li $t1 2 281 | mul $t2, $t1, $t0 282 | sub $t1, $t3, 3 283 | li $t4 1 284 | mul $t5, $t4, 4 285 | add $t4, $s0, $t5 286 | lw $t6 0($t4) 287 | mul $t4, $t0, 4 288 | li $t7 1 289 | mul $t5, $t7, 4 290 | add $t7, $s0, $t5 291 | lw $t6 0($t7) 292 | lw $t5 0($t6) 293 | li $t7 1 294 | slt $t8, $t4, $t5 295 | sub $t5, $t7, $t8 296 | beqz $t5 L16 297 | li $v0, 4 298 | la $a0, str_er 299 | syscall 300 | li $v0, 10 301 | syscall 302 | L16: nop 303 | li $t5 4 304 | move $t7 $t5 305 | add $t5, $t4, $t7 306 | move $t4 $t5 307 | add $t5, $t6, $t4 308 | add $t4, $t2, $t1 309 | sw $t4, 0($t5) 310 | add $t0, $t0, 1 311 | sub $t3, $t3, 1 312 | b L14 313 | L15: nop 314 | li $t0 0 315 | move $v0 $t0 316 | lw $s0, 0($sp) 317 | lw $s1, 4($sp) 318 | lw $ra, -4($fp) 319 | lw $fp, 8($sp) 320 | addu $sp, $sp, 16 321 | j $ra 322 | 323 | .text 324 | .globl _halloc 325 | _halloc: 326 | li $v0, 9 327 | syscall 328 | j $ra 329 | 330 | .text 331 | .globl _print 332 | _print: 333 | li $v0, 1 334 | syscall 335 | la $a0, newl 336 | li $v0, 4 337 | syscall 338 | j $ra 339 | 340 | .data 341 | .align 0 342 | newl: .asciiz "\n" 343 | .data 344 | .align 0 345 | str_er: .asciiz " ERROR: abnormal termination\n" 346 | -------------------------------------------------------------------------------- /testcases/mips/MoreThan4.s: -------------------------------------------------------------------------------- 1 | .text 2 | .globl main 3 | main: 4 | move $fp, $sp 5 | subu $sp, $sp, 16 6 | sw $ra, -4($fp) 7 | li $a0 8 8 | jal _halloc 9 | move $t0 $v0 10 | li $a0 4 11 | jal _halloc 12 | move $t1 $v0 13 | la $t2 MT4_Change 14 | sw $t2, 4($t0) 15 | la $t2 MT4_Start 16 | sw $t2, 0($t0) 17 | sw $t0, 0($t1) 18 | move $t0 $t1 19 | lw $t1 0($t0) 20 | lw $t2 0($t1) 21 | li $t1 1 22 | li $t3 2 23 | li $t4 3 24 | li $t5 4 25 | li $t6 5 26 | li $t7 6 27 | move $a0 $t0 28 | move $a1 $t1 29 | move $a2 $t3 30 | move $a3 $t4 31 | sw $t5, 0($sp) 32 | sw $t6, 4($sp) 33 | sw $t7, 8($sp) 34 | jalr $t2 35 | move $t8 $v0 36 | move $a0 $t8 37 | jal _print 38 | lw $ra, -4($fp) 39 | addu $sp, $sp, 16 40 | j $ra 41 | 42 | .text 43 | .globl MT4_Start 44 | MT4_Start: 45 | sw $fp, -8($sp) 46 | move $fp, $sp 47 | subu $sp, $sp, 48 48 | sw $ra, -4($fp) 49 | sw $s0, 24($sp) 50 | sw $s1, 28($sp) 51 | sw $s2, 32($sp) 52 | sw $s3, 36($sp) 53 | move $s0 $a0 54 | move $s1 $a1 55 | move $s2 $a2 56 | move $s3 $a3 57 | move $a0 $s1 58 | jal _print 59 | move $a0 $s2 60 | jal _print 61 | move $a0 $s3 62 | jal _print 63 | lw $v1, 0($fp) 64 | move $a0 $v1 65 | jal _print 66 | lw $v1, 4($fp) 67 | move $a0 $v1 68 | jal _print 69 | lw $v1, 8($fp) 70 | move $a0 $v1 71 | jal _print 72 | move $t0 $s0 73 | lw $t1 0($t0) 74 | lw $t2 4($t1) 75 | move $a0 $t0 76 | lw $v1, 8($fp) 77 | move $a1 $v1 78 | lw $v0, 4($fp) 79 | move $a2 $v0 80 | lw $v0, 0($fp) 81 | move $a3 $v0 82 | sw $s3, 0($sp) 83 | sw $s2, 4($sp) 84 | sw $s1, 8($sp) 85 | jalr $t2 86 | move $t1 $v0 87 | move $t0 $t1 88 | move $v0 $t0 89 | lw $s0, 24($sp) 90 | lw $s1, 28($sp) 91 | lw $s2, 32($sp) 92 | lw $s3, 36($sp) 93 | lw $ra, -4($fp) 94 | lw $fp, 40($sp) 95 | addu $sp, $sp, 48 96 | j $ra 97 | 98 | .text 99 | .globl MT4_Change 100 | MT4_Change: 101 | sw $fp, -8($sp) 102 | move $fp, $sp 103 | subu $sp, $sp, 36 104 | sw $ra, -4($fp) 105 | sw $s0, 12($sp) 106 | sw $s1, 16($sp) 107 | sw $s2, 20($sp) 108 | sw $s3, 24($sp) 109 | move $s0 $a0 110 | move $s1 $a1 111 | move $s2 $a2 112 | move $s3 $a3 113 | move $a0 $s1 114 | jal _print 115 | move $a0 $s2 116 | jal _print 117 | move $a0 $s3 118 | jal _print 119 | lw $v1, 0($fp) 120 | move $a0 $v1 121 | jal _print 122 | lw $v1, 4($fp) 123 | move $a0 $v1 124 | jal _print 125 | lw $v1, 8($fp) 126 | move $a0 $v1 127 | jal _print 128 | li $t0 0 129 | move $v0 $t0 130 | lw $s0, 12($sp) 131 | lw $s1, 16($sp) 132 | lw $s2, 20($sp) 133 | lw $s3, 24($sp) 134 | lw $ra, -4($fp) 135 | lw $fp, 28($sp) 136 | addu $sp, $sp, 36 137 | j $ra 138 | 139 | .text 140 | .globl _halloc 141 | _halloc: 142 | li $v0, 9 143 | syscall 144 | j $ra 145 | 146 | .text 147 | .globl _print 148 | _print: 149 | li $v0, 1 150 | syscall 151 | la $a0, newl 152 | li $v0, 4 153 | syscall 154 | j $ra 155 | 156 | .data 157 | .align 0 158 | newl: .asciiz "\n" 159 | .data 160 | .align 0 161 | str_er: .asciiz " ERROR: abnormal termination\n" 162 | -------------------------------------------------------------------------------- /testcases/piglet/Factorial.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT CALL 3 | BEGIN 4 | MOVE TEMP 23 5 | BEGIN 6 | MOVE TEMP 24 HALLOCATE 4 7 | MOVE TEMP 25 HALLOCATE 4 8 | HSTORE TEMP 24 0 Fac_ComputeFac 9 | HSTORE TEMP 25 0 TEMP 24 10 | RETURN 11 | TEMP 25 12 | END 13 | HLOAD TEMP 21 TEMP 23 0 14 | HLOAD TEMP 22 TEMP 21 0 15 | RETURN 16 | TEMP 22 17 | END 18 | (TEMP 23 10 ) 19 | END 20 | 21 | Fac_ComputeFac [ 2 ] 22 | BEGIN 23 | CJUMP LT TEMP 1 1 L2 24 | MOVE TEMP 20 1 25 | JUMP L3 26 | L2 MOVE TEMP 20 TIMES TEMP 1 27 | CALL 28 | BEGIN 29 | MOVE TEMP 29 TEMP 0 30 | HLOAD TEMP 27 TEMP 29 0 31 | HLOAD TEMP 28 TEMP 27 0 32 | RETURN 33 | TEMP 28 34 | END 35 | (TEMP 29 MINUS TEMP 1 1 ) 36 | L3 NOOP 37 | RETURN 38 | TEMP 20 39 | END 40 | 41 | -------------------------------------------------------------------------------- /testcases/piglet/LinearSearch.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT CALL 3 | BEGIN 4 | MOVE TEMP 35 5 | BEGIN 6 | MOVE TEMP 36 HALLOCATE 16 7 | MOVE TEMP 37 HALLOCATE 12 8 | HSTORE TEMP 36 12 LS_Init 9 | HSTORE TEMP 36 8 LS_Search 10 | HSTORE TEMP 36 4 LS_Print 11 | HSTORE TEMP 36 0 LS_Start 12 | MOVE TEMP 38 4 13 | L0 CJUMP LT TEMP 38 12 L1 14 | HSTORE PLUS TEMP 37 TEMP 38 0 0 15 | MOVE TEMP 38 PLUS TEMP 38 4 16 | JUMP L0 17 | L1 HSTORE TEMP 37 0 TEMP 36 18 | RETURN 19 | TEMP 37 20 | END 21 | 22 | HLOAD TEMP 33 TEMP 35 0 23 | HLOAD TEMP 34 TEMP 33 0 24 | RETURN 25 | TEMP 34 26 | END 27 | (TEMP 35 10 ) 28 | END 29 | 30 | LS_Start [ 2 ] 31 | 32 | BEGIN 33 | MOVE TEMP 20 CALL 34 | BEGIN 35 | MOVE TEMP 41 TEMP 0 36 | HLOAD TEMP 39 TEMP 41 0 37 | HLOAD TEMP 40 TEMP 39 12 38 | RETURN 39 | TEMP 40 40 | END 41 | (TEMP 41 TEMP 1 ) 42 | MOVE TEMP 21 CALL 43 | BEGIN 44 | MOVE TEMP 44 TEMP 0 45 | HLOAD TEMP 42 TEMP 44 0 46 | HLOAD TEMP 43 TEMP 42 4 47 | RETURN 48 | TEMP 43 49 | END 50 | (TEMP 44 ) 51 | PRINT 9999 52 | PRINT CALL 53 | BEGIN 54 | MOVE TEMP 47 TEMP 0 55 | HLOAD TEMP 45 TEMP 47 0 56 | HLOAD TEMP 46 TEMP 45 8 57 | RETURN 58 | TEMP 46 59 | END 60 | (TEMP 47 8 ) 61 | PRINT CALL 62 | BEGIN 63 | MOVE TEMP 50 TEMP 0 64 | HLOAD TEMP 48 TEMP 50 0 65 | HLOAD TEMP 49 TEMP 48 8 66 | RETURN 67 | TEMP 49 68 | END 69 | (TEMP 50 12 ) 70 | PRINT CALL 71 | BEGIN 72 | MOVE TEMP 53 TEMP 0 73 | HLOAD TEMP 51 TEMP 53 0 74 | HLOAD TEMP 52 TEMP 51 8 75 | RETURN 76 | TEMP 52 77 | END 78 | (TEMP 53 17 ) 79 | PRINT CALL 80 | BEGIN 81 | MOVE TEMP 56 TEMP 0 82 | HLOAD TEMP 54 TEMP 56 0 83 | HLOAD TEMP 55 TEMP 54 8 84 | RETURN 85 | TEMP 55 86 | END 87 | (TEMP 56 50 ) 88 | RETURN 89 | 55 90 | END 91 | 92 | LS_Print [ 1 ] 93 | 94 | BEGIN 95 | MOVE TEMP 22 1 96 | L2 CJUMP LT TEMP 22 97 | BEGIN 98 | HLOAD TEMP 58 TEMP 0 8 99 | RETURN 100 | TEMP 58 101 | END 102 | L3 103 | PRINT 104 | BEGIN 105 | HLOAD TEMP 62 PLUS 106 | BEGIN 107 | HLOAD TEMP 63 TEMP 0 4 108 | RETURN 109 | TEMP 63 110 | END 111 | PLUS 112 | BEGIN 113 | MOVE TEMP 60 TIMES TEMP 22 4 114 | HLOAD TEMP 61 115 | BEGIN 116 | HLOAD TEMP 63 TEMP 0 4 117 | RETURN 118 | TEMP 63 119 | END 120 | 0 121 | CJUMP MINUS 1 LT TEMP 60 TEMP 61 L4 122 | ERROR 123 | L4 NOOP 124 | RETURN 125 | TEMP 60 126 | END 127 | 4 0 128 | RETURN 129 | TEMP 62 130 | END 131 | 132 | MOVE TEMP 22 PLUS TEMP 22 1 133 | JUMP L2 134 | L3 NOOP 135 | RETURN 136 | 0 137 | END 138 | 139 | LS_Search [ 2 ] 140 | 141 | BEGIN 142 | MOVE TEMP 23 1 143 | MOVE TEMP 24 0 144 | MOVE TEMP 25 0 145 | L5 CJUMP LT TEMP 23 146 | BEGIN 147 | HLOAD TEMP 66 TEMP 0 8 148 | RETURN 149 | TEMP 66 150 | END 151 | L6 152 | MOVE TEMP 26 153 | BEGIN 154 | HLOAD TEMP 70 PLUS 155 | BEGIN 156 | HLOAD TEMP 71 TEMP 0 4 157 | RETURN 158 | TEMP 71 159 | END 160 | PLUS 161 | BEGIN 162 | MOVE TEMP 68 TIMES TEMP 23 4 163 | HLOAD TEMP 69 164 | BEGIN 165 | HLOAD TEMP 71 TEMP 0 4 166 | RETURN 167 | TEMP 71 168 | END 169 | 0 170 | CJUMP MINUS 1 LT TEMP 68 TEMP 69 L7 171 | ERROR 172 | L7 NOOP 173 | RETURN 174 | TEMP 68 175 | END 176 | 4 0 177 | RETURN 178 | TEMP 70 179 | END 180 | 181 | MOVE TEMP 27 PLUS TEMP 1 1 182 | CJUMP LT TEMP 26 TEMP 1 L8 183 | MOVE TEMP 28 0 184 | JUMP L9 185 | L8 186 | CJUMP MINUS 1 LT TEMP 26 TEMP 27 L10 187 | MOVE TEMP 28 0 188 | JUMP L11 189 | L10 190 | MOVE TEMP 24 1 191 | MOVE TEMP 25 1 192 | MOVE TEMP 23 193 | BEGIN 194 | HLOAD TEMP 73 TEMP 0 8 195 | RETURN 196 | TEMP 73 197 | END 198 | 199 | L11 NOOP 200 | L9 NOOP 201 | MOVE TEMP 23 PLUS TEMP 23 1 202 | JUMP L5 203 | L6 NOOP 204 | RETURN 205 | TEMP 25 206 | END 207 | 208 | LS_Init [ 2 ] 209 | 210 | BEGIN 211 | HSTORE TEMP 0 8 TEMP 1 212 | HSTORE TEMP 0 4 213 | BEGIN 214 | MOVE TEMP 75 HALLOCATE TIMES PLUS TEMP 1 1 4 215 | MOVE TEMP 76 4 216 | L12 CJUMP LT TEMP 76 TIMES PLUS TEMP 1 1 4 L13 217 | HSTORE PLUS TEMP 75 TEMP 76 0 0 218 | MOVE TEMP 76 PLUS TEMP 76 4 219 | JUMP L12 220 | L13 HSTORE TEMP 75 0 TIMES TEMP 1 4 221 | RETURN 222 | TEMP 75 223 | END 224 | 225 | MOVE TEMP 29 1 226 | MOVE TEMP 30 PLUS 227 | BEGIN 228 | HLOAD TEMP 77 TEMP 0 8 229 | RETURN 230 | TEMP 77 231 | END 232 | 1 233 | L14 CJUMP LT TEMP 29 234 | BEGIN 235 | HLOAD TEMP 80 TEMP 0 8 236 | RETURN 237 | TEMP 80 238 | END 239 | L15 240 | MOVE TEMP 31 TIMES 2 TEMP 29 241 | MOVE TEMP 32 MINUS TEMP 30 3 242 | HSTORE PLUS 243 | BEGIN 244 | MOVE TEMP 86 TIMES 1 4 245 | HLOAD TEMP 85 PLUS TEMP 0 TEMP 86 0 246 | RETURN 247 | TEMP 85 248 | END 249 | PLUS 250 | BEGIN 251 | MOVE TEMP 83 TIMES TEMP 29 4 252 | HLOAD TEMP 84 253 | BEGIN 254 | MOVE TEMP 86 TIMES 1 4 255 | HLOAD TEMP 85 PLUS TEMP 0 TEMP 86 0 256 | RETURN 257 | TEMP 85 258 | END 259 | 0 260 | CJUMP MINUS 1 LT TEMP 83 TEMP 84 L16 261 | ERROR 262 | L16 NOOP 263 | RETURN 264 | TEMP 83 265 | END 266 | 4 0 PLUS TEMP 31 TEMP 32 267 | MOVE TEMP 29 PLUS TEMP 29 1 268 | MOVE TEMP 30 MINUS TEMP 30 1 269 | JUMP L14 270 | L15 NOOP 271 | RETURN 272 | 0 273 | END 274 | -------------------------------------------------------------------------------- /testcases/piglet/MoreThan4.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT CALL 3 | BEGIN 4 | MOVE TEMP 23 5 | BEGIN 6 | MOVE TEMP 24 HALLOCATE 8 7 | MOVE TEMP 25 HALLOCATE 4 8 | HSTORE TEMP 24 4 MT4_Change 9 | HSTORE TEMP 24 0 MT4_Start 10 | HSTORE TEMP 25 0 TEMP 24 11 | RETURN 12 | TEMP 25 13 | END 14 | 15 | HLOAD TEMP 21 TEMP 23 0 16 | HLOAD TEMP 22 TEMP 21 0 17 | RETURN 18 | TEMP 22 19 | END 20 | (TEMP 23 1 2 3 4 5 6 ) 21 | END 22 | 23 | MT4_Start [ 7 ] 24 | 25 | BEGIN 26 | PRINT TEMP 1 27 | PRINT TEMP 2 28 | PRINT TEMP 3 29 | PRINT TEMP 4 30 | PRINT TEMP 5 31 | PRINT TEMP 6 32 | MOVE TEMP 20 CALL 33 | BEGIN 34 | MOVE TEMP 29 TEMP 0 35 | HLOAD TEMP 27 TEMP 29 0 36 | HLOAD TEMP 28 TEMP 27 4 37 | RETURN 38 | TEMP 28 39 | END 40 | (TEMP 29 TEMP 6 TEMP 5 TEMP 4 TEMP 3 TEMP 2 TEMP 1 ) 41 | RETURN 42 | TEMP 20 43 | END 44 | 45 | MT4_Change [ 7 ] 46 | 47 | BEGIN 48 | PRINT TEMP 1 49 | PRINT TEMP 2 50 | PRINT TEMP 3 51 | PRINT TEMP 4 52 | PRINT TEMP 5 53 | PRINT TEMP 6 54 | RETURN 55 | 0 56 | END 57 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test01.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 4 7 | HSTORE TEMP 24 0 TEMP 23 8 | RETURN TEMP 24 9 | END 10 | 11 | HLOAD TEMP 22 TEMP 21 0 12 | HLOAD TEMP 22 TEMP 22 0 13 | RETURN CALL TEMP 22(TEMP 21 ) 14 | END 15 | 16 | END 17 | Test_start [1] 18 | BEGIN 19 | RETURN 857432 20 | END 21 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test02.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 4 7 | HSTORE TEMP 24 0 TEMP 23 8 | RETURN TEMP 24 9 | END 10 | 11 | HLOAD TEMP 22 TEMP 21 0 12 | HLOAD TEMP 22 TEMP 22 0 13 | RETURN CALL TEMP 22(TEMP 21 ) 14 | END 15 | 16 | END 17 | Test_start [1] 18 | BEGIN 19 | RETURN PLUS 10 30 20 | END 21 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test03.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 TIMES MINUS 800 300 3 21 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 22 | END 23 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test04.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 BEGIN 21 | MOVE TEMP 20 10 22 | MOVE TEMP 21 HALLOCATE PLUS TIMES TEMP 20 4 4 23 | HSTORE TEMP 21 0 TEMP 20 24 | RETURN PLUS TEMP 21 4 25 | END 26 | 27 | MOVE TEMP 20 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 28 | MOVE TEMP 21 5 29 | HLOAD TEMP 22 MINUS TEMP 20 4 0 30 | CJUMP LT MINUS TEMP 22 1 TEMP 21 L1 31 | ERROR 32 | L1 HSTORE PLUS TEMP 20 TIMES TEMP 21 4 0 40 33 | RETURN BEGIN 34 | MOVE TEMP 23 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 35 | MOVE TEMP 24 5 36 | HLOAD TEMP 25 MINUS TEMP 23 4 0 37 | CJUMP LT MINUS TEMP 25 1 TEMP 24 L2 38 | ERROR 39 | L2 HLOAD TEMP 25 PLUS TEMP 23 TIMES TEMP 24 4 0 40 | RETURN TEMP 25 41 | END 42 | 43 | END 44 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test05.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 BEGIN 21 | MOVE TEMP 20 10 22 | MOVE TEMP 21 HALLOCATE PLUS TIMES TEMP 20 4 4 23 | HSTORE TEMP 21 0 TEMP 20 24 | RETURN PLUS TEMP 21 4 25 | END 26 | 27 | MOVE TEMP 20 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 28 | MOVE TEMP 21 15 29 | HLOAD TEMP 22 MINUS TEMP 20 4 0 30 | CJUMP LT MINUS TEMP 22 1 TEMP 21 L1 31 | ERROR 32 | L1 HSTORE PLUS TEMP 20 TIMES TEMP 21 4 0 70 33 | RETURN 30 34 | END 35 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test06.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 BEGIN 21 | MOVE TEMP 20 10 22 | MOVE TEMP 21 HALLOCATE PLUS TIMES TEMP 20 4 4 23 | HSTORE TEMP 21 0 TEMP 20 24 | RETURN PLUS TEMP 21 4 25 | END 26 | 27 | RETURN BEGIN 28 | HLOAD TEMP 20 MINUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 4 0 29 | RETURN TEMP 20 30 | END 31 | 32 | END 33 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test07.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 1 21 | L1 CJUMP LT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 5 L2 22 | PRINT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 23 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 1 24 | JUMP L1 25 | L2 NOOP 26 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 27 | END 28 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test08.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 10 21 | MOVE TEMP 20 LT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 20 22 | CJUMP TEMP 20 L1 23 | PRINT 1 24 | JUMP L2 25 | L1 NOOP 26 | PRINT 0 27 | L2 NOOP 28 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 29 | END 30 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test09.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 11 21 | MOVE TEMP 20 1 22 | L1 CJUMP LT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 15 L2 23 | CJUMP TEMP 20 L3 24 | PRINT 1 25 | JUMP L4 26 | L3 NOOP 27 | PRINT 0 28 | L4 NOOP 29 | MOVE TEMP 20 MINUS 1 TEMP 20 30 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 1 31 | JUMP L1 32 | L2 NOOP 33 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 34 | END 35 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test10.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 8 5 | HSTORE TEMP 23 0 Test_next 6 | HSTORE TEMP 23 4 Test_start 7 | MOVE TEMP 24 HALLOCATE 8 8 | HSTORE TEMP 24 0 TEMP 23 9 | HSTORE TEMP 24 4 0 10 | RETURN TEMP 24 11 | END 12 | 13 | HLOAD TEMP 22 TEMP 21 0 14 | HLOAD TEMP 22 TEMP 22 4 15 | RETURN CALL TEMP 22(TEMP 21 ) 16 | END 17 | 18 | END 19 | Test_start [1] 20 | BEGIN 21 | HSTORE TEMP 0 4 10 22 | MOVE TEMP 20 BEGIN 23 | MOVE TEMP 21 HALLOCATE 8 24 | HSTORE TEMP 21 0 Test_next 25 | HSTORE TEMP 21 4 Test_start 26 | MOVE TEMP 22 HALLOCATE 8 27 | HSTORE TEMP 22 0 TEMP 21 28 | HSTORE TEMP 22 4 0 29 | RETURN TEMP 22 30 | END 31 | 32 | HSTORE TEMP 0 4 BEGIN 33 | MOVE TEMP 21 TEMP 20 34 | HLOAD TEMP 22 TEMP 21 0 35 | HLOAD TEMP 22 TEMP 22 0 36 | RETURN CALL TEMP 22(TEMP 21 ) 37 | END 38 | 39 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 40 | END 41 | Test_next [1] 42 | BEGIN 43 | RETURN 20 44 | END 45 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test11.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 60 21 | PRINT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 22 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 10 23 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 24 | END 25 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test12.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 BEGIN 21 | MOVE TEMP 20 10 22 | MOVE TEMP 21 HALLOCATE PLUS TIMES TEMP 20 4 4 23 | HSTORE TEMP 21 0 TEMP 20 24 | RETURN PLUS TEMP 21 4 25 | END 26 | 27 | MOVE TEMP 20 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 28 | MOVE TEMP 21 BEGIN 29 | HLOAD TEMP 23 MINUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 4 0 30 | RETURN TEMP 23 31 | END 32 | 33 | HLOAD TEMP 22 MINUS TEMP 20 4 0 34 | CJUMP LT MINUS TEMP 22 1 TEMP 21 L1 35 | ERROR 36 | L1 HSTORE PLUS TEMP 20 TIMES TEMP 21 4 0 80 37 | RETURN 40 38 | END 39 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test13.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 8 7 | HSTORE TEMP 24 0 TEMP 23 8 | HSTORE TEMP 24 4 0 9 | RETURN TEMP 24 10 | END 11 | 12 | HLOAD TEMP 22 TEMP 21 0 13 | HLOAD TEMP 22 TEMP 22 0 14 | RETURN CALL TEMP 22(TEMP 21 ) 15 | END 16 | 17 | END 18 | Test_start [1] 19 | BEGIN 20 | HSTORE TEMP 0 4 BEGIN 21 | MOVE TEMP 20 10 22 | MOVE TEMP 21 HALLOCATE PLUS TIMES TEMP 20 4 4 23 | HSTORE TEMP 21 0 TEMP 20 24 | RETURN PLUS TEMP 21 4 25 | END 26 | 27 | MOVE TEMP 20 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 28 | MOVE TEMP 21 1 29 | HLOAD TEMP 22 MINUS TEMP 20 4 0 30 | CJUMP LT MINUS TEMP 22 1 TEMP 21 L1 31 | ERROR 32 | L1 HSTORE PLUS TEMP 20 TIMES TEMP 21 4 0 40 33 | MOVE TEMP 23 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 34 | MOVE TEMP 24 PLUS MINUS TIMES 3 4 15 4 35 | HLOAD TEMP 25 MINUS TEMP 23 4 0 36 | CJUMP LT MINUS TEMP 25 1 TEMP 24 L2 37 | ERROR 38 | L2 HSTORE PLUS TEMP 23 TIMES TEMP 24 4 0 80 39 | RETURN BEGIN 40 | MOVE TEMP 26 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 41 | MOVE TEMP 27 1 42 | HLOAD TEMP 28 MINUS TEMP 26 4 0 43 | CJUMP LT MINUS TEMP 28 1 TEMP 27 L3 44 | ERROR 45 | L3 HLOAD TEMP 28 PLUS TEMP 26 TIMES TEMP 27 4 0 46 | RETURN TEMP 28 47 | END 48 | 49 | END 50 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test14.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 4 5 | HSTORE TEMP 23 0 Test_start 6 | MOVE TEMP 24 HALLOCATE 4 7 | HSTORE TEMP 24 0 TEMP 23 8 | RETURN TEMP 24 9 | END 10 | 11 | HLOAD TEMP 22 TEMP 21 0 12 | HLOAD TEMP 22 TEMP 22 0 13 | RETURN CALL TEMP 22(TEMP 21 ) 14 | END 15 | 16 | END 17 | Test_start [1] 18 | BEGIN 19 | CJUMP BEGIN 20 | MOVE TEMP 21 0 21 | CJUMP 1 L3 22 | CJUMP 0 L3 23 | MOVE TEMP 21 1 24 | L3 NOOP 25 | RETURN TEMP 21 26 | END 27 | L1 28 | MOVE TEMP 20 0 29 | JUMP L2 30 | L1 NOOP 31 | MOVE TEMP 20 1 32 | L2 NOOP 33 | RETURN TEMP 20 34 | END 35 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test15.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 12 5 | HSTORE TEMP 23 0 Test_start 6 | HSTORE TEMP 23 4 Test_mutual2 7 | HSTORE TEMP 23 8 Test_mutual1 8 | MOVE TEMP 24 HALLOCATE 12 9 | HSTORE TEMP 24 0 TEMP 23 10 | HSTORE TEMP 24 4 0 11 | HSTORE TEMP 24 8 0 12 | RETURN TEMP 24 13 | END 14 | 15 | HLOAD TEMP 22 TEMP 21 0 16 | HLOAD TEMP 22 TEMP 22 0 17 | RETURN CALL TEMP 22(TEMP 21 ) 18 | END 19 | 20 | END 21 | Test_start [1] 22 | BEGIN 23 | HSTORE TEMP 0 4 4 24 | HSTORE TEMP 0 8 0 25 | RETURN BEGIN 26 | MOVE TEMP 20 TEMP 0 27 | HLOAD TEMP 21 TEMP 20 0 28 | HLOAD TEMP 21 TEMP 21 8 29 | RETURN CALL TEMP 21(TEMP 20 ) 30 | END 31 | 32 | END 33 | Test_mutual1 [1] 34 | BEGIN 35 | HSTORE TEMP 0 4 MINUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 1 36 | CJUMP LT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 0 L1 37 | HSTORE TEMP 0 8 0 38 | JUMP L2 39 | L1 NOOP 40 | PRINT BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 41 | HSTORE TEMP 0 8 1 42 | MOVE TEMP 20 BEGIN 43 | MOVE TEMP 21 TEMP 0 44 | HLOAD TEMP 22 TEMP 21 0 45 | HLOAD TEMP 22 TEMP 22 4 46 | RETURN CALL TEMP 22(TEMP 21 ) 47 | END 48 | 49 | L2 NOOP 50 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 51 | END 52 | Test_mutual2 [1] 53 | BEGIN 54 | HSTORE TEMP 0 4 MINUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 1 55 | CJUMP LT BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 0 L3 56 | HSTORE TEMP 0 8 0 57 | JUMP L4 58 | L3 NOOP 59 | PRINT BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 60 | HSTORE TEMP 0 8 0 61 | MOVE TEMP 20 BEGIN 62 | MOVE TEMP 21 TEMP 0 63 | HLOAD TEMP 22 TEMP 21 0 64 | HLOAD TEMP 22 TEMP 22 8 65 | RETURN CALL TEMP 22(TEMP 21 ) 66 | END 67 | 68 | L4 NOOP 69 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 70 | END 71 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test16.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 12 5 | HSTORE TEMP 23 0 Test_start 6 | HSTORE TEMP 23 4 Test_first 7 | HSTORE TEMP 23 8 Test_second 8 | MOVE TEMP 24 HALLOCATE 8 9 | HSTORE TEMP 24 0 TEMP 23 10 | HSTORE TEMP 24 4 0 11 | RETURN TEMP 24 12 | END 13 | 14 | HLOAD TEMP 22 TEMP 21 0 15 | HLOAD TEMP 22 TEMP 22 0 16 | RETURN CALL TEMP 22(TEMP 21 ) 17 | END 18 | 19 | END 20 | Test_start [1] 21 | BEGIN 22 | MOVE TEMP 20 BEGIN 23 | MOVE TEMP 21 HALLOCATE 12 24 | HSTORE TEMP 21 0 Test_start 25 | HSTORE TEMP 21 4 Test_first 26 | HSTORE TEMP 21 8 Test_second 27 | MOVE TEMP 22 HALLOCATE 8 28 | HSTORE TEMP 22 0 TEMP 21 29 | HSTORE TEMP 22 4 0 30 | RETURN TEMP 22 31 | END 32 | 33 | HSTORE TEMP 0 4 10 34 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END BEGIN 35 | MOVE TEMP 21 BEGIN 36 | MOVE TEMP 23 TEMP 20 37 | HLOAD TEMP 24 TEMP 23 0 38 | HLOAD TEMP 24 TEMP 24 4 39 | RETURN CALL TEMP 24(TEMP 23 ) 40 | END 41 | 42 | HLOAD TEMP 22 TEMP 21 0 43 | HLOAD TEMP 22 TEMP 22 8 44 | RETURN CALL TEMP 22(TEMP 21 ) 45 | END 46 | 47 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 48 | END 49 | Test_first [1] 50 | BEGIN 51 | RETURN BEGIN 52 | MOVE TEMP 20 HALLOCATE 12 53 | HSTORE TEMP 20 0 Test_start 54 | HSTORE TEMP 20 4 Test_first 55 | HSTORE TEMP 20 8 Test_second 56 | MOVE TEMP 21 HALLOCATE 8 57 | HSTORE TEMP 21 0 TEMP 20 58 | HSTORE TEMP 21 4 0 59 | RETURN TEMP 21 60 | END 61 | 62 | END 63 | Test_second [1] 64 | BEGIN 65 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 10 66 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 67 | END 68 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test17.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 12 5 | HSTORE TEMP 23 0 Test_start 6 | HSTORE TEMP 23 4 Test_first 7 | HSTORE TEMP 23 8 Test_second 8 | MOVE TEMP 24 HALLOCATE 8 9 | HSTORE TEMP 24 0 TEMP 23 10 | HSTORE TEMP 24 4 0 11 | RETURN TEMP 24 12 | END 13 | 14 | HLOAD TEMP 22 TEMP 21 0 15 | HLOAD TEMP 22 TEMP 22 0 16 | RETURN CALL TEMP 22(TEMP 21 ) 17 | END 18 | 19 | END 20 | Test_start [1] 21 | BEGIN 22 | MOVE TEMP 20 BEGIN 23 | MOVE TEMP 21 HALLOCATE 12 24 | HSTORE TEMP 21 0 Test_start 25 | HSTORE TEMP 21 4 Test_first 26 | HSTORE TEMP 21 8 Test_second 27 | MOVE TEMP 22 HALLOCATE 8 28 | HSTORE TEMP 22 0 TEMP 21 29 | HSTORE TEMP 22 4 0 30 | RETURN TEMP 22 31 | END 32 | 33 | HSTORE TEMP 0 4 10 34 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END BEGIN 35 | MOVE TEMP 21 BEGIN 36 | MOVE TEMP 23 TEMP 20 37 | HLOAD TEMP 24 TEMP 23 0 38 | HLOAD TEMP 24 TEMP 24 4 39 | RETURN CALL TEMP 24(TEMP 23 TEMP 0 ) 40 | END 41 | 42 | HLOAD TEMP 22 TEMP 21 0 43 | HLOAD TEMP 22 TEMP 22 8 44 | RETURN CALL TEMP 22(TEMP 21 ) 45 | END 46 | 47 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 48 | END 49 | Test_first [2] 50 | BEGIN 51 | MOVE TEMP 20 TEMP 1 52 | RETURN TEMP 20 53 | END 54 | Test_second [1] 55 | BEGIN 56 | HSTORE TEMP 0 4 PLUS BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 10 57 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 58 | END 59 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test18.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 8 5 | HSTORE TEMP 23 0 A21_getI1 6 | HSTORE TEMP 23 4 A21_start 7 | MOVE TEMP 24 HALLOCATE 8 8 | HSTORE TEMP 24 0 TEMP 23 9 | HSTORE TEMP 24 4 0 10 | RETURN TEMP 24 11 | END 12 | 13 | HLOAD TEMP 22 TEMP 21 0 14 | HLOAD TEMP 22 TEMP 22 4 15 | RETURN CALL TEMP 22(TEMP 21 ) 16 | END 17 | 18 | END 19 | A21_start [1] 20 | BEGIN 21 | RETURN BEGIN 22 | MOVE TEMP 20 BEGIN 23 | MOVE TEMP 22 HALLOCATE 8 24 | HSTORE TEMP 22 0 A21_getI1 25 | HSTORE TEMP 22 4 A21_start 26 | MOVE TEMP 23 HALLOCATE 8 27 | HSTORE TEMP 23 0 TEMP 22 28 | HSTORE TEMP 23 4 0 29 | RETURN TEMP 23 30 | END 31 | 32 | HLOAD TEMP 21 TEMP 20 0 33 | HLOAD TEMP 21 TEMP 21 0 34 | RETURN CALL TEMP 21(TEMP 20 ) 35 | END 36 | 37 | END 38 | A21_getI1 [1] 39 | BEGIN 40 | HSTORE TEMP 0 4 123 41 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 42 | END 43 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test19.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 8 5 | HSTORE TEMP 23 0 B22_getI1 6 | HSTORE TEMP 23 4 B22_go 7 | MOVE TEMP 24 HALLOCATE 12 8 | HSTORE TEMP 24 0 TEMP 23 9 | HSTORE TEMP 24 4 0 10 | HSTORE TEMP 24 8 0 11 | RETURN TEMP 24 12 | END 13 | 14 | HLOAD TEMP 22 TEMP 21 0 15 | HLOAD TEMP 22 TEMP 22 4 16 | RETURN CALL TEMP 22(TEMP 21 BEGIN 17 | MOVE TEMP 23 HALLOCATE 8 18 | HSTORE TEMP 23 0 B22_getI1 19 | HSTORE TEMP 23 4 B22_go 20 | MOVE TEMP 24 HALLOCATE 12 21 | HSTORE TEMP 24 0 TEMP 23 22 | HSTORE TEMP 24 4 0 23 | HSTORE TEMP 24 8 0 24 | RETURN TEMP 24 25 | END 26 | ) 27 | END 28 | 29 | END 30 | A22_getI1 [2] 31 | BEGIN 32 | HSTORE TEMP 0 4 123 33 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 34 | END 35 | B22_go [2] 36 | BEGIN 37 | RETURN BEGIN 38 | MOVE TEMP 20 TEMP 1 39 | HLOAD TEMP 21 TEMP 20 0 40 | HLOAD TEMP 21 TEMP 21 0 41 | RETURN CALL TEMP 21(TEMP 20 1 ) 42 | END 43 | 44 | END 45 | B22_getI1 [2] 46 | BEGIN 47 | CJUMP TEMP 1 L1 48 | HSTORE TEMP 0 4 456 49 | JUMP L2 50 | L1 NOOP 51 | HSTORE TEMP 0 4 789 52 | L2 NOOP 53 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 54 | END 55 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test20.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 12 5 | HSTORE TEMP 23 0 C23_init 6 | HSTORE TEMP 23 4 C23_getI1 7 | HSTORE TEMP 23 8 C23_setI1 8 | MOVE TEMP 24 HALLOCATE 32 9 | HSTORE TEMP 24 0 TEMP 23 10 | HSTORE TEMP 24 4 0 11 | HSTORE TEMP 24 8 0 12 | HSTORE TEMP 24 12 0 13 | HSTORE TEMP 24 16 0 14 | HSTORE TEMP 24 20 0 15 | HSTORE TEMP 24 24 0 16 | HSTORE TEMP 24 28 0 17 | RETURN TEMP 24 18 | END 19 | 20 | HLOAD TEMP 22 TEMP 21 0 21 | HLOAD TEMP 22 TEMP 22 0 22 | RETURN CALL TEMP 22(TEMP 21 BEGIN 23 | MOVE TEMP 23 HALLOCATE 12 24 | HSTORE TEMP 23 0 B23_init 25 | HSTORE TEMP 23 4 B23_getI1 26 | HSTORE TEMP 23 8 B23_setI1 27 | MOVE TEMP 24 HALLOCATE 24 28 | HSTORE TEMP 24 0 TEMP 23 29 | HSTORE TEMP 24 4 0 30 | HSTORE TEMP 24 8 0 31 | HSTORE TEMP 24 12 0 32 | HSTORE TEMP 24 16 0 33 | HSTORE TEMP 24 20 0 34 | RETURN TEMP 24 35 | END 36 | ) 37 | END 38 | 39 | END 40 | A23_init [2] 41 | BEGIN 42 | HSTORE TEMP 0 8 BEGIN 43 | MOVE TEMP 20 TEMP 1 44 | HLOAD TEMP 21 TEMP 20 0 45 | HLOAD TEMP 21 TEMP 21 4 46 | RETURN CALL TEMP 21(TEMP 20 ) 47 | END 48 | 49 | HSTORE TEMP 0 12 222 50 | HSTORE TEMP 0 4 BEGIN 51 | MOVE TEMP 22 TEMP 0 52 | HLOAD TEMP 23 TEMP 22 0 53 | HLOAD TEMP 23 TEMP 23 8 54 | RETURN CALL TEMP 23(TEMP 22 PLUS BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END BEGIN HLOAD TEMP 100 TEMP 0 12 RETURN TEMP 100 END ) 55 | END 56 | 57 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 58 | END 59 | A23_getI1 [1] 60 | BEGIN 61 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 62 | END 63 | A23_setI1 [2] 64 | BEGIN 65 | RETURN TEMP 1 66 | END 67 | B23_init [2] 68 | BEGIN 69 | MOVE TEMP 20 BEGIN 70 | MOVE TEMP 21 HALLOCATE 12 71 | HSTORE TEMP 21 0 A23_init 72 | HSTORE TEMP 21 4 A23_getI1 73 | HSTORE TEMP 21 8 A23_setI1 74 | MOVE TEMP 22 HALLOCATE 16 75 | HSTORE TEMP 22 0 TEMP 21 76 | HSTORE TEMP 22 4 0 77 | HSTORE TEMP 22 8 0 78 | HSTORE TEMP 22 12 0 79 | RETURN TEMP 22 80 | END 81 | 82 | HSTORE TEMP 0 20 BEGIN 83 | MOVE TEMP 21 TEMP 1 84 | HLOAD TEMP 22 TEMP 21 0 85 | HLOAD TEMP 22 TEMP 22 4 86 | RETURN CALL TEMP 22(TEMP 21 ) 87 | END 88 | 89 | HSTORE TEMP 0 16 BEGIN 90 | MOVE TEMP 23 TEMP 0 91 | HLOAD TEMP 24 TEMP 23 0 92 | HLOAD TEMP 24 TEMP 24 8 93 | RETURN CALL TEMP 24(TEMP 23 BEGIN HLOAD TEMP 100 TEMP 0 20 RETURN TEMP 100 END ) 94 | END 95 | 96 | RETURN BEGIN 97 | MOVE TEMP 25 TEMP 20 98 | HLOAD TEMP 26 TEMP 25 0 99 | HLOAD TEMP 26 TEMP 26 0 100 | RETURN CALL TEMP 26(TEMP 25 TEMP 0 ) 101 | END 102 | 103 | END 104 | B23_getI1 [1] 105 | BEGIN 106 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 16 RETURN TEMP 100 END 107 | END 108 | B23_setI1 [2] 109 | BEGIN 110 | RETURN PLUS TEMP 1 111 111 | END 112 | C23_init [2] 113 | BEGIN 114 | HSTORE TEMP 0 28 333 115 | HSTORE TEMP 0 24 BEGIN 116 | MOVE TEMP 20 TEMP 0 117 | HLOAD TEMP 21 TEMP 20 0 118 | HLOAD TEMP 21 TEMP 21 8 119 | RETURN CALL TEMP 21(TEMP 20 BEGIN HLOAD TEMP 100 TEMP 0 28 RETURN TEMP 100 END ) 120 | END 121 | 122 | RETURN BEGIN 123 | MOVE TEMP 22 TEMP 1 124 | HLOAD TEMP 23 TEMP 22 0 125 | HLOAD TEMP 23 TEMP 23 0 126 | RETURN CALL TEMP 23(TEMP 22 TEMP 0 ) 127 | END 128 | 129 | END 130 | C23_getI1 [1] 131 | BEGIN 132 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 24 RETURN TEMP 100 END 133 | END 134 | C23_setI1 [2] 135 | BEGIN 136 | RETURN TIMES TEMP 1 2 137 | END 138 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test21.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT CALL 3 | BEGIN 4 | MOVE TEMP 26 5 | BEGIN 6 | MOVE TEMP 29 HALLOCATE 8 7 | HSTORE TEMP 29 0 A24_m1 8 | HSTORE TEMP 29 4 A24_m2 9 | MOVE TEMP 30 HALLOCATE 20 10 | HSTORE TEMP 30 4 0 11 | HSTORE TEMP 30 8 0 12 | HSTORE TEMP 30 12 0 13 | HSTORE TEMP 30 16 0 14 | HSTORE TEMP 30 0 TEMP 29 15 | RETURN TEMP 30 16 | END 17 | 18 | HLOAD TEMP 27 TEMP 26 0 19 | HLOAD TEMP 28 TEMP 27 0 20 | RETURN TEMP 28 21 | END 22 | (TEMP 26 0 ) 23 | 24 | END 25 | A24_m1 [ 2 ] 26 | BEGIN 27 | CJUMP TEMP 1L0 28 | MOVE TEMP 21 29 | 5 30 | JUMP L1 31 | L0 MOVE TEMP 21 32 | 10 33 | 34 | L1 35 | NOOP 36 | 37 | HSTORE TEMP 0 4 38 | 39 | BEGIN 40 | MOVE TEMP 32 TEMP 21 41 | MOVE TEMP 33 HALLOCATE PLUS 4 TIMES 4 TEMP 32 42 | HSTORE TEMP 33 0 TEMP 32 43 | RETURN TEMP 33 44 | END 45 | 46 | MOVE TEMP 21 47 | 0 48 | MOVE TEMP 20 49 | 50 | BEGIN 51 | HLOAD TEMP 34 52 | BEGIN 53 | HLOAD TEMP 35 TEMP 0 4 54 | RETURN TEMP 35 55 | END 56 | 0 57 | RETURN TEMP 34 58 | END 59 | 60 | L2 61 | CJUMP LT TEMP 21 TEMP 20 62 | L3 MOVE TEMP 36 PLUS 63 | BEGIN 64 | HLOAD TEMP 37 TEMP 0 4 65 | RETURN TEMP 37 66 | END 67 | TIMES 4 TEMP 21 68 | HSTORE TEMP 36 4 PLUS TEMP 21 1 69 | 70 | MOVE TEMP 21 71 | PLUS TEMP 21 1 72 | 73 | 74 | JUMP L2 75 | L3 76 | NOOP 77 | 78 | HSTORE TEMP 0 12 79 | 80 | BEGIN 81 | MOVE TEMP 39 HALLOCATE 12 82 | HSTORE TEMP 39 0 A24_m1 83 | HSTORE TEMP 39 4 B24_m2 84 | MOVE TEMP 40 HALLOCATE 20 85 | HSTORE TEMP 40 4 0 86 | HSTORE TEMP 40 8 0 87 | HSTORE TEMP 40 12 0 88 | HSTORE TEMP 40 16 0 89 | HSTORE TEMP 40 0 TEMP 39 90 | RETURN TEMP 40 91 | END 92 | 93 | HSTORE TEMP 0 8 94 | 95 | BEGIN 96 | HLOAD TEMP 42 TEMP 0 12 97 | RETURN TEMP 42 98 | END 99 | 100 | 101 | RETURN CALL 102 | BEGIN 103 | MOVE TEMP 43 104 | BEGIN 105 | HLOAD TEMP 46 TEMP 0 8 106 | RETURN TEMP 46 107 | END 108 | 109 | HLOAD TEMP 44 TEMP 43 0 110 | HLOAD TEMP 45 TEMP 44 4 111 | RETURN TEMP 45 112 | END 113 | (TEMP 43 114 | BEGIN 115 | HLOAD TEMP 47 TEMP 0 4 116 | RETURN TEMP 47 117 | END 118 | ) 119 | 120 | END 121 | 122 | A24_m2 [ 2 ] 123 | BEGIN 124 | 125 | RETURN 1 126 | END 127 | 128 | 129 | B24_m2 [ 2 ] 130 | BEGIN 131 | MOVE TEMP 24 132 | 0 133 | MOVE TEMP 25 134 | 0 135 | MOVE TEMP 23 136 | 137 | BEGIN 138 | HLOAD TEMP 48 TEMP 1 0 139 | RETURN TEMP 48 140 | END 141 | 142 | L4 143 | CJUMP LT TEMP 24 TEMP 23 144 | L5 MOVE TEMP 22 145 | 146 | BEGIN 147 | MOVE TEMP 49 PLUS TEMP 1 TIMES 4 TEMP 24 148 | HLOAD TEMP 50 TEMP 49 4 149 | RETURN TEMP 50 150 | END 151 | 152 | MOVE TEMP 25 153 | PLUS TEMP 25 TEMP 22 154 | 155 | MOVE TEMP 24 156 | PLUS TEMP 24 1 157 | 158 | 159 | JUMP L4 160 | L5 161 | NOOP 162 | 163 | 164 | RETURN TEMP 25 165 | END 166 | 167 | 168 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test22.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 8 5 | HSTORE TEMP 23 0 B25_add 6 | HSTORE TEMP 23 4 B25_init 7 | MOVE TEMP 24 HALLOCATE 16 8 | HSTORE TEMP 24 0 TEMP 23 9 | HSTORE TEMP 24 4 0 10 | HSTORE TEMP 24 8 0 11 | HSTORE TEMP 24 12 0 12 | RETURN TEMP 24 13 | END 14 | 15 | HLOAD TEMP 22 TEMP 21 0 16 | HLOAD TEMP 22 TEMP 22 0 17 | RETURN CALL TEMP 22(TEMP 21 BEGIN 18 | MOVE TEMP 23 HALLOCATE 8 19 | HSTORE TEMP 23 0 C25_add 20 | HSTORE TEMP 23 4 C25_init 21 | MOVE TEMP 24 HALLOCATE 16 22 | HSTORE TEMP 24 0 TEMP 23 23 | HSTORE TEMP 24 4 0 24 | HSTORE TEMP 24 8 0 25 | HSTORE TEMP 24 12 0 26 | RETURN TEMP 24 27 | END 28 | 1 ) 29 | END 30 | 31 | END 32 | A25_add [3] 33 | BEGIN 34 | RETURN BEGIN 35 | MOVE TEMP 20 TEMP 0 36 | HLOAD TEMP 21 TEMP 20 0 37 | HLOAD TEMP 21 TEMP 21 4 38 | RETURN CALL TEMP 21(TEMP 20 TEMP 2 ) 39 | END 40 | 41 | END 42 | A25_init [2] 43 | BEGIN 44 | CJUMP LT TEMP 1 50 L1 45 | HSTORE TEMP 0 8 TEMP 1 46 | JUMP L2 47 | L1 NOOP 48 | HSTORE TEMP 0 8 TIMES 2 TEMP 1 49 | L2 NOOP 50 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 51 | END 52 | B25_add [3] 53 | BEGIN 54 | PRINT BEGIN 55 | MOVE TEMP 20 TEMP 0 56 | HLOAD TEMP 21 TEMP 20 0 57 | HLOAD TEMP 21 TEMP 21 4 58 | RETURN CALL TEMP 21(TEMP 20 TEMP 2 ) 59 | END 60 | 61 | RETURN BEGIN 62 | MOVE TEMP 22 TEMP 1 63 | HLOAD TEMP 23 TEMP 22 0 64 | HLOAD TEMP 23 TEMP 23 0 65 | RETURN CALL TEMP 23(TEMP 22 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END BEGIN HLOAD TEMP 100 TEMP 0 12 RETURN TEMP 100 END ) 66 | END 67 | 68 | END 69 | B25_init [2] 70 | BEGIN 71 | HSTORE TEMP 0 4 BEGIN 72 | MOVE TEMP 20 HALLOCATE 8 73 | HSTORE TEMP 20 0 B25_add 74 | HSTORE TEMP 20 4 B25_init 75 | MOVE TEMP 21 HALLOCATE 16 76 | HSTORE TEMP 21 0 TEMP 20 77 | HSTORE TEMP 21 4 0 78 | HSTORE TEMP 21 8 0 79 | HSTORE TEMP 21 12 0 80 | RETURN TEMP 21 81 | END 82 | 83 | HSTORE TEMP 0 8 TIMES 2 TEMP 1 84 | HSTORE TEMP 0 12 PLUS 10 TEMP 1 85 | RETURN PLUS BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END BEGIN HLOAD TEMP 100 TEMP 0 12 RETURN TEMP 100 END 86 | END 87 | C25_add [3] 88 | BEGIN 89 | PRINT BEGIN 90 | MOVE TEMP 20 TEMP 0 91 | HLOAD TEMP 21 TEMP 20 0 92 | HLOAD TEMP 21 TEMP 21 4 93 | RETURN CALL TEMP 21(TEMP 20 TEMP 2 ) 94 | END 95 | 96 | RETURN BEGIN 97 | MOVE TEMP 22 BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 98 | HLOAD TEMP 23 TEMP 22 0 99 | HLOAD TEMP 23 TEMP 23 0 100 | RETURN CALL TEMP 23(TEMP 22 TEMP 1 BEGIN HLOAD TEMP 100 TEMP 0 12 RETURN TEMP 100 END ) 101 | END 102 | 103 | END 104 | C25_init [2] 105 | BEGIN 106 | HSTORE TEMP 0 4 BEGIN 107 | MOVE TEMP 20 HALLOCATE 8 108 | HSTORE TEMP 20 0 A25_add 109 | HSTORE TEMP 20 4 A25_init 110 | MOVE TEMP 21 HALLOCATE 12 111 | HSTORE TEMP 21 0 TEMP 20 112 | HSTORE TEMP 21 4 0 113 | HSTORE TEMP 21 8 0 114 | RETURN TEMP 21 115 | END 116 | 117 | HSTORE TEMP 0 8 MINUS TEMP 1 5 118 | HSTORE TEMP 0 12 TIMES BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END TEMP 1 119 | RETURN MINUS BEGIN HLOAD TEMP 100 TEMP 0 12 RETURN TEMP 100 END BEGIN HLOAD TEMP 100 TEMP 0 8 RETURN TEMP 100 END 120 | END 121 | -------------------------------------------------------------------------------- /testcases/piglet/priv.test23.pg: -------------------------------------------------------------------------------- 1 | MAIN 2 | PRINT BEGIN 3 | MOVE TEMP 21 BEGIN 4 | MOVE TEMP 23 HALLOCATE 12 5 | HSTORE TEMP 23 0 Test_start 6 | HSTORE TEMP 23 4 Test_first 7 | HSTORE TEMP 23 8 Test_second 8 | MOVE TEMP 24 HALLOCATE 8 9 | HSTORE TEMP 24 0 TEMP 23 10 | HSTORE TEMP 24 4 0 11 | RETURN TEMP 24 12 | END 13 | 14 | HLOAD TEMP 22 TEMP 21 0 15 | HLOAD TEMP 22 TEMP 22 0 16 | RETURN CALL TEMP 22(TEMP 21 ) 17 | END 18 | 19 | END 20 | Test_start [1] 21 | BEGIN 22 | MOVE TEMP 20 BEGIN 23 | MOVE TEMP 21 HALLOCATE 12 24 | HSTORE TEMP 21 0 Test_start 25 | HSTORE TEMP 21 4 Test_first 26 | HSTORE TEMP 21 8 Test_second 27 | MOVE TEMP 22 HALLOCATE 8 28 | HSTORE TEMP 22 0 TEMP 21 29 | HSTORE TEMP 22 4 0 30 | RETURN TEMP 22 31 | END 32 | 33 | HSTORE TEMP 0 4 10 34 | HSTORE TEMP 0 4 BEGIN 35 | MOVE TEMP 21 TEMP 20 36 | HLOAD TEMP 22 TEMP 21 0 37 | HLOAD TEMP 22 TEMP 22 4 38 | RETURN CALL TEMP 22(TEMP 21 BEGIN 39 | MOVE TEMP 23 BEGIN 40 | MOVE TEMP 25 HALLOCATE 12 41 | HSTORE TEMP 25 0 Test_start 42 | HSTORE TEMP 25 4 Test_first 43 | HSTORE TEMP 25 8 Test_second 44 | MOVE TEMP 26 HALLOCATE 8 45 | HSTORE TEMP 26 0 TEMP 25 46 | HSTORE TEMP 26 4 0 47 | RETURN TEMP 26 48 | END 49 | 50 | HLOAD TEMP 24 TEMP 23 0 51 | HLOAD TEMP 24 TEMP 24 8 52 | RETURN CALL TEMP 24(TEMP 23 ) 53 | END 54 | ) 55 | END 56 | 57 | RETURN BEGIN HLOAD TEMP 100 TEMP 0 4 RETURN TEMP 100 END 58 | END 59 | Test_first [2] 60 | BEGIN 61 | RETURN TEMP 1 62 | END 63 | Test_second [1] 64 | BEGIN 65 | RETURN 30 66 | END 67 | -------------------------------------------------------------------------------- /testcases/spiglet/Factorial.spg: -------------------------------------------------------------------------------- 1 | MAIN 2 | MOVE TEMP 24 HALLOCATE 4 3 | MOVE TEMP 25 HALLOCATE 4 4 | MOVE TEMP 30 Fac_ComputeFac 5 | HSTORE TEMP 24 0 TEMP 30 6 | HSTORE TEMP 25 0 TEMP 24 7 | MOVE TEMP 23 TEMP 25 8 | HLOAD TEMP 21 TEMP 23 0 9 | HLOAD TEMP 22 TEMP 21 0 10 | MOVE TEMP 31 10 11 | MOVE TEMP 32 CALL TEMP 22( TEMP 23 TEMP 31 ) 12 | PRINT TEMP 32 13 | END 14 | Fac_ComputeFac [2] 15 | BEGIN 16 | MOVE TEMP 33 1 17 | MOVE TEMP 34 LT TEMP 1 TEMP 33 18 | CJUMP TEMP 34 L2 19 | MOVE TEMP 20 1 20 | JUMP L3 21 | L2 NOOP 22 | MOVE TEMP 29 TEMP 0 23 | HLOAD TEMP 27 TEMP 29 0 24 | HLOAD TEMP 28 TEMP 27 0 25 | MOVE TEMP 35 1 26 | MOVE TEMP 36 MINUS TEMP 1 TEMP 35 27 | MOVE TEMP 37 CALL TEMP 28( TEMP 29 TEMP 36 ) 28 | MOVE TEMP 38 TIMES TEMP 1 TEMP 37 29 | MOVE TEMP 20 TEMP 38 30 | L3 NOOP 31 | RETURN 32 | TEMP 20 33 | END 34 | 35 | -------------------------------------------------------------------------------- /testcases/spiglet/LinearSearch.spg: -------------------------------------------------------------------------------- 1 | MAIN 2 | MOVE TEMP 36 HALLOCATE 16 3 | MOVE TEMP 37 HALLOCATE 12 4 | MOVE TEMP 87 LS_Init 5 | HSTORE TEMP 36 12 TEMP 87 6 | MOVE TEMP 88 LS_Search 7 | HSTORE TEMP 36 8 TEMP 88 8 | MOVE TEMP 89 LS_Print 9 | HSTORE TEMP 36 4 TEMP 89 10 | MOVE TEMP 90 LS_Start 11 | HSTORE TEMP 36 0 TEMP 90 12 | MOVE TEMP 38 4 13 | L0 NOOP 14 | MOVE TEMP 91 12 15 | MOVE TEMP 92 LT TEMP 38 TEMP 91 16 | CJUMP TEMP 92 L1 17 | MOVE TEMP 93 PLUS TEMP 37 TEMP 38 18 | MOVE TEMP 94 0 19 | HSTORE TEMP 93 0 TEMP 94 20 | MOVE TEMP 38 PLUS TEMP 38 4 21 | JUMP L0 22 | L1 NOOP 23 | HSTORE TEMP 37 0 TEMP 36 24 | MOVE TEMP 35 TEMP 37 25 | HLOAD TEMP 33 TEMP 35 0 26 | HLOAD TEMP 34 TEMP 33 0 27 | MOVE TEMP 95 10 28 | MOVE TEMP 96 CALL TEMP 34( TEMP 35 TEMP 95 ) 29 | PRINT TEMP 96 30 | END 31 | LS_Start [2] 32 | BEGIN 33 | MOVE TEMP 41 TEMP 0 34 | HLOAD TEMP 39 TEMP 41 0 35 | HLOAD TEMP 40 TEMP 39 12 36 | MOVE TEMP 97 CALL TEMP 40( TEMP 41 TEMP 1 ) 37 | MOVE TEMP 20 TEMP 97 38 | MOVE TEMP 44 TEMP 0 39 | HLOAD TEMP 42 TEMP 44 0 40 | HLOAD TEMP 43 TEMP 42 4 41 | MOVE TEMP 98 CALL TEMP 43( TEMP 44 ) 42 | MOVE TEMP 21 TEMP 98 43 | MOVE TEMP 99 9999 44 | PRINT TEMP 99 45 | MOVE TEMP 47 TEMP 0 46 | HLOAD TEMP 45 TEMP 47 0 47 | HLOAD TEMP 46 TEMP 45 8 48 | MOVE TEMP 100 8 49 | MOVE TEMP 101 CALL TEMP 46( TEMP 47 TEMP 100 ) 50 | PRINT TEMP 101 51 | MOVE TEMP 50 TEMP 0 52 | HLOAD TEMP 48 TEMP 50 0 53 | HLOAD TEMP 49 TEMP 48 8 54 | MOVE TEMP 102 12 55 | MOVE TEMP 103 CALL TEMP 49( TEMP 50 TEMP 102 ) 56 | PRINT TEMP 103 57 | MOVE TEMP 53 TEMP 0 58 | HLOAD TEMP 51 TEMP 53 0 59 | HLOAD TEMP 52 TEMP 51 8 60 | MOVE TEMP 104 17 61 | MOVE TEMP 105 CALL TEMP 52( TEMP 53 TEMP 104 ) 62 | PRINT TEMP 105 63 | MOVE TEMP 56 TEMP 0 64 | HLOAD TEMP 54 TEMP 56 0 65 | HLOAD TEMP 55 TEMP 54 8 66 | MOVE TEMP 106 50 67 | MOVE TEMP 107 CALL TEMP 55( TEMP 56 TEMP 106 ) 68 | PRINT TEMP 107 69 | MOVE TEMP 108 55 70 | RETURN 71 | TEMP 108 72 | END 73 | LS_Print [1] 74 | BEGIN 75 | MOVE TEMP 22 1 76 | L2 NOOP 77 | HLOAD TEMP 58 TEMP 0 8 78 | MOVE TEMP 109 LT TEMP 22 TEMP 58 79 | CJUMP TEMP 109 L3 80 | HLOAD TEMP 63 TEMP 0 4 81 | MOVE TEMP 60 TIMES TEMP 22 4 82 | HLOAD TEMP 63 TEMP 0 4 83 | HLOAD TEMP 61 TEMP 63 0 84 | MOVE TEMP 110 1 85 | MOVE TEMP 111 LT TEMP 60 TEMP 61 86 | MOVE TEMP 112 MINUS TEMP 110 TEMP 111 87 | CJUMP TEMP 112 L4 88 | ERROR 89 | L4 NOOP 90 | MOVE TEMP 113 4 91 | MOVE TEMP 114 TEMP 113 92 | MOVE TEMP 115 PLUS TEMP 60 TEMP 114 93 | MOVE TEMP 116 TEMP 115 94 | MOVE TEMP 117 PLUS TEMP 63 TEMP 116 95 | HLOAD TEMP 62 TEMP 117 0 96 | PRINT TEMP 62 97 | MOVE TEMP 22 PLUS TEMP 22 1 98 | JUMP L2 99 | L3 NOOP 100 | MOVE TEMP 118 0 101 | RETURN 102 | TEMP 118 103 | END 104 | LS_Search [2] 105 | BEGIN 106 | MOVE TEMP 23 1 107 | MOVE TEMP 24 0 108 | MOVE TEMP 25 0 109 | L5 NOOP 110 | HLOAD TEMP 66 TEMP 0 8 111 | MOVE TEMP 119 LT TEMP 23 TEMP 66 112 | CJUMP TEMP 119 L6 113 | HLOAD TEMP 71 TEMP 0 4 114 | MOVE TEMP 68 TIMES TEMP 23 4 115 | HLOAD TEMP 71 TEMP 0 4 116 | HLOAD TEMP 69 TEMP 71 0 117 | MOVE TEMP 120 1 118 | MOVE TEMP 121 LT TEMP 68 TEMP 69 119 | MOVE TEMP 122 MINUS TEMP 120 TEMP 121 120 | CJUMP TEMP 122 L7 121 | ERROR 122 | L7 NOOP 123 | MOVE TEMP 123 4 124 | MOVE TEMP 124 TEMP 123 125 | MOVE TEMP 125 PLUS TEMP 68 TEMP 124 126 | MOVE TEMP 126 TEMP 125 127 | MOVE TEMP 127 PLUS TEMP 71 TEMP 126 128 | HLOAD TEMP 70 TEMP 127 0 129 | MOVE TEMP 26 TEMP 70 130 | MOVE TEMP 27 PLUS TEMP 1 1 131 | MOVE TEMP 128 LT TEMP 26 TEMP 1 132 | CJUMP TEMP 128 L8 133 | MOVE TEMP 28 0 134 | JUMP L9 135 | L8 NOOP 136 | MOVE TEMP 129 1 137 | MOVE TEMP 130 LT TEMP 26 TEMP 27 138 | MOVE TEMP 131 MINUS TEMP 129 TEMP 130 139 | CJUMP TEMP 131 L10 140 | MOVE TEMP 28 0 141 | JUMP L11 142 | L10 NOOP 143 | MOVE TEMP 24 1 144 | MOVE TEMP 25 1 145 | HLOAD TEMP 73 TEMP 0 8 146 | MOVE TEMP 23 TEMP 73 147 | L11 NOOP 148 | L9 NOOP 149 | MOVE TEMP 23 PLUS TEMP 23 1 150 | JUMP L5 151 | L6 NOOP 152 | RETURN 153 | TEMP 25 154 | END 155 | LS_Init [2] 156 | BEGIN 157 | HSTORE TEMP 0 8 TEMP 1 158 | MOVE TEMP 132 PLUS TEMP 1 1 159 | MOVE TEMP 133 4 160 | MOVE TEMP 134 TIMES TEMP 132 TEMP 133 161 | MOVE TEMP 75 HALLOCATE TEMP 134 162 | MOVE TEMP 76 4 163 | L12 NOOP 164 | MOVE TEMP 135 1 165 | MOVE TEMP 136 PLUS TEMP 1 TEMP 135 166 | MOVE TEMP 137 4 167 | MOVE TEMP 138 TEMP 137 168 | MOVE TEMP 139 TIMES TEMP 136 TEMP 138 169 | MOVE TEMP 140 LT TEMP 76 TEMP 139 170 | CJUMP TEMP 140 L13 171 | MOVE TEMP 141 PLUS TEMP 75 TEMP 76 172 | MOVE TEMP 142 0 173 | HSTORE TEMP 141 0 TEMP 142 174 | MOVE TEMP 76 PLUS TEMP 76 4 175 | JUMP L12 176 | L13 NOOP 177 | MOVE TEMP 143 4 178 | MOVE TEMP 144 TIMES TEMP 1 TEMP 143 179 | HSTORE TEMP 75 0 TEMP 144 180 | HSTORE TEMP 0 4 TEMP 75 181 | MOVE TEMP 29 1 182 | HLOAD TEMP 77 TEMP 0 8 183 | MOVE TEMP 145 1 184 | MOVE TEMP 30 PLUS TEMP 77 TEMP 145 185 | L14 NOOP 186 | HLOAD TEMP 80 TEMP 0 8 187 | MOVE TEMP 146 LT TEMP 29 TEMP 80 188 | CJUMP TEMP 146 L15 189 | MOVE TEMP 147 2 190 | MOVE TEMP 31 TIMES TEMP 147 TEMP 29 191 | MOVE TEMP 32 MINUS TEMP 30 3 192 | MOVE TEMP 148 1 193 | MOVE TEMP 86 TIMES TEMP 148 4 194 | MOVE TEMP 149 PLUS TEMP 0 TEMP 86 195 | HLOAD TEMP 85 TEMP 149 0 196 | MOVE TEMP 83 TIMES TEMP 29 4 197 | MOVE TEMP 150 1 198 | MOVE TEMP 86 TIMES TEMP 150 4 199 | MOVE TEMP 151 PLUS TEMP 0 TEMP 86 200 | HLOAD TEMP 85 TEMP 151 0 201 | HLOAD TEMP 84 TEMP 85 0 202 | MOVE TEMP 152 1 203 | MOVE TEMP 153 LT TEMP 83 TEMP 84 204 | MOVE TEMP 154 MINUS TEMP 152 TEMP 153 205 | CJUMP TEMP 154 L16 206 | ERROR 207 | L16 NOOP 208 | MOVE TEMP 155 4 209 | MOVE TEMP 156 TEMP 155 210 | MOVE TEMP 157 PLUS TEMP 83 TEMP 156 211 | MOVE TEMP 158 TEMP 157 212 | MOVE TEMP 159 PLUS TEMP 85 TEMP 158 213 | MOVE TEMP 160 PLUS TEMP 31 TEMP 32 214 | HSTORE TEMP 159 0 TEMP 160 215 | MOVE TEMP 29 PLUS TEMP 29 1 216 | MOVE TEMP 30 MINUS TEMP 30 1 217 | JUMP L14 218 | L15 NOOP 219 | MOVE TEMP 161 0 220 | RETURN 221 | TEMP 161 222 | END 223 | 224 | -------------------------------------------------------------------------------- /testcases/spiglet/MoreThan4.spg: -------------------------------------------------------------------------------- 1 | MAIN 2 | MOVE TEMP 24 HALLOCATE 8 3 | MOVE TEMP 25 HALLOCATE 4 4 | MOVE TEMP 30 MT4_Change 5 | HSTORE TEMP 24 4 TEMP 30 6 | MOVE TEMP 31 MT4_Start 7 | HSTORE TEMP 24 0 TEMP 31 8 | HSTORE TEMP 25 0 TEMP 24 9 | MOVE TEMP 23 TEMP 25 10 | HLOAD TEMP 21 TEMP 23 0 11 | HLOAD TEMP 22 TEMP 21 0 12 | MOVE TEMP 32 1 13 | MOVE TEMP 33 2 14 | MOVE TEMP 34 3 15 | MOVE TEMP 35 4 16 | MOVE TEMP 36 5 17 | MOVE TEMP 37 6 18 | MOVE TEMP 38 CALL TEMP 22( TEMP 23 TEMP 32 TEMP 33 TEMP 34 TEMP 35 TEMP 36 TEMP 37 ) 19 | PRINT TEMP 38 20 | END 21 | MT4_Start [7] 22 | BEGIN 23 | PRINT TEMP 1 24 | PRINT TEMP 2 25 | PRINT TEMP 3 26 | PRINT TEMP 4 27 | PRINT TEMP 5 28 | PRINT TEMP 6 29 | MOVE TEMP 29 TEMP 0 30 | HLOAD TEMP 27 TEMP 29 0 31 | HLOAD TEMP 28 TEMP 27 4 32 | MOVE TEMP 39 CALL TEMP 28( TEMP 29 TEMP 6 TEMP 5 TEMP 4 TEMP 3 TEMP 2 TEMP 1 ) 33 | MOVE TEMP 20 TEMP 39 34 | RETURN 35 | TEMP 20 36 | END 37 | MT4_Change [7] 38 | BEGIN 39 | PRINT TEMP 1 40 | PRINT TEMP 2 41 | PRINT TEMP 3 42 | PRINT TEMP 4 43 | PRINT TEMP 5 44 | PRINT TEMP 6 45 | MOVE TEMP 40 0 46 | RETURN 47 | TEMP 40 48 | END 49 | 50 | --------------------------------------------------------------------------------