- OLTest verbessert, ist aber nicht positiv, da Autoboxing fehlt

This commit is contained in:
Enrico Schrödter 2016-04-12 20:06:22 +02:00
parent 7363758603
commit 11e149110a
6 changed files with 18 additions and 13 deletions

View File

@ -140,12 +140,12 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
return InstructionFactory.createLoad(bytecodeType, storeIndexes.get(variableName));
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
}
public Integer getStoreIndex(String variableName) {
if(!storeIndexes.containsKey(variableName)){
storeIndexes.put(variableName, storeIndexes.size()+1);
storeIndexes.put(variableName, storeIndexes.size());
}
return storeIndexes.get(variableName);
@ -160,6 +160,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public void resetStoreIndexes() {
storeIndexes = new HashMap<>();
storeIndexes.clear();
}
}

View File

@ -431,7 +431,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
@Override
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
// TODO Auto-generated method stub
_cg.getInstructionFactory().getStoreIndex(get_Name());
return new InstructionList();
}
}

View File

@ -326,6 +326,7 @@ public class MethodCall extends Expr
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
InstructionList il = new InstructionList();
DHBWInstructionFactory _factory = cg.getInstructionFactory();
//TODO: später wiederherstelln?
_factory.resetStoreIndexes();
il.append(receiver.get_Expr().genByteCode(cg, rs));

View File

@ -7,7 +7,7 @@ class OL {
class Main {
main(x) {
main(x) {
ol;
ol = new OL();
return ol.m(x);

View File

@ -33,13 +33,13 @@ public class OLTest extends SourceFileBytecodeTest{
URL url = file.toURL();
URL[] urls = new URL[]{url};
Class stringVector = classLoader.loadClass("Integer");
Integer integer = new Integer(1);
Class[] params = new Class[1];
params[0] = stringVector;
params[0] = integer.getClass();
Method method = cls.getDeclaredMethod("m", params);
method.invoke(obj, stringVector.newInstance());
method.invoke(obj, integer);
assertTrue(true);
}catch(Exception e){
throw new RuntimeException(e);
@ -59,13 +59,13 @@ public class OLTest extends SourceFileBytecodeTest{
URL url = file.toURL();
URL[] urls = new URL[]{url};
Class stringVector = classLoader.loadClass("Boolean");
Boolean bool = new Boolean(true);
Class[] params = new Class[1];
params[0] = stringVector;
params[0] = bool.getClass();
Method method = cls.getDeclaredMethod("m", params);
method.invoke(obj, stringVector.newInstance());
method.invoke(obj, bool);
assertTrue(true);
}catch(Exception e){
throw new RuntimeException(e);

View File

@ -10,8 +10,12 @@ class Overloading{
}
main(String[] args) {
new Overloading().method(new Vector<String> ());
main(String[] args) {
ol;
ol = new Overloading();
v;
v = new Vector<String> ();
ol.method(v);
}
}