forked from JavaTX/JavaCompilerCore
- OLTest verbessert, ist aber nicht positiv, da Autoboxing fehlt
This commit is contained in:
parent
7363758603
commit
11e149110a
@ -140,12 +140,12 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
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) {
|
public Integer getStoreIndex(String variableName) {
|
||||||
if(!storeIndexes.containsKey(variableName)){
|
if(!storeIndexes.containsKey(variableName)){
|
||||||
storeIndexes.put(variableName, storeIndexes.size()+1);
|
storeIndexes.put(variableName, storeIndexes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
return storeIndexes.get(variableName);
|
return storeIndexes.get(variableName);
|
||||||
@ -160,6 +160,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetStoreIndexes() {
|
public void resetStoreIndexes() {
|
||||||
storeIndexes = new HashMap<>();
|
storeIndexes.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
// TODO Auto-generated method stub
|
_cg.getInstructionFactory().getStoreIndex(get_Name());
|
||||||
return new InstructionList();
|
return new InstructionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,7 @@ public class MethodCall extends Expr
|
|||||||
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
InstructionList il = new InstructionList();
|
InstructionList il = new InstructionList();
|
||||||
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
||||||
|
//TODO: später wiederherstelln?
|
||||||
_factory.resetStoreIndexes();
|
_factory.resetStoreIndexes();
|
||||||
|
|
||||||
il.append(receiver.get_Expr().genByteCode(cg, rs));
|
il.append(receiver.get_Expr().genByteCode(cg, rs));
|
||||||
|
@ -7,7 +7,7 @@ class OL {
|
|||||||
|
|
||||||
class Main {
|
class Main {
|
||||||
|
|
||||||
main(x) {
|
main(x) {
|
||||||
ol;
|
ol;
|
||||||
ol = new OL();
|
ol = new OL();
|
||||||
return ol.m(x);
|
return ol.m(x);
|
||||||
|
@ -33,13 +33,13 @@ public class OLTest extends SourceFileBytecodeTest{
|
|||||||
URL url = file.toURL();
|
URL url = file.toURL();
|
||||||
URL[] urls = new URL[]{url};
|
URL[] urls = new URL[]{url};
|
||||||
|
|
||||||
Class stringVector = classLoader.loadClass("Integer");
|
Integer integer = new Integer(1);
|
||||||
|
|
||||||
Class[] params = new Class[1];
|
Class[] params = new Class[1];
|
||||||
params[0] = stringVector;
|
params[0] = integer.getClass();
|
||||||
|
|
||||||
Method method = cls.getDeclaredMethod("m", params);
|
Method method = cls.getDeclaredMethod("m", params);
|
||||||
method.invoke(obj, stringVector.newInstance());
|
method.invoke(obj, integer);
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -59,13 +59,13 @@ public class OLTest extends SourceFileBytecodeTest{
|
|||||||
URL url = file.toURL();
|
URL url = file.toURL();
|
||||||
URL[] urls = new URL[]{url};
|
URL[] urls = new URL[]{url};
|
||||||
|
|
||||||
Class stringVector = classLoader.loadClass("Boolean");
|
Boolean bool = new Boolean(true);
|
||||||
|
|
||||||
Class[] params = new Class[1];
|
Class[] params = new Class[1];
|
||||||
params[0] = stringVector;
|
params[0] = bool.getClass();
|
||||||
|
|
||||||
Method method = cls.getDeclaredMethod("m", params);
|
Method method = cls.getDeclaredMethod("m", params);
|
||||||
method.invoke(obj, stringVector.newInstance());
|
method.invoke(obj, bool);
|
||||||
assertTrue(true);
|
assertTrue(true);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -10,8 +10,12 @@ class Overloading{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main(String[] args) {
|
main(String[] args) {
|
||||||
new Overloading().method(new Vector<String> ());
|
ol;
|
||||||
|
ol = new Overloading();
|
||||||
|
v;
|
||||||
|
v = new Vector<String> ();
|
||||||
|
ol.method(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user