Compare commits
25 Commits
ed4aa2d59b
...
6cec17eb45
Author | SHA1 | Date | |
---|---|---|---|
|
6cec17eb45 | ||
87be850a0e | |||
72f82ff863 | |||
7419953510 | |||
449b895d20 | |||
f0dd6d5eb6 | |||
8956362033 | |||
3227d69fc1 | |||
4ca6972ccd | |||
0047f6c08e | |||
88ce9e52f0 | |||
|
437de74cc6 | ||
|
ca77307f0c | ||
|
5f46130439 | ||
3e1456351c | |||
d26cd0c13a | |||
|
cfde5219a4 | ||
|
f414e278bb | ||
|
741a56cb99 | ||
|
02e5f3a729 | ||
|
f7338a06b3 | ||
|
3996082fa7 | ||
|
2537051668 | ||
|
82356ec189 | ||
|
561eafbf4c |
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@ -6,11 +6,6 @@
|
|||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven_central" />
|
|
||||||
<option name="name" value="Maven Central" />
|
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Maven Central repository" />
|
<option name="name" value="Maven Central repository" />
|
||||||
|
13
pom.xml
13
pom.xml
@ -44,12 +44,6 @@
|
|||||||
<version>3.26.0</version>
|
<version>3.26.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<version>5.11.0</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -84,11 +78,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>maven_central</id>
|
|
||||||
<name>Maven Central</name>
|
|
||||||
<url>https://repo.maven.apache.org/maven2/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</project>
|
</project>
|
@ -91,15 +91,15 @@ public class Main {
|
|||||||
|
|
||||||
/*------------------------- Semantic Analyzer -> typed AST -------------------------*/
|
/*------------------------- Semantic Analyzer -> typed AST -------------------------*/
|
||||||
// Use the SemanticAnalyzer to generate a typed AST
|
// Use the SemanticAnalyzer to generate a typed AST
|
||||||
//ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
||||||
// Log the typed AST
|
// Log the typed AST
|
||||||
RaupenLogger.logSemanticAnalyzer(abstractSyntaxTree);
|
RaupenLogger.logSemanticAnalyzer(typedAst);
|
||||||
|
|
||||||
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
|
||||||
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
// Use the ByteCodeGenerator to generate bytecode from the typed AST and output it to the specified directory
|
||||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath);
|
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath);
|
||||||
assert abstractSyntaxTree != null;
|
assert typedAst != null;
|
||||||
byteCodeGenerator.visit((ProgramNode) abstractSyntaxTree);
|
byteCodeGenerator.visit((ProgramNode) typedAst);
|
||||||
// Log the bytecode generation
|
// Log the bytecode generation
|
||||||
RaupenLogger.logBytecodeGenerator();
|
RaupenLogger.logBytecodeGenerator();
|
||||||
}
|
}
|
||||||
|
@ -75,12 +75,7 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) {
|
public ASTNode visitConstructorDeclaration(SimpleJavaParser.ConstructorDeclarationContext ctx) {
|
||||||
ConstructorNode constructorNode;
|
ConstructorNode constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
||||||
if(ctx.AccessModifier() != null) {
|
|
||||||
constructorNode = new ConstructorNode(ctx.AccessModifier().getText(), ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
|
||||||
} else {
|
|
||||||
constructorNode = new ConstructorNode(null, ctx.Identifier().getText(), (BlockNode) visit(ctx.blockStatement()));
|
|
||||||
}
|
|
||||||
if(ctx.parameterList() != null) {
|
if(ctx.parameterList() != null) {
|
||||||
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
for(SimpleJavaParser.ParameterContext parameter : ctx.parameterList().parameter()) {
|
||||||
constructorNode.addParameter((ParameterNode) visit(parameter));
|
constructorNode.addParameter((ParameterNode) visit(parameter));
|
||||||
|
@ -2,15 +2,13 @@ public class Compiler {
|
|||||||
public int add(int i, int j) {
|
public int add(int i, int j) {
|
||||||
return i+j;
|
return i+j;
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
|
||||||
int a = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Node {
|
public class Node {
|
||||||
public void main() {
|
public void main() {
|
||||||
Compiler compiler = new Compiler();
|
Compiler compiler = new Compiler();
|
||||||
int i = compiler.add(5, 8);
|
int i = compiler.add(5, 8);
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -10,7 +10,7 @@ compile-javac:
|
|||||||
compile-raupenpiler:
|
compile-raupenpiler:
|
||||||
cd ../.. ; mvn -DskipTests install
|
cd ../.. ; mvn -DskipTests install
|
||||||
cd ../.. ; mvn exec:java -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' "
|
cd ../.. ; mvn exec:java -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' "
|
||||||
# cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler
|
cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler
|
||||||
|
|
||||||
test: compile-javac compile-raupenpiler test-javac test-raupenpiler
|
test: compile-javac compile-raupenpiler test-javac test-raupenpiler
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ test-raupenpiler:
|
|||||||
clean:
|
clean:
|
||||||
# clean output folders
|
# clean output folders
|
||||||
rm -f ../main/resources/output/*.class
|
rm -f ../main/resources/output/*.class
|
||||||
rm -f ../main/resources/output/*.jar
|
|
||||||
rm -f ./resources/output/javac/*.class
|
rm -f ./resources/output/javac/*.class
|
||||||
rm -f ./resources/output/raupenpiler/*.class
|
rm -f ./resources/output/raupenpiler/*.class
|
||||||
# clean logs
|
# clean logs
|
||||||
|
@ -1,177 +0,0 @@
|
|||||||
package main;
|
|
||||||
|
|
||||||
import ast.ASTNode;
|
|
||||||
import ast.ProgramNode;
|
|
||||||
import bytecode.ByteCodeGenerator;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.antlr.v4.runtime.CharStream;
|
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
|
||||||
import parser.astBuilder.ASTBuilder;
|
|
||||||
import parser.generated.SimpleJavaLexer;
|
|
||||||
import parser.generated.SimpleJavaParser;
|
|
||||||
import semantic.SemanticAnalyzer;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class E2EReflectionsTest {
|
|
||||||
|
|
||||||
|
|
||||||
private CharStream mockInputCharStream;
|
|
||||||
private String outputDirectoryPath;
|
|
||||||
private SimpleJavaLexer mockLexer;
|
|
||||||
private CommonTokenStream mockTokenStream;
|
|
||||||
private SimpleJavaParser mockParser;
|
|
||||||
private ParseTree mockParseTree;
|
|
||||||
private ASTBuilder mockASTBuilder;
|
|
||||||
private ASTNode mockASTNode;
|
|
||||||
private SemanticAnalyzer mockSemanticAnalyzer;
|
|
||||||
private ASTNode mockTypedAST;
|
|
||||||
private ByteCodeGenerator mockByteCodeGenerator;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
mockInputCharStream = mock(CharStream.class);
|
|
||||||
outputDirectoryPath = "path/to/output";
|
|
||||||
mockLexer = mock(SimpleJavaLexer.class);
|
|
||||||
mockTokenStream = mock(CommonTokenStream.class);
|
|
||||||
mockParser = mock(SimpleJavaParser.class);
|
|
||||||
mockParseTree = mock(ParseTree.class);
|
|
||||||
mockASTBuilder = mock(ASTBuilder.class);
|
|
||||||
mockASTNode = mock(ASTNode.class);
|
|
||||||
mockSemanticAnalyzer = mock(SemanticAnalyzer.class);
|
|
||||||
mockTypedAST = mock(ASTNode.class);
|
|
||||||
mockByteCodeGenerator = mock(ByteCodeGenerator.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCompileFile() throws Exception {
|
|
||||||
// Mock the dependencies
|
|
||||||
SimpleJavaLexer mockLexer = mock(SimpleJavaLexer.class);
|
|
||||||
CommonTokenStream mockTokenStream = mock(CommonTokenStream.class);
|
|
||||||
SimpleJavaParser mockParser = mock(SimpleJavaParser.class);
|
|
||||||
ParseTree mockParseTree = mock(ParseTree.class);
|
|
||||||
ASTBuilder mockASTBuilder = mock(ASTBuilder.class);
|
|
||||||
ASTNode mockASTNode = mock(ASTNode.class);
|
|
||||||
SemanticAnalyzer mockSemanticAnalyzer = mock(SemanticAnalyzer.class);
|
|
||||||
ASTNode mockTypedAST = mock(ASTNode.class);
|
|
||||||
ByteCodeGenerator mockByteCodeGenerator = mock(ByteCodeGenerator.class);
|
|
||||||
|
|
||||||
// Mock the behavior
|
|
||||||
when(mockLexer.nextToken()).thenReturn(null);
|
|
||||||
when(mockTokenStream.getTokens()).thenReturn(new ArrayList<>());
|
|
||||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
|
||||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
|
||||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
|
||||||
|
|
||||||
// Use reflection to invoke the compileFile method
|
|
||||||
Method compileFileMethod = main.Main.class.getDeclaredMethod("compileFile", CharStream.class, String.class);
|
|
||||||
compileFileMethod.setAccessible(true);
|
|
||||||
|
|
||||||
compileFileMethod.invoke(null, mockInputCharStream, outputDirectoryPath);
|
|
||||||
|
|
||||||
// Verify each step
|
|
||||||
verify(mockLexer, times(1)).nextToken();
|
|
||||||
verify(mockTokenStream, times(1)).getTokens();
|
|
||||||
verify(mockParser, times(1)).program();
|
|
||||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
|
||||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
|
||||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCompileFile2() throws Exception {
|
|
||||||
// Mock the behavior
|
|
||||||
when(mockLexer.nextToken()).thenReturn(null);
|
|
||||||
when(mockTokenStream.getTokens()).thenReturn(new ArrayList<>());
|
|
||||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
|
||||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
|
||||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
|
||||||
|
|
||||||
// Use reflection to invoke the compileFile method
|
|
||||||
Method compileFileMethod = main.Main.class.getDeclaredMethod("compileFile", CharStream.class, String.class);
|
|
||||||
compileFileMethod.setAccessible(true);
|
|
||||||
|
|
||||||
compileFileMethod.invoke(null, mockInputCharStream, outputDirectoryPath);
|
|
||||||
|
|
||||||
// Verify each step
|
|
||||||
verify(mockLexer, times(1)).nextToken();
|
|
||||||
verify(mockTokenStream, times(1)).getTokens();
|
|
||||||
verify(mockParser, times(1)).program();
|
|
||||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
|
||||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
|
||||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLexer() {
|
|
||||||
// Mock the behavior
|
|
||||||
when(mockLexer.nextToken()).thenReturn(null);
|
|
||||||
|
|
||||||
// Test the lexer
|
|
||||||
SimpleJavaLexer lexer = new SimpleJavaLexer(mockInputCharStream);
|
|
||||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
|
||||||
tokenStream.fill();
|
|
||||||
|
|
||||||
assertNotNull(tokenStream.getTokens());
|
|
||||||
verify(mockLexer, atLeastOnce()).nextToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParser() {
|
|
||||||
// Mock the behavior
|
|
||||||
when(mockParser.program()).thenReturn((SimpleJavaParser.ProgramContext) mockParseTree);
|
|
||||||
|
|
||||||
// Test the parser
|
|
||||||
SimpleJavaParser parser = new SimpleJavaParser(mockTokenStream);
|
|
||||||
ParseTree parseTree = parser.program();
|
|
||||||
|
|
||||||
assertNotNull(parseTree);
|
|
||||||
verify(mockParser, times(1)).program();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testASTBuilder() {
|
|
||||||
// Mock the behavior
|
|
||||||
when(mockASTBuilder.visit(mockParseTree)).thenReturn(mockASTNode);
|
|
||||||
|
|
||||||
// Test the AST builder
|
|
||||||
ASTBuilder astBuilder = new ASTBuilder();
|
|
||||||
ASTNode abstractSyntaxTree = astBuilder.visit(mockParseTree);
|
|
||||||
|
|
||||||
assertNotNull(abstractSyntaxTree);
|
|
||||||
verify(mockASTBuilder, times(1)).visit(mockParseTree);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSemanticAnalyzer() {
|
|
||||||
// Mock the behavior
|
|
||||||
when(SemanticAnalyzer.generateTast(mockASTNode)).thenReturn(mockTypedAST);
|
|
||||||
|
|
||||||
// Test the semantic analyzer
|
|
||||||
ASTNode typedAst = SemanticAnalyzer.generateTast(mockASTNode);
|
|
||||||
|
|
||||||
assertNotNull(typedAst);
|
|
||||||
verify(mockSemanticAnalyzer, times(1)).generateTast(mockASTNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testByteCodeGenerator() {
|
|
||||||
// Test the bytecode generator
|
|
||||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator(outputDirectoryPath);
|
|
||||||
byteCodeGenerator.visit((ProgramNode) mockTypedAST);
|
|
||||||
|
|
||||||
verify(mockByteCodeGenerator, times(1)).visit((ProgramNode) mockTypedAST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,25 +9,42 @@ public class AllFeaturesClassExample {
|
|||||||
this.b = b;
|
this.b = b;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
}
|
}
|
||||||
|
private class InnerClass {
|
||||||
|
void innerMethod() {
|
||||||
|
System.out.println("Inner class method");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Methode zur Demonstration von Kontrollstrukturen
|
// Methode zur Demonstration von Kontrollstrukturen
|
||||||
void controlStructures() {
|
void controlStructures() {
|
||||||
// if-else Anweisung
|
// if-else Anweisung
|
||||||
if (a > 10) {
|
if (a > 10) {
|
||||||
// System.out.println("a ist größer als 10");
|
System.out.println("a ist größer als 10");
|
||||||
} else {
|
} else {
|
||||||
// System.out.println("a ist nicht größer als 10");
|
System.out.println("a ist nicht größer als 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
// while Schleife
|
// while Schleife
|
||||||
while (a > 0) {
|
while (a > 0) {
|
||||||
// System.out.println("a ist " + a);
|
System.out.println("a ist " + a);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for Schleife
|
// for Schleife
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
// System.out.println("for Schleife Iteration: " + i);
|
System.out.println("for Schleife Iteration: " + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch Anweisung
|
||||||
|
switch (c) {
|
||||||
|
case 'a':
|
||||||
|
System.out.println("c ist ein 'a'");
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
System.out.println("c ist ein 'b'");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("c ist nicht 'a' oder 'b'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,28 +52,15 @@ public class AllFeaturesClassExample {
|
|||||||
void logicalOperations() {
|
void logicalOperations() {
|
||||||
// Logische UND-Operation
|
// Logische UND-Operation
|
||||||
if (b && a > 5) {
|
if (b && a > 5) {
|
||||||
// System.out.println("a ist größer als 5 und b ist wahr");
|
System.out.println("a ist größer als 5 und b ist wahr");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logische ODER-Operation
|
// Logische ODER-Operation
|
||||||
if (b || a < 5) {
|
if (b || a < 5) {
|
||||||
// System.out.println("b ist wahr oder a ist kleiner als 5");
|
System.out.println("b ist wahr oder a ist kleiner als 5");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mathOperations() {
|
|
||||||
// Addition
|
|
||||||
int sum = a + 5;
|
|
||||||
// Subtraktion
|
|
||||||
int difference = a - 5;
|
|
||||||
// Multiplikation
|
|
||||||
int product = a * 5;
|
|
||||||
// Division
|
|
||||||
int quotient = a / 5;
|
|
||||||
// Modulo
|
|
||||||
int remainder = a % 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
||||||
obj.controlStructures();
|
obj.controlStructures();
|
||||||
|
70
src/test/resources/trees/correctRefType.json
Normal file
70
src/test/resources/trees/correctRefType.json
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"classes": [
|
||||||
|
{
|
||||||
|
"identifier": "testClass1",
|
||||||
|
"accessType": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"@type": "Field",
|
||||||
|
"accessTypeNode": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "testVar1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "Method",
|
||||||
|
"visibility": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "testMethod",
|
||||||
|
"parameters": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "param1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"statements": [
|
||||||
|
{
|
||||||
|
"@type": "Assignment",
|
||||||
|
"expressionLeft": {
|
||||||
|
"@type": "InstVar",
|
||||||
|
"identifier": "testVar1",
|
||||||
|
"expression": {
|
||||||
|
"@type": "This",
|
||||||
|
"type": {
|
||||||
|
"@type": "Reference",
|
||||||
|
"identifier": "testClass1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"expressionRight": {
|
||||||
|
"@type": "Literal",
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hasConstructor": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
133
src/test/resources/trees/refTypeMismatch.json
Normal file
133
src/test/resources/trees/refTypeMismatch.json
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"classes": [
|
||||||
|
{
|
||||||
|
"identifier": "testClass1",
|
||||||
|
"accessType": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"@type": "Field",
|
||||||
|
"accessTypeNode": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "testVar1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "Method",
|
||||||
|
"visibility": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "testMethod",
|
||||||
|
"parameters": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "param1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"statements": [
|
||||||
|
{
|
||||||
|
"@type": "Assignment",
|
||||||
|
"expressionLeft": {
|
||||||
|
"@type": "InstVar",
|
||||||
|
"identifier": "testVar1",
|
||||||
|
"expression": {
|
||||||
|
"@type": "This",
|
||||||
|
"type": {
|
||||||
|
"@type": "Reference",
|
||||||
|
"identifier": "testClass1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"expressionRight": {
|
||||||
|
"@type": "Literal",
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "BOOLEAN"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hasConstructor": false,
|
||||||
|
"methods": [
|
||||||
|
{
|
||||||
|
"@type": "Method",
|
||||||
|
"visibility": {
|
||||||
|
"enumAccessTypeNode": "PUBLIC"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "testMethod",
|
||||||
|
"parameters": {
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "INT"
|
||||||
|
},
|
||||||
|
"identifier": "param1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"statements": [
|
||||||
|
{
|
||||||
|
"@type": "Assignment",
|
||||||
|
"expressionLeft": {
|
||||||
|
"@type": "InstVar",
|
||||||
|
"identifier": "testVar",
|
||||||
|
"expression": {
|
||||||
|
"@type": "InstVar",
|
||||||
|
"identifier": "testVar",
|
||||||
|
"expression": {
|
||||||
|
"@type": "This",
|
||||||
|
"type": {
|
||||||
|
"@type": "Reference",
|
||||||
|
"identifier": "testClass2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"expressionRight": {
|
||||||
|
"@type": "Literal",
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"@type": "VariableDeclaration",
|
||||||
|
"type": {
|
||||||
|
"@type": "Base",
|
||||||
|
"enumType": "CHAR"
|
||||||
|
},
|
||||||
|
"identifier": "objectVar",
|
||||||
|
"expression": {
|
||||||
|
"@type": "Literal",
|
||||||
|
"type": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
src/test/resources/trees/test.json
Normal file
1
src/test/resources/trees/test.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"classes":[{"identifier":"testClass","accessType":{"enumAccessTypeNode":"PUBLIC"},"members":[{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar1"},{"@type":"Field","accessTypeNode":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"objectVar"},{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}],"hasConstructor":false,"methods":[{"@type":"Method","visibility":{"enumAccessTypeNode":"PUBLIC"},"type":{"@type":"Base","enumType":"INT"},"identifier":"testVar2","parameters":{"parameters":[{"type":{"@type":"Base","enumType":"INT"},"identifier":"param1"}]},"statements":[{"@type":"Assignment","expressionLeft":{"@type":"InstVar","identifier":"objectVar","expression":{"@type":"This","type":{"@type":"Reference","identifier":"testClass"}},"type":null},"expressionRight":{"@type":"Literal","type":{"@type":"Base","enumType":"INT"}}}]}]}]}
|
Loading…
Reference in New Issue
Block a user