-Test für Variablen erstellt

This commit is contained in:
Enrico Schrödter 2016-04-14 14:36:18 +02:00
parent 9a07201498
commit a23f77c337
4 changed files with 52 additions and 3 deletions

View File

@ -144,8 +144,9 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public Integer getStoreIndex(String variableName) {
if(!storeIndexes.containsKey(variableName)){
storeIndexes.put(variableName, storeIndexes.size()+1);
if(storeIndexes.get(variableName) == null){
Integer index = storeIndexes.size()+1;
storeIndexes.put(variableName, index);
}
return storeIndexes.get(variableName);
@ -160,6 +161,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
}
public void resetStoreIndexes() {
storeIndexes.clear();
//storeIndexes.clear();
}
}

View File

@ -610,6 +610,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
public void genByteCode(ClassGenerator cg, Class classObj) {
List<TypeinferenceResultSet> typeInterferenceResults = cg.getTypeinferenceResults().getTypeReconstructions(this, cg);
DHBWInstructionFactory _factory = cg.getInstructionFactory();
for(TypeinferenceResultSet t: typeInterferenceResults){
DHBWConstantPoolGen _cp = cg.getConstantPool();
@ -626,6 +627,10 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
for(FormalParameter parameter : this.parameterlist){
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
argumentNames[i] = parameter.getIdentifier();
_factory.getStoreIndex(parameter.getIdentifier());
i++;
}
}

View File

@ -0,0 +1,8 @@
class Variable{
public Integer method(Integer parameter){
Integer lokaleVariable;
lokaleVariable = 2;
return parameter+lokaleVariable;
}
}

View File

@ -0,0 +1,35 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Vector;
import org.junit.Test;
import org.junit.Ignore;
import bytecode.SourceFileBytecodeTest;
public class VariableTest extends SourceFileBytecodeTest{
@Override
protected void init() {
testName = "Variable";
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
}
@Test
public void testConstruct() throws Exception{
ClassLoader classLoader = getClassLoader();
Class cls = classLoader.loadClass(testName);
Object obj = cls.newInstance();
assertTrue(true);
}
}