Factory angefügt. java.lang.reflect.Modifier benutzen

This commit is contained in:
JanUlrich 2017-03-08 03:43:47 +01:00
parent 4c4c0d5ada
commit 9fae52e1e6
68 changed files with 412 additions and 543 deletions

View File

@ -3,8 +3,7 @@ package de.dhbwstuttgart.core;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import java.io.File;
import java.io.IOException;

View File

@ -4,7 +4,6 @@ import de.dhbwstuttgart.parser.antlr.Java8Lexer;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.modifier.Modifier;
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;

View File

@ -6,8 +6,8 @@ import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.modifier.*;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
@ -40,9 +40,8 @@ public class RunParser{
}
System.out.println("classes:");
for(ClassOrInterface c : f.KlassenVektor){
for(Modifier mod : c.getModifiers().getModifierList()){
System.out.println(mod.getClass().getName());
}
int mod = c.getModifiers();
System.out.println(Modifier.toString(mod));
System.out.println(c.getClassName().toString());
System.out.println("{");
for(Field field : c.getFieldDecl()){

View File

@ -2,9 +2,6 @@ package de.dhbwstuttgart.parser;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.modifier.*;
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.*;
import de.dhbwstuttgart.syntaxtree.modifier.methodModifier.MethodModifier;
import de.dhbwstuttgart.syntaxtree.operator.AndOp;
import de.dhbwstuttgart.syntaxtree.operator.OrOp;
import de.dhbwstuttgart.syntaxtree.statement.*;
@ -14,7 +11,10 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.*;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.antlr.v4.runtime.Token;
@ -191,14 +191,12 @@ public class SyntaxTreeGenerator{
}
private ClassOrInterface convertNormal(Java8Parser.NormalClassDeclarationContext ctx){
Modifiers modifiers = null;
int modifiers = 0;
if(ctx.classModifier() != null){
List<Modifier> modList = new ArrayList();
for(Java8Parser.ClassModifierContext mod : ctx.classModifier()){
Modifier newModifier = convert(mod);
modList.add(newModifier);
int newModifier = convert(mod);
modifiers += newModifier;
}
modifiers = new Modifiers(modList);
}
JavaClassName name = convert(ctx.Identifier());
Block class_block = null;
@ -255,11 +253,11 @@ public class SyntaxTreeGenerator{
}else{
retType = TypePlaceholder.fresh(header.getStart());
}
List<MethodModifier> modifiers = convert(methodDeclarationContext.methodModifier());
int modifiers = convert(methodDeclarationContext.methodModifier());
ParameterList parameterList = convert(header.methodDeclarator().formalParameterList());
Block block = null;
if(methodDeclarationContext.methodBody().block() == null){
if(! modifiers.contains(new Abstract())){
if(! Modifier.isAbstract(modifiers)){
//TODO: Error! Abstrakte Methode ohne abstrakt Keyword
}
}else{
@ -303,16 +301,19 @@ public class SyntaxTreeGenerator{
return new ParameterList(ret, ret.get(0).getOffset());
}
private List<MethodModifier> convert(List<Java8Parser.MethodModifierContext> methodModifierContexts) {
//TODO
return new ArrayList<>();
private int convert(List<Java8Parser.MethodModifierContext> methodModifierContexts) {
int ret = 0;
for(Java8Parser.MethodModifierContext mod : methodModifierContexts){
if(mod.annotation() == null)convertModifier(mod.getText());
}
return ret;
}
private List<? extends Field> convert(Java8Parser.FieldDeclarationContext fieldDeclarationContext) {
List<Field> ret = new ArrayList<>();
List<FieldModifier> modifiers = new ArrayList<>();
int modifiers = 0;
for(Java8Parser.FieldModifierContext fieldModifierContext : fieldDeclarationContext.fieldModifier()){
modifiers.add(convert(fieldModifierContext));
modifiers+=(convert(fieldModifierContext));
}
RefTypeOrTPH fieldType = convert(fieldDeclarationContext.unannType());
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
@ -356,62 +357,35 @@ public class SyntaxTreeGenerator{
return new RefType(reg.getName(name), unannClassOrInterfaceTypeContext.getStart());
}
private Modifier convert(Java8Parser.ClassModifierContext ctx){
Modifier newModifier = null;
if(ctx.annotation() == null){
TerminalNode t = (TerminalNode)ctx.getChild(0);
if(t.getText().equals("public")){
newModifier = new Public();
}
else if(t.getText().equals("private")){
newModifier = new Private();
}
else if(t.getText().equals("protected")){
newModifier = new Protected();
}
else if(t.getText().equals("abstract")){
newModifier = new Abstract();
}
else if(t.getText().equals("static")){
newModifier = new Static();
}
else if(t.getText().equals("strictfp")){
newModifier = new Strictfp();
}
else{
newModifier = new Final();
}
private int convertModifier(String modifier){
HashMap<String, Integer> modifiers = new HashMap<>();
modifiers.put(Modifier.toString(Modifier.PUBLIC), Modifier.PUBLIC);
modifiers.put(Modifier.toString(Modifier.PRIVATE), Modifier.PRIVATE);
modifiers.put(Modifier.toString(Modifier.PROTECTED), Modifier.PROTECTED);
modifiers.put(Modifier.toString(Modifier.ABSTRACT), Modifier.ABSTRACT);
modifiers.put(Modifier.toString(Modifier.STATIC), Modifier.STATIC);
modifiers.put(Modifier.toString(Modifier.STRICT), Modifier.STRICT);
modifiers.put(Modifier.toString(Modifier.FINAL), Modifier.FINAL);
modifiers.put(Modifier.toString(Modifier.TRANSIENT), Modifier.TRANSIENT);
modifiers.put(Modifier.toString(Modifier.VOLATILE), Modifier.VOLATILE);
modifiers.put(Modifier.toString(Modifier.SYNCHRONIZED), Modifier.SYNCHRONIZED);
modifiers.put(Modifier.toString(Modifier.NATIVE), Modifier.NATIVE);
modifiers.put(Modifier.toString(Modifier.INTERFACE), Modifier.INTERFACE);
int ret = 0;
for(String m : modifiers.keySet()){
if(modifier.startsWith(m))ret+=modifiers.get(m);
}
return newModifier;
return ret;
}
private int convert(Java8Parser.ClassModifierContext ctx){
if(ctx.annotation() != null)return 0;
return convertModifier(ctx.getText());
}
private FieldModifier convert(Java8Parser.FieldModifierContext ctx){
FieldModifier newModifier = null;
if(ctx.annotation() == null){
TerminalNode t = (TerminalNode)ctx.getChild(0);
if(t.getText().equals("public")){
newModifier = new PublicFieldModifier();
}
else if(t.getText().equals("private")){
newModifier = new PrivateFieldModifier();
}
else if(t.getText().equals("protected")){
newModifier = new ProtectedFieldModifier();
}
else if(t.getText().equals("static")){
newModifier = new StaticFieldModifier();
}
else if(t.getText().equals("transient")){
newModifier = new Transient();
}
else if(t.getText().equals("volatile")){
newModifier = new Volatile();
}
else{
newModifier = new FinalFieldModifier();
}
}
return newModifier;
private int convert(Java8Parser.FieldModifierContext ctx){
if(ctx.annotation() != null)return 0;
return convertModifier(ctx.getText());
}

View File

@ -2,22 +2,19 @@ package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
*/
public class ClassOrInterface extends GTVDeclarationContext implements IItemWithOffset, Generic{
protected Modifiers modifiers;
protected int modifiers;
protected JavaClassName name;
private List<Field> fields = new ArrayList<>();
private List<Method> methods = new ArrayList<>();
@ -27,12 +24,10 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
protected boolean isInterface;
private List<RefTypeOrTPH> implementedInterfaces;
public ClassOrInterface(Modifiers modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, GenericDeclarationList genericClassParameters,
public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, GenericDeclarationList genericClassParameters,
RefTypeOrTPH superClass, Boolean isInterface, List<RefTypeOrTPH> implementedInterfaces, Token offset){
super(offset);
if(modifiers != null){
this.modifiers = modifiers;
}
if(name != null){
this.name = name;
}
@ -59,7 +54,7 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
}
// Get modifiers
public Modifiers getModifiers(){
public int getModifiers(){
return this.modifiers;
}

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.modifier.methodModifier.MethodModifier;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import org.antlr.v4.runtime.Token;
@ -11,7 +10,7 @@ import java.util.List;
public class Constructor extends Method {
public Constructor(String name, RefTypeOrTPH returnType, List<MethodModifier> modifiers, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) {
public Constructor(String name, RefTypeOrTPH returnType, int modifiers, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, parameterList, block, gtvDeclarations, offset);
}
}

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.FieldModifier;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import org.antlr.v4.runtime.Token;
@ -14,7 +13,7 @@ public class Field extends GTVDeclarationContext implements Generic {
private GenericDeclarationList genericParameters;
public Field(String name, RefTypeOrTPH type, List<? extends FieldModifier> modifier, Token offset){
public Field(String name, RefTypeOrTPH type, int modifier, Token offset){
super(offset);
this.name = name;
this.type = type;

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.FieldModifier;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import org.antlr.v4.runtime.Token;
@ -22,7 +21,7 @@ public class FieldDeclaration extends Field{
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
*/
public FieldDeclaration(String name, RefTypeOrTPH typ, List<FieldModifier> modifier, Expression value, Token offset){
public FieldDeclaration(String name, RefTypeOrTPH typ, int modifier, Expression value, Token offset){
super(name, typ, modifier, offset);//Dieser Deklarator wird nicht vom Parser aufgerufen. Dadurch gibt es auch keinen Offset
this.wert = value;
}

View File

@ -14,4 +14,7 @@ public class FormalParameter extends SyntaxTreeNode
this.type = type;
}
public RefTypeOrTPH getType() {
return type;
}
}

View File

@ -21,11 +21,11 @@ public class GenericTypeVar extends SyntaxTreeNode
/**
* Hier sind die Bounds in Form von Type-Objekten abgespeichert
*/
List<RefTypeOrTPH> bounds=new ArrayList<RefTypeOrTPH>();
List<? extends RefTypeOrTPH> bounds=new ArrayList<RefTypeOrTPH>();
private Token endOffset;
private String name;
public GenericTypeVar(String s, List<RefTypeOrTPH> bounds, Token offset, Token endOffset)
public GenericTypeVar(String s, List<? extends RefTypeOrTPH> bounds, Token offset, Token endOffset)
{
super(offset);
name = s;
@ -37,7 +37,7 @@ public class GenericTypeVar extends SyntaxTreeNode
this.endOffset = endOffset;
}
public List<RefTypeOrTPH> getBounds()
public List<? extends RefTypeOrTPH> getBounds()
{
return bounds;
}

View File

@ -4,15 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.modifier.methodModifier.MethodModifier;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
import de.dhbwstuttgart.syntaxtree.statement.Block;
/**
@ -31,9 +28,9 @@ public class Method extends Field implements IItemWithOffset
private String name;
private List<String> types_in_parameterlist = new ArrayList<>();
private Modifiers modifiers;
private int modifiers;
public Method(String name, RefTypeOrTPH returnType, List<MethodModifier> modifiers, ParameterList parameterList, Block block,
public Method(String name, RefTypeOrTPH returnType, int modifiers, ParameterList parameterList, Block block,
GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, offset);
this.name = name;

View File

@ -3,11 +3,9 @@ import java.util.*;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
public class SourceFile extends SyntaxTreeNode{

View File

@ -0,0 +1,160 @@
package de.dhbwstuttgart.syntaxtree.factory;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.antlr.v4.runtime.Token;
/**
* Anmerkung:
* Die ASTFactory Methoden, welche ASTBäume aus java.lang.Class Objekten generieren, können davon ausgehen,
* dass alle Imports und Typnamen korrekt sind und müssen diese nicht überprüfen.
*/
public class ASTFactory {
/*
private final JavaClassRegistry names;
public ASTFactory(JavaClassRegistry scope){
names = scope;
}
public Class createClass(java.lang.Class jreClass){
JavaClassName name = names.getName(jreClass.getName());
List<Method> methoden = new ArrayList<>();
for(java.lang.reflect.Constructor constructor : jreClass.getConstructors()){
}
for(java.lang.reflect.Method method : jreClass.getMethods()){
methoden.add(createMethod(method, jreClass));
}
List<Field> felder = new ArrayList<>();
int modifier = jreClass.getModifiers();
boolean isInterface = jreClass.isInterface();
java.lang.Class superjreClass = jreClass.getSuperclass();
RefType superClass = null;
if(superjreClass != null){
superClass = createType(superjreClass);
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!)
superClass = createType(java.lang.Object.class);
}
List<RefType> implementedInterfaces = new ArrayList<>();
for(java.lang.Class jreInterface : jreClass.getInterfaces()){
implementedInterfaces.add(createType(jreInterface));
}
int offset = 0; //Braucht keinen Offset, da diese Klasse nicht aus einem Quellcode geparst wurde
return new ClassOrInterface(name, methoden, felder, modifier, isInterface, superClass, implementedInterfaces, offset);
}
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefType returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
RefType paramType = createType(jreParam.getType());
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), new NullToken());
List<GenericTypeVar> gtvs = new ArrayList<>();
for(TypeVariable jreTV : jreMethod.getTypeParameters()){
GenericTypeVar gtv = createGeneric(jreTV, jreTV.getName());
gtvs.add(gtv);
}
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(gtvs,new NullToken());
Token offset = new NullToken();
int modifier = jreMethod.getModifiers();
return new Method(name,returnType, modifier, parameterList, block, gtvDeclarations, offset);
}
public RefType createType(java.lang.Class jreClass){
List<RefType> params = new ArrayList<>();
for(TypeVariable jreTV : jreClass.getTypeParameters()){
RefType gtv = createType(jreTV);
params.add(gtv);
}
jreClass
return new RefType(jreClass.getName(), params, -1);
}
public RefType createType(java.lang.reflect.Type type){
RefType ret = new RefType(type.getTypeName(), -1);
//TODO hier die Generischen Variablen extrahieren
return ret;
}
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, String name){
List<RefType> genericBounds = new ArrayList<>();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){
genericBounds.add(createType(bound));
}
}
return new GenericTypeVar(name, genericBounds, new NullToken(), new NullToken());
}
public Class createObjectClass() {
return this.createClass(Object.class);
}
*/
/*
public Constructor createEmptyConstructor(Class parent){
Block block = new Block();
block.setType(new de.dhbwstuttgart.syntaxtree.type.Void(block, 0));
block.statements.add(new SuperCall(block));
return ASTFactory.createConstructor(parent, new ParameterList(), block);
}
public static Constructor createConstructor(Class superClass, ParameterList paralist, Block block){
block.parserPostProcessing(superClass);
Method method = ASTFactory.createMethod("<init>", paralist, block, superClass);
method.setType(new de.dhbwstuttgart.syntaxtree.type.Void(block, 0));
return new Constructor(method, superClass);
}
public static Class createClass(String className, RefType type, Modifiers modifiers, Menge supertypeGenPara, SourceFile parent) {
// TODO bytecode createClass
//String name, RefType superClass, Modifiers modifiers, Menge<String> supertypeGenPara
Class generatedClass = new Class(className, type, modifiers, supertypeGenPara);
generatedClass.addField(ASTFactory.createEmptyConstructor(generatedClass));
generatedClass.parserPostProcessing(parent);
return generatedClass;
}
public static Class createObject(){
return createClass(java.lang.Object.class);
}
public static Class createInterface(String className, RefType superClass, Modifiers modifiers,
Menge supertypeGenPara, SourceFile parent){
Class generatedClass = new Class(new JavaClassName(className), new ArrayList<Method>(), new ArrayList<Field>(), modifiers,
true, superClass, new ArrayList<RefType>(), new GenericDeclarationList(), -1);
generatedClass.parserPostProcessing(parent);
return generatedClass;
}
public static RefType createObjectType(){
return createObjectClass().getType();
}
*/
}

View File

@ -0,0 +1,81 @@
package de.dhbwstuttgart.syntaxtree.factory;
public class NameGenerator {
private static String strNextName = "A";
/**
* Berechnet einen neuen, eindeutigen Namen ¯Â¿Â½r eine neue
* <code>TypePlaceholder</code>. <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return Der Name
*/
public static String makeNewName()
{
// otth: Funktion berechnet einen neuen Namen anhand eines alten gespeicherten
String strReturn = strNextName;
// ¯Â¿Â½chster Name berechnen und in strNextName speichern
inc( strNextName.length() - 1 );
return strReturn;
}
/**
* Hilfsfunktion zur Berechnung eines neuen Namens
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param i
*/
private static void inc(int i)
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Erh�hung des Buchstabens an der Stelle i im String strNextName
// otth: Nach �berlauf: rekursiver Aufruf
// falls i = -1 --> neuer Buchstabe vorne anf�gen
if ( i == -1 )
{
strNextName = "A" + strNextName;
return;
}
char cBuchstabe = (char)(strNextName.charAt( i ));
cBuchstabe++;
if ( cBuchstabe - 65 > 25 )
{
// aktuelle Stelle: auf A zuruecksetzen
manipulate( i, 'A' );
// vorherige Stelle erh�hen
inc( i - 1 );
}
else
{
// aktueller Buchstabe �ndern
manipulate( i, cBuchstabe );
}
}
/**
* Hilfsfunktion zur Berechnung eines neuen Namens.
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param nStelle
* @param nWert
*/
private static void manipulate( int nStelle, char nWert )
{
// otth: Hilfsfunktion zur Berechnung eines neuen Namens
// otth: Ersetzt im String 'strNextName' an der Position 'nStelle' den Buchstaben durch 'nWert'
String strTemp = "";
for( int i = 0; i < strNextName.length(); i++)
{
if ( i == nStelle )
strTemp = strTemp + nWert;
else
strTemp = strTemp + strNextName.charAt( i );
}
strNextName = strTemp;
}
}

View File

@ -0,0 +1,9 @@
package de.dhbwstuttgart.syntaxtree.factory;
/**
* Generiert Hilfsmethoden für die Unary und Binary Operatoren
* Diese Methoden stellen die möglichen Operationen +,-,++, etc dar
*/
public class PrimitiveMethodsGenerator {
}

View File

@ -1,17 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
/**
* Stellt den Modifier Abstract dar.
*
*/
public class Abstract extends Modifier
{
public short getBitmask()
{
return 0x0400;
}
}

View File

@ -1,15 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
/**
* Stellt den Modifier Final dar.
*
*/
public class Final extends Modifier
{
public short getBitmask()
{
return 0x10;
}
}

View File

@ -1,18 +0,0 @@
/**
*
*/
package de.dhbwstuttgart.syntaxtree.modifier;
/**
* @author Daniel
*
*/
public class InterfaceModifier extends Modifier {
public short getBitmask()
{
return 0x0200;
}
}

View File

@ -1,12 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public abstract class Modifier
{
/**
* Liefert den Wert des Access-Modifiers fuer die Bytecode-Generierung
* zurueck.
*/
public abstract short getBitmask();
}

View File

@ -1,24 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
import java.util.ArrayList;
import java.util.List;
/**
* Die Klasse beinhaltet die Liste der Access-Modifier fuer eine Klasse,
* Methode usw.
*/
public class Modifiers
{
protected List<Modifier> modifier = new ArrayList<Modifier>();
public Modifiers(List<Modifier> modifier){
this.modifier = modifier;
}
public List<Modifier> getModifierList(){
return this.modifier;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public class Private extends Modifier
{
public short getBitmask()
{
return 2;
}
}

View File

@ -1,12 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public class Protected extends Modifier
{
public short getBitmask()
{
return 4;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public class Public extends Modifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,12 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public class Static extends Modifier
{
public short getBitmask()
{
return 8;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier;
public class Strictfp extends Modifier
{
public short getBitmask()
{
return 2048;
}
}

View File

@ -1,16 +0,0 @@
/**
*
*/
package de.dhbwstuttgart.syntaxtree.modifier;
/**
* @author Daniel
*
*/
public class Super extends Modifier {
public short getBitmask()
{
return 0x0020;
}
}

View File

@ -1,4 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public interface FieldModifier {
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class FinalFieldModifier implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class PrivateFieldModifier implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class ProtectedFieldModifier implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class PublicFieldModifier implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class StaticFieldModifier implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class Transient implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,11 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.fieldModifier;
public class Volatile implements FieldModifier
{
public short getBitmask()
{
return 1;
}
}

View File

@ -1,6 +0,0 @@
package de.dhbwstuttgart.syntaxtree.modifier.methodModifier;
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.FieldModifier;
public interface MethodModifier extends FieldModifier {
}

View File

@ -8,11 +8,15 @@ import java.util.List;
public class ArgumentList extends SyntaxTreeNode
{
public ArgumentList(Token offset) {
public ArgumentList(List<Expression> expr, Token offset) {
super(offset);
this.expr = expr;
}
public List<Expression> expr;
private List<Expression> expr;
public List<Expression> getArguments(){
return expr;
}
}

View File

@ -1,14 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class Assign extends Statement

View File

@ -1,14 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.HashMap;
import java.util.List;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.operator.Operator;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -2,18 +2,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.*;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
public class Block extends Statement

View File

@ -2,12 +2,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class CastExpr extends Expression
{

View File

@ -1,16 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
public class EmptyStmt extends Statement

View File

@ -5,12 +5,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import java.util.List;
public abstract class Expression extends SyntaxTreeNode
{
private RefTypeOrTPH type;

View File

@ -1,12 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class ForStmt extends Statement

View File

@ -1,28 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ALOAD;
import org.apache.bcel.generic.ASTORE;
import org.apache.bcel.generic.BranchInstruction;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.GOTO;
import org.apache.bcel.generic.GotoInstruction;
import org.apache.bcel.generic.IFEQ;
import org.apache.bcel.generic.IFNONNULL;
import org.apache.bcel.generic.IfInstruction;
import org.apache.bcel.generic.Instruction;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.NOP;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
public class IfStmt extends Statement

View File

@ -1,16 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -2,12 +2,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class InstanceOf extends BinaryExpr
{

View File

@ -1,15 +1,11 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.FunN;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
/**
* @author A10023 - Andreas Stadelmeier
* Momentan erweitert LambdaExpression noch Expr und erbt dadurch auch von ExprStatement ist also auch ein Statement

View File

@ -2,12 +2,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import java.util.List;
public class LocalOrFieldVar extends Statement{
protected final String expression;

View File

@ -1,21 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.Instruction;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LocalVariableInstruction;
import org.apache.bcel.generic.ObjectType;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -1,10 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -1,16 +1,12 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class LocalVarDecl extends Statement
{

View File

@ -1,20 +1,13 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.List;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.OderConstraint;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.Const;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
@ -35,9 +28,17 @@ public class MethodCall extends Statement
public ConstraintSet getConstraints(TypeInferenceInformation info) {
ConstraintSet ret = receiver.getConstraints(info);
//Overloading:
for(Method m : info.getMethods(name, arglist)){
//TODO
OderConstraint overloading = new OderConstraint();
for(MethodAssumption m : info.getMethods(name, arglist)){
UndConstraint methodConstraints = new UndConstraint();
methodConstraints.addConstraint(receiver.getType(), m.getReceiverType());
methodConstraints.addConstraint(m.getReturnType(), this.getType());
for(int i = 0;i<arglist.getArguments().size();i++){
methodConstraints.addConstraint(m.getArgTypes().get(i),
arglist.getArguments().get(i).getType());
}
}
ret.add(overloading);
return ret;
}
}

View File

@ -3,8 +3,7 @@ import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -4,8 +4,7 @@ import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -1,18 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.IINC;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -2,11 +2,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
public class Receiver extends Expression
{

View File

@ -1,19 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -1,13 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import java.util.List;
public abstract class Statement extends Expression
{

View File

@ -1,13 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class Super extends Expression
{
public Super(Token offset)

View File

@ -1,14 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class This extends Expression
{
public This(Token offset)

View File

@ -1,13 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class UnaryPlus extends Expression
{
public UnaryPlus(Expression expression){

View File

@ -2,12 +2,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.List;
public class WhileStmt extends Statement
{
public WhileStmt(int offset, int variableLength)

View File

@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
public abstract class Literal extends Expression

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.typeinference;
public class ConstraintSet {
public class ConstraintSet extends UndConstraint{
public void addAll(ConstraintSet constraints) {
}
@ -8,4 +8,8 @@ public class ConstraintSet {
public void add(Pair pair) {
}
public void add(KomplexeMenge<Pair> constraint){
}
}

View File

@ -0,0 +1,34 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import org.antlr.v4.runtime.misc.DoubleKeyMap;
import java.util.List;
import java.util.stream.Collectors;
public class MethodAssumption {
private RefType receiver;
private RefTypeOrTPH retType;
ParameterList params;
public MethodAssumption(RefType receiver, RefTypeOrTPH retType, ParameterList params){
this.receiver = receiver;
this.retType = retType;
this.params = params;
}
public RefType getReceiverType() {
return null;
}
public RefTypeOrTPH getReturnType() {
return retType;
}
public List<RefTypeOrTPH> getArgTypes() {
return params.formalparameter.stream().
map(formalParameter -> formalParameter.getType()).collect(Collectors.toList());
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.typeinference;
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -17,15 +18,18 @@ Zweiteres hat den Vorteil, dass bei der Entwicklung leichter Dinge hinzugefügt
Die ganze Logik steckt in dieser Klasse.
*/
public class TypeInferenceInformation {
private Method methodContext;
public void setSourceFileContext(SourceFile sf){
}
public void setMethodContext(Method methodContext) {
this.methodContext = methodContext;
}
public List<Method> getMethods(String name, ArgumentList arglist) {
public List<MethodAssumption> getMethods(String name, ArgumentList arglist) {
throw new NotImplementedException();
}
}

View File

@ -5,11 +5,11 @@ import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.modifier.Modifier;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Modifier;
public class FeatherWeightJavaTest {
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
@ -24,9 +24,8 @@ public class FeatherWeightJavaTest {
System.out.println("package: " + pkgName);
System.out.println("classes:");
for(ClassOrInterface c : f.KlassenVektor){
for(Modifier mod : c.getModifiers().getModifierList()){
System.out.println(mod.getClass().getName());
}
int mod = c.getModifiers();
System.out.println(Modifier.toString(mod));
System.out.println(c.getClassName().toString());
System.out.println("{");
for(Field field : c.getFieldDecl()){

View File

@ -4,11 +4,11 @@ import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.modifier.Modifier;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Modifier;
public class FieldTest {
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
@ -23,9 +23,8 @@ public class FieldTest {
System.out.println("package: " + pkgName);
System.out.println("classes:");
for(ClassOrInterface c : f.KlassenVektor){
for(Modifier mod : c.getModifiers().getModifierList()){
System.out.println(mod.getClass().getName());
}
int mod = c.getModifiers();
System.out.println(Modifier.toString(mod));
System.out.println(c.getClassName().toString());
System.out.println("{");
for(Field field : c.getFieldDecl()){