mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 17:28:03 +00:00
bugfix in fieldvaraccess
This commit is contained in:
parent
ad57e4baff
commit
8bccfc3a56
@ -205,38 +205,4 @@ public class TypedClass implements TypedNode {
|
|||||||
|
|
||||||
return cw.toByteArray();
|
return cw.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
TypedClass c = new TypedClass();
|
|
||||||
c.setClassName("SomeClass");
|
|
||||||
|
|
||||||
//Fields
|
|
||||||
TypedDeclaration f1 = new TypedDeclaration("someNumber", Type.INT);
|
|
||||||
TypedDeclaration f2 = new TypedDeclaration("someChar", Type.CHAR);
|
|
||||||
c.typedDeclarations = List.of(f1, f2);
|
|
||||||
|
|
||||||
//Constructors
|
|
||||||
TypedConstructor constructor = new TypedConstructor("SomeClass", List.of(new TypedParameter("test", Type.INT)), new TypedBlock(new ArrayList<>(), new ArrayList<>()));
|
|
||||||
c.typedConstructors = List.of(constructor);
|
|
||||||
|
|
||||||
//Methods
|
|
||||||
c.typedMethods = new ArrayList<>();
|
|
||||||
TypedMethod m = new TypedMethod();
|
|
||||||
m.setName("someMethod");
|
|
||||||
m.setReturnType(Type.INT);
|
|
||||||
m.setTypedParameters(List.of(new TypedParameter("test", Type.INT)));
|
|
||||||
TypedIfElse ifs = new TypedIfElse();
|
|
||||||
TypedBinary cond = new TypedBinary();
|
|
||||||
cond.setOp(Operator.GT);
|
|
||||||
//cond.setLeft(??);
|
|
||||||
cond.setRight(new TypedIntLiteral(12));
|
|
||||||
ifs.setTypedCon(cond);
|
|
||||||
m.setTypedBlock(new TypedBlock(List.of(), List.of(ifs, new TypedReturn())));
|
|
||||||
c.typedMethods.add(m);
|
|
||||||
|
|
||||||
//codeGen
|
|
||||||
byte[] code = c.codeGen();
|
|
||||||
CodeGenUtils.writeClassfile(code, "SomeClass");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,11 @@ public class TypedFieldVarAccess implements TypedExpression {
|
|||||||
if (recursiveOwnerChain != null) {
|
if (recursiveOwnerChain != null) {
|
||||||
ownerChainName = recursiveOwnerChain.getType().getReference();
|
ownerChainName = recursiveOwnerChain.getType().getReference();
|
||||||
} else {
|
} else {
|
||||||
ownerChainName = type.getReference();
|
if (type.getKind() == Type.Kind.REFERENCE) {
|
||||||
|
ownerChainName = type.getReference();
|
||||||
|
} else {
|
||||||
|
ownerChainName = ctx.getClassContext().getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ctx.getMv().visitFieldInsn(Opcodes.GETFIELD, ownerChainName, name, type.getDescriptor());
|
ctx.getMv().visitFieldInsn(Opcodes.GETFIELD, ownerChainName, name, type.getDescriptor());
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,12 +6,9 @@ public class ClassCanBeBytecoded {
|
|||||||
|
|
||||||
|
|
||||||
public int test(int var1) {
|
public int test(int var1) {
|
||||||
int i;
|
for (int i = 0; i < 12; i = i + 1) {
|
||||||
i = 0;
|
var1 = this.c.c.c.c.x + this.x;
|
||||||
while (i < 10) {
|
if (var1 * 3 == 0) {
|
||||||
i = i + 1;
|
|
||||||
var1 = var1 + 1;
|
|
||||||
if (var1 == 5) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user