forked from JavaTX/JavaCompilerCore
Erste Änderung an RefType
Tests für Extends angelegt
This commit is contained in:
parent
0a17be3c4f
commit
3a18088801
@ -178,7 +178,8 @@ public class IfStmt extends Statement
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstructionList genByteCode(ClassGenerator _cg) {
|
||||
public InstructionList genByteCode(ClassGenerator _cg) {
|
||||
InstructionFactory _factory = _cg.getInstructionFactory();
|
||||
InstructionList il = new InstructionList();
|
||||
IfInstruction ifInstruction = new IFEQ(null);
|
||||
|
||||
|
@ -814,11 +814,24 @@ public class RefType extends ObjectType implements IMatchable
|
||||
}
|
||||
|
||||
public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
|
||||
return new org.apache.commons.bcel6.generic.ObjectType(this.getTypeName());
|
||||
return new org.apache.commons.bcel6.generic.ObjectType(this.getBytecodeSignature(cg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBytecodeSignature(ClassGenerator cg) {
|
||||
//Bsp.: Ljava/util/Vector<Ljava/lang/String;>;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(getTypeName());
|
||||
|
||||
if(parameter != null){
|
||||
for(Type type: parameter){
|
||||
sb.append("%");
|
||||
sb.append(type.getBytecodeSignature(cg));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
String paramString = "";
|
||||
if(this.parameter != null && this.parameter.size()>0){
|
||||
paramString+="<";
|
||||
@ -834,6 +847,9 @@ public class RefType extends ObjectType implements IMatchable
|
||||
String typeSignature = this.getBytecodeType(cg).getSignature();
|
||||
typeSignature = typeSignature.substring(0, typeSignature.length()-1);
|
||||
return typeSignature+paramString+";";
|
||||
*/
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class BytecodeTest extends TestCase{
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public static String testFile;
|
||||
public static String outputFile;
|
||||
public String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public String testFile;
|
||||
public String outputFile;
|
||||
|
||||
protected String testName;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package bytecode;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ForTest {
|
||||
@ -8,6 +9,7 @@ public class ForTest {
|
||||
public final static String outputFile = "ForTest.class";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
@ -27,6 +28,7 @@ public class LambdaExpr2 {
|
||||
public final static String outputFile = "LambdaExpr2.class";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
@ -27,6 +28,7 @@ public class PostDecrement {
|
||||
public final static String outputFile = "PostDecrement.class";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
@ -27,6 +28,7 @@ public class PostIncrement {
|
||||
public final static String outputFile = "PostIncrement.class";
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
|
3
test/bytecode/types/ExtendsObject.jav
Normal file
3
test/bytecode/types/ExtendsObject.jav
Normal file
@ -0,0 +1,3 @@
|
||||
class ExtendsObject extends Object{
|
||||
|
||||
}
|
48
test/bytecode/types/ExtendsObjectTest.java
Normal file
48
test/bytecode/types/ExtendsObjectTest.java
Normal file
@ -0,0 +1,48 @@
|
||||
package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Vector;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.BytecodeTest;
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.core.MyCompilerAPI;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
||||
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ExtendsObjectTest extends BytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "ExtendsObject";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct(){
|
||||
try{
|
||||
Class cls = getClassToTest();
|
||||
|
||||
Constructor method = cls.getConstructor(new Class[]{});
|
||||
method.newInstance();
|
||||
assertTrue(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
4
test/bytecode/types/ExtendsVector.jav
Normal file
4
test/bytecode/types/ExtendsVector.jav
Normal file
@ -0,0 +1,4 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class ExtendsVector extends Vector{
|
||||
}
|
5
test/bytecode/types/ExtendsVectorString.jav
Normal file
5
test/bytecode/types/ExtendsVectorString.jav
Normal file
@ -0,0 +1,5 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class ExtendsVectorString extends Vector<String>{
|
||||
|
||||
}
|
48
test/bytecode/types/ExtendsVectorStringTest.java
Normal file
48
test/bytecode/types/ExtendsVectorStringTest.java
Normal file
@ -0,0 +1,48 @@
|
||||
package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Vector;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.BytecodeTest;
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.core.MyCompilerAPI;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
||||
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ExtendsVectorStringTest extends BytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "ExtendsVectorString";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct(){
|
||||
try{
|
||||
Class cls = getClassToTest();
|
||||
|
||||
Constructor method = cls.getConstructor(new Class[]{});
|
||||
method.newInstance();
|
||||
assertTrue(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
test/bytecode/types/ExtendsVectorTest.java
Normal file
48
test/bytecode/types/ExtendsVectorTest.java
Normal file
@ -0,0 +1,48 @@
|
||||
package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Vector;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.BytecodeTest;
|
||||
import plugindevelopment.TypeInsertTester;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.core.MyCompilerAPI;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
||||
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ExtendsVectorTest extends BytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "ExtendsVector";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct(){
|
||||
try{
|
||||
Class cls = getClassToTest();
|
||||
|
||||
Constructor method = cls.getConstructor(new Class[]{});
|
||||
method.newInstance();
|
||||
assertTrue(true);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package bytecode;
|
||||
package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@ -7,10 +7,13 @@ import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.BytecodeTest;
|
||||
|
||||
public class OverloadingTest extends BytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Overloading";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||
}
|
||||
|
||||
@Test
|
@ -1,4 +1,4 @@
|
||||
package bytecode;
|
||||
package bytecode.types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@ -8,10 +8,13 @@ import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.BytecodeTest;
|
||||
|
||||
public class TypedVectorTest extends BytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "TypedVector";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||
}
|
||||
|
||||
@Test
|
Loading…
Reference in New Issue
Block a user