Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
5821839cbc | |||
b6df854cc6 | |||
47c2b78713 | |||
58db64ad22 | |||
ae01af7a40 | |||
|
db93a1dfe1 | ||
|
f17745bfa5 | ||
|
0a6aa450db |
@@ -40,6 +40,7 @@ public class ClassGenerator extends ClassGen{
|
|||||||
|
|
||||||
private Map<String, ClassGenerator> extraClasses = new HashMap<>();
|
private Map<String, ClassGenerator> extraClasses = new HashMap<>();
|
||||||
private List<String> methodsNamesAndTypes = new LinkedList<>();
|
private List<String> methodsNamesAndTypes = new LinkedList<>();
|
||||||
|
private MethodGenerator methodGenerator;
|
||||||
|
|
||||||
public ClassGenerator(String name, Type superClass, String string, short accessflags, String[] strings, TypeinferenceResults typeinferenceResults) {
|
public ClassGenerator(String name, Type superClass, String string, short accessflags, String[] strings, TypeinferenceResults typeinferenceResults) {
|
||||||
super(name,superClass.get_Name(),string,accessflags,strings, new DHBWConstantPoolGen());
|
super(name,superClass.get_Name(),string,accessflags,strings, new DHBWConstantPoolGen());
|
||||||
@@ -171,7 +172,7 @@ public class ClassGenerator extends ClassGen{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addMethod(Method m) {
|
public void addMethod(Method m) {
|
||||||
String methodNameAndTypes = m.getName()+Arrays.toString(m.getArgumentTypes());
|
String methodNameAndTypes = m.getReturnType().toString()+m.getName()+Arrays.toString(m.getArgumentTypes());
|
||||||
|
|
||||||
if(methodsNamesAndTypes.contains(methodNameAndTypes)){
|
if(methodsNamesAndTypes.contains(methodNameAndTypes)){
|
||||||
return;
|
return;
|
||||||
@@ -180,9 +181,14 @@ public class ClassGenerator extends ClassGen{
|
|||||||
methodsNamesAndTypes.add(methodNameAndTypes);
|
methodsNamesAndTypes.add(methodNameAndTypes);
|
||||||
super.addMethod(m);
|
super.addMethod(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMethodeGenerator(MethodGenerator methodGenerator) {
|
||||||
|
this.methodGenerator = methodGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodGenerator getMethodGenerator() {
|
||||||
|
return methodGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -139,23 +139,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
return new INVOKEDYNAMIC(index);
|
return new INVOKEDYNAMIC(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
|
||||||
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalVariableInstruction createStore(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
|
||||||
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer getStoreIndex(String variableName) {
|
|
||||||
if(storeIndexes.get(variableName) == null){
|
|
||||||
Integer index = storeIndexes.size()+1;
|
|
||||||
storeIndexes.put(variableName, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return storeIndexes.get(variableName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type createObjectType() {
|
public static Type createObjectType() {
|
||||||
return new org.apache.commons.bcel6.generic.ObjectType("java.lang.Object");
|
return new org.apache.commons.bcel6.generic.ObjectType("java.lang.Object");
|
||||||
}
|
}
|
||||||
@@ -163,8 +146,4 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
public Attribute createSignatureAttribute(String signature) {
|
public Attribute createSignatureAttribute(String signature) {
|
||||||
return new Signature(cp.addUtf8("Signature"),2,cp.addUtf8(signature),cp.getConstantPool());
|
return new Signature(cp.addUtf8("Signature"),2,cp.addUtf8(signature),cp.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetStoreIndexes() {
|
|
||||||
//storeIndexes.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,9 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.commons.bcel6.classfile.Attribute;
|
import org.apache.commons.bcel6.classfile.Attribute;
|
||||||
import org.apache.commons.bcel6.classfile.ConstantPool;
|
import org.apache.commons.bcel6.classfile.ConstantPool;
|
||||||
@@ -16,7 +19,9 @@ import org.apache.commons.bcel6.classfile.Visitor;
|
|||||||
import org.apache.commons.bcel6.generic.BranchInstruction;
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
import org.apache.commons.bcel6.generic.ConstantPoolGen;
|
import org.apache.commons.bcel6.generic.ConstantPoolGen;
|
||||||
import org.apache.commons.bcel6.generic.Instruction;
|
import org.apache.commons.bcel6.generic.Instruction;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionFactory;
|
||||||
import org.apache.commons.bcel6.generic.InstructionList;
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.LocalVariableInstruction;
|
||||||
import org.apache.commons.bcel6.generic.MethodGen;
|
import org.apache.commons.bcel6.generic.MethodGen;
|
||||||
import org.apache.commons.bcel6.generic.StackMapTableGen;
|
import org.apache.commons.bcel6.generic.StackMapTableGen;
|
||||||
import org.apache.commons.bcel6.generic.Type;
|
import org.apache.commons.bcel6.generic.Type;
|
||||||
@@ -30,15 +35,22 @@ import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
|||||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
|
||||||
public class MethodGenerator extends MethodGen{
|
public class MethodGenerator extends MethodGen{
|
||||||
|
|
||||||
|
private Map<String, Integer> storeIndexes = new HashMap<>();
|
||||||
|
|
||||||
public MethodGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name,
|
public MethodGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name,
|
||||||
String class_name, InstructionList il, ConstantPoolGen cp) {
|
String class_name, InstructionList il, ConstantPoolGen cp) {
|
||||||
super(access_flags, return_type, arg_types, arg_names, method_name, class_name, il, cp);
|
super(access_flags, return_type, arg_types, arg_names, method_name, class_name, il, cp);
|
||||||
|
|
||||||
|
for(String name: arg_names){
|
||||||
|
getStoreIndex(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method createMethod(ClassGenerator cg, ParameterList parameter, de.dhbwstuttgart.syntaxtree.type.Type retType, Block block, TypeinferenceResultSet rs){
|
public Method createMethod(ClassGenerator cg, ParameterList parameter, de.dhbwstuttgart.syntaxtree.type.Type retType, Block block, TypeinferenceResultSet rs){
|
||||||
@@ -80,6 +92,23 @@ public class MethodGenerator extends MethodGen{
|
|||||||
return method.getMethod();
|
return method.getMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
||||||
|
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalVariableInstruction createStore(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
||||||
|
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStoreIndex(String variableName) {
|
||||||
|
if(storeIndexes.get(variableName) == null){
|
||||||
|
Integer index = storeIndexes.size()+1;
|
||||||
|
storeIndexes.put(variableName, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return storeIndexes.get(variableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,15 +78,12 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
private Modifiers modifiers;
|
private Modifiers modifiers;
|
||||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||||
protected static Logger parserlog = Logger.getLogger("parser");
|
protected static Logger parserlog = Logger.getLogger("parser");
|
||||||
|
|
||||||
protected Menge<org.apache.commons.bcel6.generic.Type[]> createdMethods = new Menge<>();
|
|
||||||
|
|
||||||
public Method(int offset) {
|
public Method(int offset) {
|
||||||
super(offset);
|
super(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method(String name, Type returnType, ParameterList parameterList,
|
public Method(String name, Type returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset) {
|
||||||
Block block, GenericDeclarationList gtvDeclarations, int offset) {
|
|
||||||
this(offset);
|
this(offset);
|
||||||
/*
|
/*
|
||||||
* if(parameterList != null)parameterList.parserPostProcessing(this);
|
* if(parameterList != null)parameterList.parserPostProcessing(this);
|
||||||
@@ -419,7 +416,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
ArrayList<String> argumentNames = new ArrayList<String>();
|
ArrayList<String> argumentNames = new ArrayList<String>();
|
||||||
|
|
||||||
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
||||||
generateArgumentList(argumentTypes, argumentNames, cg, _factory, t);
|
generateArgumentList(argumentTypes, argumentNames, cg, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
short constants = Constants.ACC_PUBLIC;
|
short constants = Constants.ACC_PUBLIC;
|
||||||
@@ -429,15 +426,15 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
|
|
||||||
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes.toArray(new org.apache.commons.bcel6.generic.Type[parameterlist.size()]) , argumentNames.toArray(new String[parameterlist.size()]), this.get_Method_Name(), getParentClass().name, il, _cp);
|
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes.toArray(new org.apache.commons.bcel6.generic.Type[parameterlist.size()]) , argumentNames.toArray(new String[parameterlist.size()]), this.get_Method_Name(), getParentClass().name, il, _cp);
|
||||||
|
|
||||||
|
cg.setMethodeGenerator(method);
|
||||||
|
|
||||||
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateArgumentList(ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes, ArrayList<String> argumentNames, ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
|
private void generateArgumentList(ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes, ArrayList<String> argumentNames, ClassGenerator cg, TypeinferenceResultSet t) {
|
||||||
for(FormalParameter parameter : this.parameterlist){
|
for(FormalParameter parameter : this.parameterlist){
|
||||||
argumentTypes.add(parameter.getType().getBytecodeType(cg, t));
|
argumentTypes.add(parameter.getType().getBytecodeType(cg, t));
|
||||||
argumentNames.add(parameter.getIdentifier());
|
argumentNames.add(parameter.getIdentifier());
|
||||||
|
|
||||||
_factory.getStoreIndex(parameter.getIdentifier());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -172,7 +172,7 @@ public class UnifyTypeFactory {
|
|||||||
|
|
||||||
public static Type convert(ReferenceType t) {
|
public static Type convert(ReferenceType t) {
|
||||||
//TODO: Hier kann man die GTVs extrahieren
|
//TODO: Hier kann man die GTVs extrahieren
|
||||||
if(t.getName() == "void")return new Void(NULL_NODE, 0);
|
if(t.getName().toString().equals(Void.VOID_NAME))return new Void(NULL_NODE, 0);
|
||||||
RefType ret = new RefType(t.getName(),null,0);
|
RefType ret = new RefType(t.getName(),null,0);
|
||||||
ret.set_ParaList(convert(t.getTypeParams()));
|
ret.set_ParaList(convert(t.getTypeParams()));
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -179,8 +179,7 @@ public class Assign extends Expr
|
|||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
DHBWInstructionFactory _factory = new DHBWInstructionFactory(cg, cg.getConstantPool());
|
DHBWInstructionFactory _factory = new DHBWInstructionFactory(cg, cg.getConstantPool());
|
||||||
InstructionList il = expr2.genByteCode(cg, rs);//expr2 rechte expr
|
InstructionList il = expr2.genByteCode(cg, rs);//expr2 rechte expr
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
String expr2Type = expr2.getType().get_Name().toString();
|
String expr2Type = expr2.getType().get_Name().toString();
|
||||||
@@ -207,7 +206,7 @@ public class Assign extends Expr
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//Es wird momentan immer von RefType ausgegangen:
|
//Es wird momentan immer von RefType ausgegangen:
|
||||||
il.append(_factory.createStore(expr2.getType().getBytecodeType(cg, rs), expr1.get_Name()));
|
il.append(cg.getMethodGenerator().createStore(expr2.getType().getBytecodeType(cg, rs), expr1.get_Name()));
|
||||||
|
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
@@ -169,7 +169,7 @@ public class LocalOrFieldVarOrClassname extends Expr
|
|||||||
|
|
||||||
String name = this.get_Name();
|
String name = this.get_Name();
|
||||||
|
|
||||||
il.append(cg.getInstructionFactory().createLoad(byteCodeType, name));
|
il.append(cg.getMethodGenerator().createLoad(byteCodeType, name));
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -376,7 +376,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
_cg.getInstructionFactory().getStoreIndex(get_Name());
|
_cg.getMethodGenerator().getStoreIndex(get_Name());
|
||||||
return new InstructionList();
|
return new InstructionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -326,8 +326,6 @@ 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();
|
|
||||||
|
|
||||||
il.append(receiver.get_Expr().genByteCode(cg, rs));
|
il.append(receiver.get_Expr().genByteCode(cg, rs));
|
||||||
|
|
||||||
@@ -346,7 +344,7 @@ public class MethodCall extends Expr
|
|||||||
argumentTypen = new org.apache.commons.bcel6.generic.Type[this.getArgumentList().size()];
|
argumentTypen = new org.apache.commons.bcel6.generic.Type[this.getArgumentList().size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Expr argument : this.arglist.expr){
|
for(Expr argument : this.arglist.expr){
|
||||||
_factory.getStoreIndex(argument.get_Name());
|
cg.getMethodGenerator().getStoreIndex(argument.get_Name());
|
||||||
|
|
||||||
argumentTypen[i] = argument.getType().getBytecodeType(cg, rs);
|
argumentTypen[i] = argument.getType().getBytecodeType(cg, rs);
|
||||||
//Das Argument auf den Stack legen:
|
//Das Argument auf den Stack legen:
|
||||||
|
@@ -602,17 +602,18 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
|
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
|
||||||
}else if(type instanceof TypePlaceholder){
|
}else if(type instanceof TypePlaceholder){
|
||||||
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
|
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
|
||||||
|
}else if(type instanceof WildcardType){
|
||||||
|
return this.getName().toString();
|
||||||
}else{
|
}else{
|
||||||
sb.append(type.getBytecodeType(cg, rs).toString().replace(".", "%"));
|
sb.append(type.getBytecodeType(cg, rs).toString().replace(".", "%"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("%");
|
sb.append("%");
|
||||||
}
|
}
|
||||||
}else{
|
return sb.toString();
|
||||||
sb.append(this.getName().toString());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.append(this.getName().toString()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericClassType getGenericClassType(){
|
public GenericClassType getGenericClassType(){
|
||||||
|
@@ -17,11 +17,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
class Test {
|
|
||||||
void methode(ArrayList<? super Integer> t){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Die Klasse Type muss abstract werden!
|
//TODO: Die Klasse Type muss abstract werden!
|
||||||
// ino.class.Type.26716.declaration
|
// ino.class.Type.26716.declaration
|
||||||
|
@@ -15,13 +15,14 @@ public class Void extends RefType
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.class.Void.26857.body
|
// ino.class.Void.26857.body
|
||||||
{
|
{
|
||||||
|
public static final String VOID_NAME = "void";
|
||||||
// ino.method.Void.26861.definition
|
// ino.method.Void.26861.definition
|
||||||
public Void(SyntaxTreeNode parent,int offset)
|
public Void(SyntaxTreeNode parent,int offset)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.Void.26861.body
|
// ino.method.Void.26861.body
|
||||||
{
|
{
|
||||||
super(parent,offset);
|
super(parent,offset);
|
||||||
super.setName("void");
|
super.setName(VOID_NAME);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@@ -287,7 +287,7 @@ public class RuleSet implements IRuleSet{
|
|||||||
if(lhsSType.getTypeParams().empty())
|
if(lhsSType.getTypeParams().empty())
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
||||||
UnifyType rhsType = pair.getRhsType();
|
UnifyType rhsType = pair.getLhsType();
|
||||||
ReferenceType rhsSType;
|
ReferenceType rhsSType;
|
||||||
|
|
||||||
if(rhsType instanceof ReferenceType)
|
if(rhsType instanceof ReferenceType)
|
||||||
|
@@ -410,11 +410,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Case unknown: If a pair fits no other case, then the type unification has failed.
|
// Case unknown: If a pair fits no other case, then the type unification has failed.
|
||||||
// Through application of the rules, every pair should have one of the above forms.
|
// Through application of the rules, every pair should have one of the above forms.
|
||||||
// Pairs that do not have one of the aboves form are contradictory.
|
// Pairs that do not have one of the aboves form are contradictory.
|
||||||
else {
|
else
|
||||||
// If a pair is not defined, the unificiation will fail, so the loop can be stopped here.
|
undefined.add(pair);
|
||||||
undefined.add(pair);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter empty sets or sets that only contain an empty set.
|
// Filter empty sets or sets that only contain an empty set.
|
||||||
@@ -428,9 +425,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
protected Set<Set<UnifyPair>> unifyCase1(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) {
|
protected Set<Set<UnifyPair>> unifyCase1(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) {
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
boolean allGen = thetaPrime.getTypeParams().size() > 0;
|
boolean allGen = true;
|
||||||
for(UnifyType t : thetaPrime.getTypeParams())
|
for(UnifyType t : thetaPrime.getTypeParams())
|
||||||
if(!(t instanceof PlaceholderType) || !((PlaceholderType) t).isGenerated()) {
|
if(t instanceof PlaceholderType && !((PlaceholderType) t).isGenerated()) {
|
||||||
allGen = false;
|
allGen = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -440,7 +437,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
for(UnifyType c : cs) {
|
for(UnifyType c : cs) {
|
||||||
Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
|
Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
|
||||||
//thetaQs.add(thetaPrime);
|
thetaQs.add(thetaPrime);
|
||||||
Set<UnifyType> thetaQPrimes = new HashSet<>();
|
Set<UnifyType> thetaQPrimes = new HashSet<>();
|
||||||
TypeParams cParams = c.getTypeParams();
|
TypeParams cParams = c.getTypeParams();
|
||||||
if(cParams.size() == 0)
|
if(cParams.size() == 0)
|
||||||
@@ -496,7 +493,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/**
|
/**
|
||||||
* Cartesian Product Case 2: (a <.? ? ext Theta')
|
* Cartesian Product Case 2: (a <.? ? ext Theta')
|
||||||
*/
|
*/
|
||||||
private Set<Set<UnifyPair>> unifyCase2(PlaceholderType a, ExtendsType extThetaPrime, IFiniteClosure fc) {
|
protected Set<Set<UnifyPair>> unifyCase2(PlaceholderType a, ExtendsType extThetaPrime, IFiniteClosure fc) {
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
UnifyType aPrime = PlaceholderType.freshPlaceholder();
|
UnifyType aPrime = PlaceholderType.freshPlaceholder();
|
||||||
@@ -516,7 +513,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/**
|
/**
|
||||||
* Cartesian Product Case 3: (a <.? ? sup Theta')
|
* Cartesian Product Case 3: (a <.? ? sup Theta')
|
||||||
*/
|
*/
|
||||||
private Set<Set<UnifyPair>> unifyCase3(PlaceholderType a, SuperType subThetaPrime, IFiniteClosure fc) {
|
protected Set<Set<UnifyPair>> unifyCase3(PlaceholderType a, SuperType subThetaPrime, IFiniteClosure fc) {
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
UnifyType aPrime = PlaceholderType.freshPlaceholder();
|
UnifyType aPrime = PlaceholderType.freshPlaceholder();
|
||||||
@@ -534,15 +531,27 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cartesian Product Case 4: (a <.? Theta')
|
||||||
|
*/
|
||||||
|
protected Set<Set<UnifyPair>> unifyCase4(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) {
|
||||||
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
|
resultPrime.add(new UnifyPair(a, thetaPrime, PairOperator.EQUALSDOT));
|
||||||
|
result.add(resultPrime);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cartesian Product Case 5: (Theta <. a)
|
* Cartesian Product Case 5: (Theta <. a)
|
||||||
*/
|
*/
|
||||||
private Set<Set<UnifyPair>> unifyCase5(UnifyType theta, PlaceholderType a, IFiniteClosure fc) {
|
protected Set<Set<UnifyPair>> unifyCase5(UnifyType theta, PlaceholderType a, IFiniteClosure fc) {
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
boolean allGen = theta.getTypeParams().size() > 0;
|
boolean allGen = true;
|
||||||
for(UnifyType t : theta.getTypeParams())
|
for(UnifyType t : theta.getTypeParams())
|
||||||
if(!(t instanceof PlaceholderType) || !((PlaceholderType) t).isGenerated()) {
|
if(t instanceof PlaceholderType && !((PlaceholderType) t).isGenerated()) {
|
||||||
allGen = false;
|
allGen = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -565,11 +574,44 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cartesian Product Case 6: (? ext Theta <.? a)
|
||||||
|
*/
|
||||||
|
protected Set<Set<UnifyPair>> unifyCase6(ExtendsType extTheta, PlaceholderType a, IFiniteClosure fc) {
|
||||||
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
UnifyType freshTph = PlaceholderType.freshPlaceholder();
|
||||||
|
UnifyType extFreshTph = new ExtendsType(freshTph);
|
||||||
|
|
||||||
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
|
resultPrime.add(new UnifyPair(a, extFreshTph, PairOperator.EQUALSDOT));
|
||||||
|
resultPrime.add(new UnifyPair(extTheta.getExtendedType(), freshTph, PairOperator.SMALLERDOT));
|
||||||
|
result.add(resultPrime);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cartesian Product Case 7: (? sup Theta <.? a)
|
||||||
|
*/
|
||||||
|
protected Set<Set<UnifyPair>> unifyCase7(SuperType supTheta, PlaceholderType a, IFiniteClosure fc) {
|
||||||
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
|
UnifyType aPrime = PlaceholderType.freshPlaceholder();
|
||||||
|
UnifyType supAPrime = new SuperType(aPrime);
|
||||||
|
UnifyType theta = supTheta.getSuperedType();
|
||||||
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
|
resultPrime.add(new UnifyPair(a, supAPrime, PairOperator.EQUALSDOT));
|
||||||
|
resultPrime.add(new UnifyPair(aPrime, theta, PairOperator.SMALLERDOT));
|
||||||
|
result.add(resultPrime);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cartesian Product Case 8: (Theta <.? a)
|
* Cartesian Product Case 8: (Theta <.? a)
|
||||||
*/
|
*/
|
||||||
private Set<Set<UnifyPair>> unifyCase8(UnifyType theta, PlaceholderType a, IFiniteClosure fc) {
|
protected Set<Set<UnifyPair>> unifyCase8(UnifyType theta, PlaceholderType a, IFiniteClosure fc) {
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
//for(UnifyType thetaS : fc.grArg(theta)) {
|
//for(UnifyType thetaS : fc.grArg(theta)) {
|
||||||
Set<UnifyPair> resultPrime = new HashSet<>();
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
|
@@ -26,7 +26,7 @@ public class FiniteClosure implements IFiniteClosure {
|
|||||||
/**
|
/**
|
||||||
* A map that maps every typename to the nodes of the inheritance graph that contain a type with that name.
|
* A map that maps every typename to the nodes of the inheritance graph that contain a type with that name.
|
||||||
*/
|
*/
|
||||||
private HashMap<String, Set<Node<UnifyType>>> strInheritanceGraph;
|
private HashMap<String, HashSet<Node<UnifyType>>> strInheritanceGraph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The initial pairs of that define the inheritance tree
|
* The initial pairs of that define the inheritance tree
|
||||||
@@ -251,6 +251,7 @@ public class FiniteClosure implements IFiniteClosure {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UnifyType> grArg(FunNType type) {
|
public Set<UnifyType> grArg(FunNType type) {
|
||||||
|
// TODO ist das richtig?
|
||||||
Set<UnifyType> result = new HashSet<UnifyType>();
|
Set<UnifyType> result = new HashSet<UnifyType>();
|
||||||
result.add(type);
|
result.add(type);
|
||||||
smaller(type).forEach(x -> result.add(new SuperType(x)));
|
smaller(type).forEach(x -> result.add(new SuperType(x)));
|
||||||
@@ -297,6 +298,7 @@ public class FiniteClosure implements IFiniteClosure {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UnifyType> smArg(FunNType type) {
|
public Set<UnifyType> smArg(FunNType type) {
|
||||||
|
// TODO ist das richtig?
|
||||||
Set<UnifyType> result = new HashSet<UnifyType>();
|
Set<UnifyType> result = new HashSet<UnifyType>();
|
||||||
result.add(type);
|
result.add(type);
|
||||||
return result;
|
return result;
|
||||||
|
15
test/bytecode/UninitializedVariable.jav
Normal file
15
test/bytecode/UninitializedVariable.jav
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
class UninitializedVariable{
|
||||||
|
|
||||||
|
Integer method(Integer v) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
UninitializedVariable ol;
|
||||||
|
ol = new UninitializedVariable();
|
||||||
|
Integer v;
|
||||||
|
ol.method(v);
|
||||||
|
}
|
||||||
|
}
|
39
test/bytecode/UninitializedVariableTest.java
Normal file
39
test/bytecode/UninitializedVariableTest.java
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
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 UninitializedVariableTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "UninitializedVariable";
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
14
test/bytecode/VariableMultimethods.jav
Normal file
14
test/bytecode/VariableMultimethods.jav
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class VariableMultimethods{
|
||||||
|
public Integer method(Integer z, Integer x, Integer y){
|
||||||
|
return x+y+z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer method(Integer x, Integer y){
|
||||||
|
return x+y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer method(Integer y){
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
98
test/bytecode/VariableMultimethodsTest.java
Normal file
98
test/bytecode/VariableMultimethodsTest.java
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
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 VariableMultimethodsTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "VariableMultimethods";
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOneArgument() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer y = 1;
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
y.getClass()
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, y);
|
||||||
|
assertEquals(new Integer(1), returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoArgument() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = 1;
|
||||||
|
Integer y = 2;
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass()
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||||
|
assertEquals(new Integer(3), returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testThreeArgument() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer z = 1;
|
||||||
|
Integer x = 2;
|
||||||
|
Integer y = 4;
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
z.getClass(),
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass()
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, z, x, y);
|
||||||
|
assertEquals(new Integer(7), returnValue);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,33 +0,0 @@
|
|||||||
package bytecode.types;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import bytecode.SourceFileBytecodeTest;
|
|
||||||
|
|
||||||
public class ExtendsTypeTest extends SourceFileBytecodeTest{
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
testName = "ExtendsType";
|
|
||||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void testConstruct() throws Exception{
|
|
||||||
ClassLoader classLoader = getClassLoader();
|
|
||||||
|
|
||||||
Class cls = classLoader.loadClass(testName);
|
|
||||||
|
|
||||||
Object obj = cls.newInstance();
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -61,7 +61,7 @@ public class ExtendsVectorStringTest extends ASTBytecodeTest{
|
|||||||
|
|
||||||
Object obj = cls.newInstance();
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
Class objectClass = classLoader.loadClass("java.lang.Object");
|
Class objectClass = classLoader.loadClass("java.lang.String");
|
||||||
|
|
||||||
Class[] params = new Class[1];
|
Class[] params = new Class[1];
|
||||||
params[0] = objectClass;
|
params[0] = objectClass;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
class OL {
|
class OL {
|
||||||
|
|
||||||
m(x) { return x + x; }
|
m(x) { return x + x; }
|
||||||
|
|
||||||
Boolean m(Boolean x) {return x; }
|
m(Boolean x) {return x; }
|
||||||
|
|
||||||
}
|
}
|
@@ -1,37 +0,0 @@
|
|||||||
package bytecode.types;
|
|
||||||
|
|
||||||
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 SuperType extends SourceFileBytecodeTest{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void init() {
|
|
||||||
testName = "ExtendsType";
|
|
||||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void testConstruct() throws Exception{
|
|
||||||
ClassLoader classLoader = getClassLoader();
|
|
||||||
|
|
||||||
Class cls = classLoader.loadClass(testName);
|
|
||||||
|
|
||||||
Object obj = cls.newInstance();
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +1,11 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
class SuperType{
|
class WildcardTest{
|
||||||
Vector<Number> numberVector;
|
void lower(Vector<? super Integer> v) {
|
||||||
|
|
||||||
void method() {
|
|
||||||
method(numberVector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void method(Vector<? super Integer> v) {
|
void upper(Vector<? extends Integer> v) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -12,7 +12,7 @@ import bytecode.SourceFileBytecodeTest;
|
|||||||
public class WildcardTest extends SourceFileBytecodeTest{
|
public class WildcardTest extends SourceFileBytecodeTest{
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
testName = "Wildcard";
|
testName = "WildcardTest";
|
||||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/types/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
test/plugindevelopment/TypeInsertTests/OverloadingVector.jav
Executable file
21
test/plugindevelopment/TypeInsertTests/OverloadingVector.jav
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
class OverloadingVector{
|
||||||
|
|
||||||
|
void method(Vector<String> v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void method(Vector<Integer> v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main(String args) {
|
||||||
|
ol;
|
||||||
|
ol = new OverloadingVector();
|
||||||
|
v;
|
||||||
|
v = new Vector<String> ();
|
||||||
|
ol.method(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,15 @@
|
|||||||
|
package plugindevelopment.TypeInsertTests;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class OverloadingVectorTest {
|
||||||
|
private static final String TEST_FILE = "OverloadingVector.jav";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void run(){
|
||||||
|
Menge<String> mustContain = new Menge<String>();
|
||||||
|
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||||
|
}
|
||||||
|
}
|
@@ -862,23 +862,24 @@ public class UnifyTest {
|
|||||||
UnifyType tphT1 = tf.getPlaceholderType("T1");
|
UnifyType tphT1 = tf.getPlaceholderType("T1");
|
||||||
UnifyType tphT2 = tf.getPlaceholderType("T2");
|
UnifyType tphT2 = tf.getPlaceholderType("T2");
|
||||||
|
|
||||||
UnifyType vector = tf.getSimpleType("Vector", "T");
|
UnifyType gtv = tf.getSimpleType("gtv");
|
||||||
UnifyType vectorE = tf.getSimpleType("Vector", tphT2);
|
UnifyType vector = tf.getSimpleType("Vector", gtv);
|
||||||
|
UnifyType vectorT2 = tf.getSimpleType("Vector", tphT2);
|
||||||
UnifyType string = tf.getSimpleType("String");
|
UnifyType string = tf.getSimpleType("String");
|
||||||
UnifyType vectorString = tf.getSimpleType("Vector", string);
|
UnifyType vectorString = tf.getSimpleType("Vector", string);
|
||||||
|
|
||||||
fcb.add(vector, tf.getSimpleType("java.lang.Object"));
|
fcb.add(vector, vector);
|
||||||
|
|
||||||
IFiniteClosure fc = fcb.getFiniteClosure();
|
IFiniteClosure fc = fcb.getFiniteClosure();
|
||||||
|
|
||||||
Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
Set<UnifyPair> eq = new HashSet<UnifyPair>();
|
||||||
|
eq.add(new UnifyPair(vectorT2, tphT1, PairOperator.SMALLERDOT));
|
||||||
eq.add(new UnifyPair(tphT1, vectorString, PairOperator.SMALLERDOT));
|
eq.add(new UnifyPair(tphT1, vectorString, PairOperator.SMALLERDOT));
|
||||||
eq.add(new UnifyPair(vectorE, tphT1, PairOperator.SMALLERDOT));
|
|
||||||
|
|
||||||
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
|
||||||
|
|
||||||
System.out.println("Test OverloadingVector:");
|
System.out.println("Test OverloadingVector:");
|
||||||
System.out.println(actual + "\n");
|
System.out.println(actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user