adapted tests to new structure of ast

This commit is contained in:
JonathanFleischmann 2024-05-20 23:01:00 +02:00
parent 72647ffe70
commit 09a327bdee
15 changed files with 294 additions and 148 deletions

View File

@ -2,6 +2,7 @@ package de.maishai.typedast.typedclass;
import de.maishai.ast.records.*;
import de.maishai.typedast.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
@ -9,6 +10,7 @@ import org.objectweb.asm.Opcodes;
import static de.maishai.typedast.Help.TypedExpressionHelp.convertExpression;
@Data
@AllArgsConstructor
public class TypedDoWhile implements TypedStatement {
private TypedBlock typedBlock;
private TypedExpression cond;

View File

@ -47,13 +47,6 @@ public class AbstractSyntax_ClassWithConstructor {
private static Constructor getConstructor1() {
List<Parameter> parameters = List.of();
List<Declaration> localVariables = List.of(
new Declaration(
"i",
Type.INT
)
);
List<Statement> statementList = List.of(
new Assignment(
new FieldVarAccess(
@ -62,6 +55,10 @@ public class AbstractSyntax_ClassWithConstructor {
"x"),
new IntLiteral(10)
),
new Declaration(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
@ -97,9 +94,7 @@ public class AbstractSyntax_ClassWithConstructor {
new Declaration(
"j",
Type.INT
)
),
List.of(
),
new For(
new Assignment(
new FieldVarAccess(
@ -134,7 +129,6 @@ public class AbstractSyntax_ClassWithConstructor {
)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -162,7 +156,6 @@ public class AbstractSyntax_ClassWithConstructor {
);
Block block = new Block(
localVariables,
statementList
);
return new Constructor(

View File

@ -53,7 +53,6 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
private static Constructor getConstructor1() {
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -71,7 +70,6 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
List.of()
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -112,7 +110,6 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
"methodCall",
List.of(),
new Block(
List.of(),
List.of(
new IfElse(
new Binary(
@ -124,7 +121,6 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
new IntLiteral(100)
),
new Block(
List.of(),
List.of(
new Return(
new BoolLiteral(false)
@ -132,7 +128,6 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
)
),
new Block(
List.of(),
List.of(
new Return(
new BoolLiteral(true)

View File

@ -49,12 +49,6 @@ public class AbstractSyntax_ClassWithConstructorWithCodeInComments {
private static Constructor getConstructor1() {
List<Parameter> parameters = List.of();
List<Declaration> localVariables = List.of(
new Declaration(
"i",
Type.INT
)
);
List<Statement> statementList = List.of(
new Assignment(
new FieldVarAccess(
@ -63,6 +57,10 @@ public class AbstractSyntax_ClassWithConstructorWithCodeInComments {
"x"),
new IntLiteral(10)
),
new Declaration(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
@ -94,7 +92,6 @@ public class AbstractSyntax_ClassWithConstructorWithCodeInComments {
)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -119,7 +116,6 @@ public class AbstractSyntax_ClassWithConstructorWithCodeInComments {
);
Block block = new Block(
localVariables,
statementList
);

View File

@ -58,7 +58,6 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
)
);
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -84,9 +83,7 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
new Declaration(
"innerRepetitions",
Type.INT
)
),
List.of(
),
new Assignment(
new FieldVarAccess(
false,
@ -107,7 +104,6 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
new IntLiteral(0)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(

View File

@ -23,7 +23,6 @@ public class AbstractSyntax_ClassWithField {
"ClassWithField",
List.of(),
new Block(
List.of(),
List.of()
)
)

View File

@ -24,7 +24,6 @@ public class AbstractSyntax_ClassWithMethod {
"ClassWithMethod",
List.of(),
new Block(
List.of(),
List.of()
)
)
@ -44,7 +43,6 @@ public class AbstractSyntax_ClassWithMethod {
"method",
List.of(),
new Block(
List.of(),
List.of(
new Return(
new BoolLiteral(false)

View File

@ -53,7 +53,6 @@ class AbstractSyntax_ClassWithMethodAndField {
)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -80,7 +79,6 @@ class AbstractSyntax_ClassWithMethodAndField {
"method",
List.of(),
new Block(
List.of(),
List.of(
new Return(
new BoolLiteral(true)

View File

@ -60,9 +60,7 @@ public class AbstractSyntax_ClassWithMultipleMethods {
new Declaration(
"returnValue",
Type.BOOL
)
),
List.of(
),
new Assignment(
new FieldVarAccess(
false,
@ -87,7 +85,6 @@ public class AbstractSyntax_ClassWithMultipleMethods {
new IntLiteral(0)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -146,7 +143,6 @@ public class AbstractSyntax_ClassWithMultipleMethods {
);
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(

View File

@ -23,11 +23,10 @@
// this.y = this.y + 1;
// } while (this.y < 10);
//
// int k;
// k = 0;
// int k = 0;
// for (k = 0; k < 10; k = k + 1) {
// if (k == 5) {
// return this;
// return;
// }
// }
//
@ -142,16 +141,6 @@ public class AbstractSyntax_ComplexClass {
private static Constructor getConstructor1() {
Block block = new Block(
List.of(
new Declaration(
"i",
Type.INT
),
new Declaration(
"k",
Type.INT
)
),
List.of(
new Assignment(
new FieldVarAccess(
@ -167,6 +156,10 @@ public class AbstractSyntax_ComplexClass {
"x"),
new IntLiteral(2)
),
new Declaration(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
@ -209,9 +202,7 @@ public class AbstractSyntax_ComplexClass {
new Declaration(
"j",
Type.INT
)
),
List.of(
),
new For(
new Assignment(
new FieldVarAccess(
@ -247,7 +238,6 @@ public class AbstractSyntax_ComplexClass {
)
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -277,7 +267,6 @@ public class AbstractSyntax_ComplexClass {
new IntLiteral(100)
),
new Block(
List.of(),
List.of(
new Break()
)
@ -299,7 +288,6 @@ public class AbstractSyntax_ComplexClass {
),
new DoWhile(
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -326,6 +314,10 @@ public class AbstractSyntax_ComplexClass {
new IntLiteral(10)
)
),
new Declaration(
"k",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
@ -364,7 +356,6 @@ public class AbstractSyntax_ComplexClass {
)
),
new Block(
List.of(),
List.of(
new IfElse(
new Binary(
@ -376,10 +367,9 @@ public class AbstractSyntax_ComplexClass {
new IntLiteral(5)
),
new Block(
List.of(),
List.of(
new Return(
new This()
null
)
)
),
@ -399,7 +389,6 @@ public class AbstractSyntax_ComplexClass {
private static Constructor getConstructor2() {
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -436,7 +425,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"x"),
@ -446,7 +435,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"y"),
@ -456,7 +445,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"c"),
"x"),
@ -466,7 +455,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"getX"
@ -477,7 +466,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"y"
@ -488,7 +477,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"getX"
@ -503,7 +492,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"c"),
"y"),
@ -525,7 +514,6 @@ public class AbstractSyntax_ComplexClass {
private static Constructor getConstructor3() {
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -569,7 +557,6 @@ public class AbstractSyntax_ComplexClass {
private static Constructor getConstructor4() {
Block block = new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
@ -632,9 +619,7 @@ public class AbstractSyntax_ComplexClass {
new Declaration(
"a",
Type.INT
)
),
List.of(
),
new Assignment(
new FieldVarAccess(
false,
@ -663,7 +648,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"x"),
@ -681,7 +666,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"y"),
@ -691,9 +676,9 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
new FieldVarAccess(
false,
true,
null,
"b"),
"c"),
@ -717,18 +702,17 @@ public class AbstractSyntax_ComplexClass {
List.of()
),
new Block(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
new MethodCall(
new FieldVarAccess(
false,
new FieldVarAccess(
false,
true,
null,
"b"
),
@ -741,7 +725,7 @@ public class AbstractSyntax_ComplexClass {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"b"
),
@ -777,7 +761,6 @@ public class AbstractSyntax_ComplexClass {
private static Method getMethod2() {
Block block = new Block(
List.of(),
List.of(
new Return(
new New(
@ -817,7 +800,6 @@ public class AbstractSyntax_ComplexClass {
private static Method getMethod3() {
Block block = new Block(
List.of(),
List.of(
new Return(
new FieldVarAccess(
@ -843,7 +825,6 @@ public class AbstractSyntax_ComplexClass {
private static Method getMethod4() {
Block block = new Block(
List.of(),
List.of(
new Return(
new FieldVarAccess(
@ -864,7 +845,6 @@ public class AbstractSyntax_ComplexClass {
private static Method getMethod5() {
Block block = new Block(
List.of(),
List.of(
new Return(
new FieldVarAccess(
@ -885,7 +865,6 @@ public class AbstractSyntax_ComplexClass {
private static Method getMethod6() {
Block block = new Block(
List.of(),
List.of(
new Return(
new BoolLiteral(false)

View File

@ -21,7 +21,6 @@ public class AbstractSyntax_PublicClass {
"PublicClass",
List.of(),
new Block(
List.of(),
List.of()
)
)

View File

@ -23,11 +23,10 @@ public class ComplexClass {
this.y = this.y + 1;
} while (this.y < 10);
int k;
k = 0;
int k = 0;
for (k = 0; k < 10; k = k + 1) {
if (k == 5) {
return this;
return;
}
}

View File

@ -225,7 +225,16 @@ public class TypedAbstractSyntax_ClassWithConstructor {
typedParameters,
typedBlock,
Type.VOID,
List.of()
List.of(
new TypedLocalVariable(
"i",
Type.INT
),
new TypedLocalVariable(
"j",
Type.INT
)
)
);
}
}

View File

@ -148,7 +148,7 @@ public class TypedAbstractSyntax_ComplexClass {
),
List.of(
new TypedAssignment(
new TypedIntLiteral(10),
new TypedIntLiteral(10, Type.INT),
new TypedFieldVarAccess(
true,
null,
@ -158,7 +158,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(2),
new TypedIntLiteral(2, Type.INT),
new TypedFieldVarAccess(
true,
null,
@ -169,7 +169,7 @@ public class TypedAbstractSyntax_ComplexClass {
),
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(0),
new TypedIntLiteral(0, Type.INT),
new TypedFieldVarAccess(
false,
null,
@ -192,7 +192,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
Operator.ADD,
new TypedIntLiteral(1),
new TypedIntLiteral(1, Type.INT),
Type.INT
),
Type.BOOL
@ -205,7 +205,7 @@ public class TypedAbstractSyntax_ComplexClass {
"i",
Type.INT),
Operator.ADD,
new TypedIntLiteral(1),
new TypedIntLiteral(1, Type.INT),
Type.INT
),
new TypedFieldVarAccess(
@ -225,7 +225,7 @@ public class TypedAbstractSyntax_ComplexClass {
List.of(
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(0),
new TypedIntLiteral(0, Type.INT),
new TypedFieldVarAccess(
false,
null,
@ -250,7 +250,7 @@ public class TypedAbstractSyntax_ComplexClass {
),
new TypedAssignment(
new TypedBinary(
new TypedIntLiteral(1),
new TypedIntLiteral(1, Type.INT),
Operator.ADD,
new TypedFieldVarAccess(
false,
@ -305,33 +305,183 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
Operator.EQ,
new TypedIntLiteral(100),
new TypedIntLiteral(100, Type.INT),
Type.BOOL
),
new TypedBlock(
List.of(),
List.of(
new TypedBreak()
)
),
Type.VOID
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
null,
Type.VOID
)
)
),
Type.VOID
),
Type.VOID
)
)
),
Type.VOID
),
Type.VOID
),
new TypedAssignment(
new TypedIntLiteral(2, Type.INT),
new TypedFieldVarAccess(
true,
null,
"y",
Type.INT
),
Type.INT
),
new TypedDoWhile(
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
true,
null,
"y",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(1, Type.INT),
Type.INT
),
new TypedFieldVarAccess(
true,
null,
"y",
Type.INT
),
Type.INT
)
),
Type.VOID
),
new TypedBinary(
new TypedFieldVarAccess(
true,
null,
"y",
Type.INT
),
Operator.LT,
new TypedIntLiteral(10, Type.INT),
Type.BOOL
),
Type.VOID
),
new TypedAssignment(
new TypedIntLiteral(0, Type.INT),
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Type.INT
),
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(0, Type.INT),
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Type.INT
),
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Operator.LT,
new TypedIntLiteral(10, Type.INT),
Type.BOOL
),
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(1, Type.INT),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Type.INT
),
new TypedBlock(
List.of(),
List.of(
new TypedIfElse(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"k",
Type.INT
),
Operator.EQ,
new TypedIntLiteral(5, Type.INT),
Type.BOOL
),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
)
),
Type.VOID
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID
)
),
Type.VOID
),
Type.VOID
)
)
),
Type.VOID
);
return new TypedConstructor(
"ComplexClass",
List.of(),
block
block,
Type.REFERENCE("ComplexClass"),
List.of(
new TypedLocalVariable("i", Type.INT),
new TypedLocalVariable("k", Type.INT),
new TypedLocalVariable("j", Type.INT)
)
);
}
@ -381,11 +531,11 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(7),
new TypedIntLiteral(7, Type.INT),
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -396,11 +546,11 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(13),
new TypedIntLiteral(13, Type.INT),
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -417,7 +567,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -432,7 +582,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -447,7 +597,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -468,7 +618,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"c",
Type.REFERENCE("ComplexClass")
@ -479,11 +629,11 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(25),
new TypedIntLiteral(25, Type.INT),
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"c",
Type.REFERENCE("ComplexClass")
@ -493,7 +643,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.VOID
);
return new TypedConstructor(
"ComplexClass",
@ -503,7 +654,11 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
block
block,
Type.REFERENCE("ComplexClass"),
List.of(
new TypedLocalVariable("x", Type.INT)
)
);
}
@ -541,7 +696,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.VOID
);
return new TypedConstructor(
"ComplexClass",
@ -555,7 +711,12 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
block
block,
Type.REFERENCE("ComplexClass"),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT)
)
);
}
@ -593,7 +754,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.VOID
);
return new TypedConstructor(
"ComplexClass",
@ -611,7 +773,13 @@ public class TypedAbstractSyntax_ComplexClass {
Type.CHAR
)
),
block
block,
Type.REFERENCE("ComplexClass"),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT),
new TypedLocalVariable("z", Type.CHAR)
)
);
}
@ -633,12 +801,12 @@ public class TypedAbstractSyntax_ComplexClass {
),
List.of(
new TypedAssignment(
new TypedIntLiteral(10),
new TypedIntLiteral(10, Type.INT),
new TypedFieldVarAccess(
false,
null,
"a",
Type.REFERENCE("ComplexClass")
Type.INT
),
Type.INT
),
@ -664,7 +832,7 @@ public class TypedAbstractSyntax_ComplexClass {
),
new TypedAssignment(
new TypedBinary(
new TypedIntLiteral(10),
new TypedIntLiteral(10, Type.INT),
Operator.ADD,
new TypedFieldVarAccess(
false,
@ -677,7 +845,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -688,11 +856,11 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(20),
new TypedIntLiteral(20, Type.INT),
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -704,7 +872,7 @@ public class TypedAbstractSyntax_ComplexClass {
),
new TypedAssignment(
new TypedBinary(
new TypedIntLiteral(20),
new TypedIntLiteral(20, Type.INT),
Operator.ADD,
new TypedFieldVarAccess(
false,
@ -717,9 +885,9 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -750,7 +918,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -761,12 +929,12 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
false,
true,
new TypedMethodCall(
new TypedFieldVarAccess(
false,
new TypedFieldVarAccess(
false,
true,
null,
"b",
Type.REFERENCE("ComplexClass")
@ -785,9 +953,14 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.VOID
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
null,
Type.VOID
),
new TypedReturn(
@ -799,7 +972,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.REFERENCE("ComplexClass")
)
)
),
Type.REFERENCE("ComplexClass")
);
return new TypedMethod(
"initComplexClass",
@ -810,7 +984,10 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
List.of(),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("a", Type.INT)
),
block
);
}
@ -839,7 +1016,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.REFERENCE("ComplexClass")
)
)
),
Type.REFERENCE("ComplexClass")
);
return new TypedMethod(
"init",
@ -854,7 +1032,10 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
List.of(),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT)
),
block
);
}
@ -872,7 +1053,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.INT
);
return new TypedMethod(
"getX",
@ -883,7 +1065,9 @@ public class TypedAbstractSyntax_ComplexClass {
Type.CHAR
)
),
List.of(),
List.of(
new TypedLocalVariable("z", Type.CHAR)
),
block
);
}
@ -901,7 +1085,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.REFERENCE("ComplexClass")
)
)
),
Type.REFERENCE("ComplexClass")
);
return new TypedMethod(
"getC",
@ -925,7 +1110,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.INT
)
)
),
Type.INT
);
return new TypedMethod(
"getX",
@ -947,7 +1133,8 @@ public class TypedAbstractSyntax_ComplexClass {
),
Type.BOOL
)
)
),
Type.BOOL
);
return new TypedMethod(
"methodCall",

View File

@ -59,6 +59,6 @@ public class ScannerParserTests {
@Test
public void testComplexClass() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ComplexClass.java"));
assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultAst);
assertEquals(AbstractSyntax_ComplexClass.get(), resultAst);
}
}