diff --git a/.classpath b/.classpath index 300190ff..4630a310 100644 --- a/.classpath +++ b/.classpath @@ -1,20 +1,5 @@ - - - - - - - - - - - - - - - @@ -26,11 +11,5 @@ - - - - - - diff --git a/pom.xml b/pom.xml index 2fa0cb42..964717ef 100644 --- a/pom.xml +++ b/pom.xml @@ -46,44 +46,44 @@ src/main/java src/test/java - - - maven-compiler-plugin - 3.7.0 - - 1.8 - 1.8 - - - - - org.rascalmpl - rascal-maven-plugin - 0.3.4 - - ${project.build.outputDirectory} - true - true - - ${project.basedir}/src/main/rascal - - - ${project.basedir}/src/main/rascal/lang/jimple/toolkit/GraphUtil.rsc - ${project.basedir}/src/main/rascal/lang/jimple/toolkit/CallGraph.rsc - - - - - it-compile - compile - - compile - - - - - - + + + + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + org.rascalmpl + rascal-maven-plugin + 0.3.4 + + ${project.build.outputDirectory} + true + true + + ${project.basedir}/src/main/rascal + + + ${project.basedir}/src/main/rascal/lang/jimple/toolkit/GraphUtil.rsc + ${project.basedir}/src/main/rascal/lang/jimple/toolkit/CallGraph.rsc + + + + + it-compile + compile + + compile + + + + + + - diff --git a/src/main/java/lang/jimple/internal/BinExpressionFactory.java b/src/main/java/lang/jimple/internal/BinExpressionFactory.java index 0f4fa448..5f540ba2 100644 --- a/src/main/java/lang/jimple/internal/BinExpressionFactory.java +++ b/src/main/java/lang/jimple/internal/BinExpressionFactory.java @@ -4,7 +4,7 @@ import lang.jimple.internal.generated.Immediate; public interface BinExpressionFactory { - + public Expression createExpression(Immediate lhs, Immediate rhs); - + } diff --git a/src/main/java/lang/jimple/internal/BranchInstructionFlow.java b/src/main/java/lang/jimple/internal/BranchInstructionFlow.java index 9e07e24c..71a553c2 100644 --- a/src/main/java/lang/jimple/internal/BranchInstructionFlow.java +++ b/src/main/java/lang/jimple/internal/BranchInstructionFlow.java @@ -20,13 +20,11 @@ public class BranchInstructionFlow implements InstructionFlow { private BranchState status; private Statement gotoMergeStmt; - + enum BranchState { - LEFT, - RIGHT, - ReadyToMerge + LEFT, RIGHT, ReadyToMerge } - + public BranchInstructionFlow(Expression condition, String target) { this.condition = condition; this.targetStatement = target; @@ -35,34 +33,32 @@ public BranchInstructionFlow(Expression condition, String target) { status = BranchState.LEFT; } - @Override public Collection merge() { List res = new ArrayList<>(); - + res.add(Statement.ifStmt(condition, targetStatement)); res.addAll(left.instructions); - if(gotoMergeStmt != null) { + if (gotoMergeStmt != null) { res.add(gotoMergeStmt); } res.add(Statement.label(targetStatement)); res.addAll(right.instructions); - if(mergeStatement != null) { + if (mergeStatement != null) { res.add(Statement.label(mergeStatement)); } - - return res; + + return res; } @Override public boolean matchMergePoint(String label) { - if(status.equals(BranchState.LEFT)) { + if (status.equals(BranchState.LEFT)) { return this.targetStatement.equals(label); - } - else if(status.equals(BranchState.RIGHT)) { + } else if (status.equals(BranchState.RIGHT)) { return this.mergeStatement.equals(label); } return false; @@ -71,31 +67,32 @@ else if(status.equals(BranchState.RIGHT)) { @Override public List environments() { List res = new ArrayList<>(); - switch(status) { - case LEFT: res.add(left); break; - case RIGHT: res.add(right); break; - case ReadyToMerge: - if(mergeStatement != null) { - res.add(left); - res.add(right); - } - else { - res.add(left); - } + switch (status) { + case LEFT: + res.add(left); + break; + case RIGHT: + res.add(right); + break; + case ReadyToMerge: + if (mergeStatement != null) { + res.add(left); + res.add(right); + } else { + res.add(left); + } } return res; } @Override public void notifyGotoStmt(Statement stmt, String label) { - if(status.equals(BranchState.LEFT)) { + if (status.equals(BranchState.LEFT)) { mergeStatement = label; gotoMergeStmt = stmt; - } - else if(status.equals(BranchState.RIGHT)) { + } else if (status.equals(BranchState.RIGHT)) { right.instructions.add(stmt); - } - else if(status.equals(BranchState.ReadyToMerge)) { + } else if (status.equals(BranchState.ReadyToMerge)) { left.instructions.add(stmt); right.instructions.add(stmt); } @@ -103,21 +100,22 @@ else if(status.equals(BranchState.ReadyToMerge)) { @Override public void nextBranch() { - switch(status) { - case LEFT: - if(mergeStatement != null) { + switch (status) { + case LEFT: + if (mergeStatement != null) { status = BranchState.RIGHT; + } else { + left.instructions.add(Statement.label(targetStatement)); + status = BranchState.ReadyToMerge; } - else { - left.instructions.add(Statement.label(targetStatement)); - status = BranchState.ReadyToMerge; - } - break; - case RIGHT: status = BranchState.ReadyToMerge; break; - case ReadyToMerge: // + break; + case RIGHT: + status = BranchState.ReadyToMerge; + break; + case ReadyToMerge: // } } - + @Override public boolean isBranch() { return true; diff --git a/src/main/java/lang/jimple/internal/Decompiler.java b/src/main/java/lang/jimple/internal/Decompiler.java index 60ac3b81..a2937070 100644 --- a/src/main/java/lang/jimple/internal/Decompiler.java +++ b/src/main/java/lang/jimple/internal/Decompiler.java @@ -21,12 +21,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.Stack; @@ -66,7 +64,6 @@ import lang.jimple.internal.generated.Type; import lang.jimple.internal.generated.Value; import lang.jimple.internal.generated.Variable; -import lang.jimple.util.Pair; /** * Decompiler used to convert Java byte code into Jimple representation. This is @@ -210,11 +207,11 @@ private void visitMethod(MethodNode mn) { mn.instructions.accept(insVisitor); // TODO: we commented this line because we want to - // solve this issue using a Jimple transformation. - // we will keep the commented implementation here just while - // we review the new strategy. + // solve this issue using a Jimple transformation. + // we will keep the commented implementation here just while + // we review the new strategy. // - // insVisitor.clearUnusedLabelInstructions(); + // insVisitor.clearUnusedLabelInstructions(); stmts = insVisitor.instructions(); @@ -279,12 +276,10 @@ private List visitTryCatchBlocks(List nodes) { } + class InstructionSetVisitor extends org.objectweb.asm.MethodVisitor { + Stack stack; - class InstructionSetVisitor extends org.objectweb.asm.MethodVisitor { - - Stack stack; - List auxiliarlyLocalVariables; HashMap localVariables; int locals; @@ -298,14 +293,15 @@ class InstructionSetVisitor extends org.objectweb.asm.MethodVisitor { HashMap catchClauses = new HashMap<>(); - public InstructionSetVisitor(int version, HashMap localVariables, List catchClauses) { + public InstructionSetVisitor(int version, HashMap localVariables, + List catchClauses) { super(version); this.localVariables = localVariables; auxiliarlyLocalVariables = new ArrayList<>(); - locals = 1; - + locals = 1; + catchClauses.forEach(c -> this.catchClauses.put(c.with, c)); - + stack = new Stack<>(); stack.push(new SingleInstructionFlow()); } @@ -317,9 +313,9 @@ public List instructions() { private void notifyGotoStmt(Statement stmt, String label) { stack.peek().notifyGotoStmt(stmt, label); } - + private void notifyReturn() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.clear(); } } @@ -327,37 +323,35 @@ private void notifyReturn() { private void nextBranch() { stack.peek().nextBranch(); } - + private boolean isBranch() { return stack.peek().isBranch(); } - + private boolean readyToMerge(String label) { return stack.peek().readyToMerge(label); } - + @Override public void visitLabel(Label label) { visitedLabels.add(label.toString()); if (catchClauses.containsKey(label.toString())) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { CatchClause c = catchClauses.get(label.toString()); env.operands.push(new Operand(c.exception, Immediate.caughtException())); referencedLabels.add(label.toString()); } } - if(isBranch() && stack.peek().matchMergePoint(label.toString())) { + if (isBranch() && stack.peek().matchMergePoint(label.toString())) { nextBranch(); - } - else if(readyToMerge(label.toString()) && stack.size() > 1) { + } else if (readyToMerge(label.toString()) && stack.size() > 1) { List stmts = new ArrayList<>(stack.pop().merge()); stack.peek().environments().get(0).instructions.addAll(stmts); stack.peek().environments().get(0).instructions.add(Statement.label(label.toString())); referencedLabels.add(label.toString()); - } - else { - for(Environment env: stack.peek().environments()) { + } else { + for (Environment env : stack.peek().environments()) { env.instructions.add(Statement.label(label.toString())); } } @@ -413,7 +407,7 @@ public void visitIincInsn(int idx, int increment) { Immediate rhs = newIntValueImmediate(increment); Expression expression = newPlusExpression(lhs, rhs); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.instructions.add(assignmentStmt(Variable.localVariable(var), expression)); } @@ -891,7 +885,7 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bsmh, List args = new ArrayList<>(); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { for (int i = 0; i < argTypes.size(); i++) { args.add(0, env.operands.pop().immediate); } @@ -901,7 +895,8 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bsmh, env.instructions.add(Statement.invokeStmt(exp)); } else { LocalVariableDeclaration local = createLocal(methodType); - env.instructions.add(assignmentStmt(Variable.localVariable(local.local), Expression.invokeExp(exp))); + env.instructions + .add(assignmentStmt(Variable.localVariable(local.local), Expression.invokeExp(exp))); env.operands.push(new Operand(local)); } } @@ -910,7 +905,7 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bsmh, @Override public void visitLdcInsn(Object value) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.push(new Operand(toJimpleTypedValue(value))); } @@ -919,7 +914,7 @@ public void visitLdcInsn(Object value) { @Override public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Immediate key = env.operands.pop().immediate; List caseStmts = new ArrayList<>(); @@ -945,7 +940,7 @@ public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) if (dflt != null) { caseStmts.add(CaseStmt.defaultOption(dflt.toString())); } - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Immediate key = env.operands.pop().immediate; env.instructions.add(Statement.tableSwitch(key, min, max, caseStmts)); } @@ -955,80 +950,80 @@ public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) @Override public void visitJumpInsn(int opcode, Label label) { if (opcode == Opcodes.GOTO) { - notifyGotoStmt(Statement.gotoStmt(label.toString()), label.toString()); // TODO: investigate this decision here. + notifyGotoStmt(Statement.gotoStmt(label.toString()), label.toString()); // TODO: investigate this + // decision here. } else if (opcode == Opcodes.JSR) { throw RuntimeExceptionFactory.illegalArgument(vf.string("unsupported instruction JSR" + opcode), null, null); } else { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Expression exp = null; Immediate first = env.operands.pop().immediate; Immediate second = Immediate.iValue(Value.intValue(0)); switch (opcode) { - case Opcodes.IFEQ: - exp = Expression.cmpeq(first, second); - break; - case Opcodes.IFNE: - exp = Expression.cmpne(first, second); - break; - case Opcodes.IFLT: - exp = Expression.cmplt(first, second); - break; - case Opcodes.IFLE: - exp = Expression.cmple(first, second); - break; - case Opcodes.IFGT: - exp = Expression.cmpgt(first, second); - break; - case Opcodes.IFGE: - exp = Expression.cmpge(first, second); - break; - case Opcodes.IF_ICMPEQ: - second = env.operands.pop().immediate; - exp = Expression.cmpeq(second, first); - break; - case Opcodes.IF_ICMPNE: - second = env.operands.pop().immediate; - exp = Expression.cmpne(second, first); - break; - case Opcodes.IF_ICMPLT: - second = env.operands.pop().immediate; - exp = Expression.cmplt(second, first); - break; - case Opcodes.IF_ICMPGE: - second = env.operands.pop().immediate; - exp = Expression.cmpge(second, first); - break; - case Opcodes.IF_ICMPGT: - second = env.operands.pop().immediate; - exp = Expression.cmpgt(second, first); - break; - case Opcodes.IF_ICMPLE: - second = env.operands.pop().immediate; - exp = Expression.cmple(second, first); - break; - case Opcodes.IF_ACMPEQ: - second = env.operands.pop().immediate; - exp = Expression.cmpeq(second, first); - break; - case Opcodes.IF_ACMPNE: - second = env.operands.pop().immediate; - exp = Expression.cmpne(second, first); - break; - case Opcodes.IFNULL: - exp = Expression.isNull(first); - break; - case Opcodes.IFNONNULL: - exp = Expression.isNotNull(first); - break; - default: - throw RuntimeExceptionFactory.illegalArgument(vf.string("invalid instruction " + opcode), null, - null); + case Opcodes.IFEQ: + exp = Expression.cmpeq(first, second); + break; + case Opcodes.IFNE: + exp = Expression.cmpne(first, second); + break; + case Opcodes.IFLT: + exp = Expression.cmplt(first, second); + break; + case Opcodes.IFLE: + exp = Expression.cmple(first, second); + break; + case Opcodes.IFGT: + exp = Expression.cmpgt(first, second); + break; + case Opcodes.IFGE: + exp = Expression.cmpge(first, second); + break; + case Opcodes.IF_ICMPEQ: + second = env.operands.pop().immediate; + exp = Expression.cmpeq(second, first); + break; + case Opcodes.IF_ICMPNE: + second = env.operands.pop().immediate; + exp = Expression.cmpne(second, first); + break; + case Opcodes.IF_ICMPLT: + second = env.operands.pop().immediate; + exp = Expression.cmplt(second, first); + break; + case Opcodes.IF_ICMPGE: + second = env.operands.pop().immediate; + exp = Expression.cmpge(second, first); + break; + case Opcodes.IF_ICMPGT: + second = env.operands.pop().immediate; + exp = Expression.cmpgt(second, first); + break; + case Opcodes.IF_ICMPLE: + second = env.operands.pop().immediate; + exp = Expression.cmple(second, first); + break; + case Opcodes.IF_ACMPEQ: + second = env.operands.pop().immediate; + exp = Expression.cmpeq(second, first); + break; + case Opcodes.IF_ACMPNE: + second = env.operands.pop().immediate; + exp = Expression.cmpne(second, first); + break; + case Opcodes.IFNULL: + exp = Expression.isNull(first); + break; + case Opcodes.IFNONNULL: + exp = Expression.isNotNull(first); + break; + default: + throw RuntimeExceptionFactory.illegalArgument(vf.string("invalid instruction " + opcode), null, + null); } - if(visitedLabels.contains(label.toString())) { + if (visitedLabels.contains(label.toString())) { env.instructions.add(Statement.ifStmt(exp, label.toString())); - } - else { + } else { stack.push(new BranchInstructionFlow(exp, label.toString())); } } @@ -1045,7 +1040,7 @@ private void invokeMethodIns(String owner, String name, String descriptor, boole InvokeExpressionFactory factory) { MethodSignature signature = methodSignature(owner.replace("/", "."), name, descriptor); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { List args = new ArrayList<>(); for (int i = 0; i < signature.formals.size(); i++) { @@ -1065,7 +1060,8 @@ private void invokeMethodIns(String owner, String name, String descriptor, boole env.instructions.add(Statement.invokeStmt(exp)); } else { LocalVariableDeclaration local = createLocal(signature.returnType); - env.instructions.add(assignmentStmt(Variable.localVariable(local.local), Expression.invokeExp(exp))); + env.instructions + .add(assignmentStmt(Variable.localVariable(local.local), Expression.invokeExp(exp))); env.operands.push(new Operand(local)); } } @@ -1096,7 +1092,7 @@ private LocalVariableDeclaration findLocalVariable(int idx) { */ private void loadIns(int var) { LocalVariableDeclaration local = findLocalVariable(var); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.push(new Operand(local)); } } @@ -1109,7 +1105,8 @@ private void storeIns(int var) { for (Environment env : stack.peek().environments()) { Immediate immediate = env.operands.pop().immediate; - env.instructions.add(assignmentStmt(Variable.localVariable(local.local), Expression.immediate(immediate))); + env.instructions + .add(assignmentStmt(Variable.localVariable(local.local), Expression.immediate(immediate))); } } @@ -1120,21 +1117,22 @@ private void storeIns(int var) { */ private void retIns(int var) { LocalVariableDeclaration local = findLocalVariable(var); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.instructions.add(Statement.retStmt(Immediate.local(local.local))); } } private void newInstanceIns(Type type) { LocalVariableDeclaration newLocal = createLocal(type); - for(Environment env: stack.peek().environments()) { - env.instructions.add(assignmentStmt(Variable.localVariable(newLocal.local), Expression.newInstance(type))); + for (Environment env : stack.peek().environments()) { + env.instructions + .add(assignmentStmt(Variable.localVariable(newLocal.local), Expression.newInstance(type))); env.operands.push(new Operand(newLocal)); } } private void aNewArrayIns(Type type) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand operand = env.operands.pop(); LocalVariableDeclaration newLocal = createLocal(Type.TArray(type)); c_iValue value = (Immediate.c_iValue) operand.immediate; @@ -1146,7 +1144,8 @@ private void aNewArrayIns(Type type) { List dims = new ArrayList<>(); dims.add(ArrayDescriptor.fixedSize(size)); - env.instructions.add(assignmentStmt(Variable.localVariable(newLocal.local), Expression.newArray(type, dims))); + env.instructions + .add(assignmentStmt(Variable.localVariable(newLocal.local), Expression.newArray(type, dims))); env.operands.push(new Operand(newLocal)); } } @@ -1155,7 +1154,7 @@ private void aNewArrayIns(Type type) { * Add a nop instruction */ private void nopIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.instructions.add(Statement.nop()); } } @@ -1164,7 +1163,7 @@ private void nopIns() { * Load a null value into the top of the operand stack. */ private void acconstNullIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.push(new Operand(Type.TNull(), Immediate.iValue(Value.nullValue()))); } } @@ -1173,7 +1172,7 @@ private void acconstNullIns() { * Load an int const into the top of the operand stack. */ private void loadIntConstIns(int value, String descriptor) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.push(new Operand(type(descriptor), Immediate.iValue(Value.intValue(value)))); } } @@ -1191,7 +1190,7 @@ private void loadRealConstIns(float value, String descriptor) { * Neg instruction (INEG, LNEG, FNEG, DNEG) */ private void negIns(Type type) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand operand = env.operands.pop(); LocalVariableDeclaration newLocal = createLocal(type); @@ -1208,7 +1207,7 @@ private void negIns(Type type) { * Instructions supporting binarya operations. */ private void binOperatorIns(Type type, BinExpressionFactory factory) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand rhs = env.operands.pop(); Operand lhs = env.operands.pop(); @@ -1223,7 +1222,7 @@ private void binOperatorIns(Type type, BinExpressionFactory factory) { } private void simpleCastIns(Type targetType) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand operand = env.operands.pop(); LocalVariableDeclaration newLocal = createLocal(targetType); env.instructions.add(assignmentStmt(Variable.localVariable(newLocal.local), @@ -1233,7 +1232,7 @@ private void simpleCastIns(Type targetType) { } private void instanceOfIns(Type type) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand operand = env.operands.pop(); LocalVariableDeclaration newLocal = createLocal(Type.TBoolean()); env.instructions.add(assignmentStmt(Variable.localVariable(newLocal.local), @@ -1243,7 +1242,7 @@ private void instanceOfIns(Type type) { } private void returnIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand operand = env.operands.pop(); env.instructions.add(Statement.returnStmt(operand.immediate)); // TODO: perhaps we should call an exit monitor here. @@ -1252,7 +1251,7 @@ private void returnIns() { } private void returnVoidIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.instructions.add(Statement.returnEmptyStmt()); // TODO: perhaps we should call an exit monitor here. notifyReturn(); @@ -1260,17 +1259,17 @@ private void returnVoidIns() { } private void arrayLengthIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand arrayRef = env.operands.pop(); LocalVariableDeclaration newLocal = createLocal("I"); - env.instructions.add( - assignmentStmt(Variable.localVariable(newLocal.local), Expression.lengthOf(arrayRef.immediate))); + env.instructions.add(assignmentStmt(Variable.localVariable(newLocal.local), + Expression.lengthOf(arrayRef.immediate))); env.operands.push(new Operand(newLocal)); } } private void throwIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand reference = env.operands.pop(); env.instructions.add(Statement.throwStmt(reference.immediate)); notifyReturn(); @@ -1279,14 +1278,14 @@ private void throwIns() { } private void monitorEnterIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand reference = env.operands.pop(); env.instructions.add(Statement.enterMonitor(reference.immediate)); } } private void monitorExitIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand reference = env.operands.pop(); env.instructions.add(Statement.exitMonitor(reference.immediate)); } @@ -1298,7 +1297,7 @@ private void monitorExitIns() { * the stack. */ private void arraySubscriptIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand idx = env.operands.pop(); Operand ref = env.operands.pop(); @@ -1326,7 +1325,7 @@ private void arraySubscriptIns() { * After popping value, idx, and array, no value is introduced into the stack. */ private void storeIntoArrayIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Immediate value = env.operands.pop().immediate; Immediate idx = env.operands.pop().immediate; Immediate arrayRef = env.operands.pop().immediate; @@ -1341,7 +1340,7 @@ private void storeIntoArrayIns() { * Removes an operand from the stack. */ private void popIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.pop(); } } @@ -1351,7 +1350,7 @@ private void popIns() { * the first operand is either a long or a double, it removes just one operand. */ private void pop2Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand value = env.operands.pop(); if (allCategory1(value.type)) { @@ -1364,7 +1363,7 @@ private void pop2Ins() { * Duplicate the top operand stack value */ private void dupIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand value = env.operands.pop(); env.operands.push(value); @@ -1376,7 +1375,7 @@ private void dupIns() { * Duplicate the top operand stack value and insert the copy two values down. */ private void dupX1Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 2; Operand value1 = env.operands.pop(); @@ -1393,7 +1392,7 @@ private void dupX1Ins() { * down. */ private void dupX2Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 2; Operand value1 = env.operands.pop(); @@ -1420,7 +1419,7 @@ private void dupX2Ins() { * it duplicates just the first value. */ private void dup2Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 2; Operand value1 = env.operands.pop(); @@ -1444,7 +1443,7 @@ private void dup2Ins() { * values down, depending on the type category of the values. */ private void dup2X1Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 3; Operand value1 = env.operands.pop(); @@ -1471,7 +1470,7 @@ private void dup2X1Ins() { * four values down */ private void dup2X2Ins() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 4; Operand value1 = env.operands.pop(); @@ -1510,7 +1509,7 @@ private void dup2X2Ins() { } private void swapIns() { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { assert env.operands.size() >= 2; Operand value1 = env.operands.pop(); @@ -1535,7 +1534,7 @@ private void getStaticIns(String owner, String field, String descriptor) { Type fieldType = type(descriptor); Expression fieldRef = Expression.fieldRef(owner.replace("/", "."), fieldType, field); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.instructions.add(Statement.assign(Variable.localVariable(newLocal.local), fieldRef)); env.operands.push(new Operand(newLocal)); @@ -1545,22 +1544,22 @@ private void getStaticIns(String owner, String field, String descriptor) { private void putStaticIns(String owner, String field, String descriptor) { FieldSignature signature = FieldSignature.fieldSignature(owner, type(descriptor), field); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand value = env.operands.pop(); - env.instructions.add(assignmentStmt(Variable.staticFieldRef(signature), Expression.immediate(value.immediate))); + env.instructions + .add(assignmentStmt(Variable.staticFieldRef(signature), Expression.immediate(value.immediate))); } } private void putFieldIns(String owner, String field, String descriptor) { FieldSignature signature = FieldSignature.fieldSignature(owner, type(descriptor), field); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Operand value = env.operands.pop(); Operand operand = env.operands.pop(); String reference = ((Immediate.c_local) operand.immediate).localName; - env.instructions.add( assignmentStmt(Variable.fieldRef(reference, signature), Expression.immediate(value.immediate))); } @@ -1581,13 +1580,12 @@ private void getFieldIns(String owner, String field, String descriptor) { Type fieldType = type(descriptor); - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { Immediate instance = env.operands.pop().immediate; - - Expression fieldRef = Expression.localFieldRef(((Immediate.c_local) instance).localName, owner, fieldType, - field); + Expression fieldRef = Expression.localFieldRef(((Immediate.c_local) instance).localName, owner, + fieldType, field); env.instructions.add(Statement.assign(Variable.localVariable(newLocal.local), fieldRef)); @@ -1625,7 +1623,7 @@ private boolean allCategory2(Type... types) { } private void pushConstantValue(Type type, Immediate immediate) { - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { env.operands.push(new Operand(type, immediate)); } } @@ -1679,9 +1677,10 @@ public void initFormalArgs(boolean staticMethod, Type classType, boolean emptyLo idx++; } } - for(Environment env: stack.peek().environments()) { + for (Environment env : stack.peek().environments()) { if (!staticMethod) { - env.instructions.add(Statement.identity(LOCAL_NAME_FOR_IMPLICIT_PARAMETER, IMPLICIT_PARAMETER_NAME, classType)); + env.instructions.add( + Statement.identity(LOCAL_NAME_FOR_IMPLICIT_PARAMETER, IMPLICIT_PARAMETER_NAME, classType)); } int idx = 0; for (Type t : formals) { diff --git a/src/main/java/lang/jimple/internal/Environment.java b/src/main/java/lang/jimple/internal/Environment.java index 6fbf221d..238d0328 100644 --- a/src/main/java/lang/jimple/internal/Environment.java +++ b/src/main/java/lang/jimple/internal/Environment.java @@ -7,11 +7,11 @@ import java.util.Stack; public class Environment { - Stack operands; - List instructions; + Stack operands; + List instructions; - public Environment() { - operands = new Stack<>(); - instructions = new ArrayList<>(); - } + public Environment() { + operands = new Stack<>(); + instructions = new ArrayList<>(); + } } diff --git a/src/main/java/lang/jimple/internal/InstructionFlow.java b/src/main/java/lang/jimple/internal/InstructionFlow.java index 2c9160f5..c1ce6891 100644 --- a/src/main/java/lang/jimple/internal/InstructionFlow.java +++ b/src/main/java/lang/jimple/internal/InstructionFlow.java @@ -7,10 +7,16 @@ public interface InstructionFlow { Collection merge(); + boolean matchMergePoint(String label); + List environments(); + void nextBranch(); + void notifyGotoStmt(Statement stmt, String label); + boolean isBranch(); + boolean readyToMerge(String label); } diff --git a/src/main/java/lang/jimple/internal/InvokeExpressionFactory.java b/src/main/java/lang/jimple/internal/InvokeExpressionFactory.java index ec6b1739..e766e7e2 100644 --- a/src/main/java/lang/jimple/internal/InvokeExpressionFactory.java +++ b/src/main/java/lang/jimple/internal/InvokeExpressionFactory.java @@ -7,7 +7,7 @@ import lang.jimple.internal.generated.MethodSignature; public interface InvokeExpressionFactory { - + public InvokeExp createInvokeExpression(String owner, MethodSignature signature, List args); } diff --git a/src/main/java/lang/jimple/internal/JimpleAbstractDataType.java b/src/main/java/lang/jimple/internal/JimpleAbstractDataType.java index 4088d9ec..73ba6f0a 100644 --- a/src/main/java/lang/jimple/internal/JimpleAbstractDataType.java +++ b/src/main/java/lang/jimple/internal/JimpleAbstractDataType.java @@ -7,20 +7,22 @@ import io.usethesource.vallang.type.TypeStore; public abstract class JimpleAbstractDataType { - + public static TypeStore typestore = new TypeStore(); public static TypeFactory tf = TypeFactory.getInstance(); - + public Type getVallangType() { return tf.abstractDataType(typestore, getBaseType()); } - + public Type getVallangConstructor() { return tf.constructor(typestore, getVallangType(), getConstructor()); } - + public abstract String getBaseType(); + public abstract String getConstructor(); - public abstract IConstructor createVallangInstance(IValueFactory vf); + + public abstract IConstructor createVallangInstance(IValueFactory vf); } diff --git a/src/main/java/lang/jimple/internal/JimpleObjectFactory.java b/src/main/java/lang/jimple/internal/JimpleObjectFactory.java index a20e226e..0b6e1b3a 100644 --- a/src/main/java/lang/jimple/internal/JimpleObjectFactory.java +++ b/src/main/java/lang/jimple/internal/JimpleObjectFactory.java @@ -24,27 +24,27 @@ public class JimpleObjectFactory { public static Type objectConstructor(String name) { return Type.TObject(name.replace("/", ".")); } - + public static Statement assignmentStmt(Variable var, Expression expression) { return Statement.assign(var, expression); } - + public static Expression newPlusExpression(Immediate lhs, Immediate rhs) { return Expression.plus(lhs, rhs); } - + public static Expression newMinusExpression(Immediate lhs, Immediate rhs) { return Expression.minus(lhs, rhs); } - + public static Expression newMultExpression(Immediate lhs, Immediate rhs) { return Expression.mult(lhs, rhs); } - + public static Expression newDivExpression(Immediate lhs, Immediate rhs) { return Expression.div(lhs, rhs); } - + public static Expression newReminderExpression(Immediate lhs, Immediate rhs) { return Expression.reminder(lhs, rhs); } @@ -68,205 +68,221 @@ public static Immediate newNullValueImmediate() { public static Immediate newLocalImmediate(String var) { return Immediate.local(var); } - + public static MethodSignature methodSignature(String owner, String name, String descriptor) { org.objectweb.asm.Type methodType = org.objectweb.asm.Type.getMethodType(descriptor); - + Type returnType = type(methodType.getReturnType().getDescriptor()); - + List formals = new ArrayList(); - - for(org.objectweb.asm.Type t: methodType.getArgumentTypes()) { + + for (org.objectweb.asm.Type t : methodType.getArgumentTypes()) { formals.add(type(t.getDescriptor())); } - - return MethodSignature.methodSignature(owner,returnType, name, formals); + + return MethodSignature.methodSignature(owner, returnType, name, formals); } - + public static Type methodReturnType(String descriptor) { return type(org.objectweb.asm.Type.getReturnType(descriptor).getDescriptor()); } - + public static List methodArgumentTypes(String descriptor) { org.objectweb.asm.Type[] args = org.objectweb.asm.Type.getArgumentTypes(descriptor); - + List res = new ArrayList<>(); - for(org.objectweb.asm.Type t: args) { + for (org.objectweb.asm.Type t : args) { res.add(type(t.getDescriptor())); } return res; } - + public static String localVariableName(boolean isStackVariable, String type, int idx) { - String infix = "r"; - - switch(type) { - case "TLong" : infix = "l"; break; - case "TChar" : infix = "c"; break; - case "TByte" : infix = "b"; break; - case "TShort" : infix = "s"; break; - case "TFloat" : infix = "f"; break; - case "TDouble" : infix = "d"; break; + String infix = "r"; + + switch (type) { + case "TLong": + infix = "l"; + break; + case "TChar": + infix = "c"; + break; + case "TByte": + infix = "b"; + break; + case "TShort": + infix = "s"; + break; + case "TFloat": + infix = "f"; + break; + case "TDouble": + infix = "d"; + break; } - - return isStackVariable ? "$" + (infix + idx) : (infix + idx); + + return isStackVariable ? "$" + (infix + idx) : (infix + idx); } + public static Type type(String descriptor) { - // primitive types - switch(descriptor) { - case "Z" : return Type.TBoolean(); - case "C" : return Type.TCharacter(); - case "B" : return Type.TByte(); - case "S" : return Type.TShort(); - case "I" : return Type.TInteger(); - case "F" : return Type.TFloat(); - case "J" : return Type.TLong(); - case "D" : return Type.TDouble(); - case "V" : return Type.TVoid(); - case "null_type" : return Type.TNull(); - default : /* do nothing */ + // primitive types + switch (descriptor) { + case "Z": + return Type.TBoolean(); + case "C": + return Type.TCharacter(); + case "B": + return Type.TByte(); + case "S": + return Type.TShort(); + case "I": + return Type.TInteger(); + case "F": + return Type.TFloat(); + case "J": + return Type.TLong(); + case "D": + return Type.TDouble(); + case "V": + return Type.TVoid(); + case "null_type": + return Type.TNull(); + default: /* do nothing */ } - // object types - if(descriptor.startsWith("L")) { - String objectName = descriptor.substring(1, descriptor.length()-1); + // object types + if (descriptor.startsWith("L")) { + String objectName = descriptor.substring(1, descriptor.length() - 1); return objectConstructor(objectName); - } - else if(descriptor.startsWith("[")) { // array types + } else if (descriptor.startsWith("[")) { // array types String baseType = descriptor.substring(1, descriptor.length()); Type base = objectConstructor(baseType); - return Type.TArray(type(baseType)); + return Type.TArray(type(baseType)); } - - // TODO: what should we do in this situation? For now, - // instead of throwing a runtime exception, lets return - // the unknown type. + + // TODO: what should we do in this situation? For now, + // instead of throwing a runtime exception, lets return + // the unknown type. return Type.TUnknown(); } public static MethodSignature methodSignature(Handle handle) { - return MethodSignature.methodSignature(handle.getOwner(), methodReturnType(handle.getDesc()) , handle.getName(), methodArgumentTypes(handle.getDesc())); + return MethodSignature.methodSignature(handle.getOwner(), methodReturnType(handle.getDesc()), handle.getName(), + methodArgumentTypes(handle.getDesc())); } - + public static List modifiers(int access) { List list = new ArrayList(); - if((access & Opcodes.ACC_PUBLIC) != 0) { + if ((access & Opcodes.ACC_PUBLIC) != 0) { list.add(Modifier.Public()); } - if((access & Opcodes.ACC_PROTECTED) != 0) { + if ((access & Opcodes.ACC_PROTECTED) != 0) { list.add(Modifier.Protected()); } - if((access & Opcodes.ACC_PRIVATE) != 0) { + if ((access & Opcodes.ACC_PRIVATE) != 0) { list.add(Modifier.Private()); - } - if((access & Opcodes.ACC_ABSTRACT) != 0) { + } + if ((access & Opcodes.ACC_ABSTRACT) != 0) { list.add(Modifier.Abstract()); } - if((access & Opcodes.ACC_STATIC) != 0) { + if ((access & Opcodes.ACC_STATIC) != 0) { list.add(Modifier.Static()); - } - if((access & Opcodes.ACC_FINAL) != 0) { + } + if ((access & Opcodes.ACC_FINAL) != 0) { list.add(Modifier.Final()); } - if((access & Opcodes.ACC_SYNCHRONIZED) != 0) { + if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) { list.add(Modifier.Synchronized()); - } - if((access & Opcodes.ACC_STRICT) != 0) { + } + if ((access & Opcodes.ACC_STRICT) != 0) { list.add(Modifier.Strictfp()); - } - if((access & Opcodes.ACC_TRANSIENT) != 0) { + } + if ((access & Opcodes.ACC_TRANSIENT) != 0) { list.add(Modifier.Transient()); } - if((access & Opcodes.ACC_VOLATILE) != 0) { + if ((access & Opcodes.ACC_VOLATILE) != 0) { list.add(Modifier.Volatile()); } - if((access & Opcodes.ACC_ENUM) != 0) { + if ((access & Opcodes.ACC_ENUM) != 0) { list.add(Modifier.Enum()); } - if((access & Opcodes.ACC_ANNOTATION) != 0) { + if ((access & Opcodes.ACC_ANNOTATION) != 0) { list.add(Modifier.Annotation()); } - if((access & Opcodes.ACC_SYNTHETIC) != 0) { + if ((access & Opcodes.ACC_SYNTHETIC) != 0) { list.add(Modifier.Synthetic()); } return list; } - + public static Pair toJimpleTypedValue(Object value) { - if((value instanceof Integer)) { - return new Pair(Type.TInteger(), Value.intValue((Integer)value)); - } - else if (value instanceof Float) { - return new Pair(Type.TFloat(), Value.floatValue((Float)value)); - } - else if(value instanceof Long) { - return new Pair(Type.TLong(), Value.longValue((Long)value)); - } - else if(value instanceof Double) { - return new Pair(Type.TDouble(), Value.doubleValue((Double)value)); - } - else if (value instanceof String) { - return new Pair(Type.TString(), Value.stringValue((String)value)); - } - else if (value instanceof org.objectweb.asm.Type) { - org.objectweb.asm.Type t = (org.objectweb.asm.Type) value; - if (t.getSort() == org.objectweb.asm.Type.METHOD) { - Type returnType = methodReturnType(t.getDescriptor()); - List formals = methodArgumentTypes(t.getDescriptor()); - - return new Pair(Type.TMethodValue(), Value.methodValue(returnType, formals)); - } - else { - return new Pair(Type.TClassValue(), Value.classValue(t.getDescriptor())); - } - } - else if(value instanceof org.objectweb.asm.Handle) { - org.objectweb.asm.Handle h = (org.objectweb.asm.Handle)value; - - if(isMethodHandle(h.getTag())) { - MethodSignature sig = MethodSignature.methodSignature(h.getOwner(), methodReturnType(h.getDesc()), h.getName(), methodArgumentTypes(h.getDesc())); - return new Pair(Type.TMethodHandle(), Value.methodHandle(sig)); + if ((value instanceof Integer)) { + return new Pair(Type.TInteger(), Value.intValue((Integer) value)); + } else if (value instanceof Float) { + return new Pair(Type.TFloat(), Value.floatValue((Float) value)); + } else if (value instanceof Long) { + return new Pair(Type.TLong(), Value.longValue((Long) value)); + } else if (value instanceof Double) { + return new Pair(Type.TDouble(), Value.doubleValue((Double) value)); + } else if (value instanceof String) { + return new Pair(Type.TString(), Value.stringValue((String) value)); + } else if (value instanceof org.objectweb.asm.Type) { + org.objectweb.asm.Type t = (org.objectweb.asm.Type) value; + if (t.getSort() == org.objectweb.asm.Type.METHOD) { + Type returnType = methodReturnType(t.getDescriptor()); + List formals = methodArgumentTypes(t.getDescriptor()); + + return new Pair(Type.TMethodValue(), Value.methodValue(returnType, formals)); + } else { + return new Pair(Type.TClassValue(), Value.classValue(t.getDescriptor())); } - else { + } else if (value instanceof org.objectweb.asm.Handle) { + org.objectweb.asm.Handle h = (org.objectweb.asm.Handle) value; + + if (isMethodHandle(h.getTag())) { + MethodSignature sig = MethodSignature.methodSignature(h.getOwner(), methodReturnType(h.getDesc()), + h.getName(), methodArgumentTypes(h.getDesc())); + return new Pair(Type.TMethodHandle(), Value.methodHandle(sig)); + } else { FieldSignature sig = FieldSignature.fieldSignature(h.getOwner(), type(h.getDesc()), h.getName()); return new Pair(Type.TFieldHandle(), Value.fieldHandle(sig)); } } throw new RuntimeException("Unknown constant type " + value.getClass()); } - + public static boolean isInterface(int access) { - return (access & Opcodes.ACC_INTERFACE) != 0; + return (access & Opcodes.ACC_INTERFACE) != 0; } - + private static boolean isMethodHandle(int tag) { - return methodTags.contains(tag); + return methodTags.contains(tag); } - - private static Set methodTags = methodTags(); + + private static Set methodTags = methodTags(); private static Set fieldTags = fieldTags(); - - private static Set methodTags() { + + private static Set methodTags() { Set tags = new HashSet<>(); - + tags.add(Opcodes.H_INVOKEVIRTUAL); tags.add(Opcodes.H_INVOKESTATIC); tags.add(Opcodes.H_INVOKESPECIAL); tags.add(Opcodes.H_NEWINVOKESPECIAL); tags.add(Opcodes.H_INVOKEINTERFACE); - - return tags; + + return tags; } - - private static Set fieldTags() { + + private static Set fieldTags() { Set tags = new HashSet<>(); - + tags.add(Opcodes.H_GETFIELD); tags.add(Opcodes.H_GETSTATIC); tags.add(Opcodes.H_GETSTATIC); tags.add(Opcodes.H_PUTSTATIC); - - return tags; + + return tags; } - + } diff --git a/src/main/java/lang/jimple/internal/Operand.java b/src/main/java/lang/jimple/internal/Operand.java index d12c8cce..c510a753 100644 --- a/src/main/java/lang/jimple/internal/Operand.java +++ b/src/main/java/lang/jimple/internal/Operand.java @@ -7,10 +7,10 @@ import lang.jimple.util.Pair; public class Operand { - - public Type type; - public Immediate immediate; - + + public Type type; + public Immediate immediate; + Operand(Type type, Immediate immediate) { this.type = type; this.immediate = immediate; diff --git a/src/main/java/lang/jimple/internal/SingleInstructionFlow.java b/src/main/java/lang/jimple/internal/SingleInstructionFlow.java index 879de434..cd5b8409 100644 --- a/src/main/java/lang/jimple/internal/SingleInstructionFlow.java +++ b/src/main/java/lang/jimple/internal/SingleInstructionFlow.java @@ -3,12 +3,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Stack; - import lang.jimple.internal.generated.Statement; public class SingleInstructionFlow implements InstructionFlow { - + Environment environment; public SingleInstructionFlow() { @@ -23,7 +21,8 @@ public List environments() { } @Override - public void nextBranch() { } + public void nextBranch() { + } @Override public void notifyGotoStmt(Statement stmt, String label) { diff --git a/src/main/java/lang/jimple/internal/generated/ArrayDescriptor.java b/src/main/java/lang/jimple/internal/generated/ArrayDescriptor.java index 7c17b022..ac7f675d 100644 --- a/src/main/java/lang/jimple/internal/generated/ArrayDescriptor.java +++ b/src/main/java/lang/jimple/internal/generated/ArrayDescriptor.java @@ -1,90 +1,75 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class ArrayDescriptor extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "ArrayDescriptor"; - } - - - - public static ArrayDescriptor fixedSize(Integer size) { - return new c_fixedSize(size); - } - - public static ArrayDescriptor variableSize() { - return new c_variableSize(); - } - - - - @EqualsAndHashCode - public static class c_fixedSize extends ArrayDescriptor { - - public Integer size; - - - public c_fixedSize(Integer size) { - - this.size = size; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_size = vf.integer(size); - - - return vf.constructor(getVallangConstructor() - - , iv_size - - ); - } - - @Override - public String getConstructor() { - return "fixedSize"; - } - } - - @EqualsAndHashCode - public static class c_variableSize extends ArrayDescriptor { - - - public c_variableSize() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "variableSize"; - } - } - - + @Override + public String getBaseType() { + return "ArrayDescriptor"; + } + + public static ArrayDescriptor fixedSize(Integer size) { + return new c_fixedSize(size); + } + + public static ArrayDescriptor variableSize() { + return new c_variableSize(); + } + + @EqualsAndHashCode + public static class c_fixedSize extends ArrayDescriptor { + + public Integer size; + + public c_fixedSize(Integer size) { + + this.size = size; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_size = vf.integer(size); + + return vf.constructor(getVallangConstructor() + + , iv_size + + ); + } + + @Override + public String getConstructor() { + return "fixedSize"; + } + } + + @EqualsAndHashCode + public static class c_variableSize extends ArrayDescriptor { + + public c_variableSize() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "variableSize"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/CaseStmt.java b/src/main/java/lang/jimple/internal/generated/CaseStmt.java index e837d257..3f85bf50 100644 --- a/src/main/java/lang/jimple/internal/generated/CaseStmt.java +++ b/src/main/java/lang/jimple/internal/generated/CaseStmt.java @@ -1,106 +1,91 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class CaseStmt extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "CaseStmt"; - } - - - - public static CaseStmt caseOption(Integer option, String targetStmt) { - return new c_caseOption(option, targetStmt); - } - - public static CaseStmt defaultOption(String targetStmt) { - return new c_defaultOption(targetStmt); - } - - - - @EqualsAndHashCode - public static class c_caseOption extends CaseStmt { - - public Integer option; - - public String targetStmt; - - - public c_caseOption(Integer option, String targetStmt) { - - this.option = option; - - this.targetStmt = targetStmt; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_option = vf.integer(option); - - IValue iv_targetStmt = vf.string(targetStmt); - - - return vf.constructor(getVallangConstructor() - - , iv_option - - , iv_targetStmt - - ); - } - - @Override - public String getConstructor() { - return "caseOption"; - } - } - - @EqualsAndHashCode - public static class c_defaultOption extends CaseStmt { - - public String targetStmt; - - - public c_defaultOption(String targetStmt) { - - this.targetStmt = targetStmt; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_targetStmt = vf.string(targetStmt); - - - return vf.constructor(getVallangConstructor() - - , iv_targetStmt - - ); - } - - @Override - public String getConstructor() { - return "defaultOption"; - } - } - - + @Override + public String getBaseType() { + return "CaseStmt"; + } + + public static CaseStmt caseOption(Integer option, String targetStmt) { + return new c_caseOption(option, targetStmt); + } + + public static CaseStmt defaultOption(String targetStmt) { + return new c_defaultOption(targetStmt); + } + + @EqualsAndHashCode + public static class c_caseOption extends CaseStmt { + + public Integer option; + + public String targetStmt; + + public c_caseOption(Integer option, String targetStmt) { + + this.option = option; + + this.targetStmt = targetStmt; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_option = vf.integer(option); + + IValue iv_targetStmt = vf.string(targetStmt); + + return vf.constructor(getVallangConstructor() + + , iv_option + + , iv_targetStmt + + ); + } + + @Override + public String getConstructor() { + return "caseOption"; + } + } + + @EqualsAndHashCode + public static class c_defaultOption extends CaseStmt { + + public String targetStmt; + + public c_defaultOption(String targetStmt) { + + this.targetStmt = targetStmt; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_targetStmt = vf.string(targetStmt); + + return vf.constructor(getVallangConstructor() + + , iv_targetStmt + + ); + } + + @Override + public String getConstructor() { + return "defaultOption"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/CatchClause.java b/src/main/java/lang/jimple/internal/generated/CatchClause.java index 505f9d67..6052fb24 100644 --- a/src/main/java/lang/jimple/internal/generated/CatchClause.java +++ b/src/main/java/lang/jimple/internal/generated/CatchClause.java @@ -1,81 +1,71 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class CatchClause extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "CatchClause"; - } - - - - - public Type exception; - - public String from; - - public String to; - - public String with; - - - public static CatchClause catchClause(Type exception, String from, String to, String with) { - return new CatchClause(exception, from, to, with); - } - - public CatchClause(Type exception, String from, String to, String with) { - - this.exception = exception; - - this.from = from; - - this.to = to; - - this.with = with; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_exception = exception.createVallangInstance(vf); - - IValue iv_from = vf.string(from); - - IValue iv_to = vf.string(to); - - IValue iv_with = vf.string(with); - - - return vf.constructor(getVallangConstructor() - - , iv_exception - - , iv_from - - , iv_to - - , iv_with - - ); - } - - @Override - public String getConstructor() { - return "catchClause"; - } - - - +public class CatchClause extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "CatchClause"; + } + + public Type exception; + + public String from; + + public String to; + + public String with; + + public static CatchClause catchClause(Type exception, String from, String to, String with) { + return new CatchClause(exception, from, to, with); + } + + public CatchClause(Type exception, String from, String to, String with) { + + this.exception = exception; + + this.from = from; + + this.to = to; + + this.with = with; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_exception = exception.createVallangInstance(vf); + + IValue iv_from = vf.string(from); + + IValue iv_to = vf.string(to); + + IValue iv_with = vf.string(with); + + return vf.constructor(getVallangConstructor() + + , iv_exception + + , iv_from + + , iv_to + + , iv_with + + ); + } + + @Override + public String getConstructor() { + return "catchClause"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/ClassOrInterfaceDeclaration.java b/src/main/java/lang/jimple/internal/generated/ClassOrInterfaceDeclaration.java index 422ad32c..8eb57d3e 100644 --- a/src/main/java/lang/jimple/internal/generated/ClassOrInterfaceDeclaration.java +++ b/src/main/java/lang/jimple/internal/generated/ClassOrInterfaceDeclaration.java @@ -1,210 +1,194 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class ClassOrInterfaceDeclaration extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "ClassOrInterfaceDeclaration"; - } - - - - public static ClassOrInterfaceDeclaration classDecl(Type typeName, List modifiers, Type superClass, List interfaces, List fields, List methods) { - return new c_classDecl(typeName, modifiers, superClass, interfaces, fields, methods); - } - - public static ClassOrInterfaceDeclaration interfaceDecl(Type typeName, List modifiers, List interfaces, List fields, List methods) { - return new c_interfaceDecl(typeName, modifiers, interfaces, fields, methods); - } - - - - @EqualsAndHashCode - public static class c_classDecl extends ClassOrInterfaceDeclaration { - - public Type typeName; - - public List modifiers; - - public Type superClass; - - public List interfaces; - - public List fields; - - public List methods; - - - public c_classDecl(Type typeName, List modifiers, Type superClass, List interfaces, List fields, List methods) { - - this.typeName = typeName; - - this.modifiers = modifiers; - - this.superClass = superClass; - - this.interfaces = interfaces; - - this.fields = fields; - - this.methods = methods; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_typeName = typeName.createVallangInstance(vf); - - IList iv_modifiers = vf.list(); - - for(Modifier v: modifiers) { - iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); - } - - - IValue iv_superClass = superClass.createVallangInstance(vf); - - IList iv_interfaces = vf.list(); - - for(Type v: interfaces) { - iv_interfaces = iv_interfaces.append(v.createVallangInstance(vf)); - } - - - IList iv_fields = vf.list(); - - for(Field v: fields) { - iv_fields = iv_fields.append(v.createVallangInstance(vf)); - } - - - IList iv_methods = vf.list(); - - for(Method v: methods) { - iv_methods = iv_methods.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_typeName - - , iv_modifiers - - , iv_superClass - - , iv_interfaces - - , iv_fields - - , iv_methods - - ); - } - - @Override - public String getConstructor() { - return "classDecl"; - } - } - - @EqualsAndHashCode - public static class c_interfaceDecl extends ClassOrInterfaceDeclaration { - - public Type typeName; - - public List modifiers; - - public List interfaces; - - public List fields; - - public List methods; - - - public c_interfaceDecl(Type typeName, List modifiers, List interfaces, List fields, List methods) { - - this.typeName = typeName; - - this.modifiers = modifiers; - - this.interfaces = interfaces; - - this.fields = fields; - - this.methods = methods; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_typeName = typeName.createVallangInstance(vf); - - IList iv_modifiers = vf.list(); - - for(Modifier v: modifiers) { - iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); - } - - - IList iv_interfaces = vf.list(); - - for(Type v: interfaces) { - iv_interfaces = iv_interfaces.append(v.createVallangInstance(vf)); - } - - - IList iv_fields = vf.list(); - - for(Field v: fields) { - iv_fields = iv_fields.append(v.createVallangInstance(vf)); - } - - - IList iv_methods = vf.list(); - - for(Method v: methods) { - iv_methods = iv_methods.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_typeName - - , iv_modifiers - - , iv_interfaces - - , iv_fields - - , iv_methods - - ); - } - - @Override - public String getConstructor() { - return "interfaceDecl"; - } - } - - + @Override + public String getBaseType() { + return "ClassOrInterfaceDeclaration"; + } + + public static ClassOrInterfaceDeclaration classDecl(Type typeName, List modifiers, Type superClass, + List interfaces, List fields, List methods) { + return new c_classDecl(typeName, modifiers, superClass, interfaces, fields, methods); + } + + public static ClassOrInterfaceDeclaration interfaceDecl(Type typeName, List modifiers, + List interfaces, List fields, List methods) { + return new c_interfaceDecl(typeName, modifiers, interfaces, fields, methods); + } + + @EqualsAndHashCode + public static class c_classDecl extends ClassOrInterfaceDeclaration { + + public Type typeName; + + public List modifiers; + + public Type superClass; + + public List interfaces; + + public List fields; + + public List methods; + + public c_classDecl(Type typeName, List modifiers, Type superClass, List interfaces, + List fields, List methods) { + + this.typeName = typeName; + + this.modifiers = modifiers; + + this.superClass = superClass; + + this.interfaces = interfaces; + + this.fields = fields; + + this.methods = methods; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_typeName = typeName.createVallangInstance(vf); + + IList iv_modifiers = vf.list(); + + for (Modifier v : modifiers) { + iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); + } + + IValue iv_superClass = superClass.createVallangInstance(vf); + + IList iv_interfaces = vf.list(); + + for (Type v : interfaces) { + iv_interfaces = iv_interfaces.append(v.createVallangInstance(vf)); + } + + IList iv_fields = vf.list(); + + for (Field v : fields) { + iv_fields = iv_fields.append(v.createVallangInstance(vf)); + } + + IList iv_methods = vf.list(); + + for (Method v : methods) { + iv_methods = iv_methods.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_typeName + + , iv_modifiers + + , iv_superClass + + , iv_interfaces + + , iv_fields + + , iv_methods + + ); + } + + @Override + public String getConstructor() { + return "classDecl"; + } + } + + @EqualsAndHashCode + public static class c_interfaceDecl extends ClassOrInterfaceDeclaration { + + public Type typeName; + + public List modifiers; + + public List interfaces; + + public List fields; + + public List methods; + + public c_interfaceDecl(Type typeName, List modifiers, List interfaces, List fields, + List methods) { + + this.typeName = typeName; + + this.modifiers = modifiers; + + this.interfaces = interfaces; + + this.fields = fields; + + this.methods = methods; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_typeName = typeName.createVallangInstance(vf); + + IList iv_modifiers = vf.list(); + + for (Modifier v : modifiers) { + iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); + } + + IList iv_interfaces = vf.list(); + + for (Type v : interfaces) { + iv_interfaces = iv_interfaces.append(v.createVallangInstance(vf)); + } + + IList iv_fields = vf.list(); + + for (Field v : fields) { + iv_fields = iv_fields.append(v.createVallangInstance(vf)); + } + + IList iv_methods = vf.list(); + + for (Method v : methods) { + iv_methods = iv_methods.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_typeName + + , iv_modifiers + + , iv_interfaces + + , iv_fields + + , iv_methods + + ); + } + + @Override + public String getConstructor() { + return "interfaceDecl"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Expression.java b/src/main/java/lang/jimple/internal/generated/Expression.java index f69095d8..9cbef448 100644 --- a/src/main/java/lang/jimple/internal/generated/Expression.java +++ b/src/main/java/lang/jimple/internal/generated/Expression.java @@ -1,1495 +1,1386 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Expression extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Expression"; - } - - - - public static Expression newInstance(Type instanceType) { - return new c_newInstance(instanceType); - } - - public static Expression newArray(Type baseType, List dims) { - return new c_newArray(baseType, dims); - } - - public static Expression cast(Type toType, Immediate immeadiate) { - return new c_cast(toType, immeadiate); - } - - public static Expression instanceOf(Type baseType, Immediate immediate) { - return new c_instanceOf(baseType, immediate); - } - - public static Expression invokeExp(InvokeExp expression) { - return new c_invokeExp(expression); - } - - public static Expression arraySubscript(String name, Immediate immediate) { - return new c_arraySubscript(name, immediate); - } - - public static Expression stringSubscript(String string, Immediate immediate) { - return new c_stringSubscript(string, immediate); - } - - public static Expression localFieldRef(String local, String className, Type fieldType, String fieldName) { - return new c_localFieldRef(local, className, fieldType, fieldName); - } - - public static Expression fieldRef(String className, Type fieldType, String fieldName) { - return new c_fieldRef(className, fieldType, fieldName); - } - - public static Expression and(Immediate lhs, Immediate rhs) { - return new c_and(lhs, rhs); - } - - public static Expression or(Immediate lhs, Immediate rhs) { - return new c_or(lhs, rhs); - } - - public static Expression xor(Immediate lhs, Immediate rhs) { - return new c_xor(lhs, rhs); - } - - public static Expression reminder(Immediate lhs, Immediate rhs) { - return new c_reminder(lhs, rhs); - } - - public static Expression isNull(Immediate immediate) { - return new c_isNull(immediate); - } - - public static Expression isNotNull(Immediate immediate) { - return new c_isNotNull(immediate); - } - - public static Expression cmp(Immediate lhs, Immediate rhs) { - return new c_cmp(lhs, rhs); - } - - public static Expression cmpg(Immediate lhs, Immediate rhs) { - return new c_cmpg(lhs, rhs); - } - - public static Expression cmpl(Immediate lhs, Immediate rhs) { - return new c_cmpl(lhs, rhs); - } - - public static Expression cmpeq(Immediate lhs, Immediate rhs) { - return new c_cmpeq(lhs, rhs); - } - - public static Expression cmpne(Immediate lhs, Immediate rhs) { - return new c_cmpne(lhs, rhs); - } - - public static Expression cmpgt(Immediate lhs, Immediate rhs) { - return new c_cmpgt(lhs, rhs); - } - - public static Expression cmpge(Immediate lhs, Immediate rhs) { - return new c_cmpge(lhs, rhs); - } - - public static Expression cmplt(Immediate lhs, Immediate rhs) { - return new c_cmplt(lhs, rhs); - } - - public static Expression cmple(Immediate lhs, Immediate rhs) { - return new c_cmple(lhs, rhs); - } - - public static Expression shl(Immediate lhs, Immediate rhs) { - return new c_shl(lhs, rhs); - } - - public static Expression shr(Immediate lhs, Immediate rhs) { - return new c_shr(lhs, rhs); - } - - public static Expression ushr(Immediate lhs, Immediate rhs) { - return new c_ushr(lhs, rhs); - } - - public static Expression plus(Immediate lhs, Immediate rhs) { - return new c_plus(lhs, rhs); - } - - public static Expression minus(Immediate lhs, Immediate rhs) { - return new c_minus(lhs, rhs); - } - - public static Expression mult(Immediate lhs, Immediate rhs) { - return new c_mult(lhs, rhs); - } - - public static Expression div(Immediate lhs, Immediate rhs) { - return new c_div(lhs, rhs); - } - - public static Expression lengthOf(Immediate immediate) { - return new c_lengthOf(immediate); - } - - public static Expression neg(Immediate immediate) { - return new c_neg(immediate); - } - - public static Expression immediate(Immediate immediate) { - return new c_immediate(immediate); - } - - - - @EqualsAndHashCode - public static class c_newInstance extends Expression { - - public Type instanceType; - - - public c_newInstance(Type instanceType) { - - this.instanceType = instanceType; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_instanceType = instanceType.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_instanceType - - ); - } - - @Override - public String getConstructor() { - return "newInstance"; - } - } - - @EqualsAndHashCode - public static class c_newArray extends Expression { - - public Type baseType; - - public List dims; - - - public c_newArray(Type baseType, List dims) { - - this.baseType = baseType; - - this.dims = dims; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_baseType = baseType.createVallangInstance(vf); - - IList iv_dims = vf.list(); - - for(ArrayDescriptor v: dims) { - iv_dims = iv_dims.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_baseType - - , iv_dims - - ); - } - - @Override - public String getConstructor() { - return "newArray"; - } - } - - @EqualsAndHashCode - public static class c_cast extends Expression { - - public Type toType; - - public Immediate immeadiate; - - - public c_cast(Type toType, Immediate immeadiate) { - - this.toType = toType; - - this.immeadiate = immeadiate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_toType = toType.createVallangInstance(vf); - - IValue iv_immeadiate = immeadiate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_toType - - , iv_immeadiate - - ); - } - - @Override - public String getConstructor() { - return "cast"; - } - } - - @EqualsAndHashCode - public static class c_instanceOf extends Expression { - - public Type baseType; - - public Immediate immediate; - - - public c_instanceOf(Type baseType, Immediate immediate) { - - this.baseType = baseType; - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_baseType = baseType.createVallangInstance(vf); - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_baseType - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "instanceOf"; - } - } - - @EqualsAndHashCode - public static class c_invokeExp extends Expression { - - public InvokeExp expression; - - - public c_invokeExp(InvokeExp expression) { - - this.expression = expression; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_expression = expression.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_expression - - ); - } - - @Override - public String getConstructor() { - return "invokeExp"; - } - } - - @EqualsAndHashCode - public static class c_arraySubscript extends Expression { - - public String name; - - public Immediate immediate; - - - public c_arraySubscript(String name, Immediate immediate) { - - this.name = name; - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_name = vf.string(name); - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_name - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "arraySubscript"; - } - } - - @EqualsAndHashCode - public static class c_stringSubscript extends Expression { - - public String string; - - public Immediate immediate; - - - public c_stringSubscript(String string, Immediate immediate) { - - this.string = string; - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_string = vf.string(string); - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_string - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "stringSubscript"; - } - } - - @EqualsAndHashCode - public static class c_localFieldRef extends Expression { - - public String local; - - public String className; - - public Type fieldType; - - public String fieldName; - - - public c_localFieldRef(String local, String className, Type fieldType, String fieldName) { - - this.local = local; - - this.className = className; - - this.fieldType = fieldType; - - this.fieldName = fieldName; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_local = vf.string(local); - - IValue iv_className = vf.string(className); - - IValue iv_fieldType = fieldType.createVallangInstance(vf); - - IValue iv_fieldName = vf.string(fieldName); - - - return vf.constructor(getVallangConstructor() - - , iv_local - - , iv_className - - , iv_fieldType - - , iv_fieldName - - ); - } - - @Override - public String getConstructor() { - return "localFieldRef"; - } - } - - @EqualsAndHashCode - public static class c_fieldRef extends Expression { - - public String className; - - public Type fieldType; - - public String fieldName; - - - public c_fieldRef(String className, Type fieldType, String fieldName) { - - this.className = className; - - this.fieldType = fieldType; - - this.fieldName = fieldName; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_className = vf.string(className); - - IValue iv_fieldType = fieldType.createVallangInstance(vf); - - IValue iv_fieldName = vf.string(fieldName); - - - return vf.constructor(getVallangConstructor() - - , iv_className - - , iv_fieldType - - , iv_fieldName - - ); - } - - @Override - public String getConstructor() { - return "fieldRef"; - } - } - - @EqualsAndHashCode - public static class c_and extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_and(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "and"; - } - } - - @EqualsAndHashCode - public static class c_or extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_or(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "or"; - } - } - - @EqualsAndHashCode - public static class c_xor extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_xor(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "xor"; - } - } - - @EqualsAndHashCode - public static class c_reminder extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_reminder(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "reminder"; - } - } - - @EqualsAndHashCode - public static class c_isNull extends Expression { - - public Immediate immediate; - - - public c_isNull(Immediate immediate) { - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "isNull"; - } - } - - @EqualsAndHashCode - public static class c_isNotNull extends Expression { - - public Immediate immediate; - - - public c_isNotNull(Immediate immediate) { - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "isNotNull"; - } - } - - @EqualsAndHashCode - public static class c_cmp extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmp(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmp"; - } - } - - @EqualsAndHashCode - public static class c_cmpg extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpg(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpg"; - } - } - - @EqualsAndHashCode - public static class c_cmpl extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpl(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpl"; - } - } - - @EqualsAndHashCode - public static class c_cmpeq extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpeq(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpeq"; - } - } - - @EqualsAndHashCode - public static class c_cmpne extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpne(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpne"; - } - } - - @EqualsAndHashCode - public static class c_cmpgt extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpgt(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpgt"; - } - } - - @EqualsAndHashCode - public static class c_cmpge extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmpge(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmpge"; - } - } - - @EqualsAndHashCode - public static class c_cmplt extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmplt(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmplt"; - } - } - - @EqualsAndHashCode - public static class c_cmple extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_cmple(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "cmple"; - } - } - - @EqualsAndHashCode - public static class c_shl extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_shl(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "shl"; - } - } - - @EqualsAndHashCode - public static class c_shr extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_shr(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "shr"; - } - } - - @EqualsAndHashCode - public static class c_ushr extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_ushr(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "ushr"; - } - } - - @EqualsAndHashCode - public static class c_plus extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_plus(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "plus"; - } - } - - @EqualsAndHashCode - public static class c_minus extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_minus(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "minus"; - } - } - - @EqualsAndHashCode - public static class c_mult extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_mult(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "mult"; - } - } - - @EqualsAndHashCode - public static class c_div extends Expression { - - public Immediate lhs; - - public Immediate rhs; - - - public c_div(Immediate lhs, Immediate rhs) { - - this.lhs = lhs; - - this.rhs = rhs; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lhs = lhs.createVallangInstance(vf); - - IValue iv_rhs = rhs.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_lhs - - , iv_rhs - - ); - } - - @Override - public String getConstructor() { - return "div"; - } - } - - @EqualsAndHashCode - public static class c_lengthOf extends Expression { - - public Immediate immediate; - - - public c_lengthOf(Immediate immediate) { - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "lengthOf"; - } - } - - @EqualsAndHashCode - public static class c_neg extends Expression { - - public Immediate immediate; - - - public c_neg(Immediate immediate) { - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "neg"; - } - } - - @EqualsAndHashCode - public static class c_immediate extends Expression { - - public Immediate immediate; - - - public c_immediate(Immediate immediate) { - - this.immediate = immediate; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_immediate = immediate.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_immediate - - ); - } - - @Override - public String getConstructor() { - return "immediate"; - } - } - - + @Override + public String getBaseType() { + return "Expression"; + } + + public static Expression newInstance(Type instanceType) { + return new c_newInstance(instanceType); + } + + public static Expression newArray(Type baseType, List dims) { + return new c_newArray(baseType, dims); + } + + public static Expression cast(Type toType, Immediate immeadiate) { + return new c_cast(toType, immeadiate); + } + + public static Expression instanceOf(Type baseType, Immediate immediate) { + return new c_instanceOf(baseType, immediate); + } + + public static Expression invokeExp(InvokeExp expression) { + return new c_invokeExp(expression); + } + + public static Expression arraySubscript(String name, Immediate immediate) { + return new c_arraySubscript(name, immediate); + } + + public static Expression stringSubscript(String string, Immediate immediate) { + return new c_stringSubscript(string, immediate); + } + + public static Expression localFieldRef(String local, String className, Type fieldType, String fieldName) { + return new c_localFieldRef(local, className, fieldType, fieldName); + } + + public static Expression fieldRef(String className, Type fieldType, String fieldName) { + return new c_fieldRef(className, fieldType, fieldName); + } + + public static Expression and(Immediate lhs, Immediate rhs) { + return new c_and(lhs, rhs); + } + + public static Expression or(Immediate lhs, Immediate rhs) { + return new c_or(lhs, rhs); + } + + public static Expression xor(Immediate lhs, Immediate rhs) { + return new c_xor(lhs, rhs); + } + + public static Expression reminder(Immediate lhs, Immediate rhs) { + return new c_reminder(lhs, rhs); + } + + public static Expression isNull(Immediate immediate) { + return new c_isNull(immediate); + } + + public static Expression isNotNull(Immediate immediate) { + return new c_isNotNull(immediate); + } + + public static Expression cmp(Immediate lhs, Immediate rhs) { + return new c_cmp(lhs, rhs); + } + + public static Expression cmpg(Immediate lhs, Immediate rhs) { + return new c_cmpg(lhs, rhs); + } + + public static Expression cmpl(Immediate lhs, Immediate rhs) { + return new c_cmpl(lhs, rhs); + } + + public static Expression cmpeq(Immediate lhs, Immediate rhs) { + return new c_cmpeq(lhs, rhs); + } + + public static Expression cmpne(Immediate lhs, Immediate rhs) { + return new c_cmpne(lhs, rhs); + } + + public static Expression cmpgt(Immediate lhs, Immediate rhs) { + return new c_cmpgt(lhs, rhs); + } + + public static Expression cmpge(Immediate lhs, Immediate rhs) { + return new c_cmpge(lhs, rhs); + } + + public static Expression cmplt(Immediate lhs, Immediate rhs) { + return new c_cmplt(lhs, rhs); + } + + public static Expression cmple(Immediate lhs, Immediate rhs) { + return new c_cmple(lhs, rhs); + } + + public static Expression shl(Immediate lhs, Immediate rhs) { + return new c_shl(lhs, rhs); + } + + public static Expression shr(Immediate lhs, Immediate rhs) { + return new c_shr(lhs, rhs); + } + + public static Expression ushr(Immediate lhs, Immediate rhs) { + return new c_ushr(lhs, rhs); + } + + public static Expression plus(Immediate lhs, Immediate rhs) { + return new c_plus(lhs, rhs); + } + + public static Expression minus(Immediate lhs, Immediate rhs) { + return new c_minus(lhs, rhs); + } + + public static Expression mult(Immediate lhs, Immediate rhs) { + return new c_mult(lhs, rhs); + } + + public static Expression div(Immediate lhs, Immediate rhs) { + return new c_div(lhs, rhs); + } + + public static Expression lengthOf(Immediate immediate) { + return new c_lengthOf(immediate); + } + + public static Expression neg(Immediate immediate) { + return new c_neg(immediate); + } + + public static Expression immediate(Immediate immediate) { + return new c_immediate(immediate); + } + + @EqualsAndHashCode + public static class c_newInstance extends Expression { + + public Type instanceType; + + public c_newInstance(Type instanceType) { + + this.instanceType = instanceType; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_instanceType = instanceType.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_instanceType + + ); + } + + @Override + public String getConstructor() { + return "newInstance"; + } + } + + @EqualsAndHashCode + public static class c_newArray extends Expression { + + public Type baseType; + + public List dims; + + public c_newArray(Type baseType, List dims) { + + this.baseType = baseType; + + this.dims = dims; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_baseType = baseType.createVallangInstance(vf); + + IList iv_dims = vf.list(); + + for (ArrayDescriptor v : dims) { + iv_dims = iv_dims.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_baseType + + , iv_dims + + ); + } + + @Override + public String getConstructor() { + return "newArray"; + } + } + + @EqualsAndHashCode + public static class c_cast extends Expression { + + public Type toType; + + public Immediate immeadiate; + + public c_cast(Type toType, Immediate immeadiate) { + + this.toType = toType; + + this.immeadiate = immeadiate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_toType = toType.createVallangInstance(vf); + + IValue iv_immeadiate = immeadiate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_toType + + , iv_immeadiate + + ); + } + + @Override + public String getConstructor() { + return "cast"; + } + } + + @EqualsAndHashCode + public static class c_instanceOf extends Expression { + + public Type baseType; + + public Immediate immediate; + + public c_instanceOf(Type baseType, Immediate immediate) { + + this.baseType = baseType; + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_baseType = baseType.createVallangInstance(vf); + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_baseType + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "instanceOf"; + } + } + + @EqualsAndHashCode + public static class c_invokeExp extends Expression { + + public InvokeExp expression; + + public c_invokeExp(InvokeExp expression) { + + this.expression = expression; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_expression = expression.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_expression + + ); + } + + @Override + public String getConstructor() { + return "invokeExp"; + } + } + + @EqualsAndHashCode + public static class c_arraySubscript extends Expression { + + public String name; + + public Immediate immediate; + + public c_arraySubscript(String name, Immediate immediate) { + + this.name = name; + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_name = vf.string(name); + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_name + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "arraySubscript"; + } + } + + @EqualsAndHashCode + public static class c_stringSubscript extends Expression { + + public String string; + + public Immediate immediate; + + public c_stringSubscript(String string, Immediate immediate) { + + this.string = string; + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_string = vf.string(string); + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_string + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "stringSubscript"; + } + } + + @EqualsAndHashCode + public static class c_localFieldRef extends Expression { + + public String local; + + public String className; + + public Type fieldType; + + public String fieldName; + + public c_localFieldRef(String local, String className, Type fieldType, String fieldName) { + + this.local = local; + + this.className = className; + + this.fieldType = fieldType; + + this.fieldName = fieldName; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_local = vf.string(local); + + IValue iv_className = vf.string(className); + + IValue iv_fieldType = fieldType.createVallangInstance(vf); + + IValue iv_fieldName = vf.string(fieldName); + + return vf.constructor(getVallangConstructor() + + , iv_local + + , iv_className + + , iv_fieldType + + , iv_fieldName + + ); + } + + @Override + public String getConstructor() { + return "localFieldRef"; + } + } + + @EqualsAndHashCode + public static class c_fieldRef extends Expression { + + public String className; + + public Type fieldType; + + public String fieldName; + + public c_fieldRef(String className, Type fieldType, String fieldName) { + + this.className = className; + + this.fieldType = fieldType; + + this.fieldName = fieldName; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_className = vf.string(className); + + IValue iv_fieldType = fieldType.createVallangInstance(vf); + + IValue iv_fieldName = vf.string(fieldName); + + return vf.constructor(getVallangConstructor() + + , iv_className + + , iv_fieldType + + , iv_fieldName + + ); + } + + @Override + public String getConstructor() { + return "fieldRef"; + } + } + + @EqualsAndHashCode + public static class c_and extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_and(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "and"; + } + } + + @EqualsAndHashCode + public static class c_or extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_or(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "or"; + } + } + + @EqualsAndHashCode + public static class c_xor extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_xor(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "xor"; + } + } + + @EqualsAndHashCode + public static class c_reminder extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_reminder(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "reminder"; + } + } + + @EqualsAndHashCode + public static class c_isNull extends Expression { + + public Immediate immediate; + + public c_isNull(Immediate immediate) { + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "isNull"; + } + } + + @EqualsAndHashCode + public static class c_isNotNull extends Expression { + + public Immediate immediate; + + public c_isNotNull(Immediate immediate) { + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "isNotNull"; + } + } + + @EqualsAndHashCode + public static class c_cmp extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmp(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmp"; + } + } + + @EqualsAndHashCode + public static class c_cmpg extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpg(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpg"; + } + } + + @EqualsAndHashCode + public static class c_cmpl extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpl(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpl"; + } + } + + @EqualsAndHashCode + public static class c_cmpeq extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpeq(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpeq"; + } + } + + @EqualsAndHashCode + public static class c_cmpne extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpne(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpne"; + } + } + + @EqualsAndHashCode + public static class c_cmpgt extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpgt(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpgt"; + } + } + + @EqualsAndHashCode + public static class c_cmpge extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmpge(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmpge"; + } + } + + @EqualsAndHashCode + public static class c_cmplt extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmplt(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmplt"; + } + } + + @EqualsAndHashCode + public static class c_cmple extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_cmple(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "cmple"; + } + } + + @EqualsAndHashCode + public static class c_shl extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_shl(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "shl"; + } + } + + @EqualsAndHashCode + public static class c_shr extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_shr(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "shr"; + } + } + + @EqualsAndHashCode + public static class c_ushr extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_ushr(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "ushr"; + } + } + + @EqualsAndHashCode + public static class c_plus extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_plus(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "plus"; + } + } + + @EqualsAndHashCode + public static class c_minus extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_minus(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "minus"; + } + } + + @EqualsAndHashCode + public static class c_mult extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_mult(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "mult"; + } + } + + @EqualsAndHashCode + public static class c_div extends Expression { + + public Immediate lhs; + + public Immediate rhs; + + public c_div(Immediate lhs, Immediate rhs) { + + this.lhs = lhs; + + this.rhs = rhs; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lhs = lhs.createVallangInstance(vf); + + IValue iv_rhs = rhs.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_lhs + + , iv_rhs + + ); + } + + @Override + public String getConstructor() { + return "div"; + } + } + + @EqualsAndHashCode + public static class c_lengthOf extends Expression { + + public Immediate immediate; + + public c_lengthOf(Immediate immediate) { + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "lengthOf"; + } + } + + @EqualsAndHashCode + public static class c_neg extends Expression { + + public Immediate immediate; + + public c_neg(Immediate immediate) { + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "neg"; + } + } + + @EqualsAndHashCode + public static class c_immediate extends Expression { + + public Immediate immediate; + + public c_immediate(Immediate immediate) { + + this.immediate = immediate; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_immediate = immediate.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_immediate + + ); + } + + @Override + public String getConstructor() { + return "immediate"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Field.java b/src/main/java/lang/jimple/internal/generated/Field.java index 9fb654c2..da754ca9 100644 --- a/src/main/java/lang/jimple/internal/generated/Field.java +++ b/src/main/java/lang/jimple/internal/generated/Field.java @@ -1,78 +1,70 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class Field extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Field"; - } - - - - - public List modifiers; - - public Type fieldType; - - public String name; - - - public static Field field(List modifiers, Type fieldType, String name) { - return new Field(modifiers, fieldType, name); - } - - public Field(List modifiers, Type fieldType, String name) { - - this.modifiers = modifiers; - - this.fieldType = fieldType; - - this.name = name; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IList iv_modifiers = vf.list(); - - for(Modifier v: modifiers) { - iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); - } - - - IValue iv_fieldType = fieldType.createVallangInstance(vf); - - IValue iv_name = vf.string(name); - - - return vf.constructor(getVallangConstructor() - - , iv_modifiers - - , iv_fieldType - - , iv_name - - ); - } - - @Override - public String getConstructor() { - return "field"; - } - - - +public class Field extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "Field"; + } + + public List modifiers; + + public Type fieldType; + + public String name; + + public static Field field(List modifiers, Type fieldType, String name) { + return new Field(modifiers, fieldType, name); + } + + public Field(List modifiers, Type fieldType, String name) { + + this.modifiers = modifiers; + + this.fieldType = fieldType; + + this.name = name; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IList iv_modifiers = vf.list(); + + for (Modifier v : modifiers) { + iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); + } + + IValue iv_fieldType = fieldType.createVallangInstance(vf); + + IValue iv_name = vf.string(name); + + return vf.constructor(getVallangConstructor() + + , iv_modifiers + + , iv_fieldType + + , iv_name + + ); + } + + @Override + public String getConstructor() { + return "field"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/FieldSignature.java b/src/main/java/lang/jimple/internal/generated/FieldSignature.java index 72aa5fba..32d2a145 100644 --- a/src/main/java/lang/jimple/internal/generated/FieldSignature.java +++ b/src/main/java/lang/jimple/internal/generated/FieldSignature.java @@ -1,73 +1,63 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class FieldSignature extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "FieldSignature"; - } - - - - - public String className; - - public Type fieldType; - - public String fieldName; - - - public static FieldSignature fieldSignature(String className, Type fieldType, String fieldName) { - return new FieldSignature(className, fieldType, fieldName); - } - - public FieldSignature(String className, Type fieldType, String fieldName) { - - this.className = className; - - this.fieldType = fieldType; - - this.fieldName = fieldName; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_className = vf.string(className); - - IValue iv_fieldType = fieldType.createVallangInstance(vf); - - IValue iv_fieldName = vf.string(fieldName); - - - return vf.constructor(getVallangConstructor() - - , iv_className - - , iv_fieldType - - , iv_fieldName - - ); - } - - @Override - public String getConstructor() { - return "fieldSignature"; - } - - - +public class FieldSignature extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "FieldSignature"; + } + + public String className; + + public Type fieldType; + + public String fieldName; + + public static FieldSignature fieldSignature(String className, Type fieldType, String fieldName) { + return new FieldSignature(className, fieldType, fieldName); + } + + public FieldSignature(String className, Type fieldType, String fieldName) { + + this.className = className; + + this.fieldType = fieldType; + + this.fieldName = fieldName; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_className = vf.string(className); + + IValue iv_fieldType = fieldType.createVallangInstance(vf); + + IValue iv_fieldName = vf.string(fieldName); + + return vf.constructor(getVallangConstructor() + + , iv_className + + , iv_fieldType + + , iv_fieldName + + ); + } + + @Override + public String getConstructor() { + return "fieldSignature"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/GotoStmt.java b/src/main/java/lang/jimple/internal/generated/GotoStmt.java index 532ae2fe..29fb8f63 100644 --- a/src/main/java/lang/jimple/internal/generated/GotoStmt.java +++ b/src/main/java/lang/jimple/internal/generated/GotoStmt.java @@ -1,57 +1,47 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class GotoStmt extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "GotoStmt"; - } - - - - - public String label; - - - public static GotoStmt gotoStmt(String label) { - return new GotoStmt(label); - } - - public GotoStmt(String label) { - - this.label = label; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_label = vf.string(label); - - - return vf.constructor(getVallangConstructor() - - , iv_label - - ); - } - - @Override - public String getConstructor() { - return "gotoStmt"; - } - - - +public class GotoStmt extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "GotoStmt"; + } + + public String label; + + public static GotoStmt gotoStmt(String label) { + return new GotoStmt(label); + } + + public GotoStmt(String label) { + + this.label = label; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_label = vf.string(label); + + return vf.constructor(getVallangConstructor() + + , iv_label + + ); + } + + @Override + public String getConstructor() { + return "gotoStmt"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Immediate.java b/src/main/java/lang/jimple/internal/generated/Immediate.java index 98c5bb74..55c84b44 100644 --- a/src/main/java/lang/jimple/internal/generated/Immediate.java +++ b/src/main/java/lang/jimple/internal/generated/Immediate.java @@ -1,126 +1,108 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Immediate extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Immediate"; - } - - - - public static Immediate local(String localName) { - return new c_local(localName); - } - - public static Immediate iValue(Value v) { - return new c_iValue(v); - } - - public static Immediate caughtException() { - return new c_caughtException(); - } - - - - @EqualsAndHashCode - public static class c_local extends Immediate { - - public String localName; - - - public c_local(String localName) { - - this.localName = localName; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_localName = vf.string(localName); - - - return vf.constructor(getVallangConstructor() - - , iv_localName - - ); - } - - @Override - public String getConstructor() { - return "local"; - } - } - - @EqualsAndHashCode - public static class c_iValue extends Immediate { - - public Value v; - - - public c_iValue(Value v) { - - this.v = v; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_v = v.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_v - - ); - } - - @Override - public String getConstructor() { - return "iValue"; - } - } - - @EqualsAndHashCode - public static class c_caughtException extends Immediate { - - - public c_caughtException() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "caughtException"; - } - } - - + @Override + public String getBaseType() { + return "Immediate"; + } + + public static Immediate local(String localName) { + return new c_local(localName); + } + + public static Immediate iValue(Value v) { + return new c_iValue(v); + } + + public static Immediate caughtException() { + return new c_caughtException(); + } + + @EqualsAndHashCode + public static class c_local extends Immediate { + + public String localName; + + public c_local(String localName) { + + this.localName = localName; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_localName = vf.string(localName); + + return vf.constructor(getVallangConstructor() + + , iv_localName + + ); + } + + @Override + public String getConstructor() { + return "local"; + } + } + + @EqualsAndHashCode + public static class c_iValue extends Immediate { + + public Value v; + + public c_iValue(Value v) { + + this.v = v; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_v = v.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_v + + ); + } + + @Override + public String getConstructor() { + return "iValue"; + } + } + + @EqualsAndHashCode + public static class c_caughtException extends Immediate { + + public c_caughtException() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "caughtException"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/InvokeExp.java b/src/main/java/lang/jimple/internal/generated/InvokeExp.java index 9fbfa0b3..2d0b1878 100644 --- a/src/main/java/lang/jimple/internal/generated/InvokeExp.java +++ b/src/main/java/lang/jimple/internal/generated/InvokeExp.java @@ -1,316 +1,291 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class InvokeExp extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "InvokeExp"; - } - - - - public static InvokeExp specialInvoke(String local, MethodSignature sig, List args) { - return new c_specialInvoke(local, sig, args); - } - - public static InvokeExp virtualInvoke(String local, MethodSignature sig, List args) { - return new c_virtualInvoke(local, sig, args); - } - - public static InvokeExp interfaceInvoke(String local, MethodSignature sig, List args) { - return new c_interfaceInvoke(local, sig, args); - } - - public static InvokeExp staticMethodInvoke(MethodSignature sig, List args) { - return new c_staticMethodInvoke(sig, args); - } - - public static InvokeExp dynamicInvoke(MethodSignature bsmSig, List bsmArgs, MethodSignature sig, List args) { - return new c_dynamicInvoke(bsmSig, bsmArgs, sig, args); - } - - - - @EqualsAndHashCode - public static class c_specialInvoke extends InvokeExp { - - public String local; - - public MethodSignature sig; - - public List args; - - - public c_specialInvoke(String local, MethodSignature sig, List args) { - - this.local = local; - - this.sig = sig; - - this.args = args; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_local = vf.string(local); - - IValue iv_sig = sig.createVallangInstance(vf); - - IList iv_args = vf.list(); - - for(Immediate v: args) { - iv_args = iv_args.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_local - - , iv_sig - - , iv_args - - ); - } - - @Override - public String getConstructor() { - return "specialInvoke"; - } - } - - @EqualsAndHashCode - public static class c_virtualInvoke extends InvokeExp { - - public String local; - - public MethodSignature sig; - - public List args; - - - public c_virtualInvoke(String local, MethodSignature sig, List args) { - - this.local = local; - - this.sig = sig; - - this.args = args; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_local = vf.string(local); - - IValue iv_sig = sig.createVallangInstance(vf); - - IList iv_args = vf.list(); - - for(Immediate v: args) { - iv_args = iv_args.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_local - - , iv_sig - - , iv_args - - ); - } - - @Override - public String getConstructor() { - return "virtualInvoke"; - } - } - - @EqualsAndHashCode - public static class c_interfaceInvoke extends InvokeExp { - - public String local; - - public MethodSignature sig; - - public List args; - - - public c_interfaceInvoke(String local, MethodSignature sig, List args) { - - this.local = local; - - this.sig = sig; - - this.args = args; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_local = vf.string(local); - - IValue iv_sig = sig.createVallangInstance(vf); - - IList iv_args = vf.list(); - - for(Immediate v: args) { - iv_args = iv_args.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_local - - , iv_sig - - , iv_args - - ); - } - - @Override - public String getConstructor() { - return "interfaceInvoke"; - } - } - - @EqualsAndHashCode - public static class c_staticMethodInvoke extends InvokeExp { - - public MethodSignature sig; - - public List args; - - - public c_staticMethodInvoke(MethodSignature sig, List args) { - - this.sig = sig; - - this.args = args; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_sig = sig.createVallangInstance(vf); - - IList iv_args = vf.list(); - - for(Immediate v: args) { - iv_args = iv_args.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_sig - - , iv_args - - ); - } - - @Override - public String getConstructor() { - return "staticMethodInvoke"; - } - } - - @EqualsAndHashCode - public static class c_dynamicInvoke extends InvokeExp { - - public MethodSignature bsmSig; - - public List bsmArgs; - - public MethodSignature sig; - - public List args; - - - public c_dynamicInvoke(MethodSignature bsmSig, List bsmArgs, MethodSignature sig, List args) { - - this.bsmSig = bsmSig; - - this.bsmArgs = bsmArgs; - - this.sig = sig; - - this.args = args; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_bsmSig = bsmSig.createVallangInstance(vf); - - IList iv_bsmArgs = vf.list(); - - for(Immediate v: bsmArgs) { - iv_bsmArgs = iv_bsmArgs.append(v.createVallangInstance(vf)); - } - - - IValue iv_sig = sig.createVallangInstance(vf); - - IList iv_args = vf.list(); - - for(Immediate v: args) { - iv_args = iv_args.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_bsmSig - - , iv_bsmArgs - - , iv_sig - - , iv_args - - ); - } - - @Override - public String getConstructor() { - return "dynamicInvoke"; - } - } - - + @Override + public String getBaseType() { + return "InvokeExp"; + } + + public static InvokeExp specialInvoke(String local, MethodSignature sig, List args) { + return new c_specialInvoke(local, sig, args); + } + + public static InvokeExp virtualInvoke(String local, MethodSignature sig, List args) { + return new c_virtualInvoke(local, sig, args); + } + + public static InvokeExp interfaceInvoke(String local, MethodSignature sig, List args) { + return new c_interfaceInvoke(local, sig, args); + } + + public static InvokeExp staticMethodInvoke(MethodSignature sig, List args) { + return new c_staticMethodInvoke(sig, args); + } + + public static InvokeExp dynamicInvoke(MethodSignature bsmSig, List bsmArgs, MethodSignature sig, + List args) { + return new c_dynamicInvoke(bsmSig, bsmArgs, sig, args); + } + + @EqualsAndHashCode + public static class c_specialInvoke extends InvokeExp { + + public String local; + + public MethodSignature sig; + + public List args; + + public c_specialInvoke(String local, MethodSignature sig, List args) { + + this.local = local; + + this.sig = sig; + + this.args = args; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_local = vf.string(local); + + IValue iv_sig = sig.createVallangInstance(vf); + + IList iv_args = vf.list(); + + for (Immediate v : args) { + iv_args = iv_args.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_local + + , iv_sig + + , iv_args + + ); + } + + @Override + public String getConstructor() { + return "specialInvoke"; + } + } + + @EqualsAndHashCode + public static class c_virtualInvoke extends InvokeExp { + + public String local; + + public MethodSignature sig; + + public List args; + + public c_virtualInvoke(String local, MethodSignature sig, List args) { + + this.local = local; + + this.sig = sig; + + this.args = args; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_local = vf.string(local); + + IValue iv_sig = sig.createVallangInstance(vf); + + IList iv_args = vf.list(); + + for (Immediate v : args) { + iv_args = iv_args.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_local + + , iv_sig + + , iv_args + + ); + } + + @Override + public String getConstructor() { + return "virtualInvoke"; + } + } + + @EqualsAndHashCode + public static class c_interfaceInvoke extends InvokeExp { + + public String local; + + public MethodSignature sig; + + public List args; + + public c_interfaceInvoke(String local, MethodSignature sig, List args) { + + this.local = local; + + this.sig = sig; + + this.args = args; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_local = vf.string(local); + + IValue iv_sig = sig.createVallangInstance(vf); + + IList iv_args = vf.list(); + + for (Immediate v : args) { + iv_args = iv_args.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_local + + , iv_sig + + , iv_args + + ); + } + + @Override + public String getConstructor() { + return "interfaceInvoke"; + } + } + + @EqualsAndHashCode + public static class c_staticMethodInvoke extends InvokeExp { + + public MethodSignature sig; + + public List args; + + public c_staticMethodInvoke(MethodSignature sig, List args) { + + this.sig = sig; + + this.args = args; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_sig = sig.createVallangInstance(vf); + + IList iv_args = vf.list(); + + for (Immediate v : args) { + iv_args = iv_args.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_sig + + , iv_args + + ); + } + + @Override + public String getConstructor() { + return "staticMethodInvoke"; + } + } + + @EqualsAndHashCode + public static class c_dynamicInvoke extends InvokeExp { + + public MethodSignature bsmSig; + + public List bsmArgs; + + public MethodSignature sig; + + public List args; + + public c_dynamicInvoke(MethodSignature bsmSig, List bsmArgs, MethodSignature sig, + List args) { + + this.bsmSig = bsmSig; + + this.bsmArgs = bsmArgs; + + this.sig = sig; + + this.args = args; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_bsmSig = bsmSig.createVallangInstance(vf); + + IList iv_bsmArgs = vf.list(); + + for (Immediate v : bsmArgs) { + iv_bsmArgs = iv_bsmArgs.append(v.createVallangInstance(vf)); + } + + IValue iv_sig = sig.createVallangInstance(vf); + + IList iv_args = vf.list(); + + for (Immediate v : args) { + iv_args = iv_args.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_bsmSig + + , iv_bsmArgs + + , iv_sig + + , iv_args + + ); + } + + @Override + public String getConstructor() { + return "dynamicInvoke"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/LocalVariableDeclaration.java b/src/main/java/lang/jimple/internal/generated/LocalVariableDeclaration.java index 3a5a1169..19399009 100644 --- a/src/main/java/lang/jimple/internal/generated/LocalVariableDeclaration.java +++ b/src/main/java/lang/jimple/internal/generated/LocalVariableDeclaration.java @@ -1,65 +1,55 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class LocalVariableDeclaration extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "LocalVariableDeclaration"; - } - - - - - public Type varType; - - public String local; - - - public static LocalVariableDeclaration localVariableDeclaration(Type varType, String local) { - return new LocalVariableDeclaration(varType, local); - } - - public LocalVariableDeclaration(Type varType, String local) { - - this.varType = varType; - - this.local = local; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_varType = varType.createVallangInstance(vf); - - IValue iv_local = vf.string(local); - - - return vf.constructor(getVallangConstructor() - - , iv_varType - - , iv_local - - ); - } - - @Override - public String getConstructor() { - return "localVariableDeclaration"; - } - - - +public class LocalVariableDeclaration extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "LocalVariableDeclaration"; + } + + public Type varType; + + public String local; + + public static LocalVariableDeclaration localVariableDeclaration(Type varType, String local) { + return new LocalVariableDeclaration(varType, local); + } + + public LocalVariableDeclaration(Type varType, String local) { + + this.varType = varType; + + this.local = local; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_varType = varType.createVallangInstance(vf); + + IValue iv_local = vf.string(local); + + return vf.constructor(getVallangConstructor() + + , iv_varType + + , iv_local + + ); + } + + @Override + public String getConstructor() { + return "localVariableDeclaration"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Method.java b/src/main/java/lang/jimple/internal/generated/Method.java index aba9434f..e8f187ec 100644 --- a/src/main/java/lang/jimple/internal/generated/Method.java +++ b/src/main/java/lang/jimple/internal/generated/Method.java @@ -1,112 +1,104 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class Method extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Method"; - } - - - - - public List modifiers; - - public Type returnType; - - public String name; - - public List formals; - - public List exceptions; - - public MethodBody body; - - - public static Method method(List modifiers, Type returnType, String name, List formals, List exceptions, MethodBody body) { - return new Method(modifiers, returnType, name, formals, exceptions, body); - } - - public Method(List modifiers, Type returnType, String name, List formals, List exceptions, MethodBody body) { - - this.modifiers = modifiers; - - this.returnType = returnType; - - this.name = name; - - this.formals = formals; - - this.exceptions = exceptions; - - this.body = body; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IList iv_modifiers = vf.list(); - - for(Modifier v: modifiers) { - iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); - } - - - IValue iv_returnType = returnType.createVallangInstance(vf); - - IValue iv_name = vf.string(name); - - IList iv_formals = vf.list(); - - for(Type v: formals) { - iv_formals = iv_formals.append(v.createVallangInstance(vf)); - } - - - IList iv_exceptions = vf.list(); - - for(Type v: exceptions) { - iv_exceptions = iv_exceptions.append(v.createVallangInstance(vf)); - } - - - IValue iv_body = body.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_modifiers - - , iv_returnType - - , iv_name - - , iv_formals - - , iv_exceptions - - , iv_body - - ); - } - - @Override - public String getConstructor() { - return "method"; - } - - - +public class Method extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "Method"; + } + + public List modifiers; + + public Type returnType; + + public String name; + + public List formals; + + public List exceptions; + + public MethodBody body; + + public static Method method(List modifiers, Type returnType, String name, List formals, + List exceptions, MethodBody body) { + return new Method(modifiers, returnType, name, formals, exceptions, body); + } + + public Method(List modifiers, Type returnType, String name, List formals, List exceptions, + MethodBody body) { + + this.modifiers = modifiers; + + this.returnType = returnType; + + this.name = name; + + this.formals = formals; + + this.exceptions = exceptions; + + this.body = body; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IList iv_modifiers = vf.list(); + + for (Modifier v : modifiers) { + iv_modifiers = iv_modifiers.append(v.createVallangInstance(vf)); + } + + IValue iv_returnType = returnType.createVallangInstance(vf); + + IValue iv_name = vf.string(name); + + IList iv_formals = vf.list(); + + for (Type v : formals) { + iv_formals = iv_formals.append(v.createVallangInstance(vf)); + } + + IList iv_exceptions = vf.list(); + + for (Type v : exceptions) { + iv_exceptions = iv_exceptions.append(v.createVallangInstance(vf)); + } + + IValue iv_body = body.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_modifiers + + , iv_returnType + + , iv_name + + , iv_formals + + , iv_exceptions + + , iv_body + + ); + } + + @Override + public String getConstructor() { + return "method"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/MethodBody.java b/src/main/java/lang/jimple/internal/generated/MethodBody.java index 6a66dab2..011c411c 100644 --- a/src/main/java/lang/jimple/internal/generated/MethodBody.java +++ b/src/main/java/lang/jimple/internal/generated/MethodBody.java @@ -1,121 +1,107 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; -import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class MethodBody extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "MethodBody"; - } - - - - public static MethodBody methodBody(List localVariableDecls, List stmts, List catchClauses) { - return new c_methodBody(localVariableDecls, stmts, catchClauses); - } - - public static MethodBody signatureOnly() { - return new c_signatureOnly(); - } - - - - @EqualsAndHashCode - public static class c_methodBody extends MethodBody { - - public List localVariableDecls; - - public List stmts; - - public List catchClauses; - - - public c_methodBody(List localVariableDecls, List stmts, List catchClauses) { - - this.localVariableDecls = localVariableDecls; - - this.stmts = stmts; - - this.catchClauses = catchClauses; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IList iv_localVariableDecls = vf.list(); - - for(LocalVariableDeclaration v: localVariableDecls) { - iv_localVariableDecls = iv_localVariableDecls.append(v.createVallangInstance(vf)); - } - - - IList iv_stmts = vf.list(); - - for(Statement v: stmts) { - iv_stmts = iv_stmts.append(v.createVallangInstance(vf)); - } - - - IList iv_catchClauses = vf.list(); - - for(CatchClause v: catchClauses) { - iv_catchClauses = iv_catchClauses.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_localVariableDecls - - , iv_stmts - - , iv_catchClauses - - ); - } - - @Override - public String getConstructor() { - return "methodBody"; - } - } - - @EqualsAndHashCode - public static class c_signatureOnly extends MethodBody { - - - public c_signatureOnly() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "signatureOnly"; - } - } - - + @Override + public String getBaseType() { + return "MethodBody"; + } + + public static MethodBody methodBody(List localVariableDecls, List stmts, + List catchClauses) { + return new c_methodBody(localVariableDecls, stmts, catchClauses); + } + + public static MethodBody signatureOnly() { + return new c_signatureOnly(); + } + + @EqualsAndHashCode + public static class c_methodBody extends MethodBody { + + public List localVariableDecls; + + public List stmts; + + public List catchClauses; + + public c_methodBody(List localVariableDecls, List stmts, + List catchClauses) { + + this.localVariableDecls = localVariableDecls; + + this.stmts = stmts; + + this.catchClauses = catchClauses; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IList iv_localVariableDecls = vf.list(); + + for (LocalVariableDeclaration v : localVariableDecls) { + iv_localVariableDecls = iv_localVariableDecls.append(v.createVallangInstance(vf)); + } + + IList iv_stmts = vf.list(); + + for (Statement v : stmts) { + iv_stmts = iv_stmts.append(v.createVallangInstance(vf)); + } + + IList iv_catchClauses = vf.list(); + + for (CatchClause v : catchClauses) { + iv_catchClauses = iv_catchClauses.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_localVariableDecls + + , iv_stmts + + , iv_catchClauses + + ); + } + + @Override + public String getConstructor() { + return "methodBody"; + } + } + + @EqualsAndHashCode + public static class c_signatureOnly extends MethodBody { + + public c_signatureOnly() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "signatureOnly"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/MethodSignature.java b/src/main/java/lang/jimple/internal/generated/MethodSignature.java index 7fdf7e6e..d9a885f5 100644 --- a/src/main/java/lang/jimple/internal/generated/MethodSignature.java +++ b/src/main/java/lang/jimple/internal/generated/MethodSignature.java @@ -1,86 +1,79 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class MethodSignature extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "MethodSignature"; - } - - - - - public String className; - - public Type returnType; - - public String methodName; - - public List formals; - - - public static MethodSignature methodSignature(String className, Type returnType, String methodName, List formals) { - return new MethodSignature(className, returnType, methodName, formals); - } - - public MethodSignature(String className, Type returnType, String methodName, List formals) { - - this.className = className; - - this.returnType = returnType; - - this.methodName = methodName; - - this.formals = formals; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_className = vf.string(className); - - IValue iv_returnType = returnType.createVallangInstance(vf); - - IValue iv_methodName = vf.string(methodName); - - IList iv_formals = vf.list(); - - for(Type v: formals) { - iv_formals = iv_formals.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_className - - , iv_returnType - - , iv_methodName - - , iv_formals - - ); - } - - @Override - public String getConstructor() { - return "methodSignature"; - } - - - +public class MethodSignature extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "MethodSignature"; + } + + public String className; + + public Type returnType; + + public String methodName; + + public List formals; + + public static MethodSignature methodSignature(String className, Type returnType, String methodName, + List formals) { + return new MethodSignature(className, returnType, methodName, formals); + } + + public MethodSignature(String className, Type returnType, String methodName, List formals) { + + this.className = className; + + this.returnType = returnType; + + this.methodName = methodName; + + this.formals = formals; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_className = vf.string(className); + + IValue iv_returnType = returnType.createVallangInstance(vf); + + IValue iv_methodName = vf.string(methodName); + + IList iv_formals = vf.list(); + + for (Type v : formals) { + iv_formals = iv_formals.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_className + + , iv_returnType + + , iv_methodName + + , iv_formals + + ); + } + + @Override + public String getConstructor() { + return "methodSignature"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Modifier.java b/src/main/java/lang/jimple/internal/generated/Modifier.java index beb83169..784adfef 100644 --- a/src/main/java/lang/jimple/internal/generated/Modifier.java +++ b/src/main/java/lang/jimple/internal/generated/Modifier.java @@ -1,418 +1,366 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; -import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Modifier extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Modifier"; - } - - - - public static Modifier Abstract() { - return new c_Abstract(); - } - - public static Modifier Final() { - return new c_Final(); - } - - public static Modifier Native() { - return new c_Native(); - } - - public static Modifier Public() { - return new c_Public(); - } - - public static Modifier Protected() { - return new c_Protected(); - } - - public static Modifier Private() { - return new c_Private(); - } - - public static Modifier Static() { - return new c_Static(); - } - - public static Modifier Synchronized() { - return new c_Synchronized(); - } - - public static Modifier Transient() { - return new c_Transient(); - } - - public static Modifier Volatile() { - return new c_Volatile(); - } - - public static Modifier Strictfp() { - return new c_Strictfp(); - } - - public static Modifier Enum() { - return new c_Enum(); - } - - public static Modifier Annotation() { - return new c_Annotation(); - } - - public static Modifier Synthetic() { - return new c_Synthetic(); - } - - - - @EqualsAndHashCode - public static class c_Abstract extends Modifier { - - - public c_Abstract() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Abstract"; - } - } - - @EqualsAndHashCode - public static class c_Final extends Modifier { - - - public c_Final() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Final"; - } - } - - @EqualsAndHashCode - public static class c_Native extends Modifier { - - - public c_Native() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Native"; - } - } - - @EqualsAndHashCode - public static class c_Public extends Modifier { - - - public c_Public() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Public"; - } - } - - @EqualsAndHashCode - public static class c_Protected extends Modifier { - - - public c_Protected() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Protected"; - } - } - - @EqualsAndHashCode - public static class c_Private extends Modifier { - - - public c_Private() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Private"; - } - } - - @EqualsAndHashCode - public static class c_Static extends Modifier { - - - public c_Static() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Static"; - } - } - - @EqualsAndHashCode - public static class c_Synchronized extends Modifier { - - - public c_Synchronized() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Synchronized"; - } - } - - @EqualsAndHashCode - public static class c_Transient extends Modifier { - - - public c_Transient() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Transient"; - } - } - - @EqualsAndHashCode - public static class c_Volatile extends Modifier { - - - public c_Volatile() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Volatile"; - } - } - - @EqualsAndHashCode - public static class c_Strictfp extends Modifier { - - - public c_Strictfp() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Strictfp"; - } - } - - @EqualsAndHashCode - public static class c_Enum extends Modifier { - - - public c_Enum() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Enum"; - } - } - - @EqualsAndHashCode - public static class c_Annotation extends Modifier { - - - public c_Annotation() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Annotation"; - } - } - - @EqualsAndHashCode - public static class c_Synthetic extends Modifier { - - - public c_Synthetic() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "Synthetic"; - } - } - - + @Override + public String getBaseType() { + return "Modifier"; + } + + public static Modifier Abstract() { + return new c_Abstract(); + } + + public static Modifier Final() { + return new c_Final(); + } + + public static Modifier Native() { + return new c_Native(); + } + + public static Modifier Public() { + return new c_Public(); + } + + public static Modifier Protected() { + return new c_Protected(); + } + + public static Modifier Private() { + return new c_Private(); + } + + public static Modifier Static() { + return new c_Static(); + } + + public static Modifier Synchronized() { + return new c_Synchronized(); + } + + public static Modifier Transient() { + return new c_Transient(); + } + + public static Modifier Volatile() { + return new c_Volatile(); + } + + public static Modifier Strictfp() { + return new c_Strictfp(); + } + + public static Modifier Enum() { + return new c_Enum(); + } + + public static Modifier Annotation() { + return new c_Annotation(); + } + + public static Modifier Synthetic() { + return new c_Synthetic(); + } + + @EqualsAndHashCode + public static class c_Abstract extends Modifier { + + public c_Abstract() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Abstract"; + } + } + + @EqualsAndHashCode + public static class c_Final extends Modifier { + + public c_Final() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Final"; + } + } + + @EqualsAndHashCode + public static class c_Native extends Modifier { + + public c_Native() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Native"; + } + } + + @EqualsAndHashCode + public static class c_Public extends Modifier { + + public c_Public() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Public"; + } + } + + @EqualsAndHashCode + public static class c_Protected extends Modifier { + + public c_Protected() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Protected"; + } + } + + @EqualsAndHashCode + public static class c_Private extends Modifier { + + public c_Private() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Private"; + } + } + + @EqualsAndHashCode + public static class c_Static extends Modifier { + + public c_Static() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Static"; + } + } + + @EqualsAndHashCode + public static class c_Synchronized extends Modifier { + + public c_Synchronized() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Synchronized"; + } + } + + @EqualsAndHashCode + public static class c_Transient extends Modifier { + + public c_Transient() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Transient"; + } + } + + @EqualsAndHashCode + public static class c_Volatile extends Modifier { + + public c_Volatile() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Volatile"; + } + } + + @EqualsAndHashCode + public static class c_Strictfp extends Modifier { + + public c_Strictfp() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Strictfp"; + } + } + + @EqualsAndHashCode + public static class c_Enum extends Modifier { + + public c_Enum() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Enum"; + } + } + + @EqualsAndHashCode + public static class c_Annotation extends Modifier { + + public c_Annotation() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Annotation"; + } + } + + @EqualsAndHashCode + public static class c_Synthetic extends Modifier { + + public c_Synthetic() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "Synthetic"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Type.java b/src/main/java/lang/jimple/internal/generated/Type.java index 8105fa91..f0172242 100644 --- a/src/main/java/lang/jimple/internal/generated/Type.java +++ b/src/main/java/lang/jimple/internal/generated/Type.java @@ -1,546 +1,483 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Type extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Type"; - } - - - - public static Type TByte() { - return new c_TByte(); - } - - public static Type TBoolean() { - return new c_TBoolean(); - } - - public static Type TShort() { - return new c_TShort(); - } - - public static Type TCharacter() { - return new c_TCharacter(); - } - - public static Type TInteger() { - return new c_TInteger(); - } - - public static Type TFloat() { - return new c_TFloat(); - } - - public static Type TDouble() { - return new c_TDouble(); - } - - public static Type TLong() { - return new c_TLong(); - } - - public static Type TObject(String name) { - return new c_TObject(name); - } - - public static Type TArray(Type baseType) { - return new c_TArray(baseType); - } - - public static Type TVoid() { - return new c_TVoid(); - } - - public static Type TString() { - return new c_TString(); - } - - public static Type TMethodValue() { - return new c_TMethodValue(); - } - - public static Type TClassValue() { - return new c_TClassValue(); - } - - public static Type TMethodHandle() { - return new c_TMethodHandle(); - } - - public static Type TFieldHandle() { - return new c_TFieldHandle(); - } - - public static Type TNull() { - return new c_TNull(); - } - - public static Type TUnknown() { - return new c_TUnknown(); - } - - - - @EqualsAndHashCode - public static class c_TByte extends Type { - - - public c_TByte() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TByte"; - } - } - - @EqualsAndHashCode - public static class c_TBoolean extends Type { - - - public c_TBoolean() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TBoolean"; - } - } - - @EqualsAndHashCode - public static class c_TShort extends Type { - - - public c_TShort() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TShort"; - } - } - - @EqualsAndHashCode - public static class c_TCharacter extends Type { - - - public c_TCharacter() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TCharacter"; - } - } - - @EqualsAndHashCode - public static class c_TInteger extends Type { - - - public c_TInteger() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TInteger"; - } - } - - @EqualsAndHashCode - public static class c_TFloat extends Type { - - - public c_TFloat() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TFloat"; - } - } - - @EqualsAndHashCode - public static class c_TDouble extends Type { - - - public c_TDouble() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TDouble"; - } - } - - @EqualsAndHashCode - public static class c_TLong extends Type { - - - public c_TLong() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TLong"; - } - } - - @EqualsAndHashCode - public static class c_TObject extends Type { - - public String name; - - - public c_TObject(String name) { - - this.name = name; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_name = vf.string(name); - - - return vf.constructor(getVallangConstructor() - - , iv_name - - ); - } - - @Override - public String getConstructor() { - return "TObject"; - } - } - - @EqualsAndHashCode - public static class c_TArray extends Type { - - public Type baseType; - - - public c_TArray(Type baseType) { - - this.baseType = baseType; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_baseType = baseType.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_baseType - - ); - } - - @Override - public String getConstructor() { - return "TArray"; - } - } - - @EqualsAndHashCode - public static class c_TVoid extends Type { - - - public c_TVoid() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TVoid"; - } - } - - @EqualsAndHashCode - public static class c_TString extends Type { - - - public c_TString() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TString"; - } - } - - @EqualsAndHashCode - public static class c_TMethodValue extends Type { - - - public c_TMethodValue() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TMethodValue"; - } - } - - @EqualsAndHashCode - public static class c_TClassValue extends Type { - - - public c_TClassValue() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TClassValue"; - } - } - - @EqualsAndHashCode - public static class c_TMethodHandle extends Type { - - - public c_TMethodHandle() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TMethodHandle"; - } - } - - @EqualsAndHashCode - public static class c_TFieldHandle extends Type { - - - public c_TFieldHandle() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TFieldHandle"; - } - } - - @EqualsAndHashCode - public static class c_TNull extends Type { - - - public c_TNull() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TNull"; - } - } - - @EqualsAndHashCode - public static class c_TUnknown extends Type { - - - public c_TUnknown() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "TUnknown"; - } - } - - + @Override + public String getBaseType() { + return "Type"; + } + + public static Type TByte() { + return new c_TByte(); + } + + public static Type TBoolean() { + return new c_TBoolean(); + } + + public static Type TShort() { + return new c_TShort(); + } + + public static Type TCharacter() { + return new c_TCharacter(); + } + + public static Type TInteger() { + return new c_TInteger(); + } + + public static Type TFloat() { + return new c_TFloat(); + } + + public static Type TDouble() { + return new c_TDouble(); + } + + public static Type TLong() { + return new c_TLong(); + } + + public static Type TObject(String name) { + return new c_TObject(name); + } + + public static Type TArray(Type baseType) { + return new c_TArray(baseType); + } + + public static Type TVoid() { + return new c_TVoid(); + } + + public static Type TString() { + return new c_TString(); + } + + public static Type TMethodValue() { + return new c_TMethodValue(); + } + + public static Type TClassValue() { + return new c_TClassValue(); + } + + public static Type TMethodHandle() { + return new c_TMethodHandle(); + } + + public static Type TFieldHandle() { + return new c_TFieldHandle(); + } + + public static Type TNull() { + return new c_TNull(); + } + + public static Type TUnknown() { + return new c_TUnknown(); + } + + @EqualsAndHashCode + public static class c_TByte extends Type { + + public c_TByte() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TByte"; + } + } + + @EqualsAndHashCode + public static class c_TBoolean extends Type { + + public c_TBoolean() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TBoolean"; + } + } + + @EqualsAndHashCode + public static class c_TShort extends Type { + + public c_TShort() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TShort"; + } + } + + @EqualsAndHashCode + public static class c_TCharacter extends Type { + + public c_TCharacter() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TCharacter"; + } + } + + @EqualsAndHashCode + public static class c_TInteger extends Type { + + public c_TInteger() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TInteger"; + } + } + + @EqualsAndHashCode + public static class c_TFloat extends Type { + + public c_TFloat() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TFloat"; + } + } + + @EqualsAndHashCode + public static class c_TDouble extends Type { + + public c_TDouble() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TDouble"; + } + } + + @EqualsAndHashCode + public static class c_TLong extends Type { + + public c_TLong() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TLong"; + } + } + + @EqualsAndHashCode + public static class c_TObject extends Type { + + public String name; + + public c_TObject(String name) { + + this.name = name; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_name = vf.string(name); + + return vf.constructor(getVallangConstructor() + + , iv_name + + ); + } + + @Override + public String getConstructor() { + return "TObject"; + } + } + + @EqualsAndHashCode + public static class c_TArray extends Type { + + public Type baseType; + + public c_TArray(Type baseType) { + + this.baseType = baseType; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_baseType = baseType.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_baseType + + ); + } + + @Override + public String getConstructor() { + return "TArray"; + } + } + + @EqualsAndHashCode + public static class c_TVoid extends Type { + + public c_TVoid() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TVoid"; + } + } + + @EqualsAndHashCode + public static class c_TString extends Type { + + public c_TString() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TString"; + } + } + + @EqualsAndHashCode + public static class c_TMethodValue extends Type { + + public c_TMethodValue() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TMethodValue"; + } + } + + @EqualsAndHashCode + public static class c_TClassValue extends Type { + + public c_TClassValue() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TClassValue"; + } + } + + @EqualsAndHashCode + public static class c_TMethodHandle extends Type { + + public c_TMethodHandle() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TMethodHandle"; + } + } + + @EqualsAndHashCode + public static class c_TFieldHandle extends Type { + + public c_TFieldHandle() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TFieldHandle"; + } + } + + @EqualsAndHashCode + public static class c_TNull extends Type { + + public c_TNull() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TNull"; + } + } + + @EqualsAndHashCode + public static class c_TUnknown extends Type { + + public c_TUnknown() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "TUnknown"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/UnnamedMethodSignature.java b/src/main/java/lang/jimple/internal/generated/UnnamedMethodSignature.java index adf388e7..e8d03f68 100644 --- a/src/main/java/lang/jimple/internal/generated/UnnamedMethodSignature.java +++ b/src/main/java/lang/jimple/internal/generated/UnnamedMethodSignature.java @@ -1,70 +1,62 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; +import io.usethesource.vallang.IValueFactory; @Builder @EqualsAndHashCode -public class UnnamedMethodSignature extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "UnnamedMethodSignature"; - } - - - - - public Type returnType; - - public List formals; - - - public static UnnamedMethodSignature unnamedMethodSignature(Type returnType, List formals) { - return new UnnamedMethodSignature(returnType, formals); - } - - public UnnamedMethodSignature(Type returnType, List formals) { - - this.returnType = returnType; - - this.formals = formals; - - } - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_returnType = returnType.createVallangInstance(vf); - - IList iv_formals = vf.list(); - - for(Type v: formals) { - iv_formals = iv_formals.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_returnType - - , iv_formals - - ); - } - - @Override - public String getConstructor() { - return "unnamedMethodSignature"; - } - - - +public class UnnamedMethodSignature extends JimpleAbstractDataType { + @Override + public String getBaseType() { + return "UnnamedMethodSignature"; + } + + public Type returnType; + + public List formals; + + public static UnnamedMethodSignature unnamedMethodSignature(Type returnType, List formals) { + return new UnnamedMethodSignature(returnType, formals); + } + + public UnnamedMethodSignature(Type returnType, List formals) { + + this.returnType = returnType; + + this.formals = formals; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_returnType = returnType.createVallangInstance(vf); + + IList iv_formals = vf.list(); + + for (Type v : formals) { + iv_formals = iv_formals.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_returnType + + , iv_formals + + ); + } + + @Override + public String getConstructor() { + return "unnamedMethodSignature"; + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Value.java b/src/main/java/lang/jimple/internal/generated/Value.java index ab788b54..d582617a 100644 --- a/src/main/java/lang/jimple/internal/generated/Value.java +++ b/src/main/java/lang/jimple/internal/generated/Value.java @@ -1,391 +1,354 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; +import lang.jimple.internal.JimpleAbstractDataType; +import java.util.List; -import lombok.*; +import lombok.*; import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Value extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Value"; - } - - - - public static Value intValue(Integer iv) { - return new c_intValue(iv); - } - - public static Value longValue(Long lv) { - return new c_longValue(lv); - } - - public static Value floatValue(Float fv) { - return new c_floatValue(fv); - } - - public static Value doubleValue(Double fv) { - return new c_doubleValue(fv); - } - - public static Value stringValue(String sv) { - return new c_stringValue(sv); - } - - public static Value methodValue(Type returnType, List formals) { - return new c_methodValue(returnType, formals); - } - - public static Value classValue(String name) { - return new c_classValue(name); - } - - public static Value methodHandle(MethodSignature methodSig) { - return new c_methodHandle(methodSig); - } - - public static Value fieldHandle(FieldSignature fieldSig) { - return new c_fieldHandle(fieldSig); - } - - public static Value nullValue() { - return new c_nullValue(); - } - - - - @EqualsAndHashCode - public static class c_intValue extends Value { - - public Integer iv; - - - public c_intValue(Integer iv) { - - this.iv = iv; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_iv = vf.integer(iv); - - - return vf.constructor(getVallangConstructor() - - , iv_iv - - ); - } - - @Override - public String getConstructor() { - return "intValue"; - } - } - - @EqualsAndHashCode - public static class c_longValue extends Value { - - public Long lv; - - - public c_longValue(Long lv) { - - this.lv = lv; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_lv = vf.integer(lv); - - - return vf.constructor(getVallangConstructor() - - , iv_lv - - ); - } - - @Override - public String getConstructor() { - return "longValue"; - } - } - - @EqualsAndHashCode - public static class c_floatValue extends Value { - - public Float fv; - - - public c_floatValue(Float fv) { - - this.fv = fv; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_fv = vf.real(fv); - - - return vf.constructor(getVallangConstructor() - - , iv_fv - - ); - } - - @Override - public String getConstructor() { - return "floatValue"; - } - } - - @EqualsAndHashCode - public static class c_doubleValue extends Value { - - public Double fv; - - - public c_doubleValue(Double fv) { - - this.fv = fv; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_fv = vf.real(fv); - - - return vf.constructor(getVallangConstructor() - - , iv_fv - - ); - } - - @Override - public String getConstructor() { - return "doubleValue"; - } - } - - @EqualsAndHashCode - public static class c_stringValue extends Value { - - public String sv; - - - public c_stringValue(String sv) { - - this.sv = sv; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_sv = vf.string(sv); - - - return vf.constructor(getVallangConstructor() - - , iv_sv - - ); - } - - @Override - public String getConstructor() { - return "stringValue"; - } - } - - @EqualsAndHashCode - public static class c_methodValue extends Value { - - public Type returnType; - - public List formals; - - - public c_methodValue(Type returnType, List formals) { - - this.returnType = returnType; - - this.formals = formals; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_returnType = returnType.createVallangInstance(vf); - - IList iv_formals = vf.list(); - - for(Type v: formals) { - iv_formals = iv_formals.append(v.createVallangInstance(vf)); - } - - - - return vf.constructor(getVallangConstructor() - - , iv_returnType - - , iv_formals - - ); - } - - @Override - public String getConstructor() { - return "methodValue"; - } - } - - @EqualsAndHashCode - public static class c_classValue extends Value { - - public String name; - - - public c_classValue(String name) { - - this.name = name; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_name = vf.string(name); - - - return vf.constructor(getVallangConstructor() - - , iv_name - - ); - } - - @Override - public String getConstructor() { - return "classValue"; - } - } - - @EqualsAndHashCode - public static class c_methodHandle extends Value { - - public MethodSignature methodSig; - - - public c_methodHandle(MethodSignature methodSig) { - - this.methodSig = methodSig; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_methodSig = methodSig.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_methodSig - - ); - } - - @Override - public String getConstructor() { - return "methodHandle"; - } - } - - @EqualsAndHashCode - public static class c_fieldHandle extends Value { - - public FieldSignature fieldSig; - - - public c_fieldHandle(FieldSignature fieldSig) { - - this.fieldSig = fieldSig; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_fieldSig = fieldSig.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_fieldSig - - ); - } - - @Override - public String getConstructor() { - return "fieldHandle"; - } - } - - @EqualsAndHashCode - public static class c_nullValue extends Value { - - - public c_nullValue() { - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - - return vf.constructor(getVallangConstructor() - - ); - } - - @Override - public String getConstructor() { - return "nullValue"; - } - } - - + @Override + public String getBaseType() { + return "Value"; + } + + public static Value intValue(Integer iv) { + return new c_intValue(iv); + } + + public static Value longValue(Long lv) { + return new c_longValue(lv); + } + + public static Value floatValue(Float fv) { + return new c_floatValue(fv); + } + + public static Value doubleValue(Double fv) { + return new c_doubleValue(fv); + } + + public static Value stringValue(String sv) { + return new c_stringValue(sv); + } + + public static Value methodValue(Type returnType, List formals) { + return new c_methodValue(returnType, formals); + } + + public static Value classValue(String name) { + return new c_classValue(name); + } + + public static Value methodHandle(MethodSignature methodSig) { + return new c_methodHandle(methodSig); + } + + public static Value fieldHandle(FieldSignature fieldSig) { + return new c_fieldHandle(fieldSig); + } + + public static Value nullValue() { + return new c_nullValue(); + } + + @EqualsAndHashCode + public static class c_intValue extends Value { + + public Integer iv; + + public c_intValue(Integer iv) { + + this.iv = iv; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_iv = vf.integer(iv); + + return vf.constructor(getVallangConstructor() + + , iv_iv + + ); + } + + @Override + public String getConstructor() { + return "intValue"; + } + } + + @EqualsAndHashCode + public static class c_longValue extends Value { + + public Long lv; + + public c_longValue(Long lv) { + + this.lv = lv; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_lv = vf.integer(lv); + + return vf.constructor(getVallangConstructor() + + , iv_lv + + ); + } + + @Override + public String getConstructor() { + return "longValue"; + } + } + + @EqualsAndHashCode + public static class c_floatValue extends Value { + + public Float fv; + + public c_floatValue(Float fv) { + + this.fv = fv; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_fv = vf.real(fv); + + return vf.constructor(getVallangConstructor() + + , iv_fv + + ); + } + + @Override + public String getConstructor() { + return "floatValue"; + } + } + + @EqualsAndHashCode + public static class c_doubleValue extends Value { + + public Double fv; + + public c_doubleValue(Double fv) { + + this.fv = fv; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_fv = vf.real(fv); + + return vf.constructor(getVallangConstructor() + + , iv_fv + + ); + } + + @Override + public String getConstructor() { + return "doubleValue"; + } + } + + @EqualsAndHashCode + public static class c_stringValue extends Value { + + public String sv; + + public c_stringValue(String sv) { + + this.sv = sv; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_sv = vf.string(sv); + + return vf.constructor(getVallangConstructor() + + , iv_sv + + ); + } + + @Override + public String getConstructor() { + return "stringValue"; + } + } + + @EqualsAndHashCode + public static class c_methodValue extends Value { + + public Type returnType; + + public List formals; + + public c_methodValue(Type returnType, List formals) { + + this.returnType = returnType; + + this.formals = formals; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_returnType = returnType.createVallangInstance(vf); + + IList iv_formals = vf.list(); + + for (Type v : formals) { + iv_formals = iv_formals.append(v.createVallangInstance(vf)); + } + + return vf.constructor(getVallangConstructor() + + , iv_returnType + + , iv_formals + + ); + } + + @Override + public String getConstructor() { + return "methodValue"; + } + } + + @EqualsAndHashCode + public static class c_classValue extends Value { + + public String name; + + public c_classValue(String name) { + + this.name = name; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_name = vf.string(name); + + return vf.constructor(getVallangConstructor() + + , iv_name + + ); + } + + @Override + public String getConstructor() { + return "classValue"; + } + } + + @EqualsAndHashCode + public static class c_methodHandle extends Value { + + public MethodSignature methodSig; + + public c_methodHandle(MethodSignature methodSig) { + + this.methodSig = methodSig; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_methodSig = methodSig.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_methodSig + + ); + } + + @Override + public String getConstructor() { + return "methodHandle"; + } + } + + @EqualsAndHashCode + public static class c_fieldHandle extends Value { + + public FieldSignature fieldSig; + + public c_fieldHandle(FieldSignature fieldSig) { + + this.fieldSig = fieldSig; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_fieldSig = fieldSig.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_fieldSig + + ); + } + + @Override + public String getConstructor() { + return "fieldHandle"; + } + } + + @EqualsAndHashCode + public static class c_nullValue extends Value { + + public c_nullValue() { + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + return vf.constructor(getVallangConstructor() + + ); + } + + @Override + public String getConstructor() { + return "nullValue"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/internal/generated/Variable.java b/src/main/java/lang/jimple/internal/generated/Variable.java index cc41cb0b..b2f6a4f2 100644 --- a/src/main/java/lang/jimple/internal/generated/Variable.java +++ b/src/main/java/lang/jimple/internal/generated/Variable.java @@ -1,186 +1,165 @@ package lang.jimple.internal.generated; -import lang.jimple.internal.JimpleAbstractDataType; -import java.util.List; - -import lombok.*; +import lang.jimple.internal.JimpleAbstractDataType; +import lombok.*; import io.usethesource.vallang.IConstructor; -import io.usethesource.vallang.IList; import io.usethesource.vallang.IValue; -import io.usethesource.vallang.IValueFactory; - +import io.usethesource.vallang.IValueFactory; @EqualsAndHashCode public abstract class Variable extends JimpleAbstractDataType { - @Override - public String getBaseType() { - return "Variable"; - } - - - - public static Variable localVariable(String local) { - return new c_localVariable(local); - } - - public static Variable arrayRef(String reference, Immediate idx) { - return new c_arrayRef(reference, idx); - } - - public static Variable fieldRef(String reference, FieldSignature field) { - return new c_fieldRef(reference, field); - } - - public static Variable staticFieldRef(FieldSignature field) { - return new c_staticFieldRef(field); - } - - - - @EqualsAndHashCode - public static class c_localVariable extends Variable { - - public String local; - - - public c_localVariable(String local) { - - this.local = local; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_local = vf.string(local); - - - return vf.constructor(getVallangConstructor() - - , iv_local - - ); - } - - @Override - public String getConstructor() { - return "localVariable"; - } - } - - @EqualsAndHashCode - public static class c_arrayRef extends Variable { - - public String reference; - - public Immediate idx; - - - public c_arrayRef(String reference, Immediate idx) { - - this.reference = reference; - - this.idx = idx; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_reference = vf.string(reference); - - IValue iv_idx = idx.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_reference - - , iv_idx - - ); - } - - @Override - public String getConstructor() { - return "arrayRef"; - } - } - - @EqualsAndHashCode - public static class c_fieldRef extends Variable { - - public String reference; - - public FieldSignature field; - - - public c_fieldRef(String reference, FieldSignature field) { - - this.reference = reference; - - this.field = field; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_reference = vf.string(reference); - - IValue iv_field = field.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_reference - - , iv_field - - ); - } - - @Override - public String getConstructor() { - return "fieldRef"; - } - } - - @EqualsAndHashCode - public static class c_staticFieldRef extends Variable { - - public FieldSignature field; - - - public c_staticFieldRef(FieldSignature field) { - - this.field = field; - - } - - @Override - public IConstructor createVallangInstance(IValueFactory vf) { - - - IValue iv_field = field.createVallangInstance(vf); - - - return vf.constructor(getVallangConstructor() - - , iv_field - - ); - } - - @Override - public String getConstructor() { - return "staticFieldRef"; - } - } - - + @Override + public String getBaseType() { + return "Variable"; + } + + public static Variable localVariable(String local) { + return new c_localVariable(local); + } + + public static Variable arrayRef(String reference, Immediate idx) { + return new c_arrayRef(reference, idx); + } + + public static Variable fieldRef(String reference, FieldSignature field) { + return new c_fieldRef(reference, field); + } + + public static Variable staticFieldRef(FieldSignature field) { + return new c_staticFieldRef(field); + } + + @EqualsAndHashCode + public static class c_localVariable extends Variable { + + public String local; + + public c_localVariable(String local) { + + this.local = local; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_local = vf.string(local); + + return vf.constructor(getVallangConstructor() + + , iv_local + + ); + } + + @Override + public String getConstructor() { + return "localVariable"; + } + } + + @EqualsAndHashCode + public static class c_arrayRef extends Variable { + + public String reference; + + public Immediate idx; + + public c_arrayRef(String reference, Immediate idx) { + + this.reference = reference; + + this.idx = idx; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_reference = vf.string(reference); + + IValue iv_idx = idx.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_reference + + , iv_idx + + ); + } + + @Override + public String getConstructor() { + return "arrayRef"; + } + } + + @EqualsAndHashCode + public static class c_fieldRef extends Variable { + + public String reference; + + public FieldSignature field; + + public c_fieldRef(String reference, FieldSignature field) { + + this.reference = reference; + + this.field = field; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_reference = vf.string(reference); + + IValue iv_field = field.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_reference + + , iv_field + + ); + } + + @Override + public String getConstructor() { + return "fieldRef"; + } + } + + @EqualsAndHashCode + public static class c_staticFieldRef extends Variable { + + public FieldSignature field; + + public c_staticFieldRef(FieldSignature field) { + + this.field = field; + + } + + @Override + public IConstructor createVallangInstance(IValueFactory vf) { + + IValue iv_field = field.createVallangInstance(vf); + + return vf.constructor(getVallangConstructor() + + , iv_field + + ); + } + + @Override + public String getConstructor() { + return "staticFieldRef"; + } + } + } \ No newline at end of file diff --git a/src/main/java/lang/jimple/util/Pair.java b/src/main/java/lang/jimple/util/Pair.java index 86ea2818..f35d4248 100644 --- a/src/main/java/lang/jimple/util/Pair.java +++ b/src/main/java/lang/jimple/util/Pair.java @@ -6,8 +6,8 @@ @Data @AllArgsConstructor public class Pair { - - First first; - Second second; + + First first; + Second second; } diff --git a/src/main/rascal/lang/jimple/core/Syntax.rsc b/src/main/rascal/lang/jimple/core/Syntax.rsc index b2979589..68f5f257 100644 --- a/src/main/rascal/lang/jimple/core/Syntax.rsc +++ b/src/main/rascal/lang/jimple/core/Syntax.rsc @@ -192,7 +192,7 @@ data Type | TFloat() | TDouble() | TLong() - | TObject(Name name) + | TObject(Name name) | TArray(Type baseType) | TVoid() | TString() diff --git a/src/main/rascal/lang/jimple/decompiler/jimplify/LambdaTransformer.rsc b/src/main/rascal/lang/jimple/decompiler/jimplify/LambdaTransformer.rsc index 50111aff..d92fe412 100644 --- a/src/main/rascal/lang/jimple/decompiler/jimplify/LambdaTransformer.rsc +++ b/src/main/rascal/lang/jimple/decompiler/jimplify/LambdaTransformer.rsc @@ -1,28 +1,216 @@ module lang::jimple::decompiler::jimplify::LambdaTransformer -import lang::jimple::core::Syntax; +import lang::jimple::core::Syntax; -str bootstrapMethod = "bootstrap$"; +import String; +import List; + +alias CID = ClassOrInterfaceDeclaration; + +str bootstrapMethod = "bootstrap$"; public list[ClassOrInterfaceDeclaration] lambdaTransformer(ClassOrInterfaceDeclaration c) { - list[ClassOrInterfaceDeclaration] classes = []; + list[ClassOrInterfaceDeclaration] classes = []; - c = visit(c) { - case dynamicInvoke(_, bsmArgs, sig, args)=> generateStaticInvokeExp(mh, sig, args) - when iValue(methodHandle(mh)):= bsmArgs[1] + c = visit(c) { //TODO: add LambdaMetafactory verification(in the indy's first argument) + + //Accumulating Transformer: traverse the tree, collect information and also transform tree. + case dynamicInvoke(_, bsmArgs, sig, args): { + classes += generateBootstrapClass(bsmArgs, sig); + MethodSignature mh = methodSignature(bsmArgs[1]); + //iValue(methodHandle(mh)) := bsmArgs[1]; + insert generateStaticInvokeExp(mh, sig, args); + } + } - classes += c; return classes; } private InvokeExp generateStaticInvokeExp(MethodSignature sig1, MethodSignature sig2, list[Immediate] args) { - MethodSignature sig = methodSignature("$", returnType(sig2), bootstrapMethod, formals(sig2)); - + MethodSignature sig = methodSignature("$", returnType(sig2), bootstrapMethod, formals(sig2)); + return staticMethodInvoke(sig, args); -} +} + +private CID generateBootstrapClass(list[Immediate] bsmArgs, MethodSignature bsmSig) { + + MethodSignature targetSig = methodSignature(bsmArgs[1]); + + str bsmClassName = "$"; + + MethodSignature bootstrapSig = methodSignature(bsmClassName, TVoid(), "\", formals(bsmSig)); + + MethodSignature initSig = methodSignature("java.lang.Object", TVoid(), "\", []); + + list[Type] classVars = formals(bsmSig); + + list[Immediate] lambdaArgs = []; + + //MethodBody local variable declarations + list[LocalVariableDeclaration] bsmLocals = generateLocalVarDecls(formals(bsmSig), 0) //instance attribute vars + + generateLocalVarDecls([TObject(bsmClassName)], size(formals(bsmSig))); //thisClass var + + list[LocalVariableDeclaration] initLocals = generateLocalVarDecls([TObject(bsmClassName)], 0) //thisClass var + + generateLocalVarDecls(formals(bsmSig), 1); //instance attribute vars + + // if the type is TObject("java.lang.Object"), jlO, we need to create local variables for type casting + + list[Type] frm1 = valueFormals(bsmArgs[0]); //lambda signature formals + list[Type] frm2 = valueFormals(bsmArgs[2]); //erased signature formals (real types) + int numArgs = size(frm1); + int numCasts = 0; + + for(i <- [0..size(frm1)]) { + if(frm1[i]!=frm2[i]) + numCasts+=1; + } + + list[LocalVariableDeclaration] targetLocals = generateLocalVarDecls([TObject(bsmClassName)], 0) //thisClass var + + generateLocalVarDecls(valueFormals(bsmArgs[0]), 1); //method param vars (Object) + //variables for cast + if(numCasts>0) + targetLocals += generateLocalVarDecls(valueFormals(bsmArgs[2]), size(valueFormals(bsmArgs[0]))+1); + + targetLocals += generateLocalVarDecls(formals(bsmSig), size(valueFormals(bsmArgs[0]))+numCasts+1); //instance attribute vars + + //return var + if(returnType(targetSig) != TVoid()) + targetLocals += [localVariableDeclaration(returnType(targetSig), "$i0")]; + + //MethodBody statements + //instantiation "fase" + list[Statement] bsmStmts = instantiateParameters(formals(bsmSig), 0) + + [assign(localVariable("$r"), newInstance(TObject(bsmClassName)))]; + + list[Statement] initStmts = [identity("$r0", "@this", TObject(bsmClassName))] + + instantiateParameters(formals(bsmSig), 1); + + list[Statement] targetStmts = [identity("$r0", "@this", TObject(bsmClassName))] + + instantiateParameters(valueFormals(bsmArgs[0]), 1); + + //BSM STATEMENTS + list[Immediate] bsmParams = [local(localVariable(decl))|decl <- prefix(bsmLocals)]; + + bsmStmts += invokeStmt(specialInvoke(localVariable(last(bsmLocals)), bootstrapSig, bsmParams)); + bsmStmts += returnStmt(local(localVariable(last(bsmLocals)))); + + //INIT STATEMENTS + initStmts += invokeStmt(specialInvoke("$r0", initSig, [])); + //fieldRef assignment + list[Immediate] initParams = [local(localVariable(decl))|decl <- tail(initLocals)]; + + for(int i <- [0..size(initParams)]) { + FieldSignature fieldSig = fieldSignature(bsmClassName, formals(bsmSig)[i], "cap"); + initStmts += assign(fieldRef("$r0", fieldSig), immediate(initParams[i])); + } + + initStmts += returnEmptyStmt(); + //TARGET STATEMENTS + //1st: casts + //for(int i <- [0..numCasts]) { + for(int i <- [0..size(valueFormals(bsmArgs[2]))]) { + if(numCasts>0) + targetStmts += assign(localVariable("$r"), cast(valueFormals(bsmArgs[2])[i], local("$r"))); + lambdaArgs += local("$r"); + } + + //2nd: localFieldRef : instance attributes (cap0,..) + for(int i <- [0..size(formals(bsmSig))]){ + Expression lfr = localFieldRef("$r0", bsmClassName, formals(bsmSig)[i], "cap"); + targetStmts += assign(localVariable("$r"), lfr); + lambdaArgs += local("$r"); + } + + if(size(frm1)>0 && size(formals(bsmSig))>0) + lambdaArgs=reverse(lambdaArgs); + + //invoke (staticinvoke) lambdaMethod + if(returnType(methodSignature(bsmArgs[1]))==TVoid()){ + targetStmts += invokeStmt(staticMethodInvoke(methodSignature(bsmArgs[1]), lambdaArgs)); + targetStmts += returnEmptyStmt(); + } else { + targetStmts += assign(localVariable("$i0"), invokeExp(staticMethodInvoke(methodSignature(bsmArgs[1]), lambdaArgs))); + targetStmts += returnStmt(local("$i0")); + } + + //Method bodies + MethodBody bsmBody = methodBody(bsmLocals, bsmStmts, []); + MethodBody initBody = methodBody(initLocals, initStmts, []); + MethodBody targetBody = methodBody(targetLocals, targetStmts, []); + + //Methods + Method bsm = method([Public(), Static()], // list[Modifiers] modifiers + returnType(bsmSig), // Type returnType + "bootstrap$", // Name name + formals(bsmSig), // list[Type] formals + [], // list[Type] exceptions //TODO! + bsmBody); // MethodBody body + + Method initMethod = method([Public(), Static()], + TVoid(), + "\", + formals(bsmSig), + [], + initBody); + + + Method targetMethod = method([Public(), Static()], + returnType(targetSig), + methodName(bsmSig), + valueFormals(bsmArgs[0]), + [], + targetBody); + + + CID bsmClass = classDecl(TObject(bsmClassName), // Type typeName + [Public(), Final()], // list[Modifiers] modifiers + object(), // Type superClass + [returnType(bsmSig)], // list[Type] interfaces + getFields(bsmSig), // list[Fields] fields + [bsm, initMethod, targetMethod]); // list[Method] methods + + return bsmClass; +} + +list[Field] getFields(MethodSignature sig){ + list[Field] fields = []; + + for(int i <- [0..size(formals(sig))]){ + fields += field([], formals(sig)[i], "cap"); + } + + return fields; +} + +list[LocalVariableDeclaration] generateLocalVarDecls(list[Type] frmls, int n){ + list[LocalVariableDeclaration] localVarDecls = []; + + for(int i <- [0..size(frmls)]){ + localVarDecls += localVariableDeclaration(frmls[i], "$r"); + } + + return localVarDecls; +} + +list[Statement] instantiateParameters(list[Type] frmls, int n){ + list[Statement] stmts = []; + + for(int i <- [0..size(frmls)]){ + stmts += identity("$r", "@parameter", frmls[i]); + } + + return stmts; +} + private str className(methodSignature(name, _, _, _)) = name; private str methodName(methodSignature(_, _, name,_)) = name; private Type returnType(methodSignature(_, aType, _, _)) = aType; private list[Type] formals(methodSignature(_, _, _, formalArgs)) = formalArgs; +private list[Type] valueFormals(iValue(methodValue(_, formalArgs))) = formalArgs; +private MethodSignature methodSignature(iValue(methodHandle(mh))) = mh; +private Identifier localVariable(localVariableDeclaration(_, local)) = local; + + + diff --git a/src/test/java/lang/jimple/internal/TestDecompiler.java b/src/test/java/lang/jimple/internal/TestDecompiler.java index 7d8cb211..b671c24e 100644 --- a/src/test/java/lang/jimple/internal/TestDecompiler.java +++ b/src/test/java/lang/jimple/internal/TestDecompiler.java @@ -25,282 +25,264 @@ public void decompileClassWithIfStatement() { IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - @Test public void decompileClassWithFields() { try { - File classFile = new File("./target/test-classes/samples/ClassWithFields.class"); + File classFile = new File("./target/test-classes/samples/ClassWithFields.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileClassWithSimpleLambdaExpression() { try { - File classFile = new File("./target/test-classes/samples/SimpleLambdaExpression.class"); + File classFile = new File("./target/test-classes/samples/SimpleLambdaExpression.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileInterface() { try { - File classFile = new File("./target/test-classes/samples/InterfaceSample.class"); + File classFile = new File("./target/test-classes/samples/InterfaceSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileAutoIncrementClass() { try { - File classFile = new File("./target/test-classes/samples/AutoIncrementSample.class"); + File classFile = new File("./target/test-classes/samples/AutoIncrementSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileWhileStmtSampleClass() { try { - File classFile = new File("./target/test-classes/samples/WhileStmtSample.class"); + File classFile = new File("./target/test-classes/samples/WhileStmtSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - + @Ignore - @Test + @Test public void decompileSlf4JMDCClass() { try { - File classFile = new File("./target/test-classes/slf4j/org/slf4j/MDC.class"); + File classFile = new File("./target/test-classes/slf4j/org/slf4j/MDC.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileNestedInterface() { try { - File classFile = new File("./target/test-classes/samples/NestedInterface.class"); + File classFile = new File("./target/test-classes/samples/NestedInterface.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } - } - - @Test + } + + @Test @Ignore public void decompileStreamAPI() { try { - File classFile = new File("./target/test-classes/samples/StreamAPI.class"); + File classFile = new File("./target/test-classes/samples/StreamAPI.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } - } - - @Test + } + + @Test public void decompileAndroidClass() { try { - File classFile = new File("./target/test-classes/android-app/oms/wmessage/main.class"); + File classFile = new File("./target/test-classes/android-app/oms/wmessage/main.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - + @Test public void decompileSwitchCaseSample() { try { - File classFile = new File("./target/test-classes/samples/SwitchCaseSample.class"); + File classFile = new File("./target/test-classes/samples/SwitchCaseSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - + @Test public void decompileControlStatements() { try { - File classFile = new File("./target/test-classes/samples/ControlStatements.class"); + File classFile = new File("./target/test-classes/samples/ControlStatements.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - - @Test + + @Test public void decompileImplicitParameter() { try { - File classFile = new File("./target/test-classes/samples/ImplicitParameterSample.class"); + File classFile = new File("./target/test-classes/samples/ImplicitParameterSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } - } - - @Test + } + + @Test public void decompileIntOpsClassFile() { try { - File classFile = new File("./target/test-classes/samples/operators/IntOps.class"); + File classFile = new File("./target/test-classes/samples/operators/IntOps.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } - } + } @Test public void decompileNewStatementSample() { try { - File classFile = new File("./target/test-classes/samples/NewStatementSample.class"); + File classFile = new File("./target/test-classes/samples/NewStatementSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } } - + @Test public void decompileAdditionalLongValueSample() { try { - File classFile = new File("./target/test-classes/samples/AdditionalLongValueSample.class"); + File classFile = new File("./target/test-classes/samples/AdditionalLongValueSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } diff --git a/src/test/java/lang/jimple/internal/TestDecompilerOnLongValues.java b/src/test/java/lang/jimple/internal/TestDecompilerOnLongValues.java index 39819233..fcd1e571 100644 --- a/src/test/java/lang/jimple/internal/TestDecompilerOnLongValues.java +++ b/src/test/java/lang/jimple/internal/TestDecompilerOnLongValues.java @@ -14,19 +14,18 @@ public class TestDecompilerOnLongValues { - @Test + @Test public void decompileInterface() { try { - File classFile = new File("./target/test-classes/samples/LongValueSample.class"); + File classFile = new File("./target/test-classes/samples/LongValueSample.class"); assertNotNull(classFile); - + IValueFactory vf = ValueFactory.getInstance(); Decompiler decompiler = new Decompiler(vf); IConstructor c = decompiler.decompile(new FileInputStream(classFile), null); - + assertNotNull(c); - } - catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); fail(e.getLocalizedMessage()); } diff --git a/src/test/java/samples/AbstractClassSample.java b/src/test/java/samples/AbstractClassSample.java index 6bd18a67..3aa92d19 100644 --- a/src/test/java/samples/AbstractClassSample.java +++ b/src/test/java/samples/AbstractClassSample.java @@ -2,5 +2,4 @@ public abstract class AbstractClassSample { - } diff --git a/src/test/java/samples/AdditionalLongValueSample.java b/src/test/java/samples/AdditionalLongValueSample.java index d1f14c3d..5d2a5cad 100644 --- a/src/test/java/samples/AdditionalLongValueSample.java +++ b/src/test/java/samples/AdditionalLongValueSample.java @@ -1,19 +1,18 @@ package samples; public class AdditionalLongValueSample { - - private double pi = 3.14; - + + private double pi = 3.14; + public long addLongValues(long factor) throws Exception { - long x = 10L; - long y = factor * 20L; - - String s0 = "" + (y * pi); - - System.out.println(s0); - - return x + y; + long x = 10L; + long y = factor * 20L; + + String s0 = "" + (y * pi); + + System.out.println(s0); + + return x + y; } - } diff --git a/src/test/java/samples/AutoIncrementSample.java b/src/test/java/samples/AutoIncrementSample.java index d85886a8..653b58fd 100644 --- a/src/test/java/samples/AutoIncrementSample.java +++ b/src/test/java/samples/AutoIncrementSample.java @@ -1,9 +1,9 @@ package samples; public class AutoIncrementSample { - + public void foo() { - int x = 1; + int x = 1; x++; System.out.println(x); } diff --git a/src/test/java/samples/ClassWithFields.java b/src/test/java/samples/ClassWithFields.java index 117f1814..ee807bd9 100644 --- a/src/test/java/samples/ClassWithFields.java +++ b/src/test/java/samples/ClassWithFields.java @@ -3,10 +3,10 @@ public class ClassWithFields { private String msg; - private String[] msgs; + private String[] msgs; public static final String txt = "Jimlpe"; protected Long value1 = 1L; transient int value2 = 9999; - String[] fixed = {"A", "B", "C", "D"}; + String[] fixed = { "A", "B", "C", "D" }; volatile int vol = 1; } diff --git a/src/test/java/samples/ControlStatements.java b/src/test/java/samples/ControlStatements.java index ff51a4d7..a1cced1d 100644 --- a/src/test/java/samples/ControlStatements.java +++ b/src/test/java/samples/ControlStatements.java @@ -1,78 +1,76 @@ package samples; -import java.util.ArrayList; - public class ControlStatements { - public void simpleIfElseIfTakeThen() { - int a = 1; - int b = 2; - int c = 3; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } + public void simpleIfElseIfTakeThen() { + int a = 1; + int b = 2; + int c = 3; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } - public void simpleIfElseIfTakeElseIf() { - int a = 2; - int b = 1; - int c = 3; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } + public void simpleIfElseIfTakeElseIf() { + int a = 2; + int b = 1; + int c = 3; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } - public void simpleIfElseIfTakeElse() { - int a = 3; - int b = 2; - int c = 1; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } + public void simpleIfElseIfTakeElse() { + int a = 3; + int b = 2; + int c = 1; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } - public void simpleIfElseTakeThen() { - int a = 1; - int b = 2; - if (a < b) { - System.out.println(a); - } else { - System.out.println(b); - } - } + public void simpleIfElseTakeThen() { + int a = 1; + int b = 2; + if (a < b) { + System.out.println(a); + } else { + System.out.println(b); + } + } - public void simpleIfElseTakeElse() { - int a = 2; - int b = 1; - if (a < b) { - System.out.println(a); - } else { - System.out.println(b); - } - } + public void simpleIfElseTakeElse() { + int a = 2; + int b = 1; + if (a < b) { + System.out.println(a); + } else { + System.out.println(b); + } + } - public void tableSwitch() { - int a = 1; - switch (a) { - case 1: - System.out.println(a); - case 2: - System.out.println(a); - default: - System.out.println(a); - } - } + public void tableSwitch() { + int a = 1; + switch (a) { + case 1: + System.out.println(a); + case 2: + System.out.println(a); + default: + System.out.println(a); + } + } } diff --git a/src/test/java/samples/IfStatement.java b/src/test/java/samples/IfStatement.java index 39eb12a8..c081eedb 100644 --- a/src/test/java/samples/IfStatement.java +++ b/src/test/java/samples/IfStatement.java @@ -2,26 +2,26 @@ public class IfStatement { - public static void foo(int x) { - if(x > 0) { - x = x + 1; - } - System.out.println(x); - } + public static void foo(int x) { + if (x > 0) { + x = x + 1; + } + System.out.println(x); + } - public static void blah(int x, int y) { - if(x < 0) { - return; - } - System.out.println(x + y); - } + public static void blah(int x, int y) { + if (x < 0) { + return; + } + System.out.println(x + y); + } - public static void ugly(int x, int y) { - int z = 0; - if(x < 0) { - z = y > 10 ? x + y : x; - } - System.out.println(z); - } + public static void ugly(int x, int y) { + int z = 0; + if (x < 0) { + z = y > 10 ? x + y : x; + } + System.out.println(z); + } } diff --git a/src/test/java/samples/ImplicitParameterSample.java b/src/test/java/samples/ImplicitParameterSample.java index d1a1accb..483fa6fe 100644 --- a/src/test/java/samples/ImplicitParameterSample.java +++ b/src/test/java/samples/ImplicitParameterSample.java @@ -1,13 +1,12 @@ package samples; public class ImplicitParameterSample { - - private int x = 10; - + + private int x = 10; + public int foo(int y) { - int z = 100; - return x + y + z; + int z = 100; + return x + y + z; } - } diff --git a/src/test/java/samples/InterfaceSample.java b/src/test/java/samples/InterfaceSample.java index f643193a..d5ff3d1d 100644 --- a/src/test/java/samples/InterfaceSample.java +++ b/src/test/java/samples/InterfaceSample.java @@ -4,7 +4,7 @@ public interface InterfaceSample { public String foo() throws IOException; - + public default void bah() { System.out.println("abc"); } diff --git a/src/test/java/samples/LongValueSample.java b/src/test/java/samples/LongValueSample.java index a9eddcb6..c48ff9fb 100644 --- a/src/test/java/samples/LongValueSample.java +++ b/src/test/java/samples/LongValueSample.java @@ -1,13 +1,12 @@ package samples; public class LongValueSample { - + public static void addLongValues() throws Exception { - long x = 10L; - long y = 20L; - + long x = 10L; + long y = 20L; + System.out.println(x + y); } - } diff --git a/src/test/java/samples/NestedInterface.java b/src/test/java/samples/NestedInterface.java index eb65ac21..45d420ed 100644 --- a/src/test/java/samples/NestedInterface.java +++ b/src/test/java/samples/NestedInterface.java @@ -5,6 +5,7 @@ interface MyInterfaceA { } class NestedInterface implements MyInterfaceA { + @Override public void display() { System.out.println("Nested interface method"); } diff --git a/src/test/java/samples/NewStatementSample.java b/src/test/java/samples/NewStatementSample.java index 9b5a9d85..02261644 100644 --- a/src/test/java/samples/NewStatementSample.java +++ b/src/test/java/samples/NewStatementSample.java @@ -1,15 +1,15 @@ package samples; public class NewStatementSample { - + public static void main(String args[]) { NewStatementSample instance = new NewStatementSample(); - - System.out.println(instance.sum(3, 4)); + + System.out.println(instance.sum(3, 4)); } - + public int sum(int x, int y) { - return x + y; + return x + y; } } diff --git a/src/test/java/samples/SimpleLambdaExpression.java b/src/test/java/samples/SimpleLambdaExpression.java index d6264d6b..0632dbfd 100644 --- a/src/test/java/samples/SimpleLambdaExpression.java +++ b/src/test/java/samples/SimpleLambdaExpression.java @@ -3,10 +3,10 @@ import java.util.Comparator; public class SimpleLambdaExpression { - + public static void main(String args[]) { Comparator c = (String l, String r) -> l.compareTo(r); - + System.out.println(c.compare("hello", "world")); } diff --git a/src/test/java/samples/StreamAPI.java b/src/test/java/samples/StreamAPI.java index c606f84f..26cb9d18 100644 --- a/src/test/java/samples/StreamAPI.java +++ b/src/test/java/samples/StreamAPI.java @@ -4,16 +4,15 @@ import java.util.List; public class StreamAPI { - + public static void main(String args[]) { List values = Arrays.asList(1, 2, 3, 4, 5); - - int z = 10; - + + int z = 10; + Integer total1 = values.stream().reduce(0, (a, b) -> a + b + z); - System.out.println(total1); + System.out.println(total1); } - } diff --git a/src/test/java/samples/SwitchCaseSample.java b/src/test/java/samples/SwitchCaseSample.java index a6a371c8..7f6e9776 100644 --- a/src/test/java/samples/SwitchCaseSample.java +++ b/src/test/java/samples/SwitchCaseSample.java @@ -1,21 +1,24 @@ package samples; public class SwitchCaseSample { - + public static void main(String args[]) { - int x = 10; - switch(random()) { - case 1: x++; - case 2: x--; - default: System.out.print("do nothing"); + int x = 10; + switch (random()) { + case 1: + x++; + case 2: + x--; + default: + System.out.print("do nothing"); } - - System.out.println(x); + + System.out.println(x); } - + // not a trully random... private static int random() { - return 1; + return 1; } } diff --git a/src/test/java/samples/WhileStmtSample.java b/src/test/java/samples/WhileStmtSample.java index b96afc14..a48e6380 100644 --- a/src/test/java/samples/WhileStmtSample.java +++ b/src/test/java/samples/WhileStmtSample.java @@ -1,13 +1,13 @@ package samples; public class WhileStmtSample { - + public static int factorial(int x) { - int res = x; - while(x > 1) { + int res = x; + while (x > 1) { res = res * (--x); } return res; } - + } diff --git a/src/test/java/samples/arrays/ArrayExample.java b/src/test/java/samples/arrays/ArrayExample.java index e4be2189..193b0fc2 100644 --- a/src/test/java/samples/arrays/ArrayExample.java +++ b/src/test/java/samples/arrays/ArrayExample.java @@ -5,24 +5,25 @@ public class ArrayExample { - public static void main(String[] args) throws Exception { - List nums = Arrays.asList(-3, 0, 1, 8); + public static void main(String[] args) throws Exception { + List nums = Arrays.asList(-3, 0, 1, 8); - Runnable r = () -> nums.forEach(n -> { + Runnable r = () -> nums.forEach(n -> { - if (n < 0) System.out.println("Negative: " + n); + if (n < 0) + System.out.println("Negative: " + n); - else System.out.println("Positive: " + n); + else + System.out.println("Positive: " + n); - }); + }); - Thread t = new Thread(r); + Thread t = new Thread(r); - t.start(); + t.start(); - t.join(); + t.join(); - } + } } - diff --git a/src/test/java/samples/arrays/Arrays.java b/src/test/java/samples/arrays/Arrays.java index debe488f..bb5bbf8b 100644 --- a/src/test/java/samples/arrays/Arrays.java +++ b/src/test/java/samples/arrays/Arrays.java @@ -2,39 +2,39 @@ public class Arrays { - public void primitiveArray() { - int[] arr = new int[] { 1, 2 }; - System.out.println(arr[0]); - System.out.println(arr[1]); - } + public void primitiveArray() { + int[] arr = new int[] { 1, 2 }; + System.out.println(arr[0]); + System.out.println(arr[1]); + } - public void primitiveArrayLengt() { - int[] arr = new int[] { 1, 2 }; - System.out.println(arr.length); - } + public void primitiveArrayLengt() { + int[] arr = new int[] { 1, 2 }; + System.out.println(arr.length); + } - public void objectArray() { - String[] arr = new String[] { "1", "2" }; - System.out.println(arr[0]); - System.out.println(arr[1]); - } + public void objectArray() { + String[] arr = new String[] { "1", "2" }; + System.out.println(arr[0]); + System.out.println(arr[1]); + } - public void manualAssignment() { - int[] arr = new int[1]; - arr[0] = 1; - System.out.println(arr[0]); - } + public void manualAssignment() { + int[] arr = new int[1]; + arr[0] = 1; + System.out.println(arr[0]); + } - public void twoDimensions() { - int[][] arr = new int[2][2]; - arr[0][0] = 1; - arr[0][1] = 2; - arr[1][0] = 3; - arr[1][1] = 4; - System.out.println(arr[0][0]); - System.out.println(arr[0][1]); - System.out.println(arr[1][0]); - System.out.println(arr[1][1]); - } + public void twoDimensions() { + int[][] arr = new int[2][2]; + arr[0][0] = 1; + arr[0][1] = 2; + arr[1][0] = 3; + arr[1][1] = 4; + System.out.println(arr[0][0]); + System.out.println(arr[0][1]); + System.out.println(arr[1][0]); + System.out.println(arr[1][1]); + } } diff --git a/src/test/java/samples/callgraph/polymorphism/Main.java b/src/test/java/samples/callgraph/polymorphism/Main.java index 659bc70c..d464f621 100644 --- a/src/test/java/samples/callgraph/polymorphism/Main.java +++ b/src/test/java/samples/callgraph/polymorphism/Main.java @@ -7,23 +7,23 @@ public class Main { - public void execute(ServiceFactory factory) { + public void execute(ServiceFactory factory) { User user = factory.createUser("ID", "NAME", "EMAIL", "PHONE"); - Service service = factory.getUserService(); + Service service = factory.getUserService(); User persistedUser = service.save(user); - //System.out.println("Persisted user: "+persistedUser.getName()); + // System.out.println("Persisted user: "+persistedUser.getName()); persistedUser.getName(); } - + public void execute2() { ServiceFactory factory = new JdbcServiceFactory(); - + User user = factory.createUser("ID", "NAME", "EMAIL", "PHONE"); factory.getUserService().save(user); } - + public void execute3(ServiceFactory factory) { factory.getUserService().save(null); } diff --git a/src/test/java/samples/callgraph/polymorphism/domain/Entity.java b/src/test/java/samples/callgraph/polymorphism/domain/Entity.java index 88b83390..d518cb08 100644 --- a/src/test/java/samples/callgraph/polymorphism/domain/Entity.java +++ b/src/test/java/samples/callgraph/polymorphism/domain/Entity.java @@ -5,6 +5,6 @@ @FunctionalInterface public interface Entity extends Serializable { - ID getId(); + ID getId(); } diff --git a/src/test/java/samples/callgraph/polymorphism/domain/User.java b/src/test/java/samples/callgraph/polymorphism/domain/User.java index 6d50856e..1d078ebc 100644 --- a/src/test/java/samples/callgraph/polymorphism/domain/User.java +++ b/src/test/java/samples/callgraph/polymorphism/domain/User.java @@ -3,7 +3,9 @@ public interface User extends Entity { public String getName(); + public String getEmail(); + public String getPassword(); - + } diff --git a/src/test/java/samples/callgraph/polymorphism/repository/Repository.java b/src/test/java/samples/callgraph/polymorphism/repository/Repository.java index 41d5d1e5..5d08e532 100644 --- a/src/test/java/samples/callgraph/polymorphism/repository/Repository.java +++ b/src/test/java/samples/callgraph/polymorphism/repository/Repository.java @@ -11,12 +11,12 @@ public interface Repository, ID extends Serializable> exten E save(E entity); - E update(E entity); + E update(E entity); - List findAll(); + List findAll(); - Optional findById(ID id); + Optional findById(ID id); + + void delete(ID id); - void delete(ID id); - } diff --git a/src/test/java/samples/callgraph/polymorphism/service/AbstractService.java b/src/test/java/samples/callgraph/polymorphism/service/AbstractService.java index 6e40f1bc..759fa917 100644 --- a/src/test/java/samples/callgraph/polymorphism/service/AbstractService.java +++ b/src/test/java/samples/callgraph/polymorphism/service/AbstractService.java @@ -15,12 +15,13 @@ public AbstractService(Repository repository) { protected abstract boolean valid(E entity); + @Override public E save(E entity) { log("[AbstractService] save: " + entity); if (valid(entity)) { return getRepository().save(entity); } - throw new RuntimeException("Invalid entity: "+entity); + throw new RuntimeException("Invalid entity: " + entity); } @Override diff --git a/src/test/java/samples/callgraph/polymorphism/service/UserService.java b/src/test/java/samples/callgraph/polymorphism/service/UserService.java index 958acec1..10cab67f 100644 --- a/src/test/java/samples/callgraph/polymorphism/service/UserService.java +++ b/src/test/java/samples/callgraph/polymorphism/service/UserService.java @@ -9,6 +9,7 @@ public UserService(Repository repository) { super(repository); } + @Override protected boolean valid(User entity) { log("[ContactService] valid: " + entity); return true; diff --git a/src/test/java/samples/callgraph/polymorphism/util/Log.java b/src/test/java/samples/callgraph/polymorphism/util/Log.java index 5aa52396..9ab208f7 100644 --- a/src/test/java/samples/callgraph/polymorphism/util/Log.java +++ b/src/test/java/samples/callgraph/polymorphism/util/Log.java @@ -4,6 +4,6 @@ public interface Log { default void log(String msg) { System.out.println(msg); - } - + } + } diff --git a/src/test/java/samples/callgraph/simple/CallGraphWithCycle.java b/src/test/java/samples/callgraph/simple/CallGraphWithCycle.java index fdc7b776..f0f010ad 100644 --- a/src/test/java/samples/callgraph/simple/CallGraphWithCycle.java +++ b/src/test/java/samples/callgraph/simple/CallGraphWithCycle.java @@ -24,7 +24,7 @@ protected void C() { F(); } - private void D() { + private void D() { A(); log("Executing D"); } @@ -40,7 +40,7 @@ private void F() { private void G() { log("Executing G"); } - + static void log(String message) { System.out.println(message); } diff --git a/src/test/java/samples/callgraph/simple/CallGraphWithRecursion.java b/src/test/java/samples/callgraph/simple/CallGraphWithRecursion.java index 955b5670..5a58f3ba 100644 --- a/src/test/java/samples/callgraph/simple/CallGraphWithRecursion.java +++ b/src/test/java/samples/callgraph/simple/CallGraphWithRecursion.java @@ -10,11 +10,11 @@ public void execute(int[] arr) { quickSort(arr, 0, arr.length - 1); System.out.println(fibonacci(10)); } - + public static long fibonacci(final int n) { return (n < 2) ? n : fibonacci(n - 1) + fibonacci(n - 2); } - + void quickSort(int arr[], int low, int high) { if (low < high) { int partitionIndex = partition(arr, low, high); diff --git a/src/test/java/samples/callgraph/simple/SimpleCallGraph.java b/src/test/java/samples/callgraph/simple/SimpleCallGraph.java index ebb2e619..4373e576 100644 --- a/src/test/java/samples/callgraph/simple/SimpleCallGraph.java +++ b/src/test/java/samples/callgraph/simple/SimpleCallGraph.java @@ -1,13 +1,7 @@ package samples.callgraph.simple; /** - A - / \ - B C - / \ / \ -D E F - \ / - G + * A / \ B C / \ / \ D E F \ / G */ public class SimpleCallGraph { @@ -30,7 +24,7 @@ protected void C() { F(); } - private void D() { + private void D() { log("Executing D"); } @@ -45,7 +39,7 @@ private void F() { private void G() { log("Executing G"); } - + static void log(String message) { System.out.println(message); } diff --git a/src/test/java/samples/constants/Constants.java b/src/test/java/samples/constants/Constants.java index c645c36a..222676dc 100644 --- a/src/test/java/samples/constants/Constants.java +++ b/src/test/java/samples/constants/Constants.java @@ -1,46 +1,46 @@ package samples.constants; public class Constants { - public void intConstant() { - int a = 512; - System.out.println(a); - } - - public void byteConstant() { - byte b = 0; - System.out.println(b); - } - - public void charConstant() { - char c = 'a'; - System.out.println(c); - } - - public void shortConstant() { - short d = 10; - System.out.println(d); - } - - public void floatConstant() { - float e = 3.14f; - System.out.println(e); - } - - public void longConstant() { - long f = 123456789; - System.out.println(f); - } - - public void doubleConstant() { - double g = 1.96969654d; - System.out.println(g); - } - - public void classConstant() { - System.out.println(Constants.class); - } - - public void stringConstant() { - System.out.println("foo"); - } + public void intConstant() { + int a = 512; + System.out.println(a); + } + + public void byteConstant() { + byte b = 0; + System.out.println(b); + } + + public void charConstant() { + char c = 'a'; + System.out.println(c); + } + + public void shortConstant() { + short d = 10; + System.out.println(d); + } + + public void floatConstant() { + float e = 3.14f; + System.out.println(e); + } + + public void longConstant() { + long f = 123456789; + System.out.println(f); + } + + public void doubleConstant() { + double g = 1.96969654d; + System.out.println(g); + } + + public void classConstant() { + System.out.println(Constants.class); + } + + public void stringConstant() { + System.out.println("foo"); + } } diff --git a/src/test/java/samples/controlStatements/ControlStatements.java b/src/test/java/samples/controlStatements/ControlStatements.java index 00b0a356..ff5e8386 100644 --- a/src/test/java/samples/controlStatements/ControlStatements.java +++ b/src/test/java/samples/controlStatements/ControlStatements.java @@ -4,175 +4,175 @@ public class ControlStatements { - public void simpleIfElseIfTakeThen() { - int a = 1; - int b = 2; - int c = 3; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } - - public void simpleIfElseIfTakeElseIf() { - int a = 2; - int b = 1; - int c = 3; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } - - public void simpleIfElseIfTakeElse() { - int a = 3; - int b = 2; - int c = 1; - if (a < b) { - System.out.println(a); - } else if (a < c) { - System.out.println(b); - } else { - System.out.println(c); - } - } - - public void simpleIfElseTakeThen() { - int a = 1; - int b = 2; - if (a < b) { - System.out.println(a); - } else { - System.out.println(b); - } - } - - public void simpleIfElseTakeElse() { - int a = 2; - int b = 1; - if (a < b) { - System.out.println(a); - } else { - System.out.println(b); - } - } - - public void tableSwitch() { - int a = 1; - switch (a) { - case 1: - System.out.println(a); - case 2: - System.out.println(a); - default: - System.out.println(a); - } - } - - public void tableSwitchDefault() { - int a = 3; - switch (a) { - case 1: - System.out.println(a); - case 2: - System.out.println(a); - default: - System.out.println(a); - } - } - - public void tableSwitchNoDefault() { - int a = 3; - switch (a) { - case 1: - System.out.println(a); - case 2: - System.out.println(a); - } - - System.out.println(a); - } - - public void lookupSwitch() { - String a = "foo"; - switch (a) { - case "foo": - System.out.println(a); - case "bar": - System.out.println(a); - default: - System.out.println(a); - } - } - - public void lookupSwitchDefault() { - String a = "baz"; - switch (a) { - case "foo": - System.out.println(a); - case "bar": - System.out.println(a); - default: - System.out.println(a); - } - } - - public void lookupSwitchNoDefault() { - String a = "baz"; - switch (a) { - case "foo": - System.out.println(a); - case "bar": - System.out.println(a); - } - System.out.println(a); - } - - public void simpleWhile() { - int a = 1; - int b = 2; - while (a < b) { - System.out.println(a); - a++; - } - } - - public void simpleDoWhile() { - int a = 1; - int b = 2; - do { - System.out.println(a); - a++; - } while (a < b); - } - - public void simpleFor() { - int a = 1; - for (int i = 0; i < a; i++) { - System.out.println(i); - } - } - - public void forIterArr() { - int[] arr = new int[] { 1, 2, 3 }; - for (int i : arr) { - System.out.println(i); - } - } - - public void forIterList() { - ArrayList list = new ArrayList<>(); - list.add("1"); - list.add("2"); - list.add("3"); - for (String s : list) { - System.out.println(s); - } - } + public void simpleIfElseIfTakeThen() { + int a = 1; + int b = 2; + int c = 3; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } + + public void simpleIfElseIfTakeElseIf() { + int a = 2; + int b = 1; + int c = 3; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } + + public void simpleIfElseIfTakeElse() { + int a = 3; + int b = 2; + int c = 1; + if (a < b) { + System.out.println(a); + } else if (a < c) { + System.out.println(b); + } else { + System.out.println(c); + } + } + + public void simpleIfElseTakeThen() { + int a = 1; + int b = 2; + if (a < b) { + System.out.println(a); + } else { + System.out.println(b); + } + } + + public void simpleIfElseTakeElse() { + int a = 2; + int b = 1; + if (a < b) { + System.out.println(a); + } else { + System.out.println(b); + } + } + + public void tableSwitch() { + int a = 1; + switch (a) { + case 1: + System.out.println(a); + case 2: + System.out.println(a); + default: + System.out.println(a); + } + } + + public void tableSwitchDefault() { + int a = 3; + switch (a) { + case 1: + System.out.println(a); + case 2: + System.out.println(a); + default: + System.out.println(a); + } + } + + public void tableSwitchNoDefault() { + int a = 3; + switch (a) { + case 1: + System.out.println(a); + case 2: + System.out.println(a); + } + + System.out.println(a); + } + + public void lookupSwitch() { + String a = "foo"; + switch (a) { + case "foo": + System.out.println(a); + case "bar": + System.out.println(a); + default: + System.out.println(a); + } + } + + public void lookupSwitchDefault() { + String a = "baz"; + switch (a) { + case "foo": + System.out.println(a); + case "bar": + System.out.println(a); + default: + System.out.println(a); + } + } + + public void lookupSwitchNoDefault() { + String a = "baz"; + switch (a) { + case "foo": + System.out.println(a); + case "bar": + System.out.println(a); + } + System.out.println(a); + } + + public void simpleWhile() { + int a = 1; + int b = 2; + while (a < b) { + System.out.println(a); + a++; + } + } + + public void simpleDoWhile() { + int a = 1; + int b = 2; + do { + System.out.println(a); + a++; + } while (a < b); + } + + public void simpleFor() { + int a = 1; + for (int i = 0; i < a; i++) { + System.out.println(i); + } + } + + public void forIterArr() { + int[] arr = new int[] { 1, 2, 3 }; + for (int i : arr) { + System.out.println(i); + } + } + + public void forIterList() { + ArrayList list = new ArrayList<>(); + list.add("1"); + list.add("2"); + list.add("3"); + for (String s : list) { + System.out.println(s); + } + } } diff --git a/src/test/java/samples/dataflow/SimpleReachDefinition.java b/src/test/java/samples/dataflow/SimpleReachDefinition.java index 625a8401..c360850a 100644 --- a/src/test/java/samples/dataflow/SimpleReachDefinition.java +++ b/src/test/java/samples/dataflow/SimpleReachDefinition.java @@ -5,17 +5,17 @@ public class SimpleReachDefinition { public void factorial(int x) { int y = x; int z = 1; - while(y > 1) { + while (y > 1) { z = z * y; y = y - 1; } - //System.out.println("Z="+z); + // System.out.println("Z="+z); y = 0; } - + // public static void main(String[] args) { // SimpleReachDefinition tmp = new SimpleReachDefinition(); // tmp.factorial(6); // } - + } \ No newline at end of file diff --git a/src/test/java/samples/dataflow/SimpleVeryBusyExpression.java b/src/test/java/samples/dataflow/SimpleVeryBusyExpression.java index 57ccee42..b8fb989b 100644 --- a/src/test/java/samples/dataflow/SimpleVeryBusyExpression.java +++ b/src/test/java/samples/dataflow/SimpleVeryBusyExpression.java @@ -1,9 +1,9 @@ package samples.dataflow; public class SimpleVeryBusyExpression { - + public void veryBusy(int a, int b, int x, int y) { - + if (a != b) { x = b - a; y = a - b; @@ -14,7 +14,7 @@ public void veryBusy(int a, int b, int x, int y) { } } - public void ppa(int a, int b, int x, int y) { + public void ppa(int a, int b, int x, int y) { if (a > b) { x = b - a; y = a - b; @@ -23,5 +23,5 @@ public void ppa(int a, int b, int x, int y) { x = a - b; } } - + } diff --git a/src/test/java/samples/emulation/Objects.java b/src/test/java/samples/emulation/Objects.java index a1fda50c..c2cf4d57 100644 --- a/src/test/java/samples/emulation/Objects.java +++ b/src/test/java/samples/emulation/Objects.java @@ -5,22 +5,22 @@ */ public class Objects { - public void jObjectToJavaObject() { - System.out.println(new Foo()); - } + public void jObjectToJavaObject() { + System.out.println(new Foo()); + } - public void systemOut() { - System.out.println(); - } + public void systemOut() { + System.out.println(); + } - private static final class Foo { + private static final class Foo { - public Foo() { - } + public Foo() { + } - @Override - public String toString() { - return "foo"; - } - } + @Override + public String toString() { + return "foo"; + } + } } diff --git a/src/test/java/samples/fieldReference/A.java b/src/test/java/samples/fieldReference/A.java index 4648b37b..1e2a1211 100644 --- a/src/test/java/samples/fieldReference/A.java +++ b/src/test/java/samples/fieldReference/A.java @@ -1,6 +1,6 @@ package samples.fieldReference; class A { - int i = 15; - public String j = "greater"; + int i = 15; + public String j = "greater"; } \ No newline at end of file diff --git a/src/test/java/samples/fieldReference/FieldReference.java b/src/test/java/samples/fieldReference/FieldReference.java index 557d3030..94829e7d 100644 --- a/src/test/java/samples/fieldReference/FieldReference.java +++ b/src/test/java/samples/fieldReference/FieldReference.java @@ -1,65 +1,65 @@ package samples.fieldReference; public class FieldReference { - private final int f = 2; - protected String b = "foo"; - private int a = 1; + private final int f = 2; + protected String b = "foo"; + private int a = 1; - public void ownField() { - System.out.println(a); - } + public void ownField() { + System.out.println(a); + } - public void ownFieldWrite() { - a++; - System.out.println(a); - } + public void ownFieldWrite() { + a++; + System.out.println(a); + } - public void otherField() { - A other = new A(); - System.out.println(other.i); - } + public void otherField() { + A other = new A(); + System.out.println(other.i); + } - public void otherFieldWrite() { - A other = new A(); - other.i++; - System.out.println(other.i); - } + public void otherFieldWrite() { + A other = new A(); + other.i++; + System.out.println(other.i); + } - public void otherFieldWrite2() { - A other = new A(); - int aO = other.i++; - System.out.println(aO); - } + public void otherFieldWrite2() { + A other = new A(); + int aO = other.i++; + System.out.println(aO); + } - public void ownFieldObject() { - System.out.println(b); - } + public void ownFieldObject() { + System.out.println(b); + } - public void ownFieldWriteObject() { - b = "new"; - System.out.println(b); - } + public void ownFieldWriteObject() { + b = "new"; + System.out.println(b); + } - public void otherFieldObject() { - A other = new A(); - System.out.println(other.j); - } + public void otherFieldObject() { + A other = new A(); + System.out.println(other.j); + } - public void otherFieldWriteObject() { - A other = new A(); - other.j = "new"; - System.out.println(other.j); - } + public void otherFieldWriteObject() { + A other = new A(); + other.j = "new"; + System.out.println(other.j); + } - public void otherFieldWrite2Object() { - A other = new A(); - String old = other.j; - other.j = "new"; - System.out.println(old); - } + public void otherFieldWrite2Object() { + A other = new A(); + String old = other.j; + other.j = "new"; + System.out.println(old); + } - public void finalField() { - System.out.println(b); - } + public void finalField() { + System.out.println(b); + } } \ No newline at end of file diff --git a/src/test/java/samples/generics/A.java b/src/test/java/samples/generics/A.java index b36eb986..d5f1c2d2 100644 --- a/src/test/java/samples/generics/A.java +++ b/src/test/java/samples/generics/A.java @@ -1,15 +1,16 @@ package samples.generics; /** - * @author Manuel Benz - * created on 13.07.18 + * @author Manuel Benz created on 13.07.18 */ public class A { - T t; + T t; - void setT(T t){this.t = t;} + void setT(T t) { + this.t = t; + } - T getT(){ - return this.t; - } + T getT() { + return this.t; + } } diff --git a/src/test/java/samples/generics/Generics.java b/src/test/java/samples/generics/Generics.java index f58eacd5..49a22395 100644 --- a/src/test/java/samples/generics/Generics.java +++ b/src/test/java/samples/generics/Generics.java @@ -7,21 +7,21 @@ */ public class Generics { - public void list() { - ArrayList list = new ArrayList<>(); - list.add("foo"); - System.out.println(list.get(0)); - } + public void list() { + ArrayList list = new ArrayList<>(); + list.add("foo"); + System.out.println(list.get(0)); + } - public void boxedList() { - ArrayList list = new ArrayList<>(); - list.add(1); - System.out.println(list.get(0)); - } + public void boxedList() { + ArrayList list = new ArrayList<>(); + list.add(1); + System.out.println(list.get(0)); + } - public void nonJDK() { - A stringA = new A<>(); - stringA.setT("foo"); - System.out.println(stringA.getT()); - } + public void nonJDK() { + A stringA = new A<>(); + stringA.setT("foo"); + System.out.println(stringA.getT()); + } } diff --git a/src/test/java/samples/inheritance/A.java b/src/test/java/samples/inheritance/A.java index 53b9e96f..4f889fc0 100644 --- a/src/test/java/samples/inheritance/A.java +++ b/src/test/java/samples/inheritance/A.java @@ -1,9 +1,9 @@ package samples.inheritance; abstract class A { - abstract void print(); + abstract void print(); - public void methodA() { - System.out.println("eval"); - } + public void methodA() { + System.out.println("eval"); + } } diff --git a/src/test/java/samples/inheritance/B.java b/src/test/java/samples/inheritance/B.java index a740f22b..38f7a7ff 100644 --- a/src/test/java/samples/inheritance/B.java +++ b/src/test/java/samples/inheritance/B.java @@ -1,14 +1,15 @@ package samples.inheritance; class B extends A { - protected int a = 5; - protected int b = 3; + protected int a = 5; + protected int b = 3; - public void print() { - System.out.println("printB"); - } + @Override + public void print() { + System.out.println("printB"); + } - public void methodB() { - System.out.println("methodB"); - } + public void methodB() { + System.out.println("methodB"); + } } diff --git a/src/test/java/samples/inheritance/C.java b/src/test/java/samples/inheritance/C.java index e9fcd530..992c51a5 100644 --- a/src/test/java/samples/inheritance/C.java +++ b/src/test/java/samples/inheritance/C.java @@ -5,14 +5,14 @@ */ public class C extends B { - public int a = 4; + public int a = 4; - @Override - public void methodA() { - System.out.println("methodAinC"); - } + @Override + public void methodA() { + System.out.println("methodAinC"); + } - public void methodC(){ - System.out.println("methodC"); - } + public void methodC() { + System.out.println("methodC"); + } } diff --git a/src/test/java/samples/inheritance/D.java b/src/test/java/samples/inheritance/D.java index e23f7df1..d4866557 100644 --- a/src/test/java/samples/inheritance/D.java +++ b/src/test/java/samples/inheritance/D.java @@ -4,8 +4,8 @@ * @author Manuel Benz created on 19.07.18 */ public class D extends A { - @Override - void print() { - System.out.println("D"); - } + @Override + void print() { + System.out.println("D"); + } } diff --git a/src/test/java/samples/inheritance/Inheritance.java b/src/test/java/samples/inheritance/Inheritance.java index cac12fdd..05fd4bc0 100644 --- a/src/test/java/samples/inheritance/Inheritance.java +++ b/src/test/java/samples/inheritance/Inheritance.java @@ -1,84 +1,84 @@ package samples.inheritance; public class Inheritance { - public void dynDispatch1() { - A b = new D(); - b.print(); - b.methodA(); - } + public void dynDispatch1() { + A b = new D(); + b.print(); + b.methodA(); + } - public void dynDispatch2() { - A b = new B(); - b.print(); - b.methodA(); - } + public void dynDispatch2() { + A b = new B(); + b.print(); + b.methodA(); + } - public void singleLevel() { - B b = new B(); - b.methodB(); - b.print(); - b.methodA(); - } + public void singleLevel() { + B b = new B(); + b.methodB(); + b.print(); + b.methodA(); + } - public void twoLevels() { - C b = new C(); - b.methodB(); - b.print(); - b.methodA(); - b.methodC(); - } + public void twoLevels() { + C b = new C(); + b.methodB(); + b.print(); + b.methodA(); + b.methodC(); + } - public void fieldOverwrite() { - final C c = new C(); - System.out.println(c.a); - System.out.println(c.b); - System.out.println(((B) c).a); - } + public void fieldOverwrite() { + final C c = new C(); + System.out.println(c.a); + System.out.println(c.b); + System.out.println(((B) c).a); + } - public void constructorOverwrite() { - SubConstructor sub = new SubConstructor(); - } + public void constructorOverwrite() { + SubConstructor sub = new SubConstructor(); + } - public void constructorOverwriteArg() { - SubConstructor sub = new SubConstructor("sup"); - } + public void constructorOverwriteArg() { + SubConstructor sub = new SubConstructor("sup"); + } - public void nestedClass() { - final X x = new X(); - x.print(); - x.methodA(); - } + public void nestedClass() { + final X x = new X(); + x.print(); + x.methodA(); + } - public void staticNestedClass() { - Y y = new Y(); - y.print(); - y.methodA(); - } + public void staticNestedClass() { + Y y = new Y(); + y.print(); + y.methodA(); + } - public void anonymousInheritance() { - A a = new A() { - @Override - void print() { - System.out.println("Abstract"); - } - }; - a.print(); - a.methodA(); - } + public void anonymousInheritance() { + A a = new A() { + @Override + void print() { + System.out.println("Abstract"); + } + }; + a.print(); + a.methodA(); + } - private static class Y extends A { + private static class Y extends A { - @Override - void print() { - System.out.println("Y"); - } - } + @Override + void print() { + System.out.println("Y"); + } + } - private class X extends A { + private class X extends A { - @Override - void print() { - System.out.println("X"); - } - } + @Override + void print() { + System.out.println("X"); + } + } } diff --git a/src/test/java/samples/inheritance/SubConstructor.java b/src/test/java/samples/inheritance/SubConstructor.java index 195faefd..f5220275 100644 --- a/src/test/java/samples/inheritance/SubConstructor.java +++ b/src/test/java/samples/inheritance/SubConstructor.java @@ -4,13 +4,13 @@ * @author Manuel Benz created on 12.07.18 */ public class SubConstructor extends SuperConstructor { - public SubConstructor() { - super(); - System.out.println("sub"); - } + public SubConstructor() { + super(); + System.out.println("sub"); + } - public SubConstructor(String arg) { - super(arg); - System.out.println("sub"); - } + public SubConstructor(String arg) { + super(arg); + System.out.println("sub"); + } } diff --git a/src/test/java/samples/inheritance/SuperConstructor.java b/src/test/java/samples/inheritance/SuperConstructor.java index 6ea4d024..6fd5d399 100644 --- a/src/test/java/samples/inheritance/SuperConstructor.java +++ b/src/test/java/samples/inheritance/SuperConstructor.java @@ -1,16 +1,15 @@ package samples.inheritance; /** - * @author Manuel Benz - * created on 12.07.18 + * @author Manuel Benz created on 12.07.18 */ public class SuperConstructor { - public SuperConstructor() { - System.out.println("sup"); - } + public SuperConstructor() { + System.out.println("sup"); + } - public SuperConstructor(String arg) { - System.out.println(arg); - } + public SuperConstructor(String arg) { + System.out.println(arg); + } } diff --git a/src/test/java/samples/interfaces/A.java b/src/test/java/samples/interfaces/A.java index c640c923..642d288d 100644 --- a/src/test/java/samples/interfaces/A.java +++ b/src/test/java/samples/interfaces/A.java @@ -4,8 +4,8 @@ * @author Manuel Benz created on 12.07.18 */ public class A extends B implements I2 { - @Override - public void printI2() { - System.out.println("implements i2"); - } + @Override + public void printI2() { + System.out.println("implements i2"); + } } diff --git a/src/test/java/samples/interfaces/B.java b/src/test/java/samples/interfaces/B.java index b5846f9a..74082558 100644 --- a/src/test/java/samples/interfaces/B.java +++ b/src/test/java/samples/interfaces/B.java @@ -2,7 +2,8 @@ // implementing single interface class B implements I1 { - public void printI1() { - System.out.println("Interface I1"); - } + @Override + public void printI1() { + System.out.println("Interface I1"); + } } diff --git a/src/test/java/samples/interfaces/C.java b/src/test/java/samples/interfaces/C.java index 9f9d6de1..e00ba256 100644 --- a/src/test/java/samples/interfaces/C.java +++ b/src/test/java/samples/interfaces/C.java @@ -2,12 +2,14 @@ public class C implements I1, I2 { - // implementing multiple interfaces - public void printI1() { - System.out.println("Interface I1"); - } + // implementing multiple interfaces + @Override + public void printI1() { + System.out.println("Interface I1"); + } - public void printI2() { - System.out.println("Interface I2"); - } + @Override + public void printI2() { + System.out.println("Interface I2"); + } } diff --git a/src/test/java/samples/interfaces/D.java b/src/test/java/samples/interfaces/D.java index d368919b..286b4ce5 100644 --- a/src/test/java/samples/interfaces/D.java +++ b/src/test/java/samples/interfaces/D.java @@ -4,8 +4,8 @@ * @author Manuel Benz created on 12.07.18 */ public class D extends C { - @Override - public void printI2() { - System.out.println("overwrites i2"); - } + @Override + public void printI2() { + System.out.println("overwrites i2"); + } } diff --git a/src/test/java/samples/interfaces/I1.java b/src/test/java/samples/interfaces/I1.java index 296c11ec..55cc8bf7 100644 --- a/src/test/java/samples/interfaces/I1.java +++ b/src/test/java/samples/interfaces/I1.java @@ -1,6 +1,6 @@ package samples.interfaces; interface I1 { - // method signature - void printI1(); + // method signature + void printI1(); } diff --git a/src/test/java/samples/interfaces/I2.java b/src/test/java/samples/interfaces/I2.java index a5ffd614..e4908c92 100644 --- a/src/test/java/samples/interfaces/I2.java +++ b/src/test/java/samples/interfaces/I2.java @@ -1,6 +1,6 @@ package samples.interfaces; interface I2 { - // method signature - void printI2(); + // method signature + void printI2(); } diff --git a/src/test/java/samples/interfaces/Interfaces.java b/src/test/java/samples/interfaces/Interfaces.java index fda33583..2fe7df97 100644 --- a/src/test/java/samples/interfaces/Interfaces.java +++ b/src/test/java/samples/interfaces/Interfaces.java @@ -1,42 +1,42 @@ package samples.interfaces; public class Interfaces { - public void singleInterface() { - B i1 = new B(); - i1.printI1(); - } + public void singleInterface() { + B i1 = new B(); + i1.printI1(); + } - public void singleInterfaceDynDispatch() { - I1 i1 = new B(); - i1.printI1(); - } + public void singleInterfaceDynDispatch() { + I1 i1 = new B(); + i1.printI1(); + } - public void multipleInterface() { - C c = new C(); - c.printI1(); - c.printI2(); - } + public void multipleInterface() { + C c = new C(); + c.printI1(); + c.printI2(); + } - public void inheritanceAndInterface() { - final A a = new A(); - a.printI2(); - a.printI1(); - } + public void inheritanceAndInterface() { + final A a = new A(); + a.printI2(); + a.printI1(); + } - public void overwriteInterfaceMethod() { - final D d = new D(); - d.printI2(); - d.printI1(); - ((C) d).printI2(); - } + public void overwriteInterfaceMethod() { + final D d = new D(); + d.printI2(); + d.printI1(); + ((C) d).printI2(); + } - public void anonymousImpl() { - I2 i2 = new I2() { - @Override - public void printI2() { - System.out.println("anonymous i2"); - } - }; - i2.printI2(); - } + public void anonymousImpl() { + I2 i2 = new I2() { + @Override + public void printI2() { + System.out.println("anonymous i2"); + } + }; + i2.printI2(); + } } diff --git a/src/test/java/samples/jimpleShowcase/JimpleShowcase.java b/src/test/java/samples/jimpleShowcase/JimpleShowcase.java index dc41abf5..2d49d4c5 100644 --- a/src/test/java/samples/jimpleShowcase/JimpleShowcase.java +++ b/src/test/java/samples/jimpleShowcase/JimpleShowcase.java @@ -1,12 +1,11 @@ package samples.jimpleShowcase; /** - * @author Manuel Benz - * created on 13.07.18 + * @author Manuel Benz created on 13.07.18 */ public class JimpleShowcase { - public void justCreateJimpleForThisClass(){ - System.out.println(); - } + public void justCreateJimpleForThisClass() { + System.out.println(); + } } diff --git a/src/test/java/samples/lambdaExpressions/AddLambda.java b/src/test/java/samples/lambdaExpressions/AddLambda.java new file mode 100644 index 00000000..04eab7e9 --- /dev/null +++ b/src/test/java/samples/lambdaExpressions/AddLambda.java @@ -0,0 +1,14 @@ +package samples.lambdaExpressions; + +interface Addable { + int add(int a, int b); +} + +public class AddLambda { + public static void main(String[] args) { + + Addable sum = (a, b) -> (a + b); + + System.out.println(sum.add(1, 2)); + } +} \ No newline at end of file diff --git a/src/test/java/samples/lambdaExpressions/IncClosure.java b/src/test/java/samples/lambdaExpressions/IncClosure.java new file mode 100644 index 00000000..2cdd284b --- /dev/null +++ b/src/test/java/samples/lambdaExpressions/IncClosure.java @@ -0,0 +1,15 @@ +package samples.lambdaExpressions; + +interface Incrementable { + int inc(int a); +} + +public class IncClosure { + public static void main(String[] args) { + int i = 1; + + Incrementable incBy = (a) -> (a+i); + + System.out.println(incBy.inc(1)); + } +} diff --git a/src/test/java/samples/lambdaExpressions/LambdaExpressions.java b/src/test/java/samples/lambdaExpressions/LambdaExpressions.java index 7486bf89..23eda242 100644 --- a/src/test/java/samples/lambdaExpressions/LambdaExpressions.java +++ b/src/test/java/samples/lambdaExpressions/LambdaExpressions.java @@ -2,45 +2,45 @@ public class LambdaExpressions { - private static void doSomethingStatic() { - System.out.println("something"); - } - - public void lambdaRet() { - functionalRet f1 = () -> "foo"; - System.out.println(f1.eval()); - } - - public void lambdaParam() { - functionalArg f1 = (arg) -> System.out.println(arg); - f1.eval("arg"); - } - - public void lambdaVoid() { - functionalVoid f1 = () -> System.out.println("void"); - f1.eval(); - } - - public void passToMethod() { - doEval(() -> System.out.println("passed as param")); - } - - private void doEval(functionalVoid re) { - re.eval(); - } - - public void functionPointer() { - LambdaExpressions es = new LambdaExpressions(); - doEval(es::doSomething); - } - - private void doSomething() { - System.out.println("something"); - } - - public void functionPointerStatic() { - LambdaExpressions es = new LambdaExpressions(); - doEval(LambdaExpressions::doSomethingStatic); - } + private static void doSomethingStatic() { + System.out.println("something"); + } + + public void lambdaRet() { + functionalRet f1 = () -> "foo"; + System.out.println(f1.eval()); + } + + public void lambdaParam() { + functionalArg f1 = (arg) -> System.out.println(arg); + f1.eval("arg"); + } + + public void lambdaVoid() { + functionalVoid f1 = () -> System.out.println("void"); + f1.eval(); + } + + public void passToMethod() { + doEval(() -> System.out.println("passed as param")); + } + + private void doEval(functionalVoid re) { + re.eval(); + } + + public void functionPointer() { + LambdaExpressions es = new LambdaExpressions(); + doEval(es::doSomething); + } + + private void doSomething() { + System.out.println("something"); + } + + public void functionPointerStatic() { + LambdaExpressions es = new LambdaExpressions(); + doEval(LambdaExpressions::doSomethingStatic); + } } diff --git a/src/test/java/samples/lambdaExpressions/Palindromes.java b/src/test/java/samples/lambdaExpressions/Palindromes.java new file mode 100644 index 00000000..75499ff8 --- /dev/null +++ b/src/test/java/samples/lambdaExpressions/Palindromes.java @@ -0,0 +1,29 @@ +package samples.lambdaExpressions; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +public class Palindromes { + public static void main(String[] args) throws Exception { + + List words = Arrays.asList("Hannah", "Ana", "Elle", "Bob", "Otto", "Natan", "Luisa", "Andre", "Renata"); + + // compare to the inverse + Comparator stringComparator = (s1, s2) -> s1.toLowerCase() + .compareTo(new StringBuilder(s2).reverse().toString().toLowerCase()); + + Runnable r = () -> words.forEach(w -> { + if (stringComparator.compare(w, w) == 0) { + System.out.println(w + " is a palindrome."); + } else { + System.out.println(w + " is not a palindrome."); + } + }); + + Thread t = new Thread(r); + t.start(); + t.join(); + + } +} \ No newline at end of file diff --git a/src/test/java/samples/lambdaExpressions/Runners.java b/src/test/java/samples/lambdaExpressions/Runners.java new file mode 100644 index 00000000..82ac0df7 --- /dev/null +++ b/src/test/java/samples/lambdaExpressions/Runners.java @@ -0,0 +1,44 @@ +package samples.lambdaExpressions; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +public class Runners { + public static void main(String[] args) throws Exception { + + List words = Arrays.asList("Hannah", "Bob", "Otto", "Natan", "Luisa", "Andre", "Renata"); + + List nums = Arrays.asList(-2, -1, 0, 1, 2); + + // compare to the inverse + Comparator stringComparator = (s1, s2) -> s1.toLowerCase() + .compareTo(new StringBuilder(s2).reverse().toString().toLowerCase()); + + Runnable rString = () -> words.forEach(w -> { + if (stringComparator.compare(w, w) == 0) { + System.out.println(w + " is a palindrome."); + } else { + System.out.println(w + " is not a palindrome."); + } + }); + + Comparator intComparator = (i1, i2) -> i1.compareTo(i2); + + Runnable rInteger = () -> nums.forEach(n -> { + if (intComparator.compare(n, 0) == 0) { + System.out.println("ZERO"); + } else { + System.out.println(n); + } + }); + + Thread t1 = new Thread(rString); + t1.start(); + t1.join(); + + Thread t2 = new Thread(rInteger); + t2.start(); + t2.join(); + } +} \ No newline at end of file diff --git a/src/test/java/samples/lambdaExpressions/SumList.java b/src/test/java/samples/lambdaExpressions/SumList.java new file mode 100644 index 00000000..d6ad3f0b --- /dev/null +++ b/src/test/java/samples/lambdaExpressions/SumList.java @@ -0,0 +1,13 @@ +package samples.lambdaExpressions; + +import java.util.Arrays; +import java.util.List; + +public class SumList { + public static void main(String[] args) throws Exception { + + List nums = Arrays.asList(1, 2, 3, 4); + + System.out.println(nums.stream().mapToInt(n -> n.intValue()).sum()); + } +} \ No newline at end of file diff --git a/src/test/java/samples/lambdaExpressions/functionalArg.java b/src/test/java/samples/lambdaExpressions/functionalArg.java index a45b43a3..cf2525ef 100644 --- a/src/test/java/samples/lambdaExpressions/functionalArg.java +++ b/src/test/java/samples/lambdaExpressions/functionalArg.java @@ -1,10 +1,9 @@ package samples.lambdaExpressions; /** - * @author Manuel Benz - * created on 12.07.18 + * @author Manuel Benz created on 12.07.18 */ @FunctionalInterface public interface functionalArg { - void eval(String foo); + void eval(String foo); } diff --git a/src/test/java/samples/lambdaExpressions/functionalRet.java b/src/test/java/samples/lambdaExpressions/functionalRet.java index 53c40199..1b38a7f9 100644 --- a/src/test/java/samples/lambdaExpressions/functionalRet.java +++ b/src/test/java/samples/lambdaExpressions/functionalRet.java @@ -2,5 +2,5 @@ @FunctionalInterface interface functionalRet { - String eval(); + String eval(); } \ No newline at end of file diff --git a/src/test/java/samples/lambdaExpressions/functionalVoid.java b/src/test/java/samples/lambdaExpressions/functionalVoid.java index 4507d3cb..757ccb8d 100644 --- a/src/test/java/samples/lambdaExpressions/functionalVoid.java +++ b/src/test/java/samples/lambdaExpressions/functionalVoid.java @@ -1,10 +1,9 @@ package samples.lambdaExpressions; /** - * @author Manuel Benz - * created on 12.07.18 + * @author Manuel Benz created on 12.07.18 */ @FunctionalInterface public interface functionalVoid { - void eval(); + void eval(); } diff --git a/src/test/java/samples/nestedControlStatements/NestedControlStatements.java b/src/test/java/samples/nestedControlStatements/NestedControlStatements.java index 30564eb9..09c959b1 100644 --- a/src/test/java/samples/nestedControlStatements/NestedControlStatements.java +++ b/src/test/java/samples/nestedControlStatements/NestedControlStatements.java @@ -2,430 +2,430 @@ public class NestedControlStatements { - private int[][] permutations3 = { { 1, 2, 3 }, { 2, 1, 3 }, { 3, 1, 2 }, { 1, 3, 2 }, { 2, 3, 1 }, { 3, 2, 1 } }; - - public void nestedIfElse() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedIfElse(ints[0], ints[1], ints[2]); - } - } - - private void nestedIfElse(int a, int b, int c) { - if (a < b) { - System.out.println(1); - if (b < c) { - System.out.println(2); - } else { - System.out.println(3); - } - } else if (a < c) { - System.out.println(4); - if (b < c) { - System.out.println(5); - } else { - System.out.println(6); - } - } else { - System.out.println(7); - if (b < c) { - System.out.println(8); - } else { - System.out.println(9); - } - } - } - - public void nestedSwitchIf() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedSwitchIf(ints[0], ints[1], ints[2]); - } - } - - private void nestedSwitchIf(int a, int b, int c) { - if (a < b) { - switch (a) { - case 1: - System.out.println(1); - case 2: - System.out.println(2); - default: - System.out.println(3); - } - } else if (a < c) { - System.out.println(4); - switch (a) { - case 1: - System.out.println(5); - case 2: - System.out.println(6); - default: - System.out.println(7); - } - } else { - System.out.println(8); - switch (a) { - case 1: - System.out.println(9); - case 2: - System.out.println(10); - default: - System.out.println(11); - } - } - } - - public void nestedWhileIf() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedWhileIf(ints[0], ints[1], ints[2]); - } - } - - private void nestedWhileIf(int a, int b, int c) { - // Nested while in if - if (a < b) { - System.out.println(1); - while (a < b) { - System.out.println(2); - a++; - } - } else if (a < c) { - System.out.println(3); - while (a < b) { - System.out.println(4); - a++; - } - } else { - System.out.println(5); - while (a < b) { - System.out.println(6); - a++; - } - } - } - - public void nestedForIf() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedForIf(ints[0], ints[1], ints[2]); - } - } - - private void nestedForIf(int a, int b, int c) { - if (a < b) { - System.out.println(1); - for (int i = 0; i < a; i++) { - System.out.println(2); - } - } else if (a < c) { - System.out.println(3); - for (int i = 0; i < a; i++) { - System.out.println(4); - } - } else { - System.out.println(5); - for (int i = 0; i < a; i++) { - System.out.println(6); - } - } - } - - public void nestedSwitchSwitch() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedSwitchSwitch(ints[0], ints[1], ints[2]); - } - } - - private void nestedSwitchSwitch(int a, int b, int c) { - // Nested switch in switch - switch (a) { - case 1: - System.out.println(1); - switch (b) { - case 5: - System.out.println(2); - case 1: - System.out.println(3); - default: - System.out.println(4); - } - case 2: - System.out.println(5); - switch (b) { - case 5: - System.out.println(6); - case 1: - System.out.println(7); - default: - System.out.println(8); - } - default: - System.out.println(9); - switch (b) { - case 5: - System.out.println(10); - case 1: - System.out.println(11); - default: - System.out.println(12); - } - } - } - - public void nestedIfSwitch() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedIfSwitch(ints[0], ints[1], ints[2]); - } - } - - private void nestedIfSwitch(int a, int b, int c) { - switch (a) { - case 1: - System.out.println(1); - if (a < b) { - System.out.println(2); - } else if (a < c) { - System.out.println(3); - } else { - System.out.println(4); - } - - case 2: - System.out.println(5); - if (a < b) { - System.out.println(6); - } else if (a < c) { - System.out.println(7); - } else { - System.out.println(8); - } - default: - System.out.println(9); - if (a < b) { - System.out.println(10); - } else if (a < c) { - System.out.println(11); - } else { - System.out.println(12); - } - } - } - - public void nestedWhileSwitch() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedWhileSwitch(ints[0], ints[1], ints[2]); - } - } - - private void nestedWhileSwitch(int a, int b, int c) { - // Nested while in switch - switch (a) { - case 1: - System.out.println(1); - while (a < b) { - a++; - System.out.println(2); - } - case 2: - System.out.println(3); - while (a < b) { - a++; - System.out.println(4); - } - default: - System.out.println(5); - while (a < b) { - a++; - System.out.println(6); - } - } - } - - public void nestedForSwitch() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedForSwitch(ints[0], ints[1], ints[2]); - } - } - - private void nestedForSwitch(int a, int b, int c) { - // Nested for in switch - switch (a) { - case 1: - System.out.println(1); - for (int i = 0; i < a; i++) { - System.out.println(2); - } - case 2: - System.out.println(3); - for (int i = 0; i < a; i++) { - System.out.println(4); - } - default: - System.out.println(5); - for (int i = 0; i < a; i++) { - System.out.println(6); - } - } - } - - public void nestedWhileWhile() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedWhileWhile(ints[0], ints[1], ints[2]); - } - } - - private void nestedWhileWhile(int a, int b, int c) { - // Nested while - while (a < b) { - System.out.println(1); - while (b < c) { - b++; - System.out.println(2); - } - a++; - } - } - - public void nestedIfWhile() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedIfWhile(ints[0], ints[1], ints[2]); - } - } - - private void nestedIfWhile(int a, int b, int c) { - // Nested if in while - while (a < b) { - System.out.println(1); - if (a < b) { - System.out.println(2); - } else if (a < c) { - System.out.println(3); - } else { - System.out.println(4); - } - a++; - } - } - - public void nestedSwitchWhile() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedSwitchWhile(ints[0], ints[1], ints[2]); - } - } - - private void nestedSwitchWhile(int a, int b, int c) { - // Nested switch in while - while (a < b) { - System.out.println(1); - switch (a) { - case 1: - System.out.println(2); - case 2: - System.out.println(3); - default: - System.out.println(4); - } - a++; - } - } - - public void nestedForWhile() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedForWhile(ints[0], ints[1], ints[2]); - } - } - - private void nestedForWhile(int a, int b, int c) { - // Nested for in while - while (a < b) { - System.out.println(1); - for (int i = 0; i < a; i++) { - System.out.println(2); - } - a++; - } - } - - public void nestedIfFor() { - for (int i = 0; i < permutations3.length; i++) { - int[] ints = permutations3[i]; - nestedIfFor(ints[0], ints[1], ints[2]); - } - } - - private void nestedIfFor(int a, int b, int c) { - // Nested if in for - for (int i = 0; i < a; i++) { - System.out.println(1); - if (a < b) { - System.out.println(2); - } else if (a < c) { - System.out.println(3); - } else { - System.out.println(4); - } - } - } - - public void nested_switch_in_for() { - int a = 5; - int b = 0; - for (int i = 0; i < a; i++) { - b++; - System.out.println(b); - switch (b) { - case 1: - System.out.println("a"); - case 2: - System.out.println("b"); - default: - System.out.println(b); - } - } - } - - public void nestedWhileFor() { - int a = 5; - int b = 3; - for (int i = 0; i < a; i++) { - System.out.println(i); - while (a < b) { - System.out.println("a is smaller than b"); - a++; - } - } - } - - public void nestedSwitchFor() { - int a = 5; - for (int i = 0; i < a; i++) { - switch (a) { - case 1: - System.out.println("foo"); - - default: - System.out.println(a); - - } - } - } - - public void nestedForFor() { - int a = 5; - for (int i = 0; i < a; i++) { - for (int j = 0; j <= i; j++) { - System.out.println(i + j); - } - } - } + private int[][] permutations3 = { { 1, 2, 3 }, { 2, 1, 3 }, { 3, 1, 2 }, { 1, 3, 2 }, { 2, 3, 1 }, { 3, 2, 1 } }; + + public void nestedIfElse() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedIfElse(ints[0], ints[1], ints[2]); + } + } + + private void nestedIfElse(int a, int b, int c) { + if (a < b) { + System.out.println(1); + if (b < c) { + System.out.println(2); + } else { + System.out.println(3); + } + } else if (a < c) { + System.out.println(4); + if (b < c) { + System.out.println(5); + } else { + System.out.println(6); + } + } else { + System.out.println(7); + if (b < c) { + System.out.println(8); + } else { + System.out.println(9); + } + } + } + + public void nestedSwitchIf() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedSwitchIf(ints[0], ints[1], ints[2]); + } + } + + private void nestedSwitchIf(int a, int b, int c) { + if (a < b) { + switch (a) { + case 1: + System.out.println(1); + case 2: + System.out.println(2); + default: + System.out.println(3); + } + } else if (a < c) { + System.out.println(4); + switch (a) { + case 1: + System.out.println(5); + case 2: + System.out.println(6); + default: + System.out.println(7); + } + } else { + System.out.println(8); + switch (a) { + case 1: + System.out.println(9); + case 2: + System.out.println(10); + default: + System.out.println(11); + } + } + } + + public void nestedWhileIf() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedWhileIf(ints[0], ints[1], ints[2]); + } + } + + private void nestedWhileIf(int a, int b, int c) { + // Nested while in if + if (a < b) { + System.out.println(1); + while (a < b) { + System.out.println(2); + a++; + } + } else if (a < c) { + System.out.println(3); + while (a < b) { + System.out.println(4); + a++; + } + } else { + System.out.println(5); + while (a < b) { + System.out.println(6); + a++; + } + } + } + + public void nestedForIf() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedForIf(ints[0], ints[1], ints[2]); + } + } + + private void nestedForIf(int a, int b, int c) { + if (a < b) { + System.out.println(1); + for (int i = 0; i < a; i++) { + System.out.println(2); + } + } else if (a < c) { + System.out.println(3); + for (int i = 0; i < a; i++) { + System.out.println(4); + } + } else { + System.out.println(5); + for (int i = 0; i < a; i++) { + System.out.println(6); + } + } + } + + public void nestedSwitchSwitch() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedSwitchSwitch(ints[0], ints[1], ints[2]); + } + } + + private void nestedSwitchSwitch(int a, int b, int c) { + // Nested switch in switch + switch (a) { + case 1: + System.out.println(1); + switch (b) { + case 5: + System.out.println(2); + case 1: + System.out.println(3); + default: + System.out.println(4); + } + case 2: + System.out.println(5); + switch (b) { + case 5: + System.out.println(6); + case 1: + System.out.println(7); + default: + System.out.println(8); + } + default: + System.out.println(9); + switch (b) { + case 5: + System.out.println(10); + case 1: + System.out.println(11); + default: + System.out.println(12); + } + } + } + + public void nestedIfSwitch() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedIfSwitch(ints[0], ints[1], ints[2]); + } + } + + private void nestedIfSwitch(int a, int b, int c) { + switch (a) { + case 1: + System.out.println(1); + if (a < b) { + System.out.println(2); + } else if (a < c) { + System.out.println(3); + } else { + System.out.println(4); + } + + case 2: + System.out.println(5); + if (a < b) { + System.out.println(6); + } else if (a < c) { + System.out.println(7); + } else { + System.out.println(8); + } + default: + System.out.println(9); + if (a < b) { + System.out.println(10); + } else if (a < c) { + System.out.println(11); + } else { + System.out.println(12); + } + } + } + + public void nestedWhileSwitch() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedWhileSwitch(ints[0], ints[1], ints[2]); + } + } + + private void nestedWhileSwitch(int a, int b, int c) { + // Nested while in switch + switch (a) { + case 1: + System.out.println(1); + while (a < b) { + a++; + System.out.println(2); + } + case 2: + System.out.println(3); + while (a < b) { + a++; + System.out.println(4); + } + default: + System.out.println(5); + while (a < b) { + a++; + System.out.println(6); + } + } + } + + public void nestedForSwitch() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedForSwitch(ints[0], ints[1], ints[2]); + } + } + + private void nestedForSwitch(int a, int b, int c) { + // Nested for in switch + switch (a) { + case 1: + System.out.println(1); + for (int i = 0; i < a; i++) { + System.out.println(2); + } + case 2: + System.out.println(3); + for (int i = 0; i < a; i++) { + System.out.println(4); + } + default: + System.out.println(5); + for (int i = 0; i < a; i++) { + System.out.println(6); + } + } + } + + public void nestedWhileWhile() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedWhileWhile(ints[0], ints[1], ints[2]); + } + } + + private void nestedWhileWhile(int a, int b, int c) { + // Nested while + while (a < b) { + System.out.println(1); + while (b < c) { + b++; + System.out.println(2); + } + a++; + } + } + + public void nestedIfWhile() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedIfWhile(ints[0], ints[1], ints[2]); + } + } + + private void nestedIfWhile(int a, int b, int c) { + // Nested if in while + while (a < b) { + System.out.println(1); + if (a < b) { + System.out.println(2); + } else if (a < c) { + System.out.println(3); + } else { + System.out.println(4); + } + a++; + } + } + + public void nestedSwitchWhile() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedSwitchWhile(ints[0], ints[1], ints[2]); + } + } + + private void nestedSwitchWhile(int a, int b, int c) { + // Nested switch in while + while (a < b) { + System.out.println(1); + switch (a) { + case 1: + System.out.println(2); + case 2: + System.out.println(3); + default: + System.out.println(4); + } + a++; + } + } + + public void nestedForWhile() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedForWhile(ints[0], ints[1], ints[2]); + } + } + + private void nestedForWhile(int a, int b, int c) { + // Nested for in while + while (a < b) { + System.out.println(1); + for (int i = 0; i < a; i++) { + System.out.println(2); + } + a++; + } + } + + public void nestedIfFor() { + for (int i = 0; i < permutations3.length; i++) { + int[] ints = permutations3[i]; + nestedIfFor(ints[0], ints[1], ints[2]); + } + } + + private void nestedIfFor(int a, int b, int c) { + // Nested if in for + for (int i = 0; i < a; i++) { + System.out.println(1); + if (a < b) { + System.out.println(2); + } else if (a < c) { + System.out.println(3); + } else { + System.out.println(4); + } + } + } + + public void nested_switch_in_for() { + int a = 5; + int b = 0; + for (int i = 0; i < a; i++) { + b++; + System.out.println(b); + switch (b) { + case 1: + System.out.println("a"); + case 2: + System.out.println("b"); + default: + System.out.println(b); + } + } + } + + public void nestedWhileFor() { + int a = 5; + int b = 3; + for (int i = 0; i < a; i++) { + System.out.println(i); + while (a < b) { + System.out.println("a is smaller than b"); + a++; + } + } + } + + public void nestedSwitchFor() { + int a = 5; + for (int i = 0; i < a; i++) { + switch (a) { + case 1: + System.out.println("foo"); + + default: + System.out.println(a); + + } + } + } + + public void nestedForFor() { + int a = 5; + for (int i = 0; i < a; i++) { + for (int j = 0; j <= i; j++) { + System.out.println(i + j); + } + } + } } diff --git a/src/test/java/samples/objects/A.java b/src/test/java/samples/objects/A.java index 0dc12fa0..25bbdc95 100644 --- a/src/test/java/samples/objects/A.java +++ b/src/test/java/samples/objects/A.java @@ -4,27 +4,27 @@ * @author Manuel Benz created on 12.07.18 */ public class A { - public void voidM() { - System.out.println("foo"); - } + public void voidM() { + System.out.println("foo"); + } - public String returnM() { - return "bar"; - } + public String returnM() { + return "bar"; + } - public void argsM(String foo, String bar) { - System.out.println(foo); - System.out.println(bar); - } + public void argsM(String foo, String bar) { + System.out.println(foo); + System.out.println(bar); + } - public void argsVar(String... foo) { - for (String s : foo) { - System.out.println(s); - } - } + public void argsVar(String... foo) { + for (String s : foo) { + System.out.println(s); + } + } - @Override - public String toString() { - return "A"; - } + @Override + public String toString() { + return "A"; + } } diff --git a/src/test/java/samples/objects/B.java b/src/test/java/samples/objects/B.java index cee63a34..eb86996d 100644 --- a/src/test/java/samples/objects/B.java +++ b/src/test/java/samples/objects/B.java @@ -4,12 +4,12 @@ * @author Manuel Benz created on 12.07.18 */ public class B { - public B() { - System.out.println("constructor"); - } + public B() { + System.out.println("constructor"); + } - @Override - public String toString() { - return "B"; - } + @Override + public String toString() { + return "B"; + } } diff --git a/src/test/java/samples/objects/Objects.java b/src/test/java/samples/objects/Objects.java index fac36eaa..493412d3 100644 --- a/src/test/java/samples/objects/Objects.java +++ b/src/test/java/samples/objects/Objects.java @@ -5,29 +5,29 @@ */ public class Objects { - public void emptyConstructor() { - A a = new A(); - System.out.println("A"); - } + public void emptyConstructor() { + A a = new A(); + System.out.println("A"); + } - public void singleConstructor() { - B a = new B(); - System.out.println("B"); - } + public void singleConstructor() { + B a = new B(); + System.out.println("B"); + } - public void methodCall() { - new A().voidM(); - } + public void methodCall() { + new A().voidM(); + } - public void methodCallReturn() { - System.out.println(new A().returnM()); - } + public void methodCallReturn() { + System.out.println(new A().returnM()); + } - public void methodCallArgs() { - new A().argsM("foo", "bar"); - } + public void methodCallArgs() { + new A().argsM("foo", "bar"); + } - public void methodCallVarArgs() { - new A().argsVar("foo", "bar"); - } + public void methodCallVarArgs() { + new A().argsVar("foo", "bar"); + } } diff --git a/src/test/java/samples/operators/A.java b/src/test/java/samples/operators/A.java index ffdd14ce..6c912950 100644 --- a/src/test/java/samples/operators/A.java +++ b/src/test/java/samples/operators/A.java @@ -1,11 +1,10 @@ package samples.operators; /** - * @author Manuel Benz - * created on 20.07.18 + * @author Manuel Benz created on 20.07.18 */ public class A { - public A() { - System.out.println("A"); - } + public A() { + System.out.println("A"); + } } diff --git a/src/test/java/samples/operators/BooleanOps.java b/src/test/java/samples/operators/BooleanOps.java index 3e7943b4..7f3ce8c8 100644 --- a/src/test/java/samples/operators/BooleanOps.java +++ b/src/test/java/samples/operators/BooleanOps.java @@ -5,23 +5,23 @@ */ public class BooleanOps { - public void logicalOr() { - boolean a = true; - boolean b = true; - boolean result = (a || b); - System.out.println(result); - } + public void logicalOr() { + boolean a = true; + boolean b = true; + boolean result = (a || b); + System.out.println(result); + } - public void logicalAnd() { - boolean a = true; - boolean b = true; - boolean result = (a && b); - System.out.println(result); - } + public void logicalAnd() { + boolean a = true; + boolean b = true; + boolean result = (a && b); + System.out.println(result); + } - public void logicalNot() { - boolean a = false; - boolean result = !(a); - System.out.println(result); - } + public void logicalNot() { + boolean a = false; + boolean result = !(a); + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/ByteOps.java b/src/test/java/samples/operators/ByteOps.java index d72cdd7f..ae4d00c2 100644 --- a/src/test/java/samples/operators/ByteOps.java +++ b/src/test/java/samples/operators/ByteOps.java @@ -2,131 +2,131 @@ public class ByteOps { - public void addition() { - byte a = 5; - byte b = 5; - byte d = (byte) (a + b); - System.out.println(d); - } - - public void subtraction() { - byte a = 5; - byte b = 5; - byte d = (byte) (b - a); - System.out.println(d); - } - - public void multiplication() { - byte a = 5; - byte b = 5; - byte d = (byte) (b * a); - System.out.println(d); - } - - public void division() { - byte a = 5; - byte b = 5; - byte d = (byte) (b / a); - System.out.println(d); - } - - public void modulus() { - byte a = 5; - byte b = 5; - byte d = (byte) (b % a); - System.out.println(d); - } - - public void simpleAssignmentOperator() { - byte a = 5; - byte d = a; - System.out.println(d); - } - - public void bitwiseAnd() { - byte a = 5; - byte b = 5; - byte d = (byte) (a & b); - System.out.println(d); - } - - public void bitwiseOr() { - byte a = 5; - byte b = 5; - byte d = (byte) (a | b); - System.out.println(d); - } - - public void bitwiseXor() { - byte a = 5; - byte b = 5; - byte d = (byte) (a ^ b); - System.out.println(d); - } - - public void bitwiseCompliment() { - byte a = 5; - byte d = (byte) ~a; - System.out.println(d); - } - - public void bitwiseLeftShift() { - byte a = 5; - byte d = (byte) (a << 2); - System.out.println(d); - } - - public void bitwiseRightShift() { - byte a = 5; - byte d = (byte) (a >> 2); - System.out.println(d); - } - - public void bitwiseRightShiftZerofill() { - byte a = 5; - byte d = (byte) (a >>> 2); - System.out.println(d); - } - - public void equals() { - byte a = 5; - byte b = 5; - boolean result = (a == b); - System.out.println(result); - } - - public void notEquals() { - byte a = 5; - byte b = 5; - boolean result = (a != b); - System.out.println(result); - } - - public void greateThan() { - byte a = 5; - byte b = 5; - boolean result = (a > b); - System.out.println(result); - } - - public void lessThan() { - byte a = 5; - byte b = 5; - boolean result = (a < b); - System.out.println(result); - } - - public void greaterOrEqualsThan() { - byte a = 5; - byte b = 5; - boolean result = (a >= b); - System.out.println(result); - } - - public void lessOrEqualsThan() { - byte a = 5; - byte b = 5; - boolean result = (a <= b); - System.out.println(result); - } + public void addition() { + byte a = 5; + byte b = 5; + byte d = (byte) (a + b); + System.out.println(d); + } + + public void subtraction() { + byte a = 5; + byte b = 5; + byte d = (byte) (b - a); + System.out.println(d); + } + + public void multiplication() { + byte a = 5; + byte b = 5; + byte d = (byte) (b * a); + System.out.println(d); + } + + public void division() { + byte a = 5; + byte b = 5; + byte d = (byte) (b / a); + System.out.println(d); + } + + public void modulus() { + byte a = 5; + byte b = 5; + byte d = (byte) (b % a); + System.out.println(d); + } + + public void simpleAssignmentOperator() { + byte a = 5; + byte d = a; + System.out.println(d); + } + + public void bitwiseAnd() { + byte a = 5; + byte b = 5; + byte d = (byte) (a & b); + System.out.println(d); + } + + public void bitwiseOr() { + byte a = 5; + byte b = 5; + byte d = (byte) (a | b); + System.out.println(d); + } + + public void bitwiseXor() { + byte a = 5; + byte b = 5; + byte d = (byte) (a ^ b); + System.out.println(d); + } + + public void bitwiseCompliment() { + byte a = 5; + byte d = (byte) ~a; + System.out.println(d); + } + + public void bitwiseLeftShift() { + byte a = 5; + byte d = (byte) (a << 2); + System.out.println(d); + } + + public void bitwiseRightShift() { + byte a = 5; + byte d = (byte) (a >> 2); + System.out.println(d); + } + + public void bitwiseRightShiftZerofill() { + byte a = 5; + byte d = (byte) (a >>> 2); + System.out.println(d); + } + + public void equals() { + byte a = 5; + byte b = 5; + boolean result = (a == b); + System.out.println(result); + } + + public void notEquals() { + byte a = 5; + byte b = 5; + boolean result = (a != b); + System.out.println(result); + } + + public void greateThan() { + byte a = 5; + byte b = 5; + boolean result = (a > b); + System.out.println(result); + } + + public void lessThan() { + byte a = 5; + byte b = 5; + boolean result = (a < b); + System.out.println(result); + } + + public void greaterOrEqualsThan() { + byte a = 5; + byte b = 5; + boolean result = (a >= b); + System.out.println(result); + } + + public void lessOrEqualsThan() { + byte a = 5; + byte b = 5; + boolean result = (a <= b); + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/DoubleOps.java b/src/test/java/samples/operators/DoubleOps.java index 1bfd18e8..4ec054f2 100644 --- a/src/test/java/samples/operators/DoubleOps.java +++ b/src/test/java/samples/operators/DoubleOps.java @@ -1,8 +1,5 @@ package samples.operators; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - public class DoubleOps { // public static void main(String[] args) throws InvocationTargetException, IllegalAccessException { @@ -15,86 +12,86 @@ public class DoubleOps { // } // } - public void addition() { - double a = 16777217d; - double b = 5d; - double d = a + b; - System.out.println(d); - } + public void addition() { + double a = 16777217d; + double b = 5d; + double d = a + b; + System.out.println(d); + } - public void subtraction() { - double a = 16777217d; - double b = 5d; - double d = b - a; - System.out.println(d); - } + public void subtraction() { + double a = 16777217d; + double b = 5d; + double d = b - a; + System.out.println(d); + } - public void multiplication() { - double a = 16777217d; - double b = 5d; - double d = b * a; - System.out.println(d); - } + public void multiplication() { + double a = 16777217d; + double b = 5d; + double d = b * a; + System.out.println(d); + } - public void division() { - double a = 16777217d; - double b = 5d; - double d = b / a; - System.out.println(d); - } + public void division() { + double a = 16777217d; + double b = 5d; + double d = b / a; + System.out.println(d); + } - public void modulus() { - double a = 16777217d; - double b = 5d; - double d = b % a; - System.out.println(d); - } + public void modulus() { + double a = 16777217d; + double b = 5d; + double d = b % a; + System.out.println(d); + } - public void simpleAssignmentOperator() { - double a = 16777217d; - double d = a; - System.out.println(d); - } + public void simpleAssignmentOperator() { + double a = 16777217d; + double d = a; + System.out.println(d); + } - public void equals() { - double a = 16777217d; - double b = 5d; - boolean result = (a == b); - System.out.println(result); - } + public void equals() { + double a = 16777217d; + double b = 5d; + boolean result = (a == b); + System.out.println(result); + } - public void notEquals() { - double a = 16777217d; - double b = 5d; - boolean result = (a != b); - System.out.println(result); - } + public void notEquals() { + double a = 16777217d; + double b = 5d; + boolean result = (a != b); + System.out.println(result); + } - public void greateThan() { - double a = 16777217d; - double b = 5d; - boolean result = (a > b); - System.out.println(result); - } + public void greateThan() { + double a = 16777217d; + double b = 5d; + boolean result = (a > b); + System.out.println(result); + } - public void lessThan() { - double a = 16777217d; - double b = 5d; - boolean result = (a < b); - System.out.println(result); - } + public void lessThan() { + double a = 16777217d; + double b = 5d; + boolean result = (a < b); + System.out.println(result); + } - public void greaterOrEqualsThan() { - double a = 16777217d; - double b = 5d; - boolean result = (a >= b); - System.out.println(result); - } + public void greaterOrEqualsThan() { + double a = 16777217d; + double b = 5d; + boolean result = (a >= b); + System.out.println(result); + } - public void lessOrEqualsThan() { - double a = 16777217d; - double b = 5d; - boolean result = (a <= b); - System.out.println(result); - } + public void lessOrEqualsThan() { + double a = 16777217d; + double b = 5d; + boolean result = (a <= b); + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/FloatOps.java b/src/test/java/samples/operators/FloatOps.java index 567c74d7..cb315c2c 100644 --- a/src/test/java/samples/operators/FloatOps.java +++ b/src/test/java/samples/operators/FloatOps.java @@ -2,96 +2,97 @@ public class FloatOps { - // public static void main(String[] args) throws InvocationTargetException, IllegalAccessException { - // FloatOps ops = new FloatOps(); - // for (Method method : ops.getClass().getMethods()) { - // if (!method.getName().contains("main")) { - // final Object invoke = method.invoke(ops); - // System.out.println(method.getName()); - // } - // } - // } + // public static void main(String[] args) throws InvocationTargetException, + // IllegalAccessException { + // FloatOps ops = new FloatOps(); + // for (Method method : ops.getClass().getMethods()) { + // if (!method.getName().contains("main")) { + // final Object invoke = method.invoke(ops); + // System.out.println(method.getName()); + // } + // } + // } - public void addition() { - float a = 5.5f; - float b = 5f; - float d = a + b; - System.out.println(d); - } + public void addition() { + float a = 5.5f; + float b = 5f; + float d = a + b; + System.out.println(d); + } - public void subtraction() { - float a = 5.5f; - float b = 5f; - float d = b - a; - System.out.println(d); - } + public void subtraction() { + float a = 5.5f; + float b = 5f; + float d = b - a; + System.out.println(d); + } - public void multiplication() { - float a = 5.5f; - float b = 5f; - float d = b * a; - System.out.println(d); - } + public void multiplication() { + float a = 5.5f; + float b = 5f; + float d = b * a; + System.out.println(d); + } - public void division() { - float a = 5.5f; - float b = 5f; - float d = b / a; - System.out.println(d); - } + public void division() { + float a = 5.5f; + float b = 5f; + float d = b / a; + System.out.println(d); + } - public void modulus() { - float a = 5.5f; - float b = 5f; - float d = b % a; - System.out.println(d); - } + public void modulus() { + float a = 5.5f; + float b = 5f; + float d = b % a; + System.out.println(d); + } - public void simpleAssignmentOperator() { - float a = 5.5f; - float d = a; - System.out.println(d); - } + public void simpleAssignmentOperator() { + float a = 5.5f; + float d = a; + System.out.println(d); + } - public void equals() { - float a = 5.5f; - float b = 5f; - boolean result = (a == b); - System.out.println(result); - } + public void equals() { + float a = 5.5f; + float b = 5f; + boolean result = (a == b); + System.out.println(result); + } - public void notEquals() { - float a = 5.5f; - float b = 5f; - boolean result = (a != b); - System.out.println(result); - } + public void notEquals() { + float a = 5.5f; + float b = 5f; + boolean result = (a != b); + System.out.println(result); + } - public void greateThan() { - float a = 5.5f; - float b = 5f; - boolean result = (a > b); - System.out.println(result); - } + public void greateThan() { + float a = 5.5f; + float b = 5f; + boolean result = (a > b); + System.out.println(result); + } - public void lessThan() { - float a = 5.5f; - float b = 5f; - boolean result = (a < b); - System.out.println(result); - } + public void lessThan() { + float a = 5.5f; + float b = 5f; + boolean result = (a < b); + System.out.println(result); + } - public void greaterOrEqualsThan() { - float a = 5.5f; - float b = 5f; - boolean result = (a >= b); - System.out.println(result); - } + public void greaterOrEqualsThan() { + float a = 5.5f; + float b = 5f; + boolean result = (a >= b); + System.out.println(result); + } - public void lessOrEqualsThan() { - float a = 5.5f; - float b = 5f; - boolean result = (a <= b); - System.out.println(result); - } + public void lessOrEqualsThan() { + float a = 5.5f; + float b = 5f; + boolean result = (a <= b); + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/IntOps.java b/src/test/java/samples/operators/IntOps.java index 6e3ba577..8586ce37 100644 --- a/src/test/java/samples/operators/IntOps.java +++ b/src/test/java/samples/operators/IntOps.java @@ -1,20 +1,13 @@ package samples.operators; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - public class IntOps { - /* - public static void main(String[] args) throws InvocationTargetException, IllegalAccessException { - IntOps ops = new IntOps(); - for (Method method : IntOps.class.getMethods()) { - if (!method.getName().contains("main")) { - final Object invoke = method.invoke(ops); - System.out.println(method.getName()); - } - } - } - */ + /* + * public static void main(String[] args) throws InvocationTargetException, + * IllegalAccessException { IntOps ops = new IntOps(); for (Method method : + * IntOps.class.getMethods()) { if (!method.getName().contains("main")) { final + * Object invoke = method.invoke(ops); System.out.println(method.getName()); } } + * } + */ // public void addition() { // int a = 5; @@ -143,11 +136,11 @@ public static void main(String[] args) throws InvocationTargetException, Illegal // boolean result = (a <= b); // System.out.println(result); // } - - public void ternaryExpression() { - int a = 5; - int b = 5; - int result = (a == b) ? 1 : 0; - System.out.println(result); - } + + public void ternaryExpression() { + int a = 5; + int b = 5; + int result = (a == b) ? 1 : 0; + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/LongOps.java b/src/test/java/samples/operators/LongOps.java index 9130f334..0fd16291 100644 --- a/src/test/java/samples/operators/LongOps.java +++ b/src/test/java/samples/operators/LongOps.java @@ -2,143 +2,143 @@ public class LongOps { - - // - // public static void main(String[] args) throws InvocationTargetException, IllegalAccessException { - // LongOps ops = new LongOps(); - // for (Method method : ops.getClass().getMethods()) { - // if (!method.getName().contains("main")) { - // System.out.println(method.getName()); - // final Object invoke = method.invoke(ops); - // } - // } - // } - - public void addition() { - long a = 2147483648L; - long b = 5L; - long d = a + b; - System.out.println(d); - } - - public void subtraction() { - long a = 2147483648L; - long b = 5L; - long d = b - a; - System.out.println(d); - } - - public void multiplication() { - long a = 2147483648L; - long b = 5L; - long d = b * a; - System.out.println(d); - } - - public void division() { - long a = 2147483648L; - long b = 5L; - long d = b / a; - System.out.println(d); - } - - public void modulus() { - long a = 2147483648L; - long b = 5L; - long d = b % a; - System.out.println(d); - } - - public void simpleAssignmentOperator() { - long a = 2147483648L; - long d = a; - System.out.println(d); - } - - public void bitwiseAnd() { - long a = 2147483648L; - long b = 5L; - long d = a & b; - System.out.println(d); - } - - public void bitwiseOr() { - long a = 2147483648L; - long b = 5L; - long d = a | b; - System.out.println(d); - } - - public void bitwiseXor() { - long a = 2147483648L; - long b = 5L; - long d = a ^ b; - System.out.println(d); - } - - public void bitwiseCompliment() { - long a = 2147483648L; - long d = ~a; - System.out.println(d); - } - - public void bitwiseLeftShift() { - long a = 2147483648L; - long d = a << 2; - System.out.println(d); - } - - public void bitwiseRightShift() { - long a = 2147483648L; - long d = a >> 2; - System.out.println(d); - } - - public void bitwiseRightShiftZerofill() { - long a = 2147483648L; - long d = a >>> 2; - System.out.println(d); - } - - public void equals() { - long a = 2147483648L; - long b = 5L; - boolean result = (a == b); - System.out.println(result); - } - - public void notEquals() { - long a = 2147483648L; - long b = 5L; - boolean result = (a != b); - System.out.println(result); - } - - public void greateThan() { - long a = 2147483648L; - long b = 5L; - boolean result = (a > b); - System.out.println(result); - } - - public void lessThan() { - long a = 2147483648L; - long b = 5L; - boolean result = (a < b); - System.out.println(result); - } - - public void greaterOrEqualsThan() { - long a = 2147483648L; - long b = 5L; - boolean result = (a >= b); - System.out.println(result); - } - - public void lessOrEqualsThan() { - long a = 2147483648L; - long b = 5L; - boolean result = (a <= b); - System.out.println(result); - } + // + // public static void main(String[] args) throws InvocationTargetException, + // IllegalAccessException { + // LongOps ops = new LongOps(); + // for (Method method : ops.getClass().getMethods()) { + // if (!method.getName().contains("main")) { + // System.out.println(method.getName()); + // final Object invoke = method.invoke(ops); + // } + // } + // } + + public void addition() { + long a = 2147483648L; + long b = 5L; + long d = a + b; + System.out.println(d); + } + + public void subtraction() { + long a = 2147483648L; + long b = 5L; + long d = b - a; + System.out.println(d); + } + + public void multiplication() { + long a = 2147483648L; + long b = 5L; + long d = b * a; + System.out.println(d); + } + + public void division() { + long a = 2147483648L; + long b = 5L; + long d = b / a; + System.out.println(d); + } + + public void modulus() { + long a = 2147483648L; + long b = 5L; + long d = b % a; + System.out.println(d); + } + + public void simpleAssignmentOperator() { + long a = 2147483648L; + long d = a; + System.out.println(d); + } + + public void bitwiseAnd() { + long a = 2147483648L; + long b = 5L; + long d = a & b; + System.out.println(d); + } + + public void bitwiseOr() { + long a = 2147483648L; + long b = 5L; + long d = a | b; + System.out.println(d); + } + + public void bitwiseXor() { + long a = 2147483648L; + long b = 5L; + long d = a ^ b; + System.out.println(d); + } + + public void bitwiseCompliment() { + long a = 2147483648L; + long d = ~a; + System.out.println(d); + } + + public void bitwiseLeftShift() { + long a = 2147483648L; + long d = a << 2; + System.out.println(d); + } + + public void bitwiseRightShift() { + long a = 2147483648L; + long d = a >> 2; + System.out.println(d); + } + + public void bitwiseRightShiftZerofill() { + long a = 2147483648L; + long d = a >>> 2; + System.out.println(d); + } + + public void equals() { + long a = 2147483648L; + long b = 5L; + boolean result = (a == b); + System.out.println(result); + } + + public void notEquals() { + long a = 2147483648L; + long b = 5L; + boolean result = (a != b); + System.out.println(result); + } + + public void greateThan() { + long a = 2147483648L; + long b = 5L; + boolean result = (a > b); + System.out.println(result); + } + + public void lessThan() { + long a = 2147483648L; + long b = 5L; + boolean result = (a < b); + System.out.println(result); + } + + public void greaterOrEqualsThan() { + long a = 2147483648L; + long b = 5L; + boolean result = (a >= b); + System.out.println(result); + } + + public void lessOrEqualsThan() { + long a = 2147483648L; + long b = 5L; + boolean result = (a <= b); + System.out.println(result); + } } diff --git a/src/test/java/samples/operators/MiscOps.java b/src/test/java/samples/operators/MiscOps.java index 084c6cb0..aba6f010 100644 --- a/src/test/java/samples/operators/MiscOps.java +++ b/src/test/java/samples/operators/MiscOps.java @@ -5,21 +5,21 @@ */ public class MiscOps { - public void instanceofOperator() { - String name = "Java"; - boolean result = name instanceof String; - System.out.println(result); - } + public void instanceofOperator() { + String name = "Java"; + boolean result = name instanceof String; + System.out.println(result); + } - public void instanceofOperator2() { - A a = new A(); - boolean result = a instanceof A; - System.out.println(result); - } + public void instanceofOperator2() { + A a = new A(); + boolean result = a instanceof A; + System.out.println(result); + } - public void ternaryOperator() { - boolean a = true; - String d = a ? "foo" : "bar"; - System.out.println(d); - } + public void ternaryOperator() { + boolean a = true; + String d = a ? "foo" : "bar"; + System.out.println(d); + } } diff --git a/src/test/java/samples/operators/ShortOps.java b/src/test/java/samples/operators/ShortOps.java index 4d776e1e..0037945d 100644 --- a/src/test/java/samples/operators/ShortOps.java +++ b/src/test/java/samples/operators/ShortOps.java @@ -2,141 +2,142 @@ public class ShortOps { - // public static void main(String[] args) throws InvocationTargetException, IllegalAccessException { - // ShortOps ops = new ShortOps(); - // for (Method method : ops.getClass().getMethods()) { - // if (!method.getName().contains("main")) { - // System.out.println(method.getName()); - // final O }bject invoke = method.invoke(ops); - // } - // } - // - - public void addition() { - short a = 5; - short b = 5; - short d = (short) (a + b); - System.out.println(d); - } - - public void subtraction() { - short a = 5; - short b = 5; - short d = (short) (b - a); - System.out.println(d); - } - - public void multiplication() { - short a = 5; - short b = 5; - short d = (short) (b * a); - System.out.println(d); - } - - public void division() { - short a = 5; - short b = 5; - short d = (short) (b / a); - System.out.println(d); - } - - public void modulus() { - short a = 5; - short b = 5; - short d = (short) (b % a); - System.out.println(d); - } - - public void simpleAssignmentOperator() { - short a = 5; - short d = a; - System.out.println(d); - } - - public void bitwiseAnd() { - short a = 5; - short b = 5; - short d = (short) (a & b); - System.out.println(d); - } - - public void bitwiseOr() { - short a = 5; - short b = 5; - short d = (short) (a | b); - System.out.println(d); - } - - public void bitwiseXor() { - short a = 5; - short b = 5; - short d = (short) (a ^ b); - System.out.println(d); - } - - public void bitwiseCompliment() { - short a = 5; - short d = (short) ~a; - System.out.println(d); - } - - public void bitwiseLeftShift() { - short a = 5; - short d = (short) (a << 2); - System.out.println(d); - } - - public void bitwiseRightShift() { - short a = 5; - short d = (short) (a >> 2); - System.out.println(d); - } - - public void bitwiseRightShiftZerofill() { - short a = 5; - short d = (short) (a >>> 2); - System.out.println(d); - } - - public void equals() { - short a = 5; - short b = 5; - boolean result = (a == b); - System.out.println(result); - } - - public void notEquals() { - short a = 5; - short b = 5; - boolean result = (a != b); - System.out.println(result); - } - - public void greateThan() { - short a = 5; - short b = 5; - boolean result = (a > b); - System.out.println(result); - } - - public void lessThan() { - short a = 5; - short b = 5; - boolean result = (a < b); - System.out.println(result); - } - - public void greaterOrEqualsThan() { - short a = 5; - short b = 5; - boolean result = (a >= b); - System.out.println(result); - } - - public void lessOrEqualsThan() { - short a = 5; - short b = 5; - boolean result = (a <= b); - System.out.println(result); - } + // public static void main(String[] args) throws InvocationTargetException, + // IllegalAccessException { + // ShortOps ops = new ShortOps(); + // for (Method method : ops.getClass().getMethods()) { + // if (!method.getName().contains("main")) { + // System.out.println(method.getName()); + // final O }bject invoke = method.invoke(ops); + // } + // } + // + + public void addition() { + short a = 5; + short b = 5; + short d = (short) (a + b); + System.out.println(d); + } + + public void subtraction() { + short a = 5; + short b = 5; + short d = (short) (b - a); + System.out.println(d); + } + + public void multiplication() { + short a = 5; + short b = 5; + short d = (short) (b * a); + System.out.println(d); + } + + public void division() { + short a = 5; + short b = 5; + short d = (short) (b / a); + System.out.println(d); + } + + public void modulus() { + short a = 5; + short b = 5; + short d = (short) (b % a); + System.out.println(d); + } + + public void simpleAssignmentOperator() { + short a = 5; + short d = a; + System.out.println(d); + } + + public void bitwiseAnd() { + short a = 5; + short b = 5; + short d = (short) (a & b); + System.out.println(d); + } + + public void bitwiseOr() { + short a = 5; + short b = 5; + short d = (short) (a | b); + System.out.println(d); + } + + public void bitwiseXor() { + short a = 5; + short b = 5; + short d = (short) (a ^ b); + System.out.println(d); + } + + public void bitwiseCompliment() { + short a = 5; + short d = (short) ~a; + System.out.println(d); + } + + public void bitwiseLeftShift() { + short a = 5; + short d = (short) (a << 2); + System.out.println(d); + } + + public void bitwiseRightShift() { + short a = 5; + short d = (short) (a >> 2); + System.out.println(d); + } + + public void bitwiseRightShiftZerofill() { + short a = 5; + short d = (short) (a >>> 2); + System.out.println(d); + } + + public void equals() { + short a = 5; + short b = 5; + boolean result = (a == b); + System.out.println(result); + } + + public void notEquals() { + short a = 5; + short b = 5; + boolean result = (a != b); + System.out.println(result); + } + + public void greateThan() { + short a = 5; + short b = 5; + boolean result = (a > b); + System.out.println(result); + } + + public void lessThan() { + short a = 5; + short b = 5; + boolean result = (a < b); + System.out.println(result); + } + + public void greaterOrEqualsThan() { + short a = 5; + short b = 5; + boolean result = (a >= b); + System.out.println(result); + } + + public void lessOrEqualsThan() { + short a = 5; + short b = 5; + boolean result = (a <= b); + System.out.println(result); + } } diff --git a/src/test/java/samples/reflection/A.java b/src/test/java/samples/reflection/A.java index 2715faff..5a93e6a2 100644 --- a/src/test/java/samples/reflection/A.java +++ b/src/test/java/samples/reflection/A.java @@ -1,11 +1,10 @@ package samples.reflection; /** - * @author Manuel Benz - * created on 21.07.18 + * @author Manuel Benz created on 21.07.18 */ public class A { - public static void staticFoo(){ - System.out.println("foo"); - } + public static void staticFoo() { + System.out.println("foo"); + } } diff --git a/src/test/java/samples/reflection/Reflection.java b/src/test/java/samples/reflection/Reflection.java index b76d6f99..bc97765f 100644 --- a/src/test/java/samples/reflection/Reflection.java +++ b/src/test/java/samples/reflection/Reflection.java @@ -8,15 +8,15 @@ */ public class Reflection { - public static void staticInvokeReflection() throws NoSuchMethodException { - // Invoking static method using reflection - Method method = A.class.getMethod("staticFoo"); - try { - method.invoke(null); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } + public static void staticInvokeReflection() throws NoSuchMethodException { + // Invoking static method using reflection + Method method = A.class.getMethod("staticFoo"); + try { + method.invoke(null); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } } diff --git a/src/test/java/samples/staticFields/StaticFields.java b/src/test/java/samples/staticFields/StaticFields.java index 73ed99a4..39a8961d 100644 --- a/src/test/java/samples/staticFields/StaticFields.java +++ b/src/test/java/samples/staticFields/StaticFields.java @@ -1,22 +1,21 @@ package samples.staticFields; public class StaticFields { - private static final int finalInt = 10; + private static final int finalInt = 10; - private static int nonFinalInt = 5; + private static int nonFinalInt = 5; - public static void finalField() { - System.out.println(finalInt); - } + public static void finalField() { + System.out.println(finalInt); + } - public static void nonFinalField() { - System.out.println(nonFinalInt); - } - - public static void nonFinalFieldAltered() { - nonFinalInt++; - System.out.println(nonFinalInt); - } + public static void nonFinalField() { + System.out.println(nonFinalInt); + } + public static void nonFinalFieldAltered() { + nonFinalInt++; + System.out.println(nonFinalInt); + } } diff --git a/src/test/java/samples/staticInvoke/StaticInvoke.java b/src/test/java/samples/staticInvoke/StaticInvoke.java index 6530588b..d892c1cd 100644 --- a/src/test/java/samples/staticInvoke/StaticInvoke.java +++ b/src/test/java/samples/staticInvoke/StaticInvoke.java @@ -2,11 +2,11 @@ public class StaticInvoke { - public static void staticInvoke() { - callee(); - } + public static void staticInvoke() { + callee(); + } - private static void callee() { - System.out.println("foo"); - } + private static void callee() { + System.out.println("foo"); + } } \ No newline at end of file diff --git a/src/test/rascal/TestSuite.rsc b/src/test/rascal/TestSuite.rsc index aaa58125..a6dadfa2 100644 --- a/src/test/rascal/TestSuite.rsc +++ b/src/test/rascal/TestSuite.rsc @@ -1,6 +1,6 @@ module TestSuite -import TestAvailableExpressions; +import lang::jimple::tests::TestAvailableExpressions; import IO; import List; @@ -9,7 +9,6 @@ data TestCase = TestCase(str name, bool () function); list[TestCase] tcs = [TestCase("TestAvailableExpressions", testAvailableExpressions)]; - public void main(list[str] _) { int count = 0; list[str] errors = []; diff --git a/src/test/rascal/lang/jimple/tests/TestLambdaTransformer.rsc b/src/test/rascal/lang/jimple/tests/TestLambdaTransformer.rsc index 401b4846..5b4ec39c 100644 --- a/src/test/rascal/lang/jimple/tests/TestLambdaTransformer.rsc +++ b/src/test/rascal/lang/jimple/tests/TestLambdaTransformer.rsc @@ -5,22 +5,34 @@ import lang::jimple::decompiler::Decompiler; import lang::jimple::decompiler::jimplify::LambdaTransformer; import lang::jimple::util::JPrettyPrinter; -import List; +import List; import IO; -loc classLocation = |project://JimpleFramework/target/test-classes/samples/SimpleLambdaExpression.class|; +str samplesPath = "JimpleFramework/target/test-classes/samples/"; + +lrel[loc, int] testRelation = [<|project://SimpleLambdaExpression.class|, 2>, // 0: Simple Lambda + <|project:///arrays/ArrayExample.class|, 3>, // 1: Array Lambda + <|project:///lambdaExpressions/AddLambda.class|, 2>, // 2: Interface Lambda + <|project:///lambdaExpressions/Palindromes.class|, 4>, // 3: Palindrome Lambda + <|project:///lambdaExpressions/Runners.class|, 7>, // 4: Multiple Runnable Lambdas + <|project:///lambdaExpressions/SumList.class|, 2>, // 5: List Lambda + <|project:///lambdaExpressions/IncClosure.class|, 2>]; // 6: Closure test bool testLambdaTransformer() { + + int n = 6; + loc classLocation = testRelation[n][0]; + ClassOrInterfaceDeclaration c = decompile(classLocation); println(prettyPrint(c)); list[ClassOrInterfaceDeclaration] classes = lambdaTransformer(c); - for(ClassOrInterfaceDeclaration aClass <- classes) { println(prettyPrint(aClass)); + //println(aClass); //abstract syntax tree } - return size(classes) == 1; + return size(classes) == testRelation[n][1]; } \ No newline at end of file