diff --git a/resources/bytecode/javFiles/Op1.jav b/resources/bytecode/javFiles/Op1.jav index 9f62c5a5..48af9df1 100644 --- a/resources/bytecode/javFiles/Op1.jav +++ b/resources/bytecode/javFiles/Op1.jav @@ -25,4 +25,10 @@ public class Op1 { var b = 20; return a ^ b; } + + public mod() { + var a = 10; + var b = 2; + return a % b; + } } \ No newline at end of file diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index f96df097..02cad496 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -958,6 +958,8 @@ public class StatementGenerator { return BinaryExpr.Operator.EQUAL; } else if (operator.equals("!=")) { return BinaryExpr.Operator.NOTEQUAL; + } else if (operator.equals("%")) { + return BinaryExpr.Operator.MOD; } else { throw new NotImplementedException(); } diff --git a/src/test/java/TestComplete.java b/src/test/java/TestComplete.java index 3269aa22..6e743108 100644 --- a/src/test/java/TestComplete.java +++ b/src/test/java/TestComplete.java @@ -848,6 +848,7 @@ public class TestComplete { assertEquals(clazz.getDeclaredMethod("or").invoke(instance), 10 | 20); assertEquals(clazz.getDeclaredMethod("and").invoke(instance), 10 & 20); assertEquals(clazz.getDeclaredMethod("xor").invoke(instance), 10 ^ 20); + assertEquals(clazz.getDeclaredMethod("mod").invoke(instance), 10 % 2); } @Ignore("Not implemented")