Merge branch 'unify' of ssh://i13029@gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify
This commit is contained in:
commit
84176275be
12
BCEL/bcelifier/IfStatement.java
Normal file
12
BCEL/bcelifier/IfStatement.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package bcelifier;
|
||||||
|
|
||||||
|
class IfStatement{
|
||||||
|
Integer methode(Boolean b){
|
||||||
|
if(b){
|
||||||
|
return 1;
|
||||||
|
}else{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
BCEL/bcelifier/IfStatementCreator.java
Normal file
71
BCEL/bcelifier/IfStatementCreator.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package bcelifier;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.*;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.MethodGenerator;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class IfStatementCreator {
|
||||||
|
private InstructionFactory _factory;
|
||||||
|
private ConstantPoolGen _cp;
|
||||||
|
private ClassGenerator _cg;
|
||||||
|
|
||||||
|
public IfStatementCreator() {
|
||||||
|
|
||||||
|
TypeinferenceResults typeinferenceResults = null;
|
||||||
|
_cg = new ClassGenerator("bcelifier.IfStatement", new RefType("java.lang.Object", null, 0), "IfStatement.java", Const.ACC_SUPER, new String[] { }, typeinferenceResults);
|
||||||
|
|
||||||
|
_cp = _cg.getConstantPool();
|
||||||
|
_factory = new InstructionFactory(_cg, _cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create(OutputStream out) throws IOException {
|
||||||
|
createMethod_0();
|
||||||
|
createMethod_1();
|
||||||
|
_cg.getJavaClass().dump(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMethod_0() {
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
MethodGen method = new MethodGenerator(0, Type.VOID, new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "<init>", "bcelifier.IfStatement", il, _cp);
|
||||||
|
|
||||||
|
InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
|
||||||
|
InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID));
|
||||||
|
method.setMaxStack();
|
||||||
|
method.setMaxLocals();
|
||||||
|
_cg.addMethod(method.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMethod_1() {
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
MethodGen method = new MethodGenerator(0, new ObjectType("java.lang.Integer"), new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "methode", "bcelifier.IfStatement", il, _cp);
|
||||||
|
|
||||||
|
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Const.INVOKEVIRTUAL));
|
||||||
|
BranchInstruction ifeq_4 = InstructionFactory.createBranchInstruction(Const.IFEQ, null);
|
||||||
|
il.append(ifeq_4);
|
||||||
|
il.append(new PUSH(_cp, 1));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC));
|
||||||
|
il.append(InstructionFactory.createReturn(Type.OBJECT));
|
||||||
|
InstructionHandle ih_12 = il.append(new PUSH(_cp, 2));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC));
|
||||||
|
il.append(InstructionFactory.createReturn(Type.OBJECT));
|
||||||
|
ifeq_4.setTarget(ih_12);
|
||||||
|
method.setMaxStack();
|
||||||
|
method.setMaxLocals();
|
||||||
|
_cg.addMethod(method.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
bcelifier.IfStatementCreator creator = new bcelifier.IfStatementCreator();
|
||||||
|
creator.create(new FileOutputStream("bcelifier.IfStatement.class"));
|
||||||
|
|
||||||
|
System.out.println("bcelifier.IfStatement.class");
|
||||||
|
}
|
||||||
|
}
|
@ -24,16 +24,16 @@ public class JavaToBCEL {
|
|||||||
public JavaToBCEL(){
|
public JavaToBCEL(){
|
||||||
try {
|
try {
|
||||||
//new BCELifier(new ClassParser(rootDirectory+"Lambda1.class").parse(), new FileOutputStream(new File(rootDirectory+"Lambda1Creator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"Lambda1.class").parse(), new FileOutputStream(new File(rootDirectory+"Lambda1Creator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"LocalVarAccess.class").parse(), new FileOutputStream(new File(rootDirectory+"LocalVarAccessCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"LocalVarAccess.class").parse(), new FileOutputStream(new File(rootDirectory+"LocalVarAccessCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"Wildcard.class").parse(), new FileOutputStream(new File(rootDirectory+"WildcardCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"Wildcard.class").parse(), new FileOutputStream(new File(rootDirectory+"WildcardCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"BooleanValue.class").parse(), new FileOutputStream(new File(rootDirectory+"BooleanValueCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"BooleanValue.class").parse(), new FileOutputStream(new File(rootDirectory+"BooleanValueCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start();
|
||||||
|
new BCELifier(new ClassParser(rootDirectory+"IfStatement.class").parse(), new FileOutputStream(new File(rootDirectory+"IfStatementCreator.java"))).start();
|
||||||
} catch (ClassFormatException | IOException e) {
|
} catch (ClassFormatException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -68,7 +68,7 @@ public class ClassGenerator extends ClassGen{
|
|||||||
//return getNearestType((TypePlaceholder) t);
|
//return getNearestType((TypePlaceholder) t);
|
||||||
return new TypePlaceholderType((TypePlaceholder) t);
|
return new TypePlaceholderType((TypePlaceholder) t);
|
||||||
}else{
|
}else{
|
||||||
return t.getBytecodeType(this, getTypeinferenceResults().getTypeReconstructions().firstElement());
|
return t.getBytecodeType(this, getTypeinferenceResults().getTypeReconstructions().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public org.apache.commons.bcel6.generic.Type getNearestUsedType(TypePlaceholder toTPH){
|
public org.apache.commons.bcel6.generic.Type getNearestUsedType(TypePlaceholder toTPH){
|
||||||
@ -150,7 +150,7 @@ public class ClassGenerator extends ClassGen{
|
|||||||
TypePlaceholder tph = it.next();
|
TypePlaceholder tph = it.next();
|
||||||
//ret += tph.getBytecodeMethodSignature(this);
|
//ret += tph.getBytecodeMethodSignature(this);
|
||||||
//ret += ":";
|
//ret += ":";
|
||||||
ret += tph.getClassSignature(this, getTypeinferenceResults().getTypeReconstructions().firstElement());
|
ret += tph.getClassSignature(this, getTypeinferenceResults().getTypeReconstructions().get(0));
|
||||||
}
|
}
|
||||||
ret += ">";
|
ret += ">";
|
||||||
}
|
}
|
||||||
|
@ -139,13 +139,18 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
return new INVOKEDYNAMIC(index);
|
return new INVOKEDYNAMIC(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
public static 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 LocalVariableInstruction createStore(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
||||||
if(!storeIndexes.containsKey(variableName)){
|
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
||||||
storeIndexes.put(variableName, storeIndexes.size()+1);
|
}
|
||||||
|
|
||||||
|
public static Integer getStoreIndex(String variableName) {
|
||||||
|
if(storeIndexes.get(variableName) == null){
|
||||||
|
Integer index = storeIndexes.size()+1;
|
||||||
|
storeIndexes.put(variableName, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return storeIndexes.get(variableName);
|
return storeIndexes.get(variableName);
|
||||||
@ -160,6 +165,6 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void resetStoreIndexes() {
|
public void resetStoreIndexes() {
|
||||||
storeIndexes = new HashMap<>();
|
//storeIndexes.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class MethodGenerator extends MethodGen{
|
|||||||
|
|
||||||
method.addAttribute(factory.createSignatureAttribute(paramTypesSig+retTypeSig));
|
method.addAttribute(factory.createSignatureAttribute(paramTypesSig+retTypeSig));
|
||||||
|
|
||||||
StackMap stackMap = new StackMapTableGen(this.getInstructionList(), cp).getStackMap();
|
StackMap stackMap = new StackMapTableGen(this, cp).getStackMap();
|
||||||
if(stackMap != null)method.addCodeAttribute(stackMap);
|
if(stackMap != null)method.addCodeAttribute(stackMap);
|
||||||
|
|
||||||
return method.getMethod();
|
return method.getMethod();
|
||||||
|
@ -159,11 +159,11 @@ public class MyCompiler implements MyCompilerAPI{
|
|||||||
FunNInterface funN = new FunNInterface(i);
|
FunNInterface funN = new FunNInterface(i);
|
||||||
ret.add(funN.getPublicFieldAssumptions());
|
ret.add(funN.getPublicFieldAssumptions());
|
||||||
}
|
}
|
||||||
for(int i = 0; i<6; i++){
|
//Keine FunVoidInterfaces in den Assumptions.
|
||||||
FunVoidNInterface funN = new FunVoidNInterface(i);
|
//for(int i = 0; i<6; i++){
|
||||||
ret.add(funN.getPublicFieldAssumptions());
|
// FunVoidNInterface funN = new FunVoidNInterface(i);
|
||||||
}
|
// ret.add(funN.getPublicFieldAssumptions());
|
||||||
|
//}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -209,43 +209,6 @@ public class MyCompiler implements MyCompilerAPI{
|
|||||||
return OutputDir;
|
return OutputDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Arne Lüdtke
|
|
||||||
* Ersetzt alle GTVs durch TPHs mit gleichem Namen. Arbeitet Rekursiv.
|
|
||||||
* ACHTUNG: BACKDOOR CREATE!!! Nur für Testzwecke verwenden.
|
|
||||||
* @param T - Typ, bei welchem die GTVs ersetzt werden sollen.
|
|
||||||
*/
|
|
||||||
public static Type makeGenericTypeVars2TypePlaceHolders(Type T)
|
|
||||||
{
|
|
||||||
if(T instanceof RefType)
|
|
||||||
{
|
|
||||||
RefType refT = (RefType)T;
|
|
||||||
if(refT.get_ParaList() != null)
|
|
||||||
{
|
|
||||||
Menge<Type> paras = refT.get_ParaList();
|
|
||||||
for(int i = 0; i<paras.size();i++)
|
|
||||||
{
|
|
||||||
Type tt = paras.elementAt(i);
|
|
||||||
if(tt instanceof GenericTypeVar)
|
|
||||||
{
|
|
||||||
GenericTypeVar gtv = (GenericTypeVar)tt;
|
|
||||||
paras.set(i,TypePlaceholder.backdoorCreate(gtv.getName().toString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
makeGenericTypeVars2TypePlaceHolders(tt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(T instanceof IMatchable)
|
|
||||||
{
|
|
||||||
Type TT = ((IMatchable)T).getMatchType();
|
|
||||||
makeGenericTypeVars2TypePlaceHolders(TT);
|
|
||||||
}
|
|
||||||
return T;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parst den Inhalt einer Datei zu einem Syntaxbaum.
|
* Parst den Inhalt einer Datei zu einem Syntaxbaum.
|
||||||
*/
|
*/
|
||||||
@ -328,3 +291,4 @@ public class MyCompiler implements MyCompilerAPI{
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ public class Logger {
|
|||||||
|
|
||||||
public static String getWholeLog(){
|
public static String getWholeLog(){
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
LOG_HISTORY.removeIf((logLine)->logLine==null);
|
||||||
Logger.LOG_HISTORY.sort((log1, log2)->log1.timestamp.compareTo(log2.timestamp));
|
Logger.LOG_HISTORY.sort((log1, log2)->log1.timestamp.compareTo(log2.timestamp));
|
||||||
ret += Logger.LOG_HISTORY.toString();
|
ret += Logger.LOG_HISTORY.toString();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -111,7 +111,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
|||||||
}
|
}
|
||||||
InstructionList fieldInitializations = new InstructionList();
|
InstructionList fieldInitializations = new InstructionList();
|
||||||
for(FieldDeclaration f : fieldDeclarations){
|
for(FieldDeclaration f : fieldDeclarations){
|
||||||
fieldInitializations.append(f.genByteCode(_cg, typeinferenceResults.getTypeReconstructions().firstElement()));
|
fieldInitializations.append(f.genByteCode(_cg, typeinferenceResults.getTypeReconstructions().get(0)));
|
||||||
}
|
}
|
||||||
//Die Konstruktoren müssen die Feld initialisierungswerte beinhalten:
|
//Die Konstruktoren müssen die Feld initialisierungswerte beinhalten:
|
||||||
for(Constructor c : constructors){
|
for(Constructor c : constructors){
|
||||||
@ -554,7 +554,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// ino.method.get_ParaList.23101.definition
|
// ino.method.get_ParaList.23101.definition
|
||||||
public Menge<? extends Type> get_ParaList()
|
public List<? extends Type> get_ParaList()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.get_ParaList.23101.body
|
// ino.method.get_ParaList.23101.body
|
||||||
{
|
{
|
||||||
|
@ -85,64 +85,6 @@ Paratyp gesetzt."); }
|
|||||||
fielddecl.addElement(i);
|
fielddecl.addElement(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.is_declared.23188.defdescription type=line
|
|
||||||
//
|
|
||||||
// ********************************************************************************************
|
|
||||||
//
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.is_declared.23188.definition
|
|
||||||
public boolean is_declared(Type t, Menge<Class> classlist)
|
|
||||||
throws SCClassBodyException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.is_declared.23188.body
|
|
||||||
{
|
|
||||||
boolean flag=false;
|
|
||||||
for(Enumeration<Class> e = classlist.elements();e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
flag = false;
|
|
||||||
Class c = e.nextElement();
|
|
||||||
|
|
||||||
// System.out.println("is_init: vergleiche "+t.get_Type_()+" mit "+c.getName());
|
|
||||||
if(c.getName().equals(t.getName())){
|
|
||||||
// System.out.println("Klasse "+t.get_Type()+"im Menge classlist gefunden.");
|
|
||||||
flag = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( t instanceof RefType && ((RefType)t).get_ParaList()!=null)
|
|
||||||
{
|
|
||||||
if( ((RefType)t).get_ParaList().size() > 0 )
|
|
||||||
{
|
|
||||||
for(Enumeration e1 = ((RefType)t).get_ParaList().elements(); e1.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
is_declared((Type)e1.nextElement(),classlist);
|
|
||||||
}
|
|
||||||
catch(SCClassBodyException ex)
|
|
||||||
{
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(flag)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SCClassBodyException ex = new SCClassBodyException();
|
|
||||||
SCExcept e = new SCExcept();
|
|
||||||
e.set_error("unbekannte Klasse "+t.getName()+".");
|
|
||||||
e.set_function("complete_parahashtable() --> is_declared()");
|
|
||||||
e.set_statement(t.getName().toString());
|
|
||||||
ex.addException(e);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.string_rec.23191.definition
|
// ino.method.string_rec.23191.definition
|
||||||
static String string_rec(Hashtable ht)
|
static String string_rec(Hashtable ht)
|
||||||
|
@ -237,7 +237,7 @@ public class FormalParameter extends SyntaxTreeNode implements Typeable, TypeIns
|
|||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){
|
if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){
|
||||||
ret += this.getType().getBytecodeSignature(null, null);
|
ret += this.getType().toString();//getBytecodeSignature(null, null);
|
||||||
}
|
}
|
||||||
return ret+this.getIdentifier();
|
return ret+this.getIdentifier();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// ino.module.Method.8564.package
|
// ino.module.Method.8564.package
|
||||||
package de.dhbwstuttgart.syntaxtree;
|
package de.dhbwstuttgart.syntaxtree;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
// ino.end
|
|
||||||
// ino.module.Method.8564.import
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -65,58 +64,23 @@ import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Method extends Field implements IItemWithOffset, TypeInsertable
|
public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||||
// ino.end
|
|
||||||
// ino.class.Method.23482.body
|
|
||||||
{
|
{
|
||||||
// ino.attribute.block.23488.declaration
|
|
||||||
private Block block;
|
private Block block;
|
||||||
// ino.end
|
|
||||||
// ino.attribute.parameterlist.23491.declaration
|
|
||||||
public ParameterList parameterlist = new ParameterList();
|
public ParameterList parameterlist = new ParameterList();
|
||||||
// ino.end
|
|
||||||
// ino.attribute.exceptionlist.23494.declaration
|
|
||||||
private ExceptionList exceptionlist;
|
private ExceptionList exceptionlist;
|
||||||
// ino.end
|
|
||||||
// ino.attribute.returntype.23497.declaration
|
|
||||||
private Type returntype;
|
private Type returntype;
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.attribute.genericMethodParameters.23500.decldescription type=javadoc
|
|
||||||
/**
|
|
||||||
* HOTI 4.5.06 Dieser Vektor beinhaltet alle Generischen Typen und v.a. die
|
|
||||||
* F-Bounded-Generics, die die Methode besitzt size()==0, falls es keine
|
|
||||||
* gibt
|
|
||||||
*/
|
|
||||||
// ino.end
|
|
||||||
// ino.attribute.genericMethodParameters.23500.declaration
|
|
||||||
// private Menge<GenericTypeVar> genericMethodParameters=new
|
|
||||||
// Menge<GenericTypeVar>();
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.attribute.overloadedID.23503.declaration
|
|
||||||
private int overloadedID;
|
private int overloadedID;
|
||||||
// ino.end
|
|
||||||
// ino.attribute.isAbstract.23506.declaration
|
|
||||||
private boolean isAbstract = false;
|
private boolean isAbstract = false;
|
||||||
// ino.end
|
|
||||||
// ino.attribute.types_in_parameterlist.23509.declaration
|
|
||||||
private Menge<String> types_in_parameterlist = new Menge<String>();
|
private Menge<String> types_in_parameterlist = new Menge<String>();
|
||||||
// ino.end
|
|
||||||
// ino.attribute.m_LineNumber.23512.declaration
|
|
||||||
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
||||||
// ino.end
|
|
||||||
private int m_Offset = -1; // hinzugef�gt hoth: 07.04.2006
|
private int m_Offset = -1; // hinzugef�gt hoth: 07.04.2006
|
||||||
private Modifiers modifiers;
|
private Modifiers modifiers;
|
||||||
// ino.attribute.inferencelog.23515.declaration
|
|
||||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||||
// ino.end
|
|
||||||
// ino.attribute.parserlog.23518.declaration
|
|
||||||
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<>();
|
protected Menge<org.apache.commons.bcel6.generic.Type[]> createdMethods = new Menge<>();
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
public Method(int offset) {
|
public Method(int offset) {
|
||||||
super(offset);
|
super(offset);
|
||||||
}
|
}
|
||||||
@ -136,51 +100,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
this.setReturnType(returnType);
|
this.setReturnType(returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* // ino.method.setGenericMethodParameters.23521.definition public void
|
|
||||||
* setGenericMethodParameters(Menge<GenericTypeVar> genericMethodParameters)
|
|
||||||
* // ino.end // ino.method.setGenericMethodParameters.23521.body {
|
|
||||||
* this.genericMethodParameters=genericMethodParameters; } // ino.end //
|
|
||||||
* ino.method.getGenericMethodParameters.23524.definition public
|
|
||||||
* Menge<GenericTypeVar> getGenericMethodParameters() // ino.end //
|
|
||||||
* ino.method.getGenericMethodParameters.23524.body {
|
|
||||||
* return(genericMethodParameters); } // ino.end
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* // ino.method.sc_init_parameterlist.23530.definition public void
|
|
||||||
* sc_init_parameterlist(boolean ext) // ino.end //
|
|
||||||
* ino.method.sc_init_parameterlist.23530.body { DeclId hilf=null;
|
|
||||||
* Menge<FormalParameter> list; FormalParameter para; String typeofpara; int
|
|
||||||
* i=1; if(this.getParameterList()!=null) //es gibt Parameter, dann: {
|
|
||||||
* hilf=declid.elementAt(0); if(ext)
|
|
||||||
* parserlog.debug("Semantik-Check hat in Methode "
|
|
||||||
* +hilf.get_Name()+" bergabewerte gefunden:");
|
|
||||||
* list=this.getParameterList().sc_get_Formalparalist(); //Menge
|
|
||||||
* Formalparalist aus FormalParameterList wird zwischen gesichert
|
|
||||||
* for(Enumeration<FormalParameter> el2=list.elements();
|
|
||||||
* el2.hasMoreElements();) { para=el2.nextElement();
|
|
||||||
* typeofpara=para.getTypeName(); if(ext)
|
|
||||||
* parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara);
|
|
||||||
* types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden
|
|
||||||
* im Menge abgelegt i++; } } else //keine Parameter vorhanden: { if(ext) {
|
|
||||||
* hilf=declid.elementAt(0);
|
|
||||||
* parserlog.debug("Semantik-Check hat in Methode "
|
|
||||||
* +hilf.get_Name()+" keine bergabewerte gefunden."); } } if(ext) {
|
|
||||||
* parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+
|
|
||||||
* types_in_parameterlist.size()+" bergabeparameter gefunden.");
|
|
||||||
* parserlog.debug
|
|
||||||
* (" namentlich: "+types_in_parameterlist.toString()); } } //
|
|
||||||
* ino.end
|
|
||||||
*/
|
|
||||||
// ino.method.getTypeName.23533.defdescription type=line
|
|
||||||
// Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die
|
|
||||||
// get_ReturnType() auf eigene Gefahr lschen.
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getTypeName.23533.definition
|
|
||||||
public JavaClassName getTypeName()
|
public JavaClassName getTypeName()
|
||||||
// ino.end
|
|
||||||
// ino.method.getTypeName.23533.body
|
|
||||||
{
|
{
|
||||||
if (this.getType() == null)
|
if (this.getType() == null)
|
||||||
return null;
|
return null;
|
||||||
@ -188,101 +108,58 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
return this.getType().getName();
|
return this.getType().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_Block.23536.definition
|
|
||||||
public Block get_Block()
|
public Block get_Block()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_Block.23536.body
|
|
||||||
{
|
{
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setReturnType.23539.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* <br/>
|
* <br/>
|
||||||
* Author: Jrg Buerle
|
* Author: Jrg Buerle
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.setReturnType.23539.definition
|
|
||||||
private void setReturnType(Type type)
|
private void setReturnType(Type type)
|
||||||
// ino.end
|
|
||||||
// ino.method.setReturnType.23539.body
|
|
||||||
{
|
{
|
||||||
this.returntype = type;
|
this.returntype = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.set_Block.23542.definition
|
|
||||||
public void set_Block(Block blo)
|
public void set_Block(Block blo)
|
||||||
// ino.end
|
|
||||||
// ino.method.set_Block.23542.body
|
|
||||||
{
|
{
|
||||||
if (blo.getType() == null)
|
if (blo.getType() == null)
|
||||||
blo.setType(this.returntype);
|
blo.setType(this.returntype);
|
||||||
this.block = blo;
|
this.block = blo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.set_Modifiers.23545.definition
|
|
||||||
public void set_Modifiers(Modifiers modif)
|
public void set_Modifiers(Modifiers modif)
|
||||||
// ino.end
|
|
||||||
// ino.method.set_Modifiers.23545.body
|
|
||||||
{
|
{
|
||||||
declid.firstElement().set_Modifiers(modif);
|
declid.firstElement().set_Modifiers(modif);
|
||||||
this.modifiers = modif;
|
this.modifiers = modif;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.set_ExceptionList.23548.definition
|
|
||||||
public void set_ExceptionList(ExceptionList exlist)
|
public void set_ExceptionList(ExceptionList exlist)
|
||||||
// ino.end
|
|
||||||
// ino.method.set_ExceptionList.23548.body
|
|
||||||
{
|
{
|
||||||
this.exceptionlist = exlist;
|
this.exceptionlist = exlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setParameterList.23551.definition
|
|
||||||
public void setParameterList(ParameterList paralist)
|
public void setParameterList(ParameterList paralist)
|
||||||
// ino.end
|
|
||||||
// ino.method.setParameterList.23551.body
|
|
||||||
{
|
{
|
||||||
this.parameterlist = paralist;
|
this.parameterlist = paralist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getParameterList.23554.definition
|
|
||||||
public ParameterList getParameterList()
|
public ParameterList getParameterList()
|
||||||
// ino.end
|
|
||||||
// ino.method.getParameterList.23554.body
|
|
||||||
{
|
{
|
||||||
// otth: gibt die Parameterliste zurueck
|
|
||||||
return this.parameterlist;
|
return this.parameterlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getParameterCount.23557.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Author: Jrg Buerle<br/>
|
* Author: Jrg Buerle<br/>
|
||||||
*
|
*
|
||||||
* @return Die Anzahl der Methoden-Paramater
|
* @return Die Anzahl der Methoden-Paramater
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.getParameterCount.23557.definition
|
|
||||||
public int getParameterCount()
|
public int getParameterCount()
|
||||||
// ino.end
|
|
||||||
// ino.method.getParameterCount.23557.body
|
|
||||||
{
|
{
|
||||||
if (this.getParameterList() == null)
|
if (this.getParameterList() == null)
|
||||||
return 0;
|
return 0;
|
||||||
@ -290,177 +167,94 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
return this.getParameterList().getParameterCount();
|
return this.getParameterList().getParameterCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_ExceptionList.23560.definition
|
|
||||||
public ExceptionList get_ExceptionList()
|
public ExceptionList get_ExceptionList()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_ExceptionList.23560.body
|
|
||||||
{
|
{
|
||||||
// otth: gibt die Exceptionliste zurueck
|
// otth: gibt die Exceptionliste zurueck
|
||||||
return this.exceptionlist;
|
return this.exceptionlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getOverloadedID.23563.definition
|
|
||||||
public int getOverloadedID()
|
public int getOverloadedID()
|
||||||
// ino.end
|
|
||||||
// ino.method.getOverloadedID.23563.body
|
|
||||||
{
|
{
|
||||||
return (overloadedID);
|
return (overloadedID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setOverloadedID.23566.definition
|
|
||||||
public void setOverloadedID(int overloadedID)
|
public void setOverloadedID(int overloadedID)
|
||||||
// ino.end
|
|
||||||
// ino.method.setOverloadedID.23566.body
|
|
||||||
{
|
{
|
||||||
this.overloadedID = overloadedID;
|
this.overloadedID = overloadedID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_Method_Name.23575.definition
|
|
||||||
public String get_Method_Name()
|
public String get_Method_Name()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_Method_Name.23575.body
|
|
||||||
{
|
{
|
||||||
DeclId hilf = declid.elementAt(0);
|
DeclId hilf = declid.elementAt(0);
|
||||||
return hilf.get_Name();
|
return hilf.get_Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.get_Type_Paralist.23578.definition
|
|
||||||
public Menge get_Type_Paralist()
|
public Menge get_Type_Paralist()
|
||||||
// ino.end
|
|
||||||
// ino.method.get_Type_Paralist.23578.body
|
|
||||||
{
|
{
|
||||||
return types_in_parameterlist;
|
return types_in_parameterlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getLineNumber.23584.definition
|
|
||||||
public int getLineNumber()
|
public int getLineNumber()
|
||||||
// ino.end
|
|
||||||
// ino.method.getLineNumber.23584.body
|
|
||||||
{
|
{
|
||||||
return m_LineNumber;
|
return m_LineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setLineNumber.23587.definition
|
|
||||||
public void setLineNumber(int lineNumber)
|
public void setLineNumber(int lineNumber)
|
||||||
// ino.end
|
|
||||||
// ino.method.setLineNumber.23587.body
|
|
||||||
{
|
{
|
||||||
m_LineNumber = lineNumber;
|
m_LineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getOffset.23590.defdescription type=line
|
|
||||||
// hinzugef�gt hoth: 07.04.2006
|
|
||||||
// ino.end
|
|
||||||
// ino.method.getOffset.23590.definition
|
|
||||||
public int getOffset()
|
public int getOffset()
|
||||||
// ino.end
|
|
||||||
// ino.method.getOffset.23590.body
|
|
||||||
{
|
{
|
||||||
return m_Offset;
|
return m_Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getVariableLength.23593.definition
|
|
||||||
public int getVariableLength()
|
public int getVariableLength()
|
||||||
// ino.end
|
|
||||||
// ino.method.getVariableLength.23593.body
|
|
||||||
{
|
{
|
||||||
return get_Method_Name().length();
|
return get_Method_Name().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setOffset.23596.defdescription type=line
|
|
||||||
// hinzugef�gt hoth: 07.04.2006
|
|
||||||
// ino.end
|
|
||||||
// ino.method.setOffset.23596.definition
|
|
||||||
public void setOffset(int Offset)
|
public void setOffset(int Offset)
|
||||||
// ino.end
|
|
||||||
// ino.method.setOffset.23596.body
|
|
||||||
{
|
{
|
||||||
m_Offset = Offset;
|
m_Offset = Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getTypeLineNumber.23602.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* <br>
|
* <br>
|
||||||
* Author: Jrg Buerle
|
* Author: Jrg Buerle
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.getTypeLineNumber.23602.definition
|
|
||||||
public int getTypeLineNumber()
|
public int getTypeLineNumber()
|
||||||
// ino.end
|
|
||||||
// ino.method.getTypeLineNumber.23602.body
|
|
||||||
{
|
{
|
||||||
return this.getLineNumber();
|
return this.getLineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.toString.23605.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* <br/>
|
* <br/>
|
||||||
* Author: Martin Pl�micke
|
* Author: Martin Pl�micke
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.toString.23605.definition
|
|
||||||
public String toString()
|
public String toString()
|
||||||
// ino.end
|
|
||||||
// ino.method.toString.23605.body
|
|
||||||
{
|
{
|
||||||
return this.getType() + " " + this.get_Name() + ((block != null) ? block.toString() : "");
|
return this.getType() + " " + this.get_Name() + ((block != null) ? block.toString() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.setAbstract.23608.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Legt fuer die ByteCodeGen fest, ob Bytecode innerhalb der Methode
|
* Legt fuer die ByteCodeGen fest, ob Bytecode innerhalb der Methode
|
||||||
* generiert wird.
|
* generiert wird.
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.setAbstract.23608.definition
|
|
||||||
public void setAbstract(boolean b)
|
public void setAbstract(boolean b)
|
||||||
// ino.end
|
|
||||||
// ino.method.setAbstract.23608.body
|
|
||||||
{
|
{
|
||||||
isAbstract = b;
|
isAbstract = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.isAbstract.23611.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Gibt zurueck, ob ByteCode innerhabl der Methode generiert wird.
|
* Gibt zurueck, ob ByteCode innerhabl der Methode generiert wird.
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.isAbstract.23611.definition
|
|
||||||
public boolean isAbstract()
|
public boolean isAbstract()
|
||||||
// ino.end
|
|
||||||
// ino.method.isAbstract.23611.body
|
|
||||||
{
|
{
|
||||||
return isAbstract;
|
return isAbstract;
|
||||||
}
|
}
|
||||||
@ -610,44 +404,40 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
|
|
||||||
public void genByteCode(ClassGenerator cg, Class classObj) {
|
public void genByteCode(ClassGenerator cg, Class classObj) {
|
||||||
List<TypeinferenceResultSet> typeInterferenceResults = cg.getTypeinferenceResults().getTypeReconstructions(this, cg);
|
List<TypeinferenceResultSet> typeInterferenceResults = cg.getTypeinferenceResults().getTypeReconstructions(this, cg);
|
||||||
|
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
||||||
|
|
||||||
for(TypeinferenceResultSet t: typeInterferenceResults){
|
for(TypeinferenceResultSet t: typeInterferenceResults){
|
||||||
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
addMethodToClassGenerator(cg, _factory, t);
|
||||||
InstructionList il = new InstructionList();
|
}
|
||||||
Class parentClass = this.getParentClass();
|
}
|
||||||
|
|
||||||
//Die Argumentliste generieren:
|
|
||||||
org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS;
|
|
||||||
String[] argumentNames = new String[]{};
|
|
||||||
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
|
||||||
argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
|
|
||||||
argumentNames = new String[this.parameterlist.size()];
|
|
||||||
int i = 0;
|
|
||||||
for(FormalParameter parameter : this.parameterlist){
|
|
||||||
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
|
|
||||||
argumentNames[i] = parameter.getIdentifier();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String nameAndSignature = get_Method_Name()+Arrays.toString(argumentTypes);
|
|
||||||
|
|
||||||
Logger.getLogger("nameAndSignature").error(nameAndSignature, Section.CODEGEN);
|
|
||||||
|
|
||||||
|
|
||||||
short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public
|
private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
|
||||||
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
Type returnType = this.getType();
|
|
||||||
|
ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes = new ArrayList<org.apache.commons.bcel6.generic.Type>();
|
||||||
|
ArrayList<String> argumentNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
||||||
|
generateArgumentList(argumentTypes, argumentNames, cg, _factory, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
short constants = Constants.ACC_PUBLIC;
|
||||||
|
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
||||||
|
|
||||||
|
Type returnType = this.getType();
|
||||||
|
|
||||||
|
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.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) {
|
||||||
|
for(FormalParameter parameter : this.parameterlist){
|
||||||
|
argumentTypes.add(parameter.getType().getBytecodeType(cg, t));
|
||||||
|
argumentNames.add(parameter.getIdentifier());
|
||||||
|
|
||||||
//Methode generieren:
|
_factory.getStoreIndex(parameter.getIdentifier());
|
||||||
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp);
|
|
||||||
|
|
||||||
//Methode generieren und anfügen:
|
|
||||||
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
|
||||||
|
|
||||||
Logger.getLogger("createMethod").debug(this.toString(), Section.CODEGEN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
@ -39,17 +39,12 @@ import de.dhbwstuttgart.syntaxtree.type.Void;
|
|||||||
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.FunNInterface;
|
import de.dhbwstuttgart.typeinference.FunNInterface;
|
||||||
import de.dhbwstuttgart.typeinference.FunNMethod;
|
|
||||||
import de.dhbwstuttgart.typeinference.KomplexeMenge;
|
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
|
||||||
import de.dhbwstuttgart.typeinference.UndConstraint;
|
|
||||||
import de.dhbwstuttgart.typeinference.UnifyConstraintsSet;
|
import de.dhbwstuttgart.typeinference.UnifyConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption;
|
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
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;
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.factory;
|
package de.dhbwstuttgart.syntaxtree.factory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.NotImplementedException;
|
import de.dhbwstuttgart.myexception.NotImplementedException;
|
||||||
import de.dhbwstuttgart.syntaxtree.NullSyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.NullSyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.FunN;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
|
||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.EinzelElement;
|
import de.dhbwstuttgart.typeinference.EinzelElement;
|
||||||
@ -29,6 +33,7 @@ import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
|||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
|
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.FunNType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||||
@ -67,18 +72,20 @@ public class UnifyTypeFactory {
|
|||||||
//Es wurde versucht ein Typ umzuwandeln, welcher noch nicht von der Factory abgedeckt ist
|
//Es wurde versucht ein Typ umzuwandeln, welcher noch nicht von der Factory abgedeckt ist
|
||||||
if(t instanceof GenericTypeVar){
|
if(t instanceof GenericTypeVar){
|
||||||
return UnifyTypeFactory.convert((GenericTypeVar)t);
|
return UnifyTypeFactory.convert((GenericTypeVar)t);
|
||||||
}else if(t instanceof RefType){
|
}else if(t instanceof FunN){
|
||||||
return UnifyTypeFactory.convert((RefType)t);
|
return UnifyTypeFactory.convert((FunN)t);
|
||||||
}else if(t instanceof TypePlaceholder){
|
}else if(t instanceof TypePlaceholder){
|
||||||
return UnifyTypeFactory.convert((TypePlaceholder)t);
|
return UnifyTypeFactory.convert((TypePlaceholder)t);
|
||||||
}else if(t instanceof ExtendsWildcardType){
|
}else if(t instanceof ExtendsWildcardType){
|
||||||
return UnifyTypeFactory.convert((ExtendsWildcardType)t);
|
return UnifyTypeFactory.convert((ExtendsWildcardType)t);
|
||||||
}else if(t instanceof SuperWildcardType){
|
}else if(t instanceof SuperWildcardType){
|
||||||
return UnifyTypeFactory.convert((SuperWildcardType)t);
|
return UnifyTypeFactory.convert((SuperWildcardType)t);
|
||||||
|
}else if(t instanceof RefType){
|
||||||
|
return UnifyTypeFactory.convert((RefType)t);
|
||||||
}
|
}
|
||||||
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
|
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UnifyType convert(RefType t){
|
public static UnifyType convert(RefType t){
|
||||||
UnifyType ret;
|
UnifyType ret;
|
||||||
if(t.getParaList() != null && t.getParaList().size() > 0){
|
if(t.getParaList() != null && t.getParaList().size() > 0){
|
||||||
@ -92,6 +99,18 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UnifyType convert(FunN t){
|
||||||
|
UnifyType ret;
|
||||||
|
Menge<UnifyType> params = new Menge<>();
|
||||||
|
if(t.getParaList() != null && t.getParaList().size() > 0){
|
||||||
|
for(Type pT : t.getParaList()){
|
||||||
|
params.add(UnifyTypeFactory.convert(pT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = FunNType.getFunNType(new TypeParams(params));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public static UnifyType convert(TypePlaceholder tph){
|
public static UnifyType convert(TypePlaceholder tph){
|
||||||
return new PlaceholderType(tph.get_Name());
|
return new PlaceholderType(tph.get_Name());
|
||||||
@ -106,7 +125,8 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static UnifyType convert(GenericTypeVar t){
|
public static UnifyType convert(GenericTypeVar t){
|
||||||
return new PlaceholderType(t.get_Name());
|
//return new PlaceholderType(t.get_Name());
|
||||||
|
return new ReferenceType(t.get_Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UnifyConstraintsSet convert(ConstraintsSet constraints) {
|
public static UnifyConstraintsSet convert(ConstraintsSet constraints) {
|
||||||
@ -151,7 +171,17 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Type convert(ReferenceType t) {
|
public static Type convert(ReferenceType t) {
|
||||||
return new RefType(t.getName(),null,0);
|
//TODO: Hier kann man die GTVs extrahieren
|
||||||
|
if(t.getName() == "void")return new Void(NULL_NODE, 0);
|
||||||
|
RefType ret = new RefType(t.getName(),null,0);
|
||||||
|
ret.set_ParaList(convert(t.getTypeParams()));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type convert(FunNType t) {
|
||||||
|
RefType ret = new RefType(t.getName(),null,0);
|
||||||
|
ret.set_ParaList(convert(t.getTypeParams()));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type convert(SuperType t) {
|
public static Type convert(SuperType t) {
|
||||||
@ -165,14 +195,29 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Type convert(PlaceholderType t) {
|
public static Type convert(PlaceholderType t) {
|
||||||
return TypePlaceholder.getInstance(t.getName());
|
TypePlaceholder ret = TypePlaceholder.getInstance(t.getName());
|
||||||
|
if(ret == null){ //Dieser TPH wurde vom Unifikationsalgorithmus erstellt
|
||||||
|
ret = TypePlaceholder.fresh(NULL_NODE);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type convert(UnifyType t) {
|
public static Type convert(UnifyType t) {
|
||||||
|
if(t instanceof FunNType)return convert((FunNType) t);
|
||||||
if(t instanceof ReferenceType)return convert((ReferenceType) t);
|
if(t instanceof ReferenceType)return convert((ReferenceType) t);
|
||||||
if(t instanceof SuperType)return convert((SuperType) t);
|
if(t instanceof SuperType)return convert((SuperType) t);
|
||||||
if(t instanceof ExtendsType)return convert((ExtendsType) t);
|
if(t instanceof ExtendsType)return convert((ExtendsType) t);
|
||||||
if(t instanceof PlaceholderType)return convert((PlaceholderType) t);
|
if(t instanceof PlaceholderType)return convert((PlaceholderType) t);
|
||||||
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
|
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<Type> convert(TypeParams typeParams) {
|
||||||
|
List<Type> ret = new ArrayList<>();
|
||||||
|
for(UnifyType uT : typeParams){
|
||||||
|
Type toAdd = convert(uT);
|
||||||
|
ret.add(toAdd);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,36 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.DUP;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.InvokeInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,5 +78,86 @@ public abstract class AddOp extends Operator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_1
|
||||||
|
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: iadd
|
||||||
|
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
|
||||||
|
12: areturn
|
||||||
|
*/
|
||||||
|
|
||||||
|
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2(), rs);
|
||||||
|
|
||||||
|
if(returnType.equals("java.lang.String")){
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
ObjectType objectType = new ObjectType("java.lang.StringBuilder");
|
||||||
|
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
il.append(_factory.createNew("java.lang.StringBuilder"));
|
||||||
|
il.append(new DUP());
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.StringBuilder", "<init>", org.apache.commons.bcel6.generic.Type.VOID, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKESPECIAL));
|
||||||
|
|
||||||
|
il.append(operator.get_Expr1().genByteCode(_cg, rs));
|
||||||
|
|
||||||
|
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.StringBuilder", "append", objectType, new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.STRING}, Constants.INVOKEVIRTUAL));
|
||||||
|
|
||||||
|
il.append(operator.get_Expr2().genByteCode(_cg, rs));
|
||||||
|
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.StringBuilder", "append", objectType, new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.STRING}, Constants.INVOKEVIRTUAL));
|
||||||
|
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.StringBuilder", "toString", new ObjectType("java.lang.String"), new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
|
||||||
|
return il;
|
||||||
|
}else{
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
|
||||||
|
|
||||||
|
il.append(getOperator(returnType));
|
||||||
|
|
||||||
|
il.append(convertValueToObject(_factory, returnType));
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getReturnType(Expr expr1, Expr expr2, TypeinferenceResultSet rs) {
|
||||||
|
Type type = expr1.getType();
|
||||||
|
if(type instanceof TypePlaceholder){
|
||||||
|
Type tphType = rs.getTypeOfPlaceholder((TypePlaceholder) expr1.getType());
|
||||||
|
if(tphType instanceof ExtendsWildcardType){
|
||||||
|
return ((ExtendsWildcardType) tphType).get_ExtendsType().get_Name();
|
||||||
|
}else if(tphType instanceof SuperWildcardType){
|
||||||
|
return ((SuperWildcardType) tphType).get_SuperType().get_Name();
|
||||||
|
}else{
|
||||||
|
return tphType.getName().toString();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return type.get_Name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract ArithmeticInstruction getOperator(String returnType);
|
||||||
|
|
||||||
|
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return _factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.INT}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
return _factory.createInvoke("java.lang.Double", "valueOf", new ObjectType("java.lang.Double"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.DOUBLE}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
return _factory.createInvoke("java.lang.Float", "valueOf", new ObjectType("java.lang.Float"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.FLOAT}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
return _factory.createInvoke("java.lang.Long", "valueOf", new ObjectType("java.lang.Long"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.LONG}, Constants.INVOKESTATIC);
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,10 +3,15 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
// ino.class.AndOp.24101.declaration
|
// ino.class.AndOp.24101.declaration
|
||||||
@ -24,6 +29,12 @@ public class AndOp extends LogOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,6 +3,17 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.DivideOp.8596.import
|
// ino.module.DivideOp.8596.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.DADD;
|
||||||
|
import org.apache.commons.bcel6.generic.DDIV;
|
||||||
|
import org.apache.commons.bcel6.generic.FADD;
|
||||||
|
import org.apache.commons.bcel6.generic.FDIV;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.IDIV;
|
||||||
|
import org.apache.commons.bcel6.generic.LADD;
|
||||||
|
import org.apache.commons.bcel6.generic.LDIV;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
@ -25,9 +36,19 @@ public class DivideOp extends MulOp
|
|||||||
super(offset,variableLength);
|
super(offset,variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return new IDIV();
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
return new DDIV();
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
return new FDIV();
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
return new LDIV();
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,10 +3,22 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.EqualOp.8597.import
|
// ino.module.EqualOp.8597.import
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPNE;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionConstants;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.NOP;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -14,6 +26,8 @@ import de.dhbwstuttgart.syntaxtree.statement.Null;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -31,6 +45,11 @@ public class EqualOp extends RelOp
|
|||||||
super(offset, variableLength);
|
super(offset, variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPNE(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.GreaterEquOp.8598.import
|
// ino.module.GreaterEquOp.8598.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPLT;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -25,6 +28,11 @@ public class GreaterEquOp extends RelOp
|
|||||||
super(offset,variableLength);
|
super(offset,variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPLT(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.GreaterOp.8599.import
|
// ino.module.GreaterOp.8599.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPLE;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class GreaterOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPLE(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.LessEquOp.8600.import
|
// ino.module.LessEquOp.8600.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPGT;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class LessEquOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPGT(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,6 +3,8 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.LessOp.8601.import
|
// ino.module.LessOp.8601.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPGE;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -25,5 +27,10 @@ public class LessOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPGE(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,10 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.MinusOp.8603.import
|
// ino.module.MinusOp.8603.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.ISUB;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,6 +29,8 @@ public class MinusOp extends AddOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new ISUB();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.ModuloOp.8604.import
|
// ino.module.ModuloOp.8604.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IREM;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class ModuloOp extends MulOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new IREM();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,16 +6,30 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.InvokeInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
// ino.class.MulOp.24231.declaration
|
// ino.class.MulOp.24231.declaration
|
||||||
public abstract class MulOp extends Operator
|
public abstract class MulOp extends Operator
|
||||||
@ -50,6 +64,62 @@ public abstract class MulOp extends Operator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
// TODO Plus Operator ist bis jetzt nur für Integer implementiert
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_1
|
||||||
|
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: imul
|
||||||
|
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
|
||||||
|
12: areturn
|
||||||
|
*/
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2(), rs);
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
|
||||||
|
|
||||||
|
il.append(getOperator(returnType));
|
||||||
|
|
||||||
|
il.append(convertValueToObject(_factory, returnType));
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getReturnType(Expr expr1, Expr expr2, TypeinferenceResultSet rs) {
|
||||||
|
Type type = expr1.getType();
|
||||||
|
if(type instanceof TypePlaceholder){
|
||||||
|
Type tphType = rs.getTypeOfPlaceholder((TypePlaceholder) expr1.getType());
|
||||||
|
if(tphType instanceof ExtendsWildcardType){
|
||||||
|
return ((ExtendsWildcardType) tphType).get_ExtendsType().get_Name();
|
||||||
|
}else if(tphType instanceof SuperWildcardType){
|
||||||
|
return ((SuperWildcardType) tphType).get_SuperType().get_Name();
|
||||||
|
}else{
|
||||||
|
return tphType.getName().toString();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return type.get_Name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract ArithmeticInstruction getOperator(String returnType);
|
||||||
|
|
||||||
|
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return _factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.INT}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
return _factory.createInvoke("java.lang.Double", "valueOf", new ObjectType("java.lang.Double"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.DOUBLE}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
return _factory.createInvoke("java.lang.Float", "valueOf", new ObjectType("java.lang.Float"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.FLOAT}, Constants.INVOKESTATIC);
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
return _factory.createInvoke("java.lang.Long", "valueOf", new ObjectType("java.lang.Long"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.LONG}, Constants.INVOKESTATIC);
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.NotEqualOp.8606.import
|
// ino.module.NotEqualOp.8606.import
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
@ -13,6 +12,9 @@ import de.dhbwstuttgart.syntaxtree.statement.Null;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ACMPEQ;
|
||||||
|
|
||||||
|
|
||||||
// ino.class.NotEqualOp.24241.declaration
|
// ino.class.NotEqualOp.24241.declaration
|
||||||
public class NotEqualOp extends RelOp
|
public class NotEqualOp extends RelOp
|
||||||
@ -28,5 +30,10 @@ public class NotEqualOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ACMPEQ(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -5,8 +5,16 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.DADD;
|
||||||
|
import org.apache.commons.bcel6.generic.FADD;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.LADD;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
import de.dhbwstuttgart.core.IItemWithOffset;
|
import de.dhbwstuttgart.core.IItemWithOffset;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
@ -19,8 +27,10 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.OderConstraint;
|
import de.dhbwstuttgart.typeinference.OderConstraint;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.UndConstraint;
|
import de.dhbwstuttgart.typeinference.UndConstraint;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
|
||||||
@ -63,11 +73,33 @@ public abstract class Operator extends SyntaxTreeNode
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract HashMap<Type,Type> getReturnTypes(TypeAssumptions ass);
|
public abstract HashMap<Type,Type> getReturnTypes(TypeAssumptions ass);
|
||||||
|
|
||||||
|
public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Menge<SyntaxTreeNode> getChildren() {
|
public Menge<SyntaxTreeNode> getChildren() {
|
||||||
return new Menge<>();
|
return new Menge<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected InstructionList getInstructionListForOperand(ClassGenerator _cg, TypeinferenceResultSet rs, Expr operand, String returnType){
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
il.append(operand.genByteCode(_cg, rs));
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Double", "doubleValue", org.apache.commons.bcel6.generic.Type.DOUBLE, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Float", "floatValue", org.apache.commons.bcel6.generic.Type.FLOAT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Long", "longValue", org.apache.commons.bcel6.generic.Type.LONG, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
}else if(returnType.equals("java.lang.String")){
|
||||||
|
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException(returnType);
|
||||||
|
}
|
||||||
|
return il;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -2,6 +2,19 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.operator;
|
package de.dhbwstuttgart.syntaxtree.operator;
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.IFEQ;
|
||||||
|
import org.apache.commons.bcel6.generic.IFNE;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionConstants;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
|
||||||
// ino.class.OrOp.24282.declaration
|
// ino.class.OrOp.24282.declaration
|
||||||
public class OrOp extends LogOp
|
public class OrOp extends LogOp
|
||||||
@ -17,6 +30,47 @@ public class OrOp extends LogOp
|
|||||||
super(offset,variableLength);
|
super(offset,variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #2 // Method java/lang/Boolean.booleanValue:()Z
|
||||||
|
4: ifne 14
|
||||||
|
7: aload_2
|
||||||
|
8: invokevirtual #2 // Method java/lang/Boolean.booleanValue:()Z
|
||||||
|
11: ifeq 18
|
||||||
|
14: iconst_1
|
||||||
|
15: goto 19
|
||||||
|
18: iconst_0
|
||||||
|
19: invokestatic #3 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
|
||||||
|
22: areturn
|
||||||
|
*/
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
InstructionList il = operator.get_Expr1().genByteCode(_cg, rs);
|
||||||
|
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", org.apache.commons.bcel6.generic.Type.BOOLEAN, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
|
||||||
|
BranchInstruction firstTest = new IFNE(null);
|
||||||
|
il.append(firstTest);
|
||||||
|
|
||||||
|
il.append(operator.get_Expr2().genByteCode(_cg, rs));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", org.apache.commons.bcel6.generic.Type.BOOLEAN, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
|
||||||
|
BranchInstruction secondTest = new IFEQ(null);
|
||||||
|
il.append(secondTest);
|
||||||
|
|
||||||
|
firstTest.setTarget(il.append(InstructionConstants.ICONST_1));
|
||||||
|
|
||||||
|
BranchInstruction gotoInstruction = new GOTO(null);
|
||||||
|
il.append(gotoInstruction);
|
||||||
|
|
||||||
|
secondTest.setTarget(il.append(InstructionConstants.ICONST_0));
|
||||||
|
|
||||||
|
gotoInstruction.setTarget(il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
|
||||||
|
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,10 +3,30 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.PlusOp.8609.import
|
// ino.module.PlusOp.8609.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.DADD;
|
||||||
|
import org.apache.commons.bcel6.generic.FADD;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.IFEQ;
|
||||||
|
import org.apache.commons.bcel6.generic.IFNE;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionConstants;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.InvokeInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.LADD;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +44,19 @@ public class PlusOp extends AddOp
|
|||||||
super(offset,variableLength);
|
super(offset,variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return new IADD();
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
return new DADD();
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
return new FADD();
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
return new LADD();
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,14 +6,24 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionConstants;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
@ -54,6 +64,45 @@ public abstract class RelOp extends Operator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #3 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_2
|
||||||
|
5: invokevirtual #3 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: if_icmplt 15
|
||||||
|
11: iconst_1
|
||||||
|
12: goto 16
|
||||||
|
15: iconst_0
|
||||||
|
16: invokestatic #2 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
|
||||||
|
19: areturn
|
||||||
|
*/
|
||||||
|
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), "java.lang.Boolean");
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), "java.lang.Boolean"));
|
||||||
|
|
||||||
|
BranchInstruction operatorBranchInstruction = getOperator();
|
||||||
|
|
||||||
|
il.append(operatorBranchInstruction);
|
||||||
|
|
||||||
|
il.append(InstructionConstants.ICONST_1);
|
||||||
|
|
||||||
|
BranchInstruction gotoInstruction = new GOTO(null);
|
||||||
|
|
||||||
|
il.append(gotoInstruction);
|
||||||
|
|
||||||
|
operatorBranchInstruction.setTarget(il.append(InstructionConstants.ICONST_0));
|
||||||
|
gotoInstruction.setTarget(il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
|
||||||
|
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract BranchInstruction getOperator();
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,13 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
|
|
||||||
// ino.module.TimesOp.8611.import
|
// ino.module.TimesOp.8611.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.DMUL;
|
||||||
|
import org.apache.commons.bcel6.generic.FMUL;
|
||||||
|
import org.apache.commons.bcel6.generic.IMUL;
|
||||||
|
import org.apache.commons.bcel6.generic.LMUL;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -22,6 +29,20 @@ public class TimesOp extends MulOp
|
|||||||
super(offset,variableLength);
|
super(offset,variableLength);
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return new IMUL();
|
||||||
|
}else if(returnType.equals("java.lang.Double")){
|
||||||
|
return new DMUL();
|
||||||
|
}else if(returnType.equals("java.lang.Float")){
|
||||||
|
return new FMUL();
|
||||||
|
}else if(returnType.equals("java.lang.Long")){
|
||||||
|
return new LMUL();
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -207,7 +207,7 @@ public class Assign extends Expr
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//Es wird momentan immer von RefType ausgegangen:
|
//Es wird momentan immer von RefType ausgegangen:
|
||||||
il.append(new ASTORE(_factory.getStoreIndex(expr1.get_Name())));
|
il.append(_factory.createStore(expr2.getType().getBytecodeType(cg, rs), expr1.get_Name()));
|
||||||
|
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
|
@ -227,27 +227,7 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
InstructionList linkeSeite = this.expr1.genByteCode(_cg, rs);
|
return op.genByteCode(_cg, rs, this);
|
||||||
InstructionList rechteSeite = this.expr2.genByteCode(_cg, rs);
|
|
||||||
if(this.getReturnType().getName().equals(new JavaClassName("String"))){
|
|
||||||
throw new TypeinferenceException("Zeichenketten zusammenfügen ist noch nicht unterstützt",this);
|
|
||||||
}
|
|
||||||
|
|
||||||
linkeSeite.append(rechteSeite);
|
|
||||||
|
|
||||||
//TODO: bytecode (Bis jetzt wird jeder Condition als EQUALS behandelt)
|
|
||||||
//TODO: bytecode autoboxing
|
|
||||||
|
|
||||||
BranchInstruction if_icmpneInstruction = new IF_ICMPNE(null);
|
|
||||||
linkeSeite.append(if_icmpneInstruction);
|
|
||||||
linkeSeite.append(InstructionConstants.ICONST_1);
|
|
||||||
|
|
||||||
BranchInstruction gotoInstruction = new GOTO(null);
|
|
||||||
|
|
||||||
linkeSeite.append(gotoInstruction);
|
|
||||||
if_icmpneInstruction.setTarget(linkeSeite.append(InstructionConstants.ICONST_0));
|
|
||||||
gotoInstruction.setTarget(linkeSeite.append(new NOP()));
|
|
||||||
return linkeSeite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ForStmt extends Statement
|
public class ForStmt extends Statement
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -164,38 +164,13 @@ public class LambdaExpression extends Expr{
|
|||||||
ret.add(method_body.TYPEStmt(ArgumentAssumptions.add(assumptions))); //Es gibt die LambdaExpression nur mit einem Block als Method Body, nicht mit einer einzelnen Expression
|
ret.add(method_body.TYPEStmt(ArgumentAssumptions.add(assumptions))); //Es gibt die LambdaExpression nur mit einem Block als Method Body, nicht mit einer einzelnen Expression
|
||||||
|
|
||||||
//Die Constraints für ParameterTypen und Ret Typ erstellen:
|
//Die Constraints für ParameterTypen und Ret Typ erstellen:
|
||||||
Menge<Type> modifiedParamTypes = new Menge<>();
|
|
||||||
for(Type pT : paramTypes){
|
|
||||||
if(pT instanceof WildcardType){
|
|
||||||
//Auf Typfehler kontrollieren. Siehe Bug #12 Kommentar 3
|
|
||||||
if(pT instanceof ExtendsWildcardType){
|
|
||||||
throw new TypeinferenceException("Typfehler von Parametertyp "+pT,this);
|
|
||||||
}else{
|
|
||||||
modifiedParamTypes.add(pT);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
modifiedParamTypes.add(new SuperWildcardType((ObjectType) pT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Type retType = method_body.getType();
|
Type retType = method_body.getType();
|
||||||
// PN < TPH PN
|
|
||||||
if(retType instanceof WildcardType){
|
|
||||||
//Auf Typfehler kontrollieren. Siehe Bug #12 Kommentar 3
|
|
||||||
if(retType instanceof SuperWildcardType){
|
|
||||||
throw new TypeinferenceException("Typfehler von Parametertyp "+retType,this);
|
|
||||||
}else{
|
|
||||||
//retType bleibt unverändert
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
//Die LambdaExpression kann zu diesem Zeit schon feststellen, ob der Return-Type Void ist (Kein Return-Statement):
|
|
||||||
if(!typeIsVoid(retType)){ //Nur, wenn es nicht void ist, kann der ExtendsWildcardType gebildet werden.
|
|
||||||
retType = new ExtendsWildcardType((ObjectType) retType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(typeIsVoid(retType)){//In diesem Fall, muss der Typ des LambdaAusdrucks FunVoid sein
|
if(typeIsVoid(retType)){//In diesem Fall, muss der Typ des LambdaAusdrucks FunVoid sein
|
||||||
this.lambdaType = new FunVoidN(modifiedParamTypes);
|
this.lambdaType = new FunVoidN(paramTypes);
|
||||||
}else{
|
}else{
|
||||||
this.lambdaType = new FunN(retType, modifiedParamTypes);
|
this.lambdaType = new FunN(retType, paramTypes);
|
||||||
}
|
}
|
||||||
ret.add(ConstraintsSet.createSingleConstraint(lambdaType.TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
|
ret.add(ConstraintsSet.createSingleConstraint(lambdaType.TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
|
||||||
|
|
||||||
|
@ -99,59 +99,6 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.is_declared.25587.definition
|
|
||||||
public void is_declared(Type t, Menge<Class> classlist)
|
|
||||||
throws SCStatementException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.is_declared.25587.body
|
|
||||||
{
|
|
||||||
boolean flag=false;
|
|
||||||
for(Enumeration<Class> e = classlist.elements();e.hasMoreElements();){
|
|
||||||
flag = false;
|
|
||||||
Class c = e.nextElement();
|
|
||||||
|
|
||||||
// System.out.println("is_init: vergleiche "+t.get_Type_()+" mit "+c.get_classname());
|
|
||||||
if(c.getName().equals(t.getName())){
|
|
||||||
// System.out.println("Klasse "+t.get_Type()+" im Menge classlist gefunden.");
|
|
||||||
flag = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( t instanceof RefType )
|
|
||||||
{
|
|
||||||
if(((RefType)t).get_ParaList()!=null)
|
|
||||||
{
|
|
||||||
if( ((RefType)t).get_ParaList().size()>0)
|
|
||||||
{
|
|
||||||
for(Enumeration e1 = ((RefType)t).get_ParaList().elements();e1.hasMoreElements();)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
is_declared((Type)e1.nextElement(),classlist);
|
|
||||||
}
|
|
||||||
catch(SCStatementException ex)
|
|
||||||
{
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!flag)
|
|
||||||
{
|
|
||||||
SCStatementException ex = new SCStatementException();
|
|
||||||
SCExcept e = new SCExcept();
|
|
||||||
e.set_error("unbekannte Klasse "+t.getName()+".");
|
|
||||||
e.set_function("complete_parahashtable() --> is_declared()");
|
|
||||||
e.set_statement(t.getName().toString());
|
|
||||||
ex.addException(e);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// ino.method.check_anz.25590.definition
|
// ino.method.check_anz.25590.definition
|
||||||
public void check_anz(Type type, Menge paralist, Menge<Class> classlist)
|
public void check_anz(Type type, Menge paralist, Menge<Class> classlist)
|
||||||
@ -429,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) {
|
||||||
// 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));
|
||||||
|
@ -6,7 +6,11 @@ import java.util.Enumeration;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
import org.apache.commons.bcel6.generic.ClassGen;
|
import org.apache.commons.bcel6.generic.ClassGen;
|
||||||
|
import org.apache.commons.bcel6.generic.DUP;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.IFEQ;
|
||||||
import org.apache.commons.bcel6.generic.InstructionList;
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
@ -138,8 +142,20 @@ public class WhileStmt extends Statement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
// TODO Bytecode
|
//TOD: while Statement
|
||||||
throw new NotImplementedException();
|
InstructionList il = expr.genByteCode(_cg, rs);
|
||||||
|
|
||||||
|
BranchInstruction ifeq = new IFEQ(null);
|
||||||
|
il.append(ifeq);
|
||||||
|
|
||||||
|
il.append(loop_block.genByteCode(_cg, rs));
|
||||||
|
|
||||||
|
il.append(new GOTO(il.getStart()));
|
||||||
|
|
||||||
|
ifeq.setTarget(il.append(new DUP()));
|
||||||
|
|
||||||
|
|
||||||
|
return il;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
import de.dhbwstuttgart.parser.JavaClassName;
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
import de.dhbwstuttgart.syntaxtree.Method;
|
||||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Spezifikation "Complete Typeinference in Java 8" von Martin Plümicke
|
* @see Spezifikation "Complete Typeinference in Java 8" von Martin Plümicke
|
||||||
@ -23,7 +29,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
public class FunN extends RefType {
|
public class FunN extends RefType {
|
||||||
|
|
||||||
private Type R;
|
private Type R;
|
||||||
private Menge<Type> T;
|
private List<? extends Type> T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Stadelmeier, a10023
|
* @author Andreas Stadelmeier, a10023
|
||||||
@ -33,7 +39,7 @@ public class FunN extends RefType {
|
|||||||
* @param T
|
* @param T
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FunN(Type R, Menge<Type> T) {
|
public FunN(Type R, List<? extends Type> T) {
|
||||||
super("",null,0);
|
super("",null,0);
|
||||||
if(T==null || R == null)throw new NullPointerException();
|
if(T==null || R == null)throw new NullPointerException();
|
||||||
setT(T);
|
setT(T);
|
||||||
@ -44,11 +50,11 @@ public class FunN extends RefType {
|
|||||||
/**
|
/**
|
||||||
* Spezieller Konstruktor um eine FunN ohne Returntype zu generieren
|
* Spezieller Konstruktor um eine FunN ohne Returntype zu generieren
|
||||||
*/
|
*/
|
||||||
protected FunN(Menge<Type> T){
|
protected FunN(List<? extends Type> list){
|
||||||
super("",null,0);
|
super("",null,0);
|
||||||
if(T==null)throw new NullPointerException();
|
if(list==null)throw new NullPointerException();
|
||||||
setT(T);
|
setT(list);
|
||||||
this.name = new JavaClassName("Fun"+T.size());//getName();
|
this.name = new JavaClassName("Fun"+list.size());//getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,15 +74,6 @@ public class FunN extends RefType {
|
|||||||
setT(t);
|
setT(t);
|
||||||
|
|
||||||
this.name = new JavaClassName("Fun"+parameterCount);
|
this.name = new JavaClassName("Fun"+parameterCount);
|
||||||
/*
|
|
||||||
Menge<Type> t = new Menge<Type>();
|
|
||||||
for(int i=0;i<parameterCount;i++){
|
|
||||||
t.add(TypePlaceholder.fresh(this));
|
|
||||||
}
|
|
||||||
R = TypePlaceholder.fresh(this);
|
|
||||||
T = t;
|
|
||||||
this.name = getName();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,11 +84,16 @@ public class FunN extends RefType {
|
|||||||
Menge<Type> t = new Menge<Type>();
|
Menge<Type> t = new Menge<Type>();
|
||||||
if(R!=null)t.add(R);
|
if(R!=null)t.add(R);
|
||||||
if(T!=null)t.addAll(T);
|
if(T!=null)t.addAll(T);
|
||||||
|
for(Type type : t){
|
||||||
|
if(type instanceof WildcardType){
|
||||||
|
throw new DebugException("Der FunN-Typ darf keine Wildcards in den Parameter enthalten");
|
||||||
|
}
|
||||||
|
}
|
||||||
this.set_ParaList(t);
|
this.set_ParaList(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setT(Menge<Type> T){
|
protected void setT(List<? extends Type> list){
|
||||||
this.T = T;
|
this.T = list;
|
||||||
calculateNewParalist();
|
calculateNewParalist();
|
||||||
}
|
}
|
||||||
protected void setR(Type R){
|
protected void setR(Type R){
|
||||||
@ -137,6 +139,18 @@ public class FunN extends RefType {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
|
||||||
|
//FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt:
|
||||||
|
List<Type> paraList = new ArrayList<>();
|
||||||
|
for(Type t : this.T){
|
||||||
|
Type toAdd = t.TYPE(ass, parent);
|
||||||
|
//if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this);
|
||||||
|
paraList.add(toAdd);
|
||||||
|
}
|
||||||
|
FunN ret = new FunN(this.R.TYPE(ass, parent),paraList);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public CMethodTypeAssumption toCMethodTypeAssumption() {
|
public CMethodTypeAssumption toCMethodTypeAssumption() {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
import de.dhbwstuttgart.parser.JavaClassName;
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.Class;
|
import de.dhbwstuttgart.syntaxtree.Class;
|
||||||
@ -12,7 +14,7 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
|||||||
|
|
||||||
public class GenericClassType extends RefType{
|
public class GenericClassType extends RefType{
|
||||||
|
|
||||||
public GenericClassType(String fullyQualifiedName, Menge parameter, SyntaxTreeNode parent, int offset) {
|
public GenericClassType(String fullyQualifiedName, List parameter, SyntaxTreeNode parent, int offset) {
|
||||||
super(fullyQualifiedName, parameter, parent, offset);
|
super(fullyQualifiedName, parameter, parent, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.logger.Logger;
|
import de.dhbwstuttgart.logger.Logger;
|
||||||
@ -47,7 +48,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
private boolean IsArray = false;
|
private boolean IsArray = false;
|
||||||
|
|
||||||
// ino.attribute.parameter.26625.declaration
|
// ino.attribute.parameter.26625.declaration
|
||||||
private Menge<Type> parameter = null;
|
private List<Type> parameter = null;
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.primitiveFlag.29412.decldescription type=javadoc
|
// ino.attribute.primitiveFlag.29412.decldescription type=javadoc
|
||||||
/**
|
/**
|
||||||
@ -97,7 +98,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.RefType.26640.definition
|
// ino.method.RefType.26640.definition
|
||||||
public RefType(String fullyQualifiedName, Menge parameter,SyntaxTreeNode parent, int offset)
|
public RefType(String fullyQualifiedName, List parameter,SyntaxTreeNode parent, int offset)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.RefType.26640.body
|
// ino.method.RefType.26640.body
|
||||||
{
|
{
|
||||||
@ -134,52 +135,6 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
this(jName.toString(), parent, offset);
|
this(jName.toString(), parent, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.Type2Key.26646.definition
|
|
||||||
public String Type2Key()
|
|
||||||
// ino.end
|
|
||||||
// ino.method.Type2Key.26646.body
|
|
||||||
{
|
|
||||||
if(parameter==null)
|
|
||||||
{
|
|
||||||
return name.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String para = new String();
|
|
||||||
for(Enumeration e=parameter.elements();e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
String t = ((Type)e.nextElement()).Type2Key();
|
|
||||||
if(para.length() > 0)
|
|
||||||
para = para +", "+ t;
|
|
||||||
else para = " " + t;
|
|
||||||
}
|
|
||||||
return name + "<"+para + " >" ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.Type2String.26649.definition
|
|
||||||
public String Type2String()
|
|
||||||
// ino.end
|
|
||||||
// ino.method.Type2String.26649.body
|
|
||||||
{
|
|
||||||
if(parameter==null)
|
|
||||||
{
|
|
||||||
return name.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String para = new String();
|
|
||||||
for(Enumeration e=parameter.elements();e.hasMoreElements();)
|
|
||||||
{
|
|
||||||
String t = ((Type)e.nextElement()).Type2String();
|
|
||||||
if(para.length() > 0)
|
|
||||||
para = para +", "+ t;
|
|
||||||
else para = " " + t;
|
|
||||||
}
|
|
||||||
return name + "<"+para + " >" ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
|
* Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
|
||||||
@ -290,7 +245,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
* @param v
|
* @param v
|
||||||
*/
|
*/
|
||||||
// ino.method.set_ParaList.26661.definition
|
// ino.method.set_ParaList.26661.definition
|
||||||
public void set_ParaList(Menge<Type> v)
|
public void set_ParaList(List<Type> v)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.set_ParaList.26661.body
|
// ino.method.set_ParaList.26661.body
|
||||||
{
|
{
|
||||||
@ -301,8 +256,6 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
else paralist.add(t);
|
else paralist.add(t);
|
||||||
}*/
|
}*/
|
||||||
this.parameter = v;//paralist;
|
this.parameter = v;//paralist;
|
||||||
//parserlog.debug("T->Type.java->set_ParaList->parameter: " + parameter);
|
|
||||||
//parserlog.debug("T->Type.java->get_Type: " + getName());
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@ -310,7 +263,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
* @return gibt bei leere Parameterliste null zurück. Ist entscheidend für unify-Algorithmus
|
* @return gibt bei leere Parameterliste null zurück. Ist entscheidend für unify-Algorithmus
|
||||||
*/
|
*/
|
||||||
// ino.method.get_ParaList.26664.definition
|
// ino.method.get_ParaList.26664.definition
|
||||||
public Menge<Type> get_ParaList()
|
public List<Type> get_ParaList()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.get_ParaList.26664.body
|
// ino.method.get_ParaList.26664.body
|
||||||
{
|
{
|
||||||
@ -319,7 +272,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
public Menge<Type> getParaList(){
|
public List<Type> getParaList(){
|
||||||
if(this.parameter==null)return new Menge<>();
|
if(this.parameter==null)return new Menge<>();
|
||||||
return this.parameter;
|
return this.parameter;
|
||||||
}
|
}
|
||||||
@ -341,179 +294,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
// otth: Liefert den Namen des Typs, ohne Parameter, z.B. Stapel bei Stapel<IntZahl>
|
// otth: Liefert den Namen des Typs, ohne Parameter, z.B. Stapel bei Stapel<IntZahl>
|
||||||
return name.toString();
|
return name.toString();
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.getParaN.26673.definition
|
|
||||||
public String getParaN( int n )
|
|
||||||
throws SCException
|
|
||||||
// ino.end
|
|
||||||
// ino.method.getParaN.26673.body
|
|
||||||
{
|
|
||||||
// otth: liefert n.ten Parameter
|
|
||||||
if( parameter == null )
|
|
||||||
{
|
|
||||||
throw new SCException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( n >= parameter.size() )
|
|
||||||
return "";
|
|
||||||
|
|
||||||
return ((Type)parameter.elementAt(n)).getName().toString();
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.isTV.26676.definition
|
|
||||||
public boolean isTV( int n )
|
|
||||||
// ino.end
|
|
||||||
// ino.method.isTV.26676.body
|
|
||||||
{
|
|
||||||
// otth: Prueft, ob Parameter n eine TV ist
|
|
||||||
return parameter.elementAt(n) instanceof TypePlaceholder;
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.is_Equiv.26679.defdescription type=line
|
|
||||||
// GenericTypeVar ergaenzt PL 06-03-16
|
|
||||||
// ino.end
|
|
||||||
// ino.method.is_Equiv.26679.definition
|
|
||||||
public boolean is_Equiv(RefType ty2, Hashtable<JavaClassName,Type> ht)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.is_Equiv.26679.body
|
|
||||||
{
|
|
||||||
//vergleicht einen Typ ty2 mit dem aktuellen Typ, ob es bis auf Variablenumbennung
|
|
||||||
//gleich ist.
|
|
||||||
//System.out.println("is_EquivSTART: " + this.get_Type());
|
|
||||||
//System.out.println("is_EquivSTART: " + ty2.get_Type());
|
|
||||||
if (this.getTypeName().equals(ty2.getTypeName())) {
|
|
||||||
//System.out.println("is_EquivSTARTx: " + this.get_Type());
|
|
||||||
if ((get_ParaList() != null) && (ty2.get_ParaList() != null)) {
|
|
||||||
if (get_ParaList().size() == ty2.get_ParaList().size()) {
|
|
||||||
for(int i=0; i < get_ParaList().size(); i++) {
|
|
||||||
Type pty1 = (Type)get_ParaList().elementAt(i);
|
|
||||||
Type pty2 = (Type)ty2.get_ParaList().elementAt(i);
|
|
||||||
if ((pty1 instanceof RefType) && (pty2 instanceof RefType)) {
|
|
||||||
//System.out.println("Instance RefType" + ((RefType)pty1).get_Type());
|
|
||||||
//System.out.println("Instance RefType" + ((RefType)pty2).get_Type());
|
|
||||||
if (!((RefType)pty1).is_Equiv((RefType)pty2, ht)) return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((pty1 instanceof TypePlaceholder) && (pty2 instanceof TypePlaceholder)) {
|
|
||||||
//System.out.println("Instance TypePlaceholder" + (((TypePlaceholder)pty1).get_Type()));
|
|
||||||
//System.out.println("Instance TypePlaceholder" + (((TypePlaceholder)pty2).get_Type()));
|
|
||||||
if (ht.get((((TypePlaceholder)pty1).getName())) != null) {
|
|
||||||
//System.out.println(ht.get((((TypePlaceholder)pty1).getName())));
|
|
||||||
if (!((TypePlaceholder)ht.get((((TypePlaceholder)pty1).getName()))).getName().equals(pty2.getName())) return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//System.out.println("INPUT" + pty1.getName());
|
|
||||||
//System.out.println("INPUT" + pty2);
|
|
||||||
ht.put(pty1.getName(), pty2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((pty1 instanceof GenericTypeVar) && (pty2 instanceof GenericTypeVar)) {
|
|
||||||
if (ht.get((((GenericTypeVar)pty1).getName())) != null) {
|
|
||||||
if (!((GenericTypeVar)ht.get((((GenericTypeVar)pty1).getName()))).getName().equals(pty2.getName())) return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ht.put(pty1.getName(), pty2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//Typ ohne Parameter
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.Equiv2Equal.26682.definition
|
|
||||||
public boolean Equiv2Equal(RefType ty2, Hashtable<JavaClassName,Type> ht)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.Equiv2Equal.26682.body
|
|
||||||
{
|
|
||||||
//vergleicht einen Typ ty2 mit dem aktuellen Typ, ob er bis auf Variablenumbennung
|
|
||||||
//gleich ist und bennent ty2 so um, dass sie gleich sind.
|
|
||||||
//System.out.println("is_EquivSTART: " + this.getName());
|
|
||||||
//System.out.println("is_EquivSTART: " + ty2.getName());
|
|
||||||
if (this.getTypeName().equals(ty2.getTypeName())) {
|
|
||||||
//System.out.println("is_EquivSTARTx: " + this.getName());
|
|
||||||
if ((get_ParaList() != null) && (ty2.get_ParaList() != null)) {
|
|
||||||
if (get_ParaList().size() == ty2.get_ParaList().size()) {
|
|
||||||
for(int i=0; i < get_ParaList().size(); i++) {
|
|
||||||
Type pty1 = (Type)get_ParaList().elementAt(i);
|
|
||||||
Type pty2 = (Type)ty2.get_ParaList().elementAt(i);
|
|
||||||
if ((pty1 instanceof RefType) && (pty2 instanceof RefType)) {
|
|
||||||
//System.out.println("Instance RefType" + ((RefType)pty1).getName());
|
|
||||||
//System.out.println("Instance RefType" + ((RefType)pty2).getName());
|
|
||||||
if (!((RefType)pty1).is_Equiv((RefType)pty2, ht)) return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((pty1 instanceof TypePlaceholder) && (pty2 instanceof TypePlaceholder)) {
|
|
||||||
//System.out.println("Instance TypePlaceholder" + (((TypePlaceholder)pty1).getName()));
|
|
||||||
//System.out.println("Instance TypePlaceholder" + (((TypePlaceholder)pty2).getName()));
|
|
||||||
if (ht.get((((TypePlaceholder)pty1).getName())) != null) {
|
|
||||||
//System.out.println(ht.get((((TypePlaceholder)pty1).getName())));
|
|
||||||
if (!((TypePlaceholder)ht.get((((TypePlaceholder)pty1).getName()))).getName().equals(pty2.getName())) return false;
|
|
||||||
else { //Typvariablen gleich machen
|
|
||||||
// #JB# 11.04.2005
|
|
||||||
// ###########################################################
|
|
||||||
((TypePlaceholder)pty2).backdoorSetName(((TypePlaceholder)ht.get((((TypePlaceholder)pty1).getName()))).getName().toString());
|
|
||||||
//pty2.setName(((TypePlaceholder)ht.get((((TypePlaceholder)pty1).getName()))).getName());
|
|
||||||
// ###########################################################
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//System.out.println("INPUT" + pty1.getName());
|
|
||||||
//System.out.println("INPUT" + pty2);
|
|
||||||
ht.put(pty1.getName(), pty2);
|
|
||||||
// #JB# 11.04.2005
|
|
||||||
// ###########################################################
|
|
||||||
((TypePlaceholder)pty2).backdoorSetName(pty1.getName().toString());
|
|
||||||
//pty2.setName(pty1.getName());
|
|
||||||
// ###########################################################
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//Typ ohne Parameter
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.equals.26685.defdescription type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Author: Jrg Buerle<br/>
|
* Author: Jrg Buerle<br/>
|
||||||
* @param Object
|
* @param Object
|
||||||
@ -565,11 +346,11 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
{
|
{
|
||||||
if(this.get_ParaList() != null )
|
if(this.get_ParaList() != null )
|
||||||
{
|
{
|
||||||
Menge para = this.get_ParaList();
|
List para = this.get_ParaList();
|
||||||
Menge<Type> clonepara = new Menge<Type>();
|
Menge<Type> clonepara = new Menge<Type>();
|
||||||
for(int i = 0; i< para.size(); i++)
|
for(int i = 0; i< para.size(); i++)
|
||||||
{
|
{
|
||||||
clonepara.addElement(((Type)para.elementAt(i)).clone());
|
clonepara.addElement(((Type)para.get(i)).clone());
|
||||||
}
|
}
|
||||||
RefType newRefType=new RefType(this.getTypeName(), clonepara,this.getParent(),getOffset());
|
RefType newRefType=new RefType(this.getTypeName(), clonepara,this.getParent(),getOffset());
|
||||||
newRefType.setPrimitiveFlag(this.getPrimitiveFlag());
|
newRefType.setPrimitiveFlag(this.getPrimitiveFlag());
|
||||||
@ -598,10 +379,10 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
String para = new String();
|
String para = new String();
|
||||||
Enumeration e=parameter.elements();
|
Iterator<Type> e=parameter.iterator();
|
||||||
while(e.hasMoreElements())
|
while(e.hasNext())
|
||||||
{
|
{
|
||||||
Type ty = (Type)e.nextElement();
|
Type ty = (Type)e.next();
|
||||||
String t = ty.toString();
|
String t = ty.toString();
|
||||||
if(para.length() > 0)
|
if(para.length() > 0)
|
||||||
para = para +", "+ t;
|
para = para +", "+ t;
|
||||||
|
@ -71,19 +71,6 @@ public class ConstraintsSet extends UndMenge<Pair> implements Iterable<OderConst
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* Aus dem ConstraintsSet [ u1, u2, ... (OderConstraint), ... uN ] werden alle
|
|
||||||
* UndConstraints, welche sich nicht innerhalb eines OderConstraints befinden, herausgefiltert
|
|
||||||
* @return [u1, ... , uN]
|
|
||||||
*/
|
|
||||||
private Vector<UndConstraint> filterUndConstraints() {
|
|
||||||
Vector<UndConstraint> ret = new Vector<>();
|
|
||||||
for(OderConstraint con : constraintsSet){
|
|
||||||
UndConstraint filtered = con.filterUndConstraints();
|
|
||||||
if(filtered != null)ret.add(filtered);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(UndConstraint singleConstraint) {
|
public void add(UndConstraint singleConstraint) {
|
||||||
OderConstraint toAdd = new OderConstraint();
|
OderConstraint toAdd = new OderConstraint();
|
||||||
|
@ -2,9 +2,14 @@ package de.dhbwstuttgart.typeinference;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.parser.JavaClassName;
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.Class;
|
import de.dhbwstuttgart.syntaxtree.Class;
|
||||||
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.FunN;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
@ -78,5 +83,19 @@ public class FunNInterface extends Class{
|
|||||||
return new FunNMethod(this.get_ParaList());
|
return new FunNMethod(this.get_ParaList());
|
||||||
//return new FunNMethod(this.get_ParaList().size()-1);
|
//return new FunNMethod(this.get_ParaList().size()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RefType getType() {
|
||||||
|
List<? extends Type> paraList = this.get_ParaList();
|
||||||
|
Iterator<? extends Type> paraIter = paraList.iterator();
|
||||||
|
Type R = paraIter.next();
|
||||||
|
List<Type> paraListNew = new ArrayList<>();
|
||||||
|
while(paraIter.hasNext()){
|
||||||
|
paraListNew.add(paraIter.next());
|
||||||
|
}
|
||||||
|
return new FunN(R, paraListNew);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package de.dhbwstuttgart.typeinference;
|
|||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.Class;
|
import de.dhbwstuttgart.syntaxtree.Class;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
import de.dhbwstuttgart.syntaxtree.Method;
|
||||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||||
@ -16,10 +19,10 @@ public class FunNMethod extends Method{
|
|||||||
*
|
*
|
||||||
* @param N - Anzahl der Parameter (Beispiel: Fun2<R, T1, T2>)
|
* @param N - Anzahl der Parameter (Beispiel: Fun2<R, T1, T2>)
|
||||||
*/
|
*/
|
||||||
public FunNMethod(Menge<? extends Type> paralist){
|
public FunNMethod(List<? extends Type> paralist){
|
||||||
super(0); //Hat keinen Offset, da nur theoretisch gedachte Methode
|
super(0); //Hat keinen Offset, da nur theoretisch gedachte Methode
|
||||||
int N = paralist.size(); //In der paraliste ist der erste Parameter der Rückgabetyp
|
int N = paralist.size(); //In der paraliste ist der erste Parameter der Rückgabetyp
|
||||||
this.setType(paralist.firstElement());
|
this.setType(paralist.get(0));
|
||||||
this.set_DeclId(new DeclId("apply"));
|
this.set_DeclId(new DeclId("apply"));
|
||||||
ParameterList pl = new ParameterList();
|
ParameterList pl = new ParameterList();
|
||||||
Menge<FormalParameter> fpList = new Menge<FormalParameter>();
|
Menge<FormalParameter> fpList = new Menge<FormalParameter>();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.dhbwstuttgart.typeinference;
|
package de.dhbwstuttgart.typeinference;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import java.util.List;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||||
@ -17,7 +18,7 @@ public class FunVoidNMethod extends Method{
|
|||||||
*
|
*
|
||||||
* @param N - Anzahl der Parameter (Beispiel: Fun2<R, T1, T2>)
|
* @param N - Anzahl der Parameter (Beispiel: Fun2<R, T1, T2>)
|
||||||
*/
|
*/
|
||||||
public FunVoidNMethod(Menge<? extends Type> paralist, Class parent){
|
public FunVoidNMethod(List<? extends Type> paralist, Class parent){
|
||||||
super(0); //Hat keinen Offset, da nur theoretisch gedachte Methode
|
super(0); //Hat keinen Offset, da nur theoretisch gedachte Methode
|
||||||
int N = paralist.size();
|
int N = paralist.size();
|
||||||
this.setType(new Void(this, -1));
|
this.setType(new Void(this, -1));
|
||||||
|
@ -59,7 +59,9 @@ public class OderConstraint extends OderMenge<Pair>{
|
|||||||
* @param toAdd
|
* @param toAdd
|
||||||
*/
|
*/
|
||||||
public void addConstraint(Pair toAdd){
|
public void addConstraint(Pair toAdd){
|
||||||
oderConstraintPairs.add(new SingleConstraint(toAdd));
|
UndConstraint uCons = new UndConstraint();
|
||||||
|
uCons.addConstraint(toAdd);
|
||||||
|
oderConstraintPairs.add(uCons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,6 +9,7 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||||
@ -143,8 +144,8 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
RefType RT1=(RefType)TA1;
|
RefType RT1=(RefType)TA1;
|
||||||
RefType RT2=(RefType)TA2;
|
RefType RT2=(RefType)TA2;
|
||||||
if(RT1.getTypeName().equals(RT2.getTypeName())){
|
if(RT1.getTypeName().equals(RT2.getTypeName())){
|
||||||
Menge<Type> v1=RT1.get_ParaList();
|
List<Type> v1=RT1.get_ParaList();
|
||||||
Menge<Type> v2=RT2.get_ParaList();
|
List<Type> v2=RT2.get_ParaList();
|
||||||
if(v1==null && v2==null){
|
if(v1==null && v2==null){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
@ -155,8 +156,8 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
for(int i=0;i<v1.size();i++){
|
for(int i=0;i<v1.size();i++){
|
||||||
Type t1=v1.elementAt(i);
|
Type t1=v1.get(i);
|
||||||
Type t2=v2.elementAt(i);
|
Type t2=v2.get(i);
|
||||||
if(((t1 instanceof GenericTypeVar) && (t2 instanceof GenericTypeVar ))){
|
if(((t1 instanceof GenericTypeVar) && (t2 instanceof GenericTypeVar ))){
|
||||||
// alles ok, egal was drin steht, denn das kann man so nicht nachvollz.
|
// alles ok, egal was drin steht, denn das kann man so nicht nachvollz.
|
||||||
}else{
|
}else{
|
||||||
@ -257,52 +258,6 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.Pair_isEquiv.26582.definition
|
|
||||||
public boolean Pair_isEquiv(Pair p)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.Pair_isEquiv.26582.body
|
|
||||||
{
|
|
||||||
//vergleicht Paare mit Reftype's, bis auf Variablenumbennung
|
|
||||||
Hashtable<JavaClassName,Type> ht = new Hashtable<JavaClassName,Type>();
|
|
||||||
//System.out.println((((RefType)TA1).is_Equiv((RefType)p.TA1, ht)));
|
|
||||||
//System.out.println(((RefType)TA2).is_Equiv((RefType)p.TA2, ht));
|
|
||||||
|
|
||||||
//Typen boxen, da es sich um TypePlaceholder handeln koennte
|
|
||||||
Menge<Type> hilfsMenge1 = new Menge<Type>();
|
|
||||||
Menge<Type> hilfsMenge2 = new Menge<Type>();
|
|
||||||
hilfsMenge1.addElement(TA1);
|
|
||||||
hilfsMenge2.addElement(TA2);
|
|
||||||
Menge<Type> hilfsMenge3 = new Menge<Type>();
|
|
||||||
Menge<Type> hilfsMenge4 = new Menge<Type>();
|
|
||||||
hilfsMenge3.addElement(p.TA1);
|
|
||||||
hilfsMenge4.addElement(p.TA2);
|
|
||||||
//return (((RefType)TA1).is_Equiv((RefType)p.TA1, ht) && ((RefType)TA2).is_Equiv((RefType)p.TA2, ht));
|
|
||||||
return (new RefType("dummy", hilfsMenge3,null,-1)).is_Equiv(new RefType("dummy", hilfsMenge1,null,-1), ht) &&
|
|
||||||
(new RefType("dummy", hilfsMenge4,null,-1)).is_Equiv(new RefType("dummy", hilfsMenge2,null,-1), ht);
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.isInMenge.26585.definition
|
|
||||||
public boolean isInMenge( Menge<Pair> V )
|
|
||||||
// ino.end
|
|
||||||
// ino.method.isInMenge.26585.body
|
|
||||||
{
|
|
||||||
// otth: prueft, ob Paar in Vektor liegt
|
|
||||||
for( int i = 0; i < V.size(); i++ )
|
|
||||||
{
|
|
||||||
if( V.elementAt(i) instanceof Pair )
|
|
||||||
{
|
|
||||||
//if( this.toString().equals( ( (Pair)V.elementAt(i) ).toString() ) )
|
|
||||||
if(Pair_isEquiv(V.elementAt(i))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.equals.26588.defdescription type=javadoc
|
// ino.method.equals.26588.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* <br/>Author: J�rg B�uerle
|
* <br/>Author: J�rg B�uerle
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package de.dhbwstuttgart.typeinference;
|
package de.dhbwstuttgart.typeinference;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
import de.dhbwstuttgart.logger.Logger;
|
import de.dhbwstuttgart.logger.Logger;
|
||||||
import de.dhbwstuttgart.logger.Section;
|
import de.dhbwstuttgart.logger.Section;
|
||||||
@ -9,21 +11,21 @@ import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
|||||||
|
|
||||||
public class TypeinferenceResults {
|
public class TypeinferenceResults {
|
||||||
|
|
||||||
private Menge<TypeinferenceResultSet> typeReconstructions;
|
private List<TypeinferenceResultSet> typeReconstructions;
|
||||||
|
|
||||||
public TypeinferenceResults() {
|
public TypeinferenceResults() {
|
||||||
typeReconstructions = new Menge<>();
|
typeReconstructions = new Menge<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeinferenceResults(Menge<TypeinferenceResultSet> typeReconstructions) {
|
public TypeinferenceResults(List<TypeinferenceResultSet> typeReconstructions) {
|
||||||
this.typeReconstructions = typeReconstructions;
|
this.typeReconstructions = typeReconstructions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menge<TypeinferenceResultSet> getTypeReconstructions() {
|
public List<TypeinferenceResultSet> getTypeReconstructions() {
|
||||||
return typeReconstructions;
|
return typeReconstructions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menge<TypeinferenceResultSet> getTypeReconstructions(Method method, ClassGenerator cg) {
|
public List<TypeinferenceResultSet> getTypeReconstructions(Method method, ClassGenerator cg) {
|
||||||
return typeReconstructions;
|
return typeReconstructions;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,7 +33,11 @@ public class UndConstraint extends UndMenge<Pair> {
|
|||||||
|
|
||||||
public void addConstraint(Type type, Type rT) {
|
public void addConstraint(Type type, Type rT) {
|
||||||
Pair p = new Pair(type, rT);
|
Pair p = new Pair(type, rT);
|
||||||
this.set.add(new EinzelElement<Pair>(p));
|
addConstraint(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConstraint(Pair toAdd){
|
||||||
|
this.set.add(new EinzelElement<Pair>(toAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,18 +257,6 @@ public class TypeAssumptions {
|
|||||||
* @return null, falls der Typ nicht vorhanden ist.
|
* @return null, falls der Typ nicht vorhanden ist.
|
||||||
*/
|
*/
|
||||||
public Type getTypeFor(Type t, SyntaxTreeNode inNode){
|
public Type getTypeFor(Type t, SyntaxTreeNode inNode){
|
||||||
/*
|
|
||||||
if(t instanceof WildcardType){
|
|
||||||
WildcardType wt = (WildcardType)t;
|
|
||||||
Type innerType = wt.GetWildcardType();
|
|
||||||
innerType = getTypeFor(innerType, t).getType();
|
|
||||||
wt.SetWildcardType(innerType);
|
|
||||||
return new ConstraintType(wt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(t instanceof TypePlaceholder)
|
|
||||||
return new ConstraintType((TypePlaceholder)t); //Handelt es sich um einen TypePlaceholder kann dieser nicht in den Assumptions vorkommen.
|
|
||||||
*/
|
|
||||||
//Alle bekannten Klassen nach diesem Typ durchsuchen:
|
//Alle bekannten Klassen nach diesem Typ durchsuchen:
|
||||||
JavaClassName typName = t.getName();
|
JavaClassName typName = t.getName();
|
||||||
for(ClassAssumption ass : this.classAssumptions){
|
for(ClassAssumption ass : this.classAssumptions){
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
package de.dhbwstuttgart.typeinference.exceptions;
|
package de.dhbwstuttgart.typeinference.exceptions;
|
||||||
|
|
||||||
public class NotImplementedException extends RuntimeException {
|
public class NotImplementedException extends RuntimeException {
|
||||||
|
|
||||||
|
public NotImplementedException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotImplementedException(String string) {
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class FunNType extends UnifyType {
|
|||||||
* Creates a FunN-Type with the specified TypeParameters.
|
* Creates a FunN-Type with the specified TypeParameters.
|
||||||
*/
|
*/
|
||||||
protected FunNType(TypeParams p) {
|
protected FunNType(TypeParams p) {
|
||||||
super("FuN", p);
|
super("Fun"+(p.size()-1), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,10 +56,7 @@ public abstract class ASTBytecodeTest {
|
|||||||
|
|
||||||
String rootDirectory = getRootDirectory();
|
String rootDirectory = getRootDirectory();
|
||||||
|
|
||||||
System.out.println(rootDirectory);
|
|
||||||
|
|
||||||
JavaClass javaClass = result.getByteCode().getJavaClass();
|
JavaClass javaClass = result.getByteCode().getJavaClass();
|
||||||
System.out.println(javaClass.toString());
|
|
||||||
javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class"));
|
javaClass.dump(new File(rootDirectory+javaClass.getClassName()+".class"));
|
||||||
|
|
||||||
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
||||||
@ -68,7 +65,6 @@ public abstract class ASTBytecodeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
System.out.print(e.getMessage());
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,8 +87,4 @@ public abstract class ASTBytecodeTest {
|
|||||||
public String getTestName() {
|
public String getTestName() {
|
||||||
return "No Testname defined!";
|
return "No Testname defined!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class AssignTest {
|
public class AssignTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Assign.jav";
|
testName = "Assign";
|
||||||
public final static String outputFile = "Assign.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BinaryTest {
|
public class BinaryTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Binary.jav";
|
testName = "Binary";
|
||||||
public final static String outputFile = "Binary.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BinaryTest2 {
|
public class BinaryTest2 extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Binary2.jav";
|
testName = "Binary2";
|
||||||
public final static String outputFile = "Binary2.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BoolLitTest {
|
public class BoolLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "BoolLit.jav";
|
testName = "BoolLit";
|
||||||
public final static String outputFile = "BoolLit.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class CharLitTest {
|
public class CharLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "CharLitTest.jav";
|
testName = "CharLit";
|
||||||
public final static String outputFile = "CharLitTest.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ConditionTest {
|
public class ConditionTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Condition.jav";
|
testName = "Condition";
|
||||||
public final static String outputFile = "Condition.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class EmptyClassTest {
|
public class EmptyClassTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "EmptyClass.jav";
|
testName = "EmptyClass";
|
||||||
public final static String outputFile = "EmptyClass.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class FieldDeclarationTest {
|
public class FieldDeclarationTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "FieldDeclaration.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "FieldDeclaration.class";
|
testName = "FieldDeclaration";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
class IfElse{
|
class ForTest{
|
||||||
method(){
|
void method(){
|
||||||
for( i = 0; i < 10 ; i = i++){
|
for(Integer i = 0; i < 10 ; i = i + 1){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,20 @@ package bytecode;
|
|||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ForTest {
|
public class ForTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "ForTest.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "ForTest.class";
|
testName = "ForTest";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testConstruct() throws Exception{
|
||||||
public void test() {
|
ClassLoader classLoader = getClassLoader();
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdTest {
|
public class IdTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Id.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Id.class";
|
testName = "Id";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
class Id {
|
class IdentityField {
|
||||||
<GPM, FNF extends GPM> Fun1<? extends GPM, ? super FNF> op = (x) -> x;
|
<GPM, FNF extends GPM> Fun1<? extends GPM, ? super FNF> op = (x) -> x;
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdentityFieldTest {
|
public class IdentityFieldTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IdentityField.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IdentityField.class";
|
testName = "IdentityField";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdentityTest {
|
public class IdentityTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Identity.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Identity.class";
|
testName = "Identity";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ class IfElseIfStatement{
|
|||||||
return 0;
|
return 0;
|
||||||
}else if(flag){
|
}else if(flag){
|
||||||
return 1;
|
return 1;
|
||||||
|
}else{
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfElseIfStatementTest {
|
public class IfElseIfStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfElseIfStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfElseIfStatement.class";
|
testName = "IfElseIfStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfElseStatementTest {
|
public class IfElseStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfElseStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfElseStatement.class";
|
testName = "IfElseStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfStatementTest {
|
public class IfStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfStatement.class";
|
testName = "IfStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class LambdaExpr2 {
|
public class LambdaExpr2Test extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "LambdaExpr2.jav";
|
testName = "LambdaExpr";
|
||||||
public final static String outputFile = "LambdaExpr2.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testConstruct() throws Exception{
|
||||||
public void test() {
|
ClassLoader classLoader = getClassLoader();
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class LambdaExpr {
|
public class LambdaExprTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "LambdaExpr.jav";
|
testName = "LambdaExpr";
|
||||||
public final static String outputFile = "LambdaExpr.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MainTest {
|
public class MainTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Main.jav";
|
testName = "Main";
|
||||||
public final static String outputFile = "Main.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
class Matrix extends Vector<Vector<Integer>> {
|
class Matrix_lambda extends Vector<Vector<Integer>> {
|
||||||
op = (Matrix m) -> (f) -> f.apply(this, m);
|
op = (Matrix m) -> (f) -> f.apply(this, m);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
class Matrix2 {
|
class Matrix_lambda2 {
|
||||||
op = (f) -> f.apply(2);
|
op = (f) -> f.apply(2);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
class Matrix3 {
|
class Matrix_lambda3 {
|
||||||
op = (f) -> f.apply();
|
op = (f) -> f.apply();
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest {
|
public class Matrix_lambdaTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix_lambda.class";
|
testName = "Matrix_lambda";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest2 {
|
public class Matrix_lambdaTest2 extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda2.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix2.class";
|
testName = "Matrix_lambda2";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest3 {
|
public class Matrix_lambdaTest3 extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda3.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix3.class";
|
testName = "Matrix_lambda3";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
18
test/bytecode/MethodAndVariable.jav
Normal file
18
test/bytecode/MethodAndVariable.jav
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
class MethodAndVariable{
|
||||||
|
public Integer method(Integer parameter){
|
||||||
|
Integer lokaleVariable;
|
||||||
|
lokaleVariable = 2;
|
||||||
|
|
||||||
|
Integer lokaleVariable2;
|
||||||
|
lokaleVariable2 = method2(lokaleVariable);
|
||||||
|
|
||||||
|
return parameter+lokaleVariable2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer method2(Integer parameter){
|
||||||
|
Integer lokaleVariable;
|
||||||
|
lokaleVariable = 2;
|
||||||
|
|
||||||
|
return parameter+lokaleVariable;
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodCallTest {
|
public class MethodCallTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodCall.jav";
|
testName = "MethodCall";
|
||||||
public final static String outputFile = "MethodCall.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodEmpty {
|
public class MethodEmpty extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodEmpty.jav";
|
testName = "MethodEmpty";
|
||||||
public final static String outputFile = "MethodEmpty.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodEmptyRetType {
|
public class MethodEmptyRetType extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodEmptyRetType.jav";
|
testName = "MethodEmptyRetType";
|
||||||
public final static String outputFile = "MethodEmptyRetType.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
26
test/bytecode/MethodsAndVariableTest.java
Normal file
26
test/bytecode/MethodsAndVariableTest.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
|
||||||
|
public class MethodsAndVariableTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "MethodAndVariable";
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/MultiClass.jav
Normal file
5
test/bytecode/MultiClass.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class MultiClass{
|
||||||
|
}
|
||||||
|
|
||||||
|
class MultiClass2{
|
||||||
|
}
|
49
test/bytecode/MultiClassTest.java
Normal file
49
test/bytecode/MultiClassTest.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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 MultiClassTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "MultiClass";
|
||||||
|
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 testConstruct2() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName+2);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -23,35 +23,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class NewStatementTest {
|
public class NewStatementTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "NewStatement.jav";
|
testName = "NewStatement";
|
||||||
public final static String outputFile = "NewStatement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void testUntypedVectorDeclaredMethods() {
|
|
||||||
try{
|
|
||||||
File file = new File(System.getProperty("user.dir")+"/test/bytecode/types/");
|
|
||||||
URL url = file.toURL();
|
|
||||||
URL[] urls = new URL[]{url};
|
|
||||||
|
|
||||||
ClassLoader classLoader = new URLClassLoader(urls);
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
Class untypedVectorTest = classLoader.loadClass("UntypedVector");
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
for(Method method: untypedVectorTest.getDeclaredMethods()){
|
|
||||||
System.out.println(method.toGenericString());
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ParameterTest {
|
public class ParameterTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Parameter.jav";
|
testName = "Parameter";
|
||||||
public final static String outputFile = "Parameter.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class PostDecrement {
|
public class PostDecrement extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "PostDecrement.jav";
|
testName = "PostDecrement";
|
||||||
public final static String outputFile = "PostDecrement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testConstruct() throws Exception{
|
||||||
public void test() {
|
ClassLoader classLoader = getClassLoader();
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class PostIncrement {
|
public class PostIncrement extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "PostIncrement.jav";
|
testName = "PostIncrement";
|
||||||
public final static String outputFile = "PostIncrement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testConstruct() throws Exception{
|
||||||
public void test() {
|
ClassLoader classLoader = getClassLoader();
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ReturnTest {
|
public class ReturnTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Return.jav";
|
testName = "Return";
|
||||||
public final static String outputFile = "Return.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RunnableTest {
|
public class RunnableTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Runnable.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Runnable.class";
|
testName = "Runnable";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,20 +38,20 @@ public class SingleClassTester {
|
|||||||
Menge<ByteCodeResult> bytecode = compiler.generateBytecode(sourceFiles, results);
|
Menge<ByteCodeResult> bytecode = compiler.generateBytecode(sourceFiles, results);
|
||||||
//System.out.println(bytecode);
|
//System.out.println(bytecode);
|
||||||
|
|
||||||
|
for(ByteCodeResult result: bytecode){
|
||||||
|
JavaClass javaClass = result.getByteCode().getJavaClass();
|
||||||
ByteCodeResult result = bytecode.firstElement();
|
javaClass.dump(new File(outputDirectory+javaClass.getClassName()+".class"));
|
||||||
|
|
||||||
JavaClass javaClass = result.getByteCode().getJavaClass();
|
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
||||||
javaClass.dump(new File(outputDirectory+javaClass.getClassName()+".class"));
|
JavaClass jc = cg.getJavaClass();
|
||||||
|
jc.dump(new File(outputDirectory+jc.getClassName()+".class"));
|
||||||
for(ClassGenerator cg: result.getByteCode().getExtraClasses().values()){
|
}
|
||||||
JavaClass jc = cg.getJavaClass();
|
|
||||||
jc.dump(new File(outputDirectory+jc.getClassName()+".class"));
|
Logger.getLogger("SingleClassTester").error(result.getByteCode().getJavaClass().toString(), Section.CODEGEN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.getLogger("SingleClassTester").error(result.getByteCode().getJavaClass().toString(), Section.CODEGEN);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException | yyException e) {
|
} catch (IOException | yyException e) {
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class StringLitTest {
|
public class StringLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "StringLitTest.jav";
|
testName = "StringLitTest";
|
||||||
public final static String outputFile = "StringLitTest.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class SystemOutPrintlnTest {
|
public class SystemOutPrintlnTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "SystemOutPrintln.jav";
|
testName = "SystemOutPrintln";
|
||||||
public final static String outputFile = "SystemOutPrintln.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
class Test3{
|
class Test3{
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
System.out.println(new LambdaExpr2().op.apply());
|
System.out.println(new LambdaExpr2Test().op.apply());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user