// ino.module.LocalOrFieldVar.8637.package package mycompiler.mystatement; // ino.end // ino.module.LocalOrFieldVar.8637.import import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.JVMCode; import mycompiler.myclass.Class; import mycompiler.myclass.UsedId; import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.SCExcept; import mycompiler.myexception.SCStatementException; import mycompiler.mytype.GenericTypeVar; import mycompiler.mytype.RefType; import mycompiler.mytype.Type; import mycompiler.mytype.TypePlaceholder; import mycompiler.mytypereconstruction.CSupportData; import mycompiler.mytypereconstruction.CTriple; import mycompiler.mytypereconstruction.set.CSubstitutionSet; import mycompiler.mytypereconstruction.set.CTripleSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumptionkey.CInstVarKey; import mycompiler.mytypereconstruction.typeassumptionkey.CLocalVarKey; import org.apache.log4j.Logger; // ino.end import sun.reflect.generics.reflectiveObjects.NotImplementedException; import typinferenz.JavaCodeResult; import typinferenz.SingleConstraint; import typinferenz.ConstraintsSet; import typinferenz.FreshTypeVariable; import typinferenz.ResultSet; import typinferenz.assumptions.TypeAssumptions; // ino.class.LocalOrFieldVar.25503.declaration public class LocalOrFieldVar extends Expr // ino.end // ino.class.LocalOrFieldVar.25503.body { // ino.attribute.parserlog.25507.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end // ino.method.LocalOrFieldVar.25510.definition public LocalOrFieldVar(int offset, int variableLength) // ino.end // ino.method.LocalOrFieldVar.25510.body { super(offset,variableLength); } // ino.end // ino.method.LocalOrFieldVar.25513.definition public LocalOrFieldVar(String n, int offset) // ino.end // ino.method.LocalOrFieldVar.25513.body { super(offset,n.length()); usedid = new UsedId(offset); usedid.set_Name(n); } // ino.end // ino.method.set_UsedId.25519.definition public void set_UsedId(UsedId u) // ino.end // ino.method.set_UsedId.25519.body { this.usedid=u; } // ino.end // ino.method.get_Name.25522.definition public String get_Name() // ino.end // ino.method.get_Name.25522.body { return usedid.get_Name_1Element(); } // ino.end // ino.method.codegen.25525.definition public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException // ino.end // ino.method.codegen.25525.body { Vector name_vector = get_Name_Vector(); Vector type_vector = get_Type_Vector(); String local_name = null; String class_name = null; String type = null; for(int i=0; i < name_vector.size(); i++) { local_name = (String)name_vector.elementAt(i); try {// TEST SCJU. ArrayIndexoutofBounds umgehen! type = JVMCode.get_codegen_Type((String)type_vector.elementAt(i), paralist); } catch (Throwable e) {type = null; } int index = code.get_indexOf_Var(local_name); if(index != -1) { // LocalVar try { String local_type = code.get_TypeOf_Var(local_name).getName(); code.add_code(JVMCode.nload_n(local_type, index)); } catch(JVMCodeException e) { // out of nstore_n String local_type = code.get_TypeOf_Var(local_name).getName(); code.add_code(JVMCode.nload(local_type)); code.add_code_byte((byte)index); } } else { // FieldVar code.add_code(JVMCode.aload_0); code.add_code(JVMCode.getfield); code.add_code_short(classfile.add_field_ref(local_name, class_name, type)); } try { // TEST SCJU. ArrayIndexoutofBounds umgehen! class_name = (String)type_vector.elementAt(i); } catch (Throwable e) { } } // Falls noetig, Unboxing auf primitiven Typ! if (this.getTypeVariable() instanceof RefType) { RefType rt = (RefType) this.getTypeVariable(); if (! rt.getPrimitiveFlag()) return; if (rt.getName().equalsIgnoreCase("java.lang.Integer")) { // Int Unboxen code.add_code(JVMCode.invokevirtual); code.add_code_short(classfile.add_method_ref("java/lang/Integer", "intValue", "()I")); } } } // ino.end // ino.end // ino.method.TRStatement.25531.definition public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData) // ino.end // ino.method.TRStatement.25531.body { throw CTypeReconstructionException.createNotImplementedException(); } // ino.end // ino.method.toString.25534.defdescription type=javadoc /** *
Author: Martin Pl�micke * @return */ // ino.end // ino.method.toString.25534.definition public String toString() // ino.end // ino.method.toString.25534.body { if(getTypeVariable()==null)return usedid.toString(); return usedid.toString() + ": " + getTypeVariable().toString(); } // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.25537.definition public void wandleRefTypeAttributes2GenericAttributes(Vector paralist, Vector genericMethodParameters) // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.25537.body { } // ino.end public void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable) { if(this.get_UsedId().get_Name_1Element().equals(NameVariable)) { //wenn Variable mit gleichem Namen gefunden->schreibe Offset localAssumption.addOffset(this.get_UsedId().getOffset()); } } @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); //gibt es eine Assumption für den die LocalOrFieldVar-Variablen, dann folgendes ausführen: Type thisTypeAssumption = assumptions.getVarType(this.get_Name()); this.setTypeVariable(thisTypeAssumption); //ret.add(new Constraint(thisTypeAssumption, this.getTypeVariable())); return ret; } public String getTypeInformation(){ return this.getTypeVariable()+" "+this.get_Name(); } @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { return new JavaCodeResult(this.get_Name()); } } // ino.end