forked from JavaTX/JavaCompilerCore
-Test für Variablen erstellt
This commit is contained in:
parent
9a07201498
commit
a23f77c337
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
8
test/bytecode/Variable.jav
Normal file
8
test/bytecode/Variable.jav
Normal file
@ -0,0 +1,8 @@
|
||||
class Variable{
|
||||
public Integer method(Integer parameter){
|
||||
Integer lokaleVariable;
|
||||
lokaleVariable = 2;
|
||||
|
||||
return parameter+lokaleVariable;
|
||||
}
|
||||
}
|
35
test/bytecode/VariableTest.java
Normal file
35
test/bytecode/VariableTest.java
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user