Print now can print fields of thisClass

This commit is contained in:
Jochen Seyfried 2024-07-04 10:04:31 +02:00
parent 6a56f51050
commit e801717444

View File

@ -60,9 +60,13 @@ public class PrintStatement extends AbstractType implements IStatement {
} }
counter++; counter++;
} }
// If not a localVar, maybe a class field of this class
if (index == -1){ if (index == -1){
throw new Exception("Variable " + variableName + " not found"); String typeOfField = typeContext.get(thisClass).get(variableName);
if (typeOfField == null){
throw new Exception("Variable " + variableName + " not found in local variables or class fields.");
}
mv.visitFieldInsn(Opcodes.GETSTATIC, thisClass, variableName, "I");
} }
mv.visitVarInsn(Opcodes.ILOAD, index); mv.visitVarInsn(Opcodes.ILOAD, index);