Merge mit ANTLR branch
This commit is contained in:
commit
72bcfd41d3
@ -69,9 +69,9 @@
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Method</a></li>
|
||||
<li><a href="#methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Method</a></li>
|
||||
</ul>
|
||||
<ul class="subNavList">
|
||||
<li>Detail: </li>
|
||||
@ -100,7 +100,7 @@
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/GTVDeclarationContext.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.GTVDeclarationContext</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.Class</a></li>
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.ClassOrInterface</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>de.dhbwstuttgart.syntaxtree.BasicAssumptionClass</li>
|
||||
@ -137,7 +137,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</a>
|
||||
<h3>Field Summary</h3>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Fields inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -173,7 +173,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</a>
|
||||
<h3>Method Summary</h3>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Methods inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -287,9 +287,9 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Method</a></li>
|
||||
<li><a href="#methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Method</a></li>
|
||||
</ul>
|
||||
<ul class="subNavList">
|
||||
<li>Detail: </li>
|
||||
|
@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/GTVDeclarationContext.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.GTVDeclarationContext</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>de.dhbwstuttgart.syntaxtree.Class</li>
|
||||
<li>de.dhbwstuttgart.syntaxtree.ClassOrInterface</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -75,7 +75,7 @@ var activeTableTab = "activeTableTab";
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/GTVDeclarationContext.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.GTVDeclarationContext</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.Class</a></li>
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.ClassOrInterface</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>de.dhbwstuttgart.syntaxtree.Interface</li>
|
||||
@ -148,7 +148,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</a>
|
||||
<h3>Field Summary</h3>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Fields inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -205,7 +205,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</tr>
|
||||
</table>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Methods inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -356,7 +356,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<html lang="de">
|
||||
<head>
|
||||
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
|
||||
<title>Uses of Class de.dhbwstuttgart.syntaxtree.Class</title>
|
||||
<title>Uses of Class de.dhbwstuttgart.syntaxtree.ClassOrInterface</title>
|
||||
<meta name="date" content="2015-05-12">
|
||||
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
|
||||
<script type="text/javascript" src="../../../../script.js"></script>
|
||||
@ -70,7 +70,7 @@
|
||||
</a></div>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
<div class="header">
|
||||
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.Class" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.Class</h2>
|
||||
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.ClassOrInterface" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.Class</h2>
|
||||
</div>
|
||||
<div class="classUseContainer">
|
||||
<ul class="blockList">
|
||||
|
@ -75,7 +75,7 @@ var activeTableTab = "activeTableTab";
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/GTVDeclarationContext.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.GTVDeclarationContext</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.Class</a></li>
|
||||
<li><a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">de.dhbwstuttgart.syntaxtree.ClassOrInterface</a></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>de.dhbwstuttgart.typeinference.FunNInterface</li>
|
||||
@ -148,7 +148,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</a>
|
||||
<h3>Field Summary</h3>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Fields inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -205,7 +205,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
</tr>
|
||||
</table>
|
||||
<ul class="blockList">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">
|
||||
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">
|
||||
<!-- -->
|
||||
</a>
|
||||
<h3>Methods inherited from class de.dhbwstuttgart.syntaxtree.<a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class in de.dhbwstuttgart.syntaxtree">Class</a></h3>
|
||||
@ -362,7 +362,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/Class.html" title="class i
|
||||
<ul class="subNavList">
|
||||
<li>Summary: </li>
|
||||
<li>Nested | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.Class">Field</a> | </li>
|
||||
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.ClassOrInterface">Field</a> | </li>
|
||||
<li><a href="#constructor.summary">Constr</a> | </li>
|
||||
<li><a href="#method.summary">Method</a></li>
|
||||
</ul>
|
||||
|
@ -5,29 +5,34 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.typecheck.*;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
public class RunParser{
|
||||
public static void main(String[] args){
|
||||
try{
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String inputString = sc.nextLine();
|
||||
while(sc.hasNextLine()) inputString = inputString + sc.nextLine();
|
||||
InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
|
||||
ANTLRInputStream input = new ANTLRInputStream(stream);
|
||||
Java8Lexer lexer = new Java8Lexer(input);
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
Java8Parser parser = new Java8Parser(tokens);
|
||||
ParserRuleContext tree = parser.compilationUnit();
|
||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(null);
|
||||
generator.convert((Java8Parser.CompilationUnitContext) tree);
|
||||
}
|
||||
catch(Exception e){
|
||||
System.out.println("An exception occured which is unknown and on our TODO list.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args){
|
||||
try{
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String inputString = sc.nextLine();
|
||||
while(sc.hasNextLine()) inputString = inputString + sc.nextLine();
|
||||
InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
|
||||
ANTLRInputStream input = new ANTLRInputStream(stream);
|
||||
Java8Lexer lexer = new Java8Lexer(input);
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
Java8Parser parser = new Java8Parser(tokens);
|
||||
Java8Parser.CompilationUnitContext tree = parser.compilationUnit();
|
||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator();
|
||||
generator.getNames(tree);
|
||||
SourceFile f = generator.convert((Java8Parser.CompilationUnitContext) tree);
|
||||
for(ClassOrInterface c : f.KlassenVektor){
|
||||
System.out.println(c.getClassName().toString());
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
System.out.println("An exception occured which is unknown and on our TODO list.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,69 @@
|
||||
package de.dhbwstuttgart.parser;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.typecheck.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SyntaxTreeGenerator {
|
||||
|
||||
public SyntaxTreeGenerator(JavaClassRegistry nameReg){
|
||||
//TODO: Implement
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
public class SyntaxTreeGenerator{
|
||||
JavaClassRegistry reg = new JavaClassRegistry();
|
||||
String packageDecl = "";
|
||||
|
||||
public void getNames(Java8Parser.CompilationUnitContext ctx){
|
||||
if(ctx.packageDeclaration() != null){
|
||||
for(TerminalNode t : ctx.packageDeclaration().Identifier()){
|
||||
this.packageDecl = this.packageDecl + "." + t.toString();
|
||||
}
|
||||
this.packageDecl = this.packageDecl.substring(1);
|
||||
}
|
||||
|
||||
public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
|
||||
List<Class> classes = new ArrayList<>();
|
||||
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||
Class newClass = convert(typeDecl.classDeclaration());
|
||||
classes.add(newClass);
|
||||
String nameString = "";
|
||||
for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||
if(typeDecl.interfaceDeclaration() != null){
|
||||
if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){
|
||||
if(packageDecl != ""){
|
||||
nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
|
||||
}
|
||||
else{
|
||||
nameString = typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
|
||||
}
|
||||
this.reg.existingClasses.add(new JavaClassName(nameString));
|
||||
}
|
||||
return new SourceFile(classes);
|
||||
}
|
||||
else{
|
||||
if(typeDecl.classDeclaration().normalClassDeclaration() != null){
|
||||
if(packageDecl != ""){
|
||||
nameString = packageDecl + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
|
||||
}
|
||||
else{
|
||||
nameString = typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
|
||||
}
|
||||
this.reg.existingClasses.add(new JavaClassName(nameString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Class convert(Java8Parser.ClassDeclarationContext ctx) {
|
||||
//TODO: Implement
|
||||
return null;
|
||||
public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
|
||||
List<ClassOrInterface> classes = new ArrayList<>();
|
||||
for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||
ClassOrInterface newClass = convert(typeDecl.classDeclaration());
|
||||
classes.add(newClass);
|
||||
}
|
||||
return new SourceFile(classes);
|
||||
}
|
||||
|
||||
private ClassOrInterface convert(Java8Parser.ClassDeclarationContext ctx) {
|
||||
ClassOrInterface newClass = new ClassOrInterface();
|
||||
String name = "";
|
||||
if(this.packageDecl != ""){
|
||||
name = packageDecl + "." + ctx.normalClassDeclaration().Identifier().toString();
|
||||
}
|
||||
else{
|
||||
name = ctx.normalClassDeclaration().Identifier().toString();
|
||||
}
|
||||
newClass.setClassName(new JavaClassName(name));
|
||||
return newClass;
|
||||
}
|
||||
}
|
||||
|
@ -2,3 +2,4 @@
|
||||
|
||||
* Core-Problem: Typinferenz vs. Konstruktoren
|
||||
* möglicherweise Problem: falsche Return-Expressions
|
||||
* Problem: Line-Comments werden nicht erkannt bzw. führen dazu dass das gesamte File nicht geparsed wird (Java8.g4).
|
||||
|
@ -10,3 +10,9 @@
|
||||
= Idee bei mehreren Files =
|
||||
* Zunächst alle Files anschauen und Pakate/Klassen für die spätere Verwendung "registrieren".
|
||||
* Danach erst das komplette Package/alle Klassen imselben Verzeichnis parsen.
|
||||
|
||||
== Fragen/PProbleme SyntaxTreeGenerator ==
|
||||
|
||||
* ClassRegistry: Unklar, woher diese kommen soll.
|
||||
* Konstruktor für Class fehlt.
|
||||
* Namenskonflikt Class vs. Class in Java?
|
||||
|
@ -1,265 +0,0 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.core.IItemWithOffset;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.*;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
|
||||
*/
|
||||
public class Class extends GTVDeclarationContext implements IItemWithOffset, Generic, GenericTypeInsertable
|
||||
{
|
||||
/**
|
||||
* Loggerinstanzen
|
||||
*/
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
protected static Logger codegenlog = Logger.getLogger("codegen");
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
protected Logger typinferenzLog = Logger.getLogger(Class.class.getName());
|
||||
|
||||
protected Modifiers modifiers;
|
||||
protected JavaClassName name;
|
||||
private Block class_block;
|
||||
private List<Field> fielddecl = new ArrayList<>();
|
||||
private GenericDeclarationList genericClassParameters;
|
||||
private int offset;
|
||||
private RefType superClass;
|
||||
protected boolean isInterface;
|
||||
private List<RefType> implementedInterfaces;
|
||||
|
||||
public Class(JavaClassName name, GenericDeclarationList genericDeclarations, List<Method> methode, List<Field> felder, int offset) {
|
||||
super(offset);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// TypeReconstructionAlgorithmus
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Ausgangspunkt f�r den Typrekonstruktionsalgorithmus. Hier werden zun�chst
|
||||
* die Mengen von Typannahmen V_fields_methods und V_i erstellt, die als Eingabe
|
||||
* f�r den Algorithmus dienen.<br/>
|
||||
* (siehe Algorithmus 5.17 TRProg, Martin Pl�micke)
|
||||
* <br/>Author: J�rg B�uerle
|
||||
* @param supportData
|
||||
* @param globalAssumptions
|
||||
* @return Liste aller bisher berechneten, m�glichen Typkombinationen
|
||||
* @throws CTypeReconstructionException
|
||||
*/
|
||||
public ConstraintsSet typeReconstruction(TypeAssumptions globalAssumptions)
|
||||
{
|
||||
//////////////////////////////
|
||||
// Und los geht's:
|
||||
//////////////////////////////
|
||||
inferencelog.info("Rufe TRStart()...", Section.TYPEINFERENCE);
|
||||
|
||||
//////////////////////////////
|
||||
// Ab hier ...
|
||||
// @author A10023 - Andreas Stadelmeier:
|
||||
//////////////////////////////
|
||||
//Erzeuge Assumptions:
|
||||
TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
|
||||
//Globale Assumptions anfügen:
|
||||
assumptions.add(globalAssumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
|
||||
typinferenzLog.debug("Erstellte Assumptions: "+assumptions, Section.TYPEINFERENCE);
|
||||
|
||||
//Gibt es hier eine ClassCastException stimmt etwas grundsätzlich nicht!
|
||||
//this.superClass = (RefType)this.superClass.TYPE(assumptions, this);
|
||||
|
||||
for(Field f:this.getFields()){
|
||||
oderConstraints.add(f.TYPE(assumptions));
|
||||
}
|
||||
typinferenzLog.debug("Erstellte Constraints: "+oderConstraints, Section.TYPEINFERENCE);
|
||||
|
||||
return oderConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
|
||||
* Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
|
||||
* @return Die erstellten TypeAssumptions
|
||||
*/
|
||||
private TypeAssumptions getPrivateFieldAssumptions() {
|
||||
if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
|
||||
TypeAssumptions assumptions = new TypeAssumptions(this.getName());
|
||||
|
||||
for(Field field : this.getFields()){
|
||||
if(!field.isPublic())assumptions.add(field.createTypeAssumptions(this));
|
||||
}
|
||||
|
||||
this.typeAssumptions = assumptions; //Diese müssen anschlieÃend nicht wieder generiert werden.
|
||||
return assumptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
* @return
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
public String getTypeInformation(Menge<Method> methodList, Menge<Expr> fieldList){
|
||||
String ret = this.name+": ";
|
||||
for(Expr field : fieldList){
|
||||
ret+=field.getTypeInformation()+"\n";
|
||||
}
|
||||
for(Method m : methodList){
|
||||
ret+=m.getTypeInformation()+"\n";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generiert den JavaCode dieser Klasse im Falle für das übergebene resultSet.
|
||||
* Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
|
||||
* @return Java-Sourcefile
|
||||
*/
|
||||
public JavaCodeResult printJavaCode(ResultSet reconstructionResult){
|
||||
JavaCodeResult ret = new JavaCodeResult("class ");
|
||||
|
||||
JavaCodeResult classBodyCode = new JavaCodeResult();
|
||||
if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult)).attach(" ");
|
||||
|
||||
classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult)).attach("\n");
|
||||
|
||||
JavaCodeResult bodyString = new JavaCodeResult("{\n");
|
||||
for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult) ).attach( "\n" );
|
||||
bodyString.attach("}\n");
|
||||
|
||||
classBodyCode.attach(bodyString);
|
||||
|
||||
//Zuerst die generischen Parameter für diese Klasse berechnen:
|
||||
//this.createGenericTypeVars(classBodyCode.getUnresolvedTPH());
|
||||
|
||||
if(this.genericClassParameters != null && this.genericClassParameters.size()>0){
|
||||
ret.attach("<");
|
||||
|
||||
Iterator<GenericTypeVar> it = this.genericClassParameters.iterator();
|
||||
while(it.hasNext()){
|
||||
GenericTypeVar tph = it.next();
|
||||
ret.attach(tph.printJavaCode(reconstructionResult));
|
||||
if(it.hasNext())ret.attach(", ");
|
||||
}
|
||||
ret.attach(">");
|
||||
}
|
||||
|
||||
String stringReturn = ret.attach(classBodyCode).toString();
|
||||
|
||||
return new JavaCodeResult(stringReturn);
|
||||
}
|
||||
|
||||
public int getOffset(){
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen RefType, welcher auf diese Klasse verweist
|
||||
* Ersetzt alle Generischen Variablen in der Parameterliste mit TPH
|
||||
* @return
|
||||
*/
|
||||
public RefType getType() {
|
||||
return new RefType(this.getName().toString(), this.get_ParaList(),this, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ermittelt die Sichtbaren Felder und Methoden der Klasse.
|
||||
* (Momentan sind im Projekt alle Felder und Methoden "package private", da der Parser keine Access-Modifier einlesen kann.
|
||||
* @return
|
||||
*/
|
||||
public TypeAssumptions getPublicFieldAssumptions() {
|
||||
TypeAssumptions ret = new TypeAssumptions();//this.getPrivateFieldAssumptions();
|
||||
ret.addClassAssumption(new ClassAssumption(this));
|
||||
for(Field f : this.getFields()){
|
||||
if(f.isPublic())ret.add(f.createTypeAssumptions(this));
|
||||
}
|
||||
for(GenericTypeVar gtv : this.getGenericParameter()){
|
||||
ret.add(gtv.createAssumptions());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(!(obj instanceof Class))return false;
|
||||
Class cl = (Class) obj;
|
||||
if(!(cl.getName().equals(this.getName())))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericDeclarationList getGenericParameter() {
|
||||
return this.genericClassParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SyntaxTreeNode> getChildren() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return "class "+this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenericParameter(GenericDeclarationList params) {
|
||||
this.genericClassParameters = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenericVarDeclarationString(String genericVarDeclaration) {
|
||||
if(this.genericClassParameters != null){
|
||||
return ", "+genericVarDeclaration;
|
||||
}else{
|
||||
return "<"+genericVarDeclaration+">";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGenericVarDeclarationOffset(){
|
||||
// Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||
if(this.genericClassParameters != null){
|
||||
return this.genericClassParameters.getEndOffset();
|
||||
}else{
|
||||
return this.offset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Super Klasse dieser Klasse.
|
||||
* @return null für Klasse Object
|
||||
*/
|
||||
public RefType getSuperClass(){
|
||||
return this.superClass;
|
||||
}
|
||||
@Override
|
||||
public boolean isClass() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isInterface(){
|
||||
return isInterface;
|
||||
}
|
||||
}
|
252
src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
Executable file
252
src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
Executable file
@ -0,0 +1,252 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.core.IItemWithOffset;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
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 JavaClassName name;
|
||||
private Block class_block;
|
||||
private List<Field> fielddecl = new ArrayList<>();
|
||||
private GenericDeclarationList genericClassParameters;
|
||||
private int offset;
|
||||
private RefType superClass;
|
||||
protected boolean isInterface;
|
||||
private List<RefType> implementedInterfaces;
|
||||
private List<Field> fields;
|
||||
|
||||
public ClassOrInterface(int offset) {
|
||||
super(offset);
|
||||
}
|
||||
|
||||
// Gets class name
|
||||
public JavaClassName getClassName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// TypeReconstructionAlgorithmus
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Ausgangspunkt f�r den Typrekonstruktionsalgorithmus. Hier werden zun�chst
|
||||
* die Mengen von Typannahmen V_fields_methods und V_i erstellt, die als Eingabe
|
||||
* f�r den Algorithmus dienen.<br/>
|
||||
* (siehe Algorithmus 5.17 TRProg, Martin Pl�micke)
|
||||
* <br/>Author: J�rg B�uerle
|
||||
*
|
||||
* @param supportData
|
||||
* @param globalAssumptions
|
||||
* @return Liste aller bisher berechneten, m�glichen Typkombinationen
|
||||
* @throws CTypeReconstructionException
|
||||
*/
|
||||
public ConstraintsSet typeReconstruction(TypeAssumptions globalAssumptions) {
|
||||
//////////////////////////////
|
||||
// Und los geht's:
|
||||
//////////////////////////////
|
||||
inferencelog.info("Rufe TRStart()...", Section.TYPEINFERENCE);
|
||||
|
||||
//////////////////////////////
|
||||
// Ab hier ...
|
||||
// @author A10023 - Andreas Stadelmeier:
|
||||
//////////////////////////////
|
||||
//Erzeuge Assumptions:
|
||||
TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
|
||||
//Globale Assumptions anfügen:
|
||||
assumptions.add(globalAssumptions);
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
|
||||
|
||||
typinferenzLog.debug("Erstellte Assumptions: " + assumptions, Section.TYPEINFERENCE);
|
||||
|
||||
//Gibt es hier eine ClassCastException stimmt etwas grundsätzlich nicht!
|
||||
//this.superClass = (RefType)this.superClass.TYPE(assumptions, this);
|
||||
|
||||
for (Field f : this.getFields()) {
|
||||
oderConstraints.add(f.TYPE(assumptions));
|
||||
}
|
||||
typinferenzLog.debug("Erstellte Constraints: " + oderConstraints, Section.TYPEINFERENCE);
|
||||
|
||||
return oderConstraints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
|
||||
* Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
|
||||
* @return Die erstellten TypeAssumptions
|
||||
*/
|
||||
private TypeAssumptions getPrivateFieldAssumptions() {
|
||||
if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
|
||||
TypeAssumptions assumptions = new TypeAssumptions(this.getName());
|
||||
|
||||
for(Field field : this.getFields()){
|
||||
if(!field.isPublic())assumptions.add(field.createTypeAssumptions(this));
|
||||
}
|
||||
|
||||
this.typeAssumptions = assumptions; //Diese müssen anschlieÃend nicht wieder generiert werden.
|
||||
return assumptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
* @return
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generiert den JavaCode dieser Klasse im Falle für das übergebene resultSet.
|
||||
* Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
|
||||
* @return Java-Sourcefile
|
||||
*/
|
||||
public JavaCodeResult printJavaCode(ResultSet reconstructionResult){
|
||||
JavaCodeResult ret = new JavaCodeResult("class ");
|
||||
|
||||
JavaCodeResult classBodyCode = new JavaCodeResult();
|
||||
if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult)).attach(" ");
|
||||
|
||||
classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult)).attach("\n");
|
||||
|
||||
JavaCodeResult bodyString = new JavaCodeResult("{\n");
|
||||
for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult) ).attach( "\n" );
|
||||
bodyString.attach("}\n");
|
||||
|
||||
classBodyCode.attach(bodyString);
|
||||
|
||||
//Zuerst die generischen Parameter für diese Klasse berechnen:
|
||||
//this.createGenericTypeVars(classBodyCode.getUnresolvedTPH());
|
||||
|
||||
if(this.genericClassParameters != null && this.genericClassParameters.size()>0){
|
||||
ret.attach("<");
|
||||
|
||||
Iterator<GenericTypeVar> it = this.genericClassParameters.iterator();
|
||||
while(it.hasNext()){
|
||||
GenericTypeVar tph = it.next();
|
||||
ret.attach(tph.printJavaCode(reconstructionResult));
|
||||
if(it.hasNext())ret.attach(", ");
|
||||
}
|
||||
ret.attach(">");
|
||||
}
|
||||
|
||||
String stringReturn = ret.attach(classBodyCode).toString();
|
||||
|
||||
return new JavaCodeResult(stringReturn);
|
||||
}
|
||||
|
||||
public int getOffset(){
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt einen RefType, welcher auf diese Klasse verweist
|
||||
* Ersetzt alle Generischen Variablen in der Parameterliste mit TPH
|
||||
* @return
|
||||
*/
|
||||
public RefType getType() {
|
||||
return new RefType(this.getName().toString(), this.get_ParaList(),this, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ermittelt die Sichtbaren Felder und Methoden der Klasse.
|
||||
* (Momentan sind im Projekt alle Felder und Methoden "package private", da der Parser keine Access-Modifier einlesen kann.
|
||||
* @return
|
||||
*/
|
||||
public TypeAssumptions getPublicFieldAssumptions() {
|
||||
TypeAssumptions ret = new TypeAssumptions();//this.getPrivateFieldAssumptions();
|
||||
ret.addClassAssumption(new ClassAssumption(this));
|
||||
for(Field f : this.getFields()){
|
||||
if(f.isPublic())ret.add(f.createTypeAssumptions(this));
|
||||
}
|
||||
for(GenericTypeVar gtv : this.getGenericParameter()){
|
||||
ret.add(gtv.createAssumptions());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(!(obj instanceof Class))return false;
|
||||
Class cl = (Class) obj;
|
||||
if(!(cl.getName().equals(this.getName())))return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericDeclarationList getGenericParameter() {
|
||||
return this.genericClassParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SyntaxTreeNode> getChildren() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
return "class "+this.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenericVarDeclarationString(String genericVarDeclaration) {
|
||||
if(this.genericClassParameters != null){
|
||||
return ", "+genericVarDeclaration;
|
||||
}else{
|
||||
return "<"+genericVarDeclaration+">";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGenericVarDeclarationOffset(){
|
||||
// Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||
if(this.genericClassParameters != null){
|
||||
return this.genericClassParameters.getEndOffset();
|
||||
}else{
|
||||
return this.offset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Super Klasse dieser Klasse.
|
||||
* @return null für Klasse Object
|
||||
*/
|
||||
public RefType getSuperClass(){
|
||||
return this.superClass;
|
||||
}
|
||||
@Override
|
||||
public boolean isClass() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isInterface(){
|
||||
return isInterface;
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.*;
|
||||
|
||||
@ -14,10 +11,7 @@ import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
@ -31,23 +25,38 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
|
||||
|
||||
public class SourceFile extends SyntaxTreeNode
|
||||
{
|
||||
|
||||
protected static Logger codegenlog = Logger.getLogger("codegen");
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
|
||||
private String pkgName;
|
||||
|
||||
public List<Class> KlassenVektor = new Menge<Class>();
|
||||
private List<JavaClassName> imports;
|
||||
public class SourceFile extends SyntaxTreeNode{
|
||||
|
||||
private String pkgName;
|
||||
|
||||
public List<ClassOrInterface> KlassenVektor = new ArrayList<>();
|
||||
private List<JavaClassName> imports;
|
||||
|
||||
/**
|
||||
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
|
||||
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
|
||||
*/
|
||||
public SourceFile(List<Class> classDefinitions) {
|
||||
public SourceFile(String pkgName,List<ClassOrInterface> classDefinitions,List<JavaClassName> imports){
|
||||
super(0);
|
||||
this.KlassenVektor = classDefinitions;
|
||||
if(pkgName != null){
|
||||
this.pkgName = pkgName;
|
||||
}
|
||||
if(imports != null){
|
||||
this.imports = imports;
|
||||
}
|
||||
}
|
||||
|
||||
public SourceFile(List<ClassOrInterface> classDefinitions){
|
||||
this(null, classDefinitions, null);
|
||||
}
|
||||
|
||||
public SourceFile(String pkgName, List<ClassOrInterface> classDefinitions){
|
||||
this(pkgName, classDefinitions, null);
|
||||
}
|
||||
|
||||
public SourceFile(List<ClassOrInterface> classDefinitions, List<JavaClassName> imports){
|
||||
this(null, classDefinitions, imports);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,4 +555,3 @@ public class SourceFile extends SyntaxTreeNode
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -2,6 +2,7 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
import java.util.Iterator;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
@ -10,27 +11,15 @@ import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.Typeable;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
|
||||
public abstract class Executeable extends SyntaxTreeNode implements Typeable
|
||||
public abstract class Executeable extends SyntaxTreeNode
|
||||
{
|
||||
private Type type;
|
||||
|
||||
public Executeable(Type type,int offset) {
|
||||
super(offset);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type getType(){
|
||||
return type;
|
||||
}
|
||||
|
||||
public Executeable(int offset) {
|
||||
super(offset); }
|
||||
|
||||
public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs);
|
||||
|
||||
//public abstract String getTypeInformation();
|
||||
}
|
||||
|
@ -1,29 +1,26 @@
|
||||
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.typeinference.Typeable;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
|
||||
public abstract class Expr extends Executeable
|
||||
public abstract class Expr extends Executeable implements Typeable
|
||||
{
|
||||
private RefType type;
|
||||
|
||||
public Expr(Type type, int offset) {
|
||||
super(type, offset);
|
||||
public Expr(RefType type, int offset) {
|
||||
super(offset);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public RefType getType(){
|
||||
return type;
|
||||
}
|
||||
|
||||
public abstract String get_Name();
|
||||
|
||||
/**
|
||||
|
@ -1,11 +1,6 @@
|
||||
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.bcel.generic.BranchInstruction;
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.GOTO;
|
||||
import org.apache.bcel.generic.IF_ICMPGE;
|
||||
import org.apache.bcel.generic.InstructionHandle;
|
||||
@ -15,25 +10,12 @@ import org.apache.bcel.generic.NOP;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.LogOp;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.Operator;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.RelOp;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
|
||||
public class ForStmt extends Statement
|
||||
{
|
||||
@ -48,53 +30,18 @@ public class ForStmt extends Statement
|
||||
|
||||
public ForStmt(int offset, int variableLength)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
|
||||
void sc_check(Menge<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "FOR ";
|
||||
}
|
||||
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
{
|
||||
if(body_Loop_block!=null){
|
||||
body_Loop_block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void set_head_Initializer(Expr expr) {
|
||||
head_Initializer = expr;
|
||||
|
||||
}
|
||||
|
||||
public void set_head_Condition(Expr expr) {
|
||||
head_Condition = expr;
|
||||
|
||||
}
|
||||
|
||||
public void set_head_Loop_expr(Expr expr) {
|
||||
head_Loop_expr = expr;
|
||||
|
||||
}
|
||||
|
||||
public void set_body_Loop_block(Statement statement) {
|
||||
body_Loop_block = statement;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
//TODO: TYPEStmt
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
this.setType(TypePlaceholder.fresh(this));
|
||||
|
||||
ret.add(body_Loop_block.TYPEStmt(assumptions));
|
||||
|
||||
|
@ -1,26 +1,12 @@
|
||||
// ino.module.LocalVarDecl.8638.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.LocalVarDecl.8638.import
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassHelper;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
@ -28,275 +14,37 @@ import de.dhbwstuttgart.typeinference.TypeInsertable;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.LocalVarAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.LocalVarDecl.25540.declaration
|
||||
public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
// ino.end
|
||||
// ino.class.LocalVarDecl.25540.body
|
||||
{
|
||||
// ino.method.LocalVarDecl.25545.definition
|
||||
public LocalVarDecl(int offset,int variableLength)
|
||||
// ino.end
|
||||
// ino.method.LocalVarDecl.25545.body
|
||||
public LocalVarDecl(RefType type, int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
this.type = type;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.declid.25548.declaration
|
||||
private Menge<DeclId> declid = new Menge<DeclId>();
|
||||
// ino.end
|
||||
// ino.attribute.paralist.25554.declaration
|
||||
private Menge paralist = null;
|
||||
// ino.end
|
||||
// ino.attribute.parahash.25557.declaration
|
||||
private Hashtable<String,Type> parahash = null;
|
||||
// ino.end
|
||||
// ino.attribute.inferencelog.25560.declaration
|
||||
|
||||
private String name;
|
||||
private RefType type;
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.25563.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
// ino.attribute.block.25566.declaration
|
||||
public Block block;
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_DeclId.25575.definition
|
||||
public void set_DeclId(DeclId did)
|
||||
// ino.end
|
||||
// ino.method.set_DeclId.25575.body
|
||||
{
|
||||
this.declid.addElement(did);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Name.25578.definition
|
||||
public String get_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Name.25578.body
|
||||
{
|
||||
DeclId hilf;
|
||||
hilf=declid.elementAt(0);
|
||||
return hilf.get_Name();
|
||||
return name;
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.set_ParaList.25581.definition
|
||||
public void set_ParaList(Menge pl)
|
||||
// ino.end
|
||||
// ino.method.set_ParaList.25581.body
|
||||
{
|
||||
this.paralist = pl;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
// ino.method.check_anz.25590.definition
|
||||
public void check_anz(Type type, Menge paralist, Menge<Class> classlist)
|
||||
throws SCStatementException
|
||||
// ino.end
|
||||
// ino.method.check_anz.25590.body
|
||||
{
|
||||
boolean flag = false;
|
||||
for(Enumeration<Class> e2 = classlist.elements();e2.hasMoreElements();){
|
||||
Class c = e2.nextElement();
|
||||
// System.out.println("vergleiche "+type.get_Type_()+" mit "+c.getName());
|
||||
if(c.getName().equals(type.getName())){
|
||||
// System.out.println("if(c.getName().equals(type.get_Type())){");
|
||||
if(c.get_ParaList().size()>0 && paralist!=null){
|
||||
|
||||
parserlog.debug("Type "+type.getName()+" in classlist gefunden!");
|
||||
parserlog.debug("Anzahl der localvar.paralist:"+ paralist.size()+" class.paralist: (soll) "+c.get_ParaList().size());
|
||||
if(paralist.size()==c.get_ParaList().size()){
|
||||
|
||||
for(Enumeration e3=paralist.elements();e3.hasMoreElements();){
|
||||
Type t = (Type)e3.nextElement();
|
||||
parserlog.debug("Type "+t.getName()+" wird gerade untersucht");
|
||||
|
||||
try
|
||||
{
|
||||
if ( t instanceof RefType )
|
||||
{
|
||||
check_anz(t, ((RefType)t).get_ParaList(),classlist);
|
||||
}
|
||||
}
|
||||
catch(SCStatementException ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
flag = true;
|
||||
parserlog.debug("flag gesetzt");
|
||||
break;
|
||||
}
|
||||
else{
|
||||
SCStatementException ex = new SCStatementException();
|
||||
SCExcept e = new SCExcept();
|
||||
e.set_error("Klasse "+c.getName()+" ist falsch parametrisiert!");
|
||||
e.set_function("complete_parahashtable() --> check_anz()");
|
||||
e.set_statement(type.getName().toString());
|
||||
ex.addException(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
else if(c.get_ParaList().size()==0 && paralist!=null){
|
||||
SCStatementException ex = new SCStatementException();
|
||||
SCExcept e = new SCExcept();
|
||||
e.set_error("Klasse "+c.getName()+" ist nicht parametrisierbar!");
|
||||
e.set_function("complete_parahashtable() --> check_anz()");
|
||||
e.set_statement(type.getName().toString());
|
||||
ex.addException(e);
|
||||
throw ex;
|
||||
}
|
||||
else if(paralist==null && c.get_ParaList().size()>0){
|
||||
parserlog.debug(paralist.toString());
|
||||
parserlog.debug(c.getName()+" "+c.get_ParaList().size());
|
||||
SCStatementException ex = new SCStatementException();
|
||||
SCExcept e = new SCExcept();
|
||||
e.set_error("Klasse "+c.getName()+" �berhaupt garnicht parametrisiert!");
|
||||
e.set_function("complete_parahashtable() --> check_anz()");
|
||||
e.set_statement(type.getName().toString());
|
||||
ex.addException(e);
|
||||
throw ex;
|
||||
|
||||
}
|
||||
else{
|
||||
flag = true;
|
||||
parserlog.debug(type.getName()+" nicht parametrisierbar");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!flag)
|
||||
{
|
||||
SCStatementException ex = new SCStatementException();
|
||||
SCExcept e = new SCExcept();
|
||||
if ( type instanceof RefType )
|
||||
{
|
||||
e.set_error("Type " + type.getName()+ " falsche Parameter-Anzahl " + ((RefType)type).get_ParaList().size());
|
||||
}
|
||||
e.set_function("complete_parahashtable() --> check_anz()");
|
||||
e.set_statement(type.getName().toString());
|
||||
ex.addException(e);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
*/
|
||||
|
||||
public Menge<DeclId> getDeclidMenge()
|
||||
// ino.end
|
||||
// ino.method.getDeclidMenge.25596.body
|
||||
{
|
||||
return declid;
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.setDeclidMenge.25599.definition
|
||||
public void setDeclidMenge(Menge<DeclId> declid)
|
||||
// ino.end
|
||||
// ino.method.setDeclidMenge.25599.body
|
||||
{
|
||||
this.declid = declid;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getLineNumber.25602.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: J�rg B�uerle
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.getLineNumber.25602.definition
|
||||
public int getLineNumber()
|
||||
// ino.end
|
||||
// ino.method.getLineNumber.25602.body
|
||||
{
|
||||
if(declid.size()<=0)
|
||||
return MyCompiler.NO_LINENUMBER;
|
||||
else{
|
||||
return declid.elementAt(0).getLineNumber();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getOffset.25605.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Thomas Hornberger
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.getOffset.25605.definition
|
||||
public int getOffset()
|
||||
// ino.end
|
||||
// ino.method.getOffset.25605.body
|
||||
{
|
||||
if(declid.size()<=0)
|
||||
return MyCompiler.NO_LINENUMBER;
|
||||
else{
|
||||
return declid.elementAt(0).getOffset();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.getTypeLineNumber.25611.defdescription type=javadoc
|
||||
/**
|
||||
* <br>Author: J�rg B�uerle
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.getTypeLineNumber.25611.definition
|
||||
public int getTypeLineNumber()
|
||||
// ino.end
|
||||
// ino.method.getTypeLineNumber.25611.body
|
||||
{
|
||||
return this.getLineNumber();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.toString.25617.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.toString.25617.definition
|
||||
public String toString()
|
||||
// ino.end
|
||||
// ino.method.toString.25617.body
|
||||
{
|
||||
if(this.getType() == null)return "no type " + declid.toString();
|
||||
return this.getType().toString() + " " + declid.toString();
|
||||
return this.getType().toString() + " " + get_Name();
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25620.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25620.body
|
||||
{
|
||||
|
||||
Type fpType=getType();
|
||||
// Nur wenn es sich um ein RefType-Field handelt
|
||||
Type pendantPara = null;
|
||||
if(fpType instanceof RefType)
|
||||
pendantPara = ((RefType)fpType).findGenericType(paralist, new Menge<GenericTypeVar>());
|
||||
//GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
|
||||
setType(pendantPara);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
/**
|
||||
@ -307,30 +55,14 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
if((this.getType() instanceof RefType)){
|
||||
Type replaceType = null;
|
||||
replaceType = assumptions.checkType((RefType)this.getType(), this);
|
||||
this.setType(replaceType);
|
||||
}
|
||||
assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird.
|
||||
//if(this.getType() == null)throw new DebugException("Parser Post Processing nicht aufgerufen");
|
||||
ret.add(ConstraintsSet.createSingleConstraint(this.getType().TYPE(assumptions, this), this.getType().TYPE(assumptions, this)));
|
||||
//assumptions.remove(null); // falls Variable mit diesem Namen bereits vorhanden.
|
||||
this.setReturnType(new Void(this,0)); //Return typ einer Variablendeklaration ist Void
|
||||
ret.add(ConstraintsSet.createSingleConstraint(this.getType(), this.getType());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(){
|
||||
if(this.getType() == null)return "no type " + declid.toString();
|
||||
if(this.getType() instanceof TypePlaceholder)return declid.toString();
|
||||
return this.getType().toString() + " " + declid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
if(this.getType()==null || this.getType() instanceof TypePlaceholder)this.setType(TypePlaceholder.fresh(this));
|
||||
return this.getType().toString() + " " + get_Name();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -348,11 +80,6 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
ret.attach(this.get_Name()+";");
|
||||
return ret;}
|
||||
|
||||
@Override
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return this.get_Name();
|
||||
@ -376,5 +103,9 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
_cg.getMethodGenerator().getStoreIndex(get_Name());
|
||||
return new InstructionList();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public RefType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -49,11 +49,11 @@ public class MethodCall extends Expr
|
||||
}
|
||||
|
||||
// ino.method.MethodCall.25627.definition
|
||||
public MethodCall(int offset, int variableLength)
|
||||
public MethodCall(int offset)
|
||||
// ino.end
|
||||
// ino.method.MethodCall.25627.body
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
@ -1,22 +1,11 @@
|
||||
// ino.module.NotExpr.8643.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.NotExpr.8643.import
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.OderConstraint;
|
||||
@ -26,95 +15,48 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.NotExpr.25873.declaration
|
||||
public class NotExpr extends UnaryExpr
|
||||
// ino.end
|
||||
// ino.class.NotExpr.25873.body
|
||||
{
|
||||
// ino.method.NotExpr.25877.definition
|
||||
public NotExpr(int offset,int variableLength)
|
||||
// ino.end
|
||||
// ino.method.NotExpr.25877.body
|
||||
public NotExpr(int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
// ino.end
|
||||
// ino.attribute.not.25880.declaration
|
||||
|
||||
private UnaryNot not;
|
||||
// ino.end
|
||||
// ino.attribute.expr.25883.declaration
|
||||
public Expr expr;
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.25886.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.get_Name.25892.definition
|
||||
|
||||
public String get_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Name.25892.body
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Expr.25895.definition
|
||||
public Expr get_Expr()
|
||||
// ino.end
|
||||
// ino.method.get_Expr.25895.body
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_UnaryNot.25898.definition
|
||||
public void set_UnaryNot(UnaryNot unot)
|
||||
// ino.end
|
||||
// ino.method.set_UnaryNot.25898.body
|
||||
{
|
||||
this.not = unot;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Expr.25901.definition
|
||||
public void set_Expr(Expr ex)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.25901.body
|
||||
{
|
||||
this.expr = ex;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
public void if_codegen(ClassFile classfile, Code_attribute code, boolean sw) throws JVMCodeException {
|
||||
if(expr instanceof NotExpr) if_codegen(classfile, code, !sw);
|
||||
else {
|
||||
expr.codegen(classfile, code);
|
||||
not.if_codegen(classfile, code, sw);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25916.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25916.body
|
||||
{
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
OderConstraint constraint = new OderConstraint();
|
||||
constraint.addConstraint(this.getType().TYPE(assumptions, this), new RefType("Boolean",this,-1).TYPE(assumptions, this));
|
||||
expr.TYPEExpr(assumptions);
|
||||
constraint.addConstraint(expr.getType(), assumptions.getBooleanType());
|
||||
ret.add(constraint);
|
||||
return ret;
|
||||
}
|
||||
@ -139,4 +81,3 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,102 +1,27 @@
|
||||
// ino.module.PositivExpr.8645.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.PositivExpr.8645.import
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.PositivExpr.25947.declaration
|
||||
public class PositivExpr extends UnaryExpr
|
||||
// ino.end
|
||||
// ino.class.PositivExpr.25947.body
|
||||
{
|
||||
// ino.method.PositivExpr.25951.definition
|
||||
public PositivExpr(int offset,int variableLength)
|
||||
// ino.end
|
||||
// ino.method.PositivExpr.25951.body
|
||||
public PositivExpr(int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
// ino.end
|
||||
// ino.attribute.plus.25954.declaration
|
||||
protected UnaryPlus plus;
|
||||
// ino.end
|
||||
// ino.attribute.expr.25957.declaration
|
||||
public Expr expr;
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.25960.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.set_UnaryPlus.25963.definition
|
||||
public void set_UnaryPlus(UnaryPlus up)
|
||||
// ino.end
|
||||
// ino.method.set_UnaryPlus.25963.body
|
||||
{
|
||||
this.plus = up;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Expr.25966.definition
|
||||
public void set_Expr(Expr ex)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.25966.body
|
||||
{
|
||||
this.expr = ex;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Name.25969.definition
|
||||
public String get_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Name.25969.body
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
// ino.method.sc_check.25972.definition
|
||||
public void sc_check(Menge<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
||||
// ino.end
|
||||
// ino.method.sc_check.25972.body
|
||||
{
|
||||
if(ext)
|
||||
parserlog.debug(" ---PositivExpr---");
|
||||
//Wartet noch auf Implementierung
|
||||
}
|
||||
// ino.end
|
||||
*/
|
||||
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25984.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.25984.body
|
||||
{
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
@ -105,7 +30,7 @@ public class PositivExpr extends UnaryExpr
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@ -124,4 +49,3 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,9 +1,5 @@
|
||||
// ino.module.PreDecExpr.8648.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.PreDecExpr.8648.import
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
@ -13,10 +9,7 @@ import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
@ -47,33 +40,11 @@ public class PreDecExpr extends UnaryExpr
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.set_Expr.26068.definition
|
||||
public void set_Expr(Expr ex)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.26068.body
|
||||
{
|
||||
this.expr = ex;
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.get_Name.26071.definition
|
||||
|
||||
public String get_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Name.26071.body
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26086.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26086.body
|
||||
{
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
|
@ -1,22 +1,11 @@
|
||||
// ino.module.PreIncExpr.8649.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.PreIncExpr.8649.import
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
@ -29,34 +18,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
|
||||
|
||||
// ino.class.PreIncExpr.26089.declaration
|
||||
public class PreIncExpr extends UnaryExpr
|
||||
// ino.end
|
||||
// ino.class.PreIncExpr.26089.body
|
||||
{
|
||||
// ino.method.PreIncExpr.26093.definition
|
||||
public PreIncExpr(int offset,int variableLength)
|
||||
// ino.end
|
||||
// ino.method.PreIncExpr.26093.body
|
||||
public PreIncExpr(int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.26099.declaration
|
||||
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.method.set_Expr.26102.definition
|
||||
public void set_Expr(Expr ex)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.26102.body
|
||||
{
|
||||
this.expr = ex;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.get_Name.26105.definition
|
||||
public String get_Name()
|
||||
|
@ -1,9 +1,5 @@
|
||||
// ino.module.Receiver.8650.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.Receiver.8650.import
|
||||
import java.util.Hashtable;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
@ -16,87 +12,37 @@ import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.Receiver.26123.declaration
|
||||
public class Receiver
|
||||
// ino.end
|
||||
// ino.class.Receiver.26123.body
|
||||
{
|
||||
// ino.attribute.expr.26126.declaration
|
||||
private Expr expr;
|
||||
private TypeAssumptions typeAssumptions;
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.26129.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
// ino.method.Receiver.26132.defdescription type=javadoc
|
||||
/**
|
||||
* Autor: J�rg B�uerle
|
||||
* @param expr
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.Receiver.26132.definition
|
||||
public Receiver(Expr expr)
|
||||
// ino.end
|
||||
// ino.method.Receiver.26132.body
|
||||
{
|
||||
this.expr = expr;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Type.26138.definition
|
||||
public String get_Type()
|
||||
// ino.end
|
||||
// ino.method.get_Type.26138.body
|
||||
{
|
||||
return expr.getTypeName();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Expr.26141.definition
|
||||
public void set_Expr(Expr express)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.26141.body
|
||||
{
|
||||
expr=express;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Expr.26144.definition
|
||||
public Expr get_Expr()
|
||||
// ino.end
|
||||
// ino.method.get_Expr.26144.body
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.toString.26147.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.toString.26147.definition
|
||||
public String toString()
|
||||
// ino.end
|
||||
// ino.method.toString.26147.body
|
||||
{
|
||||
return expr.toString();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
public void setClass(Class cl){
|
||||
this.receiverClass = cl;
|
||||
}
|
||||
*/
|
||||
|
||||
public Class getReceiverClass(ClassGenerator cg, TypeinferenceResultSet rs){
|
||||
de.dhbwstuttgart.syntaxtree.type.Type receiverType = this.get_Expr().getType();
|
||||
RefType receiverType = this.get_Expr().getType();
|
||||
if(receiverType instanceof TypePlaceholder){
|
||||
receiverType = rs.getTypeOfPlaceholder((TypePlaceholder)receiverType);
|
||||
}
|
||||
@ -124,4 +70,3 @@ public class Receiver
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,42 +1,20 @@
|
||||
// ino.module.Statement.8652.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.ConstantPoolGen;
|
||||
import org.apache.bcel.generic.InstructionFactory;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.core.IItemWithOffset;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.Typeable;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
|
||||
|
||||
|
||||
public abstract class Statement extends Executeable
|
||||
{
|
||||
|
||||
|
||||
public Statement(Type type,int offset)
|
||||
public Statement(int offset)
|
||||
{
|
||||
super(type,offset);
|
||||
super(offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author AI10023 - Andreas Stadelmeier
|
||||
* Implementierung des Java 8 - Typinferenzalgorithmus von Martin Plümicke
|
||||
@ -58,14 +36,6 @@ public abstract class Statement extends Executeable
|
||||
public String getDescription(){
|
||||
return this.printJavaCode(new ResultSet(new Menge<Pair>())).toString();
|
||||
}
|
||||
|
||||
public void setReturnType(Type t){
|
||||
}
|
||||
|
||||
public Type getReturnType(){
|
||||
return new de.dhbwstuttgart.syntaxtree.type.Void(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
// ino.module.This.8654.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.This.8654.import
|
||||
import java.util.Hashtable;
|
||||
// ino.module.This.8654.import
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionFactory;
|
||||
import org.apache.bcel.generic.InstructionHandle;
|
||||
@ -17,10 +19,6 @@ import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
@ -33,104 +31,26 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
|
||||
// ino.class.This.26261.declaration
|
||||
public class This extends Expr
|
||||
// ino.end
|
||||
// ino.class.This.26261.body
|
||||
{
|
||||
// ino.method.This.26265.definition
|
||||
public This(int offset,int variableLength)
|
||||
// ino.end
|
||||
// ino.method.This.26265.body
|
||||
public This(RefType type, int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(type, offset);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
public This(SyntaxTreeNode parent){
|
||||
this(0,0);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
// ino.attribute.arglist.26268.declaration
|
||||
public ArgumentList arglist;
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.parserlog.26271.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.set_ArgumentList.26274.definition
|
||||
public void set_ArgumentList(ArgumentList al)
|
||||
// ino.end
|
||||
// ino.method.set_ArgumentList.26274.body
|
||||
{
|
||||
this.arglist = al;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
public ArgumentList getArgumentList()
|
||||
{
|
||||
return this.arglist;
|
||||
}
|
||||
|
||||
// ino.method.set_UsedId.26277.definition
|
||||
public void set_UsedId(UsedId ui)
|
||||
// ino.end
|
||||
// ino.method.set_UsedId.26277.body
|
||||
{
|
||||
this.usedid = ui;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
// ino.method.sc_check.26280.definition
|
||||
public void sc_check(Menge<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
||||
throws SCStatementException
|
||||
// ino.end
|
||||
// ino.method.sc_check.26280.body
|
||||
{
|
||||
if(ext)
|
||||
parserlog.debug(" ---This---");
|
||||
}
|
||||
// ino.end
|
||||
*/
|
||||
|
||||
// ino.method.get_Name.26286.definition
|
||||
public String get_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Name.26286.body
|
||||
{ return null; }
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26295.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26295.body
|
||||
{
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//this.set_Type(new);
|
||||
//this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen.
|
||||
this.setType(this.getParentClass().getType());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
throw new TypeinferenceException("this ist keine Anweisung", this);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
// ino.end
|
||||
// ino.method.toString.25738.body
|
||||
{
|
||||
//return receiver/*.toString()*/ + " " + usedid.toString();
|
||||
return type + " (" + "this" +"(" + this.getArgumentList() + "))";
|
||||
return "this";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,9 +21,9 @@ public abstract class UnaryExpr extends MethodCall
|
||||
{
|
||||
public Expr expr;
|
||||
|
||||
public UnaryExpr(int offset,int variableLength)
|
||||
public UnaryExpr(int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
// ino.module.WhileStmt.8659.package
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.end
|
||||
// ino.module.WhileStmt.8659.import
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
@ -18,12 +17,7 @@ import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.LogOp;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.Operator;
|
||||
import de.dhbwstuttgart.syntaxtree.operator.RelOp;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
@ -32,90 +26,38 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.UndConstraint;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.class.WhileStmt.26326.declaration
|
||||
public class WhileStmt extends Statement
|
||||
// ino.end
|
||||
// ino.class.WhileStmt.26326.body
|
||||
{
|
||||
// ino.method.WhileStmt.26330.definition
|
||||
public WhileStmt(int offset, int variableLength)
|
||||
// ino.end
|
||||
// ino.method.WhileStmt.26330.body
|
||||
public WhileStmt(Expr boolExpr, Statement loop_block,int offset)
|
||||
{
|
||||
super(offset,variableLength);
|
||||
super(offset);
|
||||
expr = boolExpr;
|
||||
this.loop_block = loop_block;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.expr.26333.declaration
|
||||
public Expr expr;
|
||||
// ino.end
|
||||
// ino.attribute.loop_block.26336.declaration
|
||||
public Statement loop_block;
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.parserlog.26339.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Expr.26342.definition
|
||||
public void set_Expr(Expr exp)
|
||||
// ino.end
|
||||
// ino.method.set_Expr.26342.body
|
||||
{
|
||||
this.expr = exp;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Loop_block.26345.definition
|
||||
public void set_Loop_block(Statement blk)
|
||||
// ino.end
|
||||
// ino.method.set_Loop_block.26345.body
|
||||
{
|
||||
this.loop_block = blk;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.toString.26360.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Martin Pl�micke
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.toString.26360.definition
|
||||
public String toString()
|
||||
// ino.end
|
||||
// ino.method.toString.26360.body
|
||||
{
|
||||
return "WHILE " + loop_block.toString();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26363.definition
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.wandleRefTypeAttributes2GenericAttributes.26363.body
|
||||
{
|
||||
if(loop_block!=null){
|
||||
loop_block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
ret.add(expr.TYPEExpr(assumptions));
|
||||
UndConstraint exprMustBeBool = ConstraintsSet.createSingleConstraint(expr.getType().TYPE(assumptions, this), new RefType("Boolean",this, 0).TYPE(assumptions, this)); // while(expr){}; expr <. boolean
|
||||
UndConstraint exprMustBeBool = ConstraintsSet.createSingleConstraint(expr.getType(), assumptions.getBooleanType()); // while(expr){}; expr <. boolean
|
||||
ret.add(exprMustBeBool);
|
||||
ret.add(this.loop_block.TYPEStmt(assumptions));
|
||||
this.setType(loop_block.getType());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Stellt eine Wildcard mit oberer Grenze dar.
|
||||
@ -16,7 +18,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
*
|
||||
*/
|
||||
|
||||
public class ExtendsWildcardType extends WildcardType implements ITypeContainer, IMatchable{
|
||||
public class ExtendsWildcardType extends WildcardType {
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
@ -28,7 +30,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
this.name = new JavaClassName(this.toString());
|
||||
}
|
||||
|
||||
public ExtendsWildcardType(ObjectType extendsType) {
|
||||
public ExtendsWildcardType(RefType extendsType) {
|
||||
this(extendsType.getOffset(),extendsType);
|
||||
}
|
||||
|
||||
@ -38,7 +40,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
* Beispiel: ? extends Integer.
|
||||
* Integer wird zurückgegeben.
|
||||
*/
|
||||
public ObjectType get_ExtendsType()
|
||||
public RefType get_ExtendsType()
|
||||
{
|
||||
return this.innerType;
|
||||
}
|
||||
@ -85,7 +87,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
* Das gleiche wie get_ExtendsType().
|
||||
* Ãberschreibt die Methode der Superklasse.
|
||||
*/
|
||||
public Type GetWildcardType()
|
||||
public RefType GetWildcardType()
|
||||
{
|
||||
return this.get_ExtendsType();
|
||||
}
|
||||
@ -95,7 +97,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
* Setzt den Typ in der Wildcard
|
||||
* @param T - Type to be set
|
||||
*/
|
||||
public void SetWildcardType(ObjectType T)
|
||||
public void SetWildcardType(RefType T)
|
||||
{
|
||||
//if(T instanceof RefType)
|
||||
this.innerType = (RefType)T;
|
||||
@ -106,7 +108,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
* Das gleiche wie get_ExtendsType().
|
||||
* Implementiert ITypeContainer
|
||||
*/
|
||||
public ObjectType getContainedType()
|
||||
public RefType getContainedType()
|
||||
{
|
||||
return this.get_ExtendsType();
|
||||
}
|
||||
@ -116,7 +118,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
|
||||
* Wird über IMatchable implementiert.
|
||||
*/
|
||||
public ObjectType getMatchType()
|
||||
public RefType getMatchType()
|
||||
{
|
||||
return this.get_ExtendsType();
|
||||
}
|
||||
@ -127,8 +129,8 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
public List<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
List<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
|
||||
return ret;
|
||||
}
|
||||
@ -138,24 +140,12 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
super.parserPostProcessing(parent);
|
||||
this.innerType.parserPostProcessing(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
|
||||
//Folgender TypeCast ist sicher. Wird ein ObjectType in einen ConstraintType umgewandelt und wieder zurück, kann kein Fehler auftreten.
|
||||
this.innerType = (ObjectType) this.innerType.TYPE(ass, parent);
|
||||
return super.TYPE(ass, parent);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg) {
|
||||
return new de.dhbwstuttgart.bytecode.WildcardType(this.innerType.get_Name(), "+");
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
|
||||
/*
|
||||
public String get_Name() {
|
||||
return "? extends "+this.innerType.get_Name();
|
||||
return "? extends "+this.innerType.getName();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.logger.*;
|
||||
@ -31,12 +32,6 @@ public class TypePlaceholder extends RefType
|
||||
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
|
||||
private SyntaxTreeNode parent;
|
||||
|
||||
|
||||
@Override
|
||||
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Privater Konstruktor - Eine TypePlaceholder-Variable wird �ber die
|
||||
* Factory-Methode <code>fresh()</code> erzeugt.
|
||||
@ -237,9 +232,9 @@ public class TypePlaceholder extends RefType
|
||||
}
|
||||
|
||||
@Override
|
||||
public Menge<TypePlaceholder> getUnresolvedTPH(ResultSet resultSet) {
|
||||
Menge<TypePlaceholder> ret = super.getUnresolvedTPH(resultSet);
|
||||
Type t = resultSet.getTypeEqualTo(this);
|
||||
public List<TypePlaceholder> getUnresolvedTPH(ResultSet resultSet) {
|
||||
List<TypePlaceholder> ret = super.getUnresolvedTPH(resultSet);
|
||||
RefType t = resultSet.getTypeEqualTo(this);
|
||||
if(t instanceof TypePlaceholder){
|
||||
ret.add((TypePlaceholder)t);
|
||||
}
|
||||
@ -248,7 +243,7 @@ public class TypePlaceholder extends RefType
|
||||
|
||||
@Override
|
||||
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||
Type resolvedType = rs.getTypeOfPlaceholder(this);
|
||||
RefType resolvedType = rs.getTypeOfPlaceholder(this);
|
||||
if(resolvedType instanceof TypePlaceholder){
|
||||
return DHBWInstructionFactory.createObjectType();
|
||||
}
|
||||
@ -261,7 +256,7 @@ public class TypePlaceholder extends RefType
|
||||
System.out.println("");
|
||||
return null;
|
||||
}
|
||||
Type resolvedType = rs.getTypeOfPlaceholder(this);
|
||||
RefType resolvedType = rs.getTypeOfPlaceholder(this);
|
||||
if(resolvedType instanceof TypePlaceholder){
|
||||
cg.addUsedTPH((TypePlaceholder)resolvedType);
|
||||
return new TypePlaceholderType((TypePlaceholder)resolvedType).getSignature();
|
||||
@ -269,23 +264,4 @@ public class TypePlaceholder extends RefType
|
||||
return resolvedType.getBytecodeSignature(cg, rs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||
//Die Signaturen in der Klasse bauen sich für Generische Variabeln (also TPHs) folgendermaßen auf: "GVAR:SuperClass"
|
||||
String ret = this.get_Name();//this.getBytecodeSignature(cg);
|
||||
//ret = ret.substring(1, ret.length()-1) + ":"; //";" mit ":" ersetzen
|
||||
ret+=":";
|
||||
Menge<TypePlaceholder> possibleTPHs = cg.getUsedTPH();
|
||||
possibleTPHs.remove(this);
|
||||
//TODO: hier komplett überarbeiten. Wann wird ein TPH eine generische Variable, das sollte geklärt werden.
|
||||
org.apache.bcel.generic.Type nearestType = null;//cg.getNearestUsedType(this, possibleTPHs);
|
||||
//if(nearestType instanceof TypePlaceholderType){ //Handelt es sich um einen weiteren TPH als nächsten Typ, so ist es ein allgemeiner Typ und wir nehmen Object als Superklasse
|
||||
if(nearestType == null){
|
||||
ret += cg.getInstructionFactory().createObjectType().getSignature();
|
||||
}else{
|
||||
ret += nearestType.getSignature();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,12 +56,6 @@ public abstract class WildcardType extends RefType{
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
|
||||
this.innerType = innerType.TYPE(ass, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@ -84,10 +78,5 @@ public abstract class WildcardType extends RefType{
|
||||
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||
return this.innerType.getBytecodeSignature(cg, rs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaClassName getName() {
|
||||
return new JavaClassName(this.get_Name());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,19 +7,13 @@ import java.util.List;
|
||||
* Stellt den Namen einer Java Klasse dar.
|
||||
* Dieser kann auch den Packagenamen mit beinhalten: de.dhbwstuttgart.typeinference.Menge
|
||||
*
|
||||
* @author janulrich
|
||||
*
|
||||
*
|
||||
* @author Andreas Stadelmeier
|
||||
*/
|
||||
public class JavaClassName {
|
||||
|
||||
private String name;
|
||||
private PackageName packageName;
|
||||
|
||||
/**
|
||||
* TODO: JavaClassName sollten aus den Assumptions generiert werden.
|
||||
* Diese wissen, welche Typen und Typnamen existieren und können direkt auf Korrektheit prüfen.
|
||||
*/
|
||||
|
||||
public JavaClassName(String name){
|
||||
if(name == null)throw new NullPointerException();
|
||||
|
||||
@ -38,15 +32,14 @@ public class JavaClassName {
|
||||
this.name = names[names.length-1];
|
||||
}
|
||||
}
|
||||
|
||||
//Auto-generated hashCode:
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
//result = prime * result
|
||||
// + ((packageName == null) ? 0 : packageName.hashCode()); //PackageName does not infect hashCode
|
||||
result = prime * result
|
||||
+ ((packageName == null) ? 0 : packageName.hashCode()); //PackageName does not infect hashCode
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.logger.*;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus;
|
||||
@ -87,7 +88,7 @@ public class ConstraintsSet extends UndMenge<Pair> implements Iterable<OderConst
|
||||
return this.constraintsSet;
|
||||
}
|
||||
|
||||
public static UndConstraint createSingleConstraint(Type t1, Type t2){
|
||||
public static UndConstraint createSingleConstraint(RefType t1, RefType t2){
|
||||
UndConstraint ret = new UndConstraint();
|
||||
ret.addConstraint(t1, t2);
|
||||
return ret;
|
||||
|
@ -50,7 +50,7 @@ public class OderConstraint extends OderMenge<Pair>{
|
||||
* @param p1
|
||||
* @param p2
|
||||
*/
|
||||
public void addConstraint(Type p1, Type p2){
|
||||
public void addConstraint(RefType p1, RefType p2){
|
||||
addConstraint(new Pair(p1,p2));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus;
|
||||
@ -31,7 +32,7 @@ public class UndConstraint extends UndMenge<Pair> {
|
||||
return ret.iterator().next();
|
||||
}
|
||||
|
||||
public void addConstraint(Type type, Type rT) {
|
||||
public void addConstraint(RefType type, RefType rT) {
|
||||
Pair p = new Pair(type, rT);
|
||||
addConstraint(p);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package de.dhbwstuttgart.typeinference.assumptions;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.TypeInsertable;
|
||||
|
||||
public class Assumption {
|
||||
@ -18,7 +18,7 @@ public class Assumption {
|
||||
this.typable = ass;
|
||||
}
|
||||
|
||||
public Type getAssumedType() {
|
||||
public RefType getAssumedType() {
|
||||
return this.typable.getType();
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
package de.dhbwstuttgart.typeinference.assumptions;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
|
||||
public class LocalVarAssumption extends Assumption {
|
||||
private LocalVarDecl localVar;
|
||||
private Type type;
|
||||
private RefType type;
|
||||
|
||||
public LocalVarAssumption(LocalVarDecl localVar, Type declaredType){
|
||||
public LocalVarAssumption(LocalVarDecl localVar, RefType declaredType){
|
||||
super(localVar);
|
||||
this.localVar = localVar;
|
||||
this.type = declaredType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getAssumedType() {
|
||||
public RefType getAssumedType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,10 @@ public class TypeAssumptions {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RefType getBooleanType() {
|
||||
return new RefType("java.lang.Boolean",-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft einen Typ auf das vorhandensein in den BasicAssumptions.
|
||||
* Dabei werden alle Konstruktoren nach diesem Typ durchsucht. Denn jede Klasse hat einen Konstruktor und der muss in den TypeAssumptions vorhanden sein.
|
||||
|
Loading…
Reference in New Issue
Block a user