Merge branch 'bigRefactoring' into strucTypes_dev2

This commit is contained in:
JanUlrich 2017-03-22 16:22:20 +01:00
commit 2c7f4770a3
99 changed files with 900 additions and 609 deletions

View File

@ -109,7 +109,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.GenericTypeVar</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.GenericRefType</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.GenericTypeVar</li>
@ -174,7 +174,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.htm
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.GenericTypeVar">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.GenericRefType">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.type.<a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.html" title="class in de.dhbwstuttgart.syntaxtree.type">GenericTypeVar</a></h3>
@ -265,7 +265,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.htm
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.GenericTypeVar">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.GenericRefType">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.type.<a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.html" title="class in de.dhbwstuttgart.syntaxtree.type">GenericTypeVar</a></h3>

View File

@ -109,7 +109,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.type.GenericTypeVar</li>
<li>de.dhbwstuttgart.syntaxtree.type.GenericRefType</li>
</ul>
</li>
</ul>

View File

@ -109,7 +109,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.type.Void</li>
@ -219,7 +219,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" titl
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.type.<a href="../../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">RefType</a></h3>

View File

@ -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.type.GenericTypeVar</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.type.GenericRefType</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.type.GenericTypeVar" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.type.GenericTypeVar</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.type.GenericRefType" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.type.GenericTypeVar</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.type.RefTypeOrTPH</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric</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.type.RefTypeOrTPH" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.type.RefType</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.type.RefType</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.UndMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li><a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.constraints.UndMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.ConstraintsSet</li>
@ -148,7 +148,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="c
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">UndMenge</a></h3>
@ -213,7 +213,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="c
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">UndMenge</a></h3>

View File

@ -109,7 +109,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH</a></li>
<li><a href="../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.FunN</li>
@ -245,7 +245,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.type.<a href="../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="class in de.dhbwstuttgart.syntaxtree.type">RefType</a></h3>

View File

@ -100,10 +100,10 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.OderMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li><a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.constraints.OderMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.OderConstraint</li>
<li>de.dhbwstuttgart.typeinference.constraints.OderConstraint</li>
</ul>
</li>
</ul>
@ -144,7 +144,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.OderMenge">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.OderMenge">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="class in de.dhbwstuttgart.typeinference">OderMenge</a></h3>
@ -214,7 +214,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.OderMenge">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.OderMenge">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="class in de.dhbwstuttgart.typeinference">OderMenge</a></h3>

View File

@ -103,7 +103,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Enum&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.PairOperator.html" title="enum in de.dhbwstuttgart.typeinference">Pair.PairOperator</a>&gt;</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.Pair.PairOperator</li>
<li>de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator</li>
</ul>
</li>
</ul>

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.Pair</li>
<li>de.dhbwstuttgart.typeinference.constraints.Pair</li>
</ul>
</li>
</ul>
@ -381,7 +381,7 @@ extends java.lang.Object</pre>
<a href="../../../de/dhbwstuttgart/syntaxtree/type/Type.html" title="class in de.dhbwstuttgart.syntaxtree.type">Type</a>&nbsp;TA2)</pre>
</li>
</ul>
<a name="Pair-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.typeinference.Pair.PairOperator-">
<a name="Pair-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator-">
<!-- -->
</a>
<ul class="blockList">
@ -392,7 +392,7 @@ extends java.lang.Object</pre>
<a href="../../../de/dhbwstuttgart/typeinference/Pair.PairOperator.html" title="enum in de.dhbwstuttgart.typeinference">Pair.PairOperator</a>&nbsp;eOp)</pre>
</li>
</ul>
<a name="Pair-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.typeinference.Pair.PairOperator-boolean-">
<a name="Pair-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.syntaxtree.type.Type-de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator-boolean-">
<!-- -->
</a>
<ul class="blockListLast">
@ -560,7 +560,7 @@ extends java.lang.Object</pre>
Gibt den Operator zurück.</div>
</li>
</ul>
<a name="SetOperator-de.dhbwstuttgart.typeinference.Pair.PairOperator-">
<a name="SetOperator-de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator-">
<!-- -->
</a>
<ul class="blockList">

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../de/dhbwstuttgart/typeinference/EinzelElement.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.EinzelElement</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li><a href="../../../de/dhbwstuttgart/typeinference/EinzelElement.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.constraints.EinzelElement</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.SingleConstraint</li>
@ -178,7 +178,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/EinzelElement.html" tit
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.EinzelElement">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.EinzelElement">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/EinzelElement.html" title="class in de.dhbwstuttgart.typeinference">EinzelElement</a></h3>

View File

@ -75,7 +75,7 @@ var activeTableTab = "activeTableTab";
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
@ -100,10 +100,10 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.UndMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li><a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.constraints.UndMenge</a>&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.UndConstraint</li>
<li>de.dhbwstuttgart.typeinference.constraints.UndConstraint</li>
</ul>
</li>
</ul>
@ -139,7 +139,7 @@ implements java.lang.Iterable&lt;<a href="../../../de/dhbwstuttgart/typeinferenc
</a>
<h3>Field Summary</h3>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">
<li class="blockList"><a name="fields.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">
<!-- -->
</a>
<h3>Fields inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">UndMenge</a></h3>
@ -199,7 +199,7 @@ implements java.lang.Iterable&lt;<a href="../../../de/dhbwstuttgart/typeinferenc
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">UndMenge</a></h3>
@ -359,7 +359,7 @@ implements java.lang.Iterable&lt;<a href="../../../de/dhbwstuttgart/typeinferenc
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#fields.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">Field</a>&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>

View File

@ -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.typeinference.EinzelElement</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.EinzelElement</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.typeinference.EinzelElement" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.EinzelElement</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.EinzelElement" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.EinzelElement</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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 Interface de.dhbwstuttgart.typeinference.KomplexeMenge</title>
<title>Uses of Interface de.dhbwstuttgart.typeinference.constraints.KomplexeMenge</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 Interface de.dhbwstuttgart.typeinference.KomplexeMenge" class="title">Uses of Interface<br>de.dhbwstuttgart.typeinference.KomplexeMenge</h2>
<h2 title="Uses of Interface de.dhbwstuttgart.typeinference.constraints.KomplexeMenge" class="title">Uses of Interface<br>de.dhbwstuttgart.typeinference.KomplexeMenge</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.typeinference.OderConstraint</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.OderConstraint</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,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.OderConstraint" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.OderConstraint</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.OderConstraint" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.OderConstraint</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.typeinference.OderConstraint</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.typeinference.constraints.OderConstraint</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -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.typeinference.OderMenge</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.OderMenge</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.typeinference.OderMenge" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.OderMenge</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.OderMenge" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.OderMenge</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.typeinference.Pair.PairOperator</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator</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>
@ -12,13 +12,12 @@
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class de.dhbwstuttgart.typeinference.Pair.PairOperator";
parent.document.title="Uses of Class de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator";
}
}
catch(err) {
}
//-->
</script>
//--></script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
@ -70,7 +69,7 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.Pair.PairOperator" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.Pair.PairOperator</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.Pair.PairOperator</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.typeinference.Pair</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.Pair</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.typeinference.Pair" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.Pair</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.Pair" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.Pair</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.typeinference.UndConstraint</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.UndConstraint</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.typeinference.UndConstraint" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.UndConstraint</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.UndConstraint" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.UndConstraint</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -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.typeinference.UndMenge</title>
<title>Uses of Class de.dhbwstuttgart.typeinference.constraints.UndMenge</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.typeinference.UndMenge" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.UndMenge</h2>
<h2 title="Uses of Class de.dhbwstuttgart.typeinference.constraints.UndMenge" class="title">Uses of Class<br>de.dhbwstuttgart.typeinference.UndMenge</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.UndMenge</a>&lt;<a href="../../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li><a href="../../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.constraints.UndMenge</a>&lt;<a href="../../../../de/dhbwstuttgart/typeinference/Pair.html" title="class in de.dhbwstuttgart.typeinference">Pair</a>&gt;</li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.ConstraintsSet</a></li>
@ -173,7 +173,7 @@ extends <a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html"
<code><a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html#add-de.dhbwstuttgart.typeinference.ConstraintsSet-">add</a>, <a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html#add-de.dhbwstuttgart.typeinference.KomplexeMenge-">add</a>, <a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html#filterWrongConstraints-de.dhbwstuttgart.typeinference.unify.Unifier-">filterWrongConstraints</a>, <a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html#unifyUndConstraints-de.dhbwstuttgart.typeinference.unify.Unifier-">unifyUndConstraints</a></code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.UndMenge">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.typeinference.constraints.UndMenge">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.typeinference.<a href="../../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="class in de.dhbwstuttgart.typeinference">UndMenge</a></h3>

View File

@ -1,15 +1,21 @@
package de.dhbwstuttgart.core;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class JavaTXCompiler {
@ -17,10 +23,26 @@ public class JavaTXCompiler {
public void typeInference(){
ConstraintSet cons = new ConstraintSet();
List<ClassOrInterface> allClasses = new ArrayList<>();
for(SourceFile sf : sourceFiles){
allClasses.addAll(sf.getClasses());
}
FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses);
for(SourceFile sf : sourceFiles){
cons.addAll(sf.getConstraints(sf.getTypeInferenceInformation(sourceFiles)));
}
System.out.println(cons);
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
TypeUnify unify = new TypeUnify();
for(List<Constraint<UnifyPair>> xCons : unifyCons.cartesianProduct()){
Set<UnifyPair> xConsSet = new HashSet<>();
for(Constraint<UnifyPair> constraint : xCons){
xConsSet.addAll(constraint);
}
Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
System.out.println(result);
}
}
public void parse(File sourceFile) throws IOException, ClassNotFoundException {

View File

@ -31,7 +31,8 @@ public class JavaTXParser {
for(Class cl : PackageCrawler.getClassesInPackage("java.lang")){
ret.add(cl.getName());
}
//TODO: Wieso muss man das händisch anhängen?
ret.add("java.lang.Object");
return ret;
}
}

View File

@ -0,0 +1,7 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import java.util.HashSet;
public class GenericsRegistry extends HashSet<String> {
}

View File

@ -8,9 +8,8 @@ import de.dhbwstuttgart.syntaxtree.operator.OrOp;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.*;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.TerminalNode;
@ -26,20 +25,25 @@ public class StatementGenerator {
private JavaClassRegistry reg;
private Set<String> localVars = new HashSet<>();
private GenericsRegistry generics;
public StatementGenerator(JavaClassRegistry reg){
public StatementGenerator(JavaClassRegistry reg, GenericsRegistry generics){
this.reg = reg;
this.generics = generics;
}
public Method convert(Java8Parser.MethodDeclarationContext methodDeclarationContext) {
Java8Parser.MethodHeaderContext header = methodDeclarationContext.methodHeader();
String name = header.methodDeclarator().Identifier().getText();
RefTypeOrTPH retType;
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), methodDeclarationContext.methodHeader().getStart());
if(methodDeclarationContext.methodHeader().typeParameters() != null){
gtvDeclarations = TypeGenerator.convert(methodDeclarationContext.methodHeader().typeParameters(), reg, generics);
}
RefTypeOrTPHOrWildcardOrGeneric retType;
if(header.result() != null){
if(header.result().unannType() != null){
retType = TypeGenerator.convert(header.result().unannType(), reg);
retType = TypeGenerator.convert(header.result().unannType(), reg, generics);
}
else retType = new de.dhbwstuttgart.syntaxtree.type.Void(header.result().getStart());
}else{
@ -55,10 +59,6 @@ public class StatementGenerator {
}else{
block = this.convert(methodDeclarationContext.methodBody().block());
}
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), methodDeclarationContext.methodHeader().getStart());
if(methodDeclarationContext.methodHeader().typeParameters() != null){
gtvDeclarations = TypeGenerator.convert(methodDeclarationContext.methodHeader().typeParameters());
}
return new Method(name, retType, modifiers, parameterList,block, gtvDeclarations, methodDeclarationContext.getStart());
}
@ -78,9 +78,9 @@ public class StatementGenerator {
for(Java8Parser.FormalParameterContext fp : fps){
String paramName = SyntaxTreeGenerator.convert(fp.variableDeclaratorId());
RefTypeOrTPH type;
RefTypeOrTPHOrWildcardOrGeneric type;
if(fp.unannType() != null){
type = TypeGenerator.convert(fp.unannType(), reg);
type = TypeGenerator.convert(fp.unannType(), reg, generics);
}else{
type = TypePlaceholder.fresh(fp.getStart());
}
@ -285,7 +285,7 @@ public class StatementGenerator {
receiver = new This(offset);
}else if(receiver == null){ //Handelt es sich um keinen Statischen Klassennamen:
String part = expression.substring(0,expression.length() - (1 + parts[parts.length-1].length()));
receiver = generateFieldVarOrClassname(part, offset);
receiver = generateLocalOrFieldVarOrClassName(part, offset);
}
return new FieldVar(receiver, parts[parts.length-1], TypePlaceholder.fresh(offset) ,offset);
}
@ -418,11 +418,11 @@ public class StatementGenerator {
if(declaration.variableModifier() != null && declaration.variableModifier().size() > 0){
//TODO
}
RefTypeOrTPH type;
RefTypeOrTPHOrWildcardOrGeneric type;
if(declaration.unannType()==null){
type = TypePlaceholder.fresh(declaration.getStart());
}else{
type = TypeGenerator.convert(declaration.unannType(), reg);
type = TypeGenerator.convert(declaration.unannType(), reg, generics);
}
for(Java8Parser.VariableDeclaratorContext varDecl : declaration.variableDeclaratorList().variableDeclarator()){
TerminalNode name = varDecl.variableDeclaratorId().Identifier();
@ -754,9 +754,13 @@ public class StatementGenerator {
receiver = generateLocalOrFieldVarOrClassName(methodInvocationContext.typeName().getText(), methodInvocationContext.typeName().getStart());
}else if(methodInvocationContext.expressionName()!=null){
receiver = convert(methodInvocationContext.expressionName());
}else if(methodInvocationContext.toString().startsWith("super")){
}else if(methodInvocationContext.toString().startsWith("super")) {
receiver = new Super(methodInvocationContext.getStart());
}else throw new NotImplementedException();
}else if(methodInvocationContext.methodName() != null){
receiver = new This(methodInvocationContext.methodName().getStart());
}else {
throw new NotImplementedException();
}
ArgumentList argumentList = convert(methodInvocationContext.argumentList());
MethodCall ret = new MethodCall(new Receiver(receiver), name, argumentList, methodInvocationContext.getStart());

View File

@ -1,13 +1,15 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.InvalidClassNameException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.PackageCrawler;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.*;
@ -19,13 +21,12 @@ import java.util.List;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.TerminalNode;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class SyntaxTreeGenerator{
private JavaClassRegistry reg;
private String pkgName = "";
List<JavaClassName> imports = new ArrayList();
private GenericsRegistry generics = new GenericsRegistry();
public SyntaxTreeGenerator(JavaClassRegistry reg){
this.reg = reg;
}
@ -51,10 +52,10 @@ public class SyntaxTreeGenerator{
else{
nameString = typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
}
//Die Generic TypeParameter Definitionen ebenfalls an die JavaClassName-Registry anfügen:
//Die Generic TypeParameter Definitionen Nicht! an die JavaClassName-Registry anfügen:
if(typeDecl.classDeclaration().normalClassDeclaration().typeParameters() != null){
for(Java8Parser.TypeParameterContext tp : typeDecl.classDeclaration().normalClassDeclaration().typeParameters().typeParameterList().typeParameter()){
this.reg.add(tp.Identifier().toString());
//this.reg.add(tp.Identifier().toString());
}
}
this.reg.add(nameString);
@ -199,17 +200,27 @@ public class SyntaxTreeGenerator{
}
}
JavaClassName name = convert(ctx.Identifier());
GenericDeclarationList genericClassParameters = TypeGenerator.convert(ctx.typeParameters(), reg, generics);
Block class_block = null;
List<Field> fielddecl = convertFields(ctx.classBody());
List<Method> methods = convertMethods(ctx.classBody());
GenericDeclarationList genericClassParameters = null;
Token offset = ctx.getStart();
RefTypeOrTPH superClass = null;
RefType superClass ;
if(ctx.superclass() != null){
superClass = convert(ctx.superclass());
}else{
superClass = new ASTFactory(reg).createObjectClass().getType();
}
Boolean isInterface = false;
List<RefTypeOrTPH> implementedInterfaces = null;
List<RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces = null;
return new ClassOrInterface(modifiers, name, fielddecl, methods, genericClassParameters, superClass, isInterface, implementedInterfaces, offset);
}
private RefType convert(Java8Parser.SuperclassContext superclass) {
throw new NotImplementedException();
}
private List<Method> convertMethods(Java8Parser.ClassBodyContext classBodyContext) {
List<Method> ret = new ArrayList<>();
for(Java8Parser.ClassBodyDeclarationContext classMember : classBodyContext.classBodyDeclaration()){
@ -218,7 +229,7 @@ public class SyntaxTreeGenerator{
if(classMemberDeclarationContext.fieldDeclaration() != null){
//Do nothing!
}else if(classMemberDeclarationContext.methodDeclaration()!= null){
StatementGenerator stmtGen = new StatementGenerator(reg);
StatementGenerator stmtGen = new StatementGenerator(reg, generics);
ret.add(stmtGen.convert(classMemberDeclarationContext.methodDeclaration()));
}
}
@ -255,7 +266,12 @@ public class SyntaxTreeGenerator{
for(Java8Parser.FieldModifierContext fieldModifierContext : fieldDeclarationContext.fieldModifier()){
modifiers+=(convert(fieldModifierContext));
}
RefTypeOrTPH fieldType = TypeGenerator.convert(fieldDeclarationContext.unannType(), reg);
RefTypeOrTPHOrWildcardOrGeneric fieldType;
if(fieldDeclarationContext.unannType() != null){
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannType(), reg, generics);
}else{
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.getStart());
}
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
String fieldName = convert(varCtx.variableDeclaratorId());
if(varCtx.variableInitializer() != null){

View File

@ -1,22 +1,40 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.ArrayList;
import java.util.List;
public class TypeGenerator {
public static RefTypeOrTPH convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg) {
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
String name = unannClassOrInterfaceTypeContext.getText();
if(!reg.contains(name)){ //Dann könnte es ein Generische Type sein:
if(generics.contains(name)){
return new GenericRefType(new GenericTypeName(name), unannClassOrInterfaceTypeContext.getStart());
}else{
throw new TypeinferenceException("Der Typ "+ name + " ist nicht vorhanden",unannClassOrInterfaceTypeContext.getStart());
}
}
return new RefType(reg.getName(name), unannClassOrInterfaceTypeContext.getStart());
}
public static RefTypeOrTPH convert(Java8Parser.UnannTypeContext unannTypeContext, JavaClassRegistry reg) {
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannTypeContext unannTypeContext, JavaClassRegistry reg, GenericsRegistry genericsRegistry) {
if(unannTypeContext.unannPrimitiveType()!=null){
throw new NotImplementedException();
}else
@ -27,11 +45,38 @@ public class TypeGenerator {
JavaClassName name = reg.getName(unannTypeContext.unannReferenceType().unannTypeVariable().Identifier().toString());
return new RefType(name, unannTypeContext.getStart());
}
return TypeGenerator.convert(unannTypeContext.unannReferenceType().unannClassOrInterfaceType(), reg);
return TypeGenerator.convert(unannTypeContext.unannReferenceType().unannClassOrInterfaceType(), reg, genericsRegistry);
}
public static GenericDeclarationList convert(Java8Parser.TypeParametersContext typeParametersContext) {
throw new NotImplementedException();
public static GenericDeclarationList convert(Java8Parser.TypeParametersContext typeParametersContext, JavaClassRegistry reg, GenericsRegistry generics) {
if(typeParametersContext == null){
return new GenericDeclarationList(new ArrayList<>(), new NullToken());
}
Token endOffset = typeParametersContext.getStop();
List<GenericTypeVar> typeVars = new ArrayList<>();
for(Java8Parser.TypeParameterContext typeParameter : typeParametersContext.typeParameterList().typeParameter()){
typeVars.add(convert(typeParameter, reg, generics));
endOffset = typeParameter.getStop();
}
return new GenericDeclarationList(typeVars, endOffset);
}
public static GenericTypeVar convert(Java8Parser.TypeParameterContext typeParameter, JavaClassRegistry reg, GenericsRegistry generics) {
String name = typeParameter.Identifier().getText();
List<RefTypeOrTPHOrWildcardOrGeneric> bounds = TypeGenerator.convert(typeParameter.typeBound(),reg, generics);
GenericTypeVar ret = new GenericTypeVar(name, bounds, typeParameter.getStart(), typeParameter.getStop());
generics.add(name);
return ret;
}
public static List<RefTypeOrTPHOrWildcardOrGeneric> convert(Java8Parser.TypeBoundContext typeBoundContext, JavaClassRegistry reg, GenericsRegistry generics) {
if(typeBoundContext == null){
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
ret.add(new ASTFactory(reg).createObjectClass().getType());
return ret;
}
throw new de.dhbwstuttgart.exceptions.NotImplementedException();
}
}

View File

@ -3,8 +3,8 @@ package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
@ -21,12 +21,12 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
private List<Method> methods = new ArrayList<>();
private GenericDeclarationList genericClassParameters;
private Token offset;
private RefTypeOrTPH superClass;
private RefTypeOrTPHOrWildcardOrGeneric superClass;
protected boolean isInterface;
private List<? extends RefTypeOrTPH> implementedInterfaces;
private List<? extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces;
public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, GenericDeclarationList genericClassParameters,
RefTypeOrTPH superClass, Boolean isInterface, List<? extends RefTypeOrTPH> implementedInterfaces, Token offset){
RefTypeOrTPHOrWildcardOrGeneric superClass, Boolean isInterface, List<? extends RefTypeOrTPHOrWildcardOrGeneric> implementedInterfaces, Token offset){
super(offset);
this.modifiers = modifiers;
if(name != null){
@ -69,7 +69,7 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
public ConstraintSet getConstraints(TypeInferenceInformation info) {
ConstraintSet ret = new ConstraintSet();
for(Method m : this.getMethods()){
m.getConstraints(info);
ret.addAll(m.getConstraints(info, this));
}
return ret;
}
@ -77,4 +77,8 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
public RefType getType() {
return new RefType(this.getClassName(), this.getOffset());
}
public RefTypeOrTPHOrWildcardOrGeneric getSuperClass() {
return superClass;
}
}

View File

@ -1,16 +1,14 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.syntaxtree.statement.Block;
import java.util.List;
public class Constructor extends Method {
public Constructor(String name, RefTypeOrTPH returnType, int modifiers, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) {
public Constructor(String name, RefTypeOrTPHOrWildcardOrGeneric returnType, int modifiers, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, parameterList, block, gtvDeclarations, offset);
}
}

View File

@ -1,14 +1,14 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import java.util.List;
public class ExceptionList
{
private List<RefTypeOrTPH> exceptions;
private List<RefTypeOrTPHOrWildcardOrGeneric> exceptions;
public ExceptionList(List<RefTypeOrTPH> exceptions){
public ExceptionList(List<RefTypeOrTPHOrWildcardOrGeneric> exceptions){
this.exceptions = exceptions;
}
}

View File

@ -1,29 +1,27 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
import java.util.List;
public class Field extends GTVDeclarationContext implements Generic {
private String name;
private RefTypeOrTPH type;
private RefTypeOrTPHOrWildcardOrGeneric type;
private GenericDeclarationList genericParameters;
public Field(String name, RefTypeOrTPH type, int modifier, Token offset){
public Field(String name, RefTypeOrTPHOrWildcardOrGeneric type, int modifier, Token offset){
super(offset);
this.name = name;
this.type = type;
}
public String getName(){
public String getName(){
return this.name;
}
public RefTypeOrTPH getType() {
public RefTypeOrTPHOrWildcardOrGeneric getType() {
return type;
}
}

View File

@ -3,9 +3,7 @@ package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
/**
* Eine Feldinitialisation steht ¼r eine Felddeklaration mit gleichzeitiger Wertzuweisung
@ -21,7 +19,7 @@ public class FieldDeclaration extends Field{
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
*/
public FieldDeclaration(String name, RefTypeOrTPH typ, int modifier, Expression value, Token offset){
public FieldDeclaration(String name, RefTypeOrTPHOrWildcardOrGeneric typ, int modifier, Expression value, Token offset){
super(name, typ, modifier, offset);//Dieser Deklarator wird nicht vom Parser aufgerufen. Dadurch gibt es auch keinen Offset
this.wert = value;
}

View File

@ -1,20 +1,20 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class FormalParameter extends SyntaxTreeNode
{
private RefTypeOrTPH type;
private RefTypeOrTPHOrWildcardOrGeneric type;
private String name;
public FormalParameter(String name, RefTypeOrTPH type, Token offset){
public FormalParameter(String name, RefTypeOrTPHOrWildcardOrGeneric type, Token offset){
super(offset);
this.name = name;
this.type = type;
}
public RefTypeOrTPH getType() {
public RefTypeOrTPHOrWildcardOrGeneric getType() {
return type;
}

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
import java.util.ArrayList;
@ -21,15 +21,15 @@ public class GenericTypeVar extends SyntaxTreeNode
/**
* Hier sind die Bounds in Form von Type-Objekten abgespeichert
*/
List<? extends RefTypeOrTPH> bounds=new ArrayList<RefTypeOrTPH>();
List<? extends RefTypeOrTPHOrWildcardOrGeneric> bounds=new ArrayList<RefTypeOrTPHOrWildcardOrGeneric>();
private Token endOffset;
private String name;
public GenericTypeVar(String s, List<? extends RefTypeOrTPH> bounds, Token offset, Token endOffset)
public GenericTypeVar(String s, List<? extends RefTypeOrTPHOrWildcardOrGeneric> bounds, Token offset, Token endOffset)
{
super(offset);
name = s;
if(bounds != null)for(RefTypeOrTPH t : bounds){
if(bounds != null)for(RefTypeOrTPHOrWildcardOrGeneric t : bounds){
//if(t!=null)this.extendVars.add(t);
}
//this.genericTypeVar = new RefType(s,offset);
@ -37,7 +37,7 @@ public class GenericTypeVar extends SyntaxTreeNode
this.endOffset = endOffset;
}
public List<? extends RefTypeOrTPH> getBounds()
public List<? extends RefTypeOrTPHOrWildcardOrGeneric> getBounds()
{
return bounds;
}

View File

@ -1,11 +1,11 @@
package de.dhbwstuttgart.syntaxtree;
import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
@ -26,17 +26,16 @@ public class Method extends Field implements IItemWithOffset
private ParameterList parameterlist = new ParameterList(new ArrayList<>(), new NullToken());
private ExceptionList exceptionlist;
public Method(String name, RefTypeOrTPH returnType, int modifiers, ParameterList parameterList, Block block,
public Method(String name, RefTypeOrTPHOrWildcardOrGeneric returnType, int modifiers, ParameterList parameterList, Block block,
GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, offset);
this.parameterlist = parameterList;
this.block = block;
}
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceInformation info, ClassOrInterface currentClass) {
ConstraintSet ret = new ConstraintSet();
info.setMethodContext(this);
ret.addAll(block.getConstraints(info));
ret.addAll(block.getConstraints(new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, this)));
return ret;
}

View File

@ -4,7 +4,7 @@ import java.util.*;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;

View File

@ -9,7 +9,8 @@ import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typecheck.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
@ -18,8 +19,6 @@ import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
/**
* Anmerkung:
@ -49,13 +48,13 @@ public class ASTFactory {
java.lang.Class superjreClass = jreClass.getSuperclass();
RefType superClass;
if(superjreClass != null){
superClass = createType(superjreClass);
superClass = (RefType) createType(superjreClass);
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!)
superClass = createType(java.lang.Object.class);
superClass = (RefType) createType(java.lang.Object.class);
}
List<RefType> implementedInterfaces = new ArrayList<>();
for(java.lang.Class jreInterface : jreClass.getInterfaces()){
implementedInterfaces.add(createType(jreInterface));
implementedInterfaces.add((RefType) createType(jreInterface));
}
GenericDeclarationList genericDeclarationList = createGenerics(jreClass.getTypeParameters(), jreClass, null);
@ -63,32 +62,47 @@ public class ASTFactory {
return new ClassOrInterface(modifier, name, felder, methoden, genericDeclarationList, superClass,isInterface, implementedInterfaces, offset);
}
private Method createConstructor(Constructor constructor, Class jreClass) {
throw new NotImplementedException();
}
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefType returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
private de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) {
String name = constructor.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass);
Parameter[] jreParams = constructor.getParameters();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
RefType paramType = createType(jreParam.getType());
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType());
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), new NullToken());
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod);
GenericDeclarationList gtvDeclarations = createGenerics(constructor.getTypeParameters(), inClass, constructor.getName());
Token offset = new NullToken();
int modifier = constructor.getModifiers();
return new de.dhbwstuttgart.syntaxtree.Constructor(name,returnType, modifier, parameterList, block, gtvDeclarations, offset);
}
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefTypeOrTPHOrWildcardOrGeneric returnType;
returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType());
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
}
ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), new NullToken());
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod.getName());
Token offset = new NullToken();
int modifier = jreMethod.getModifiers();
return new Method(name,returnType, modifier, parameterList, block, gtvDeclarations, offset);
}
public GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, java.lang.reflect.Method contextM){
List<GenericTypeVar> gtvs = new ArrayList<>();
public GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, String methodName){
List<de.dhbwstuttgart.syntaxtree.GenericTypeVar> gtvs = new ArrayList<>();
for(TypeVariable jreTV : typeParameters){
GenericTypeVar gtv = createGeneric(jreTV, jreTV.getName());
de.dhbwstuttgart.syntaxtree.GenericTypeVar gtv = createGeneric(jreTV, jreTV.getName());
gtvs.add(gtv);
}
return new GenericDeclarationList(gtvs,new NullToken());
@ -105,31 +119,48 @@ public class ASTFactory {
}
*/
public RefType createType(java.lang.reflect.Type type){
if(type instanceof TypeVariable){
//GTVDeclarationContext via "(TypeVariable) type).getGenericDeclaration()"
return new GenericRefType(new GenericTypeName(type.getTypeName(),
new GTVDeclarationContext(new NullToken()) {}), new NullToken());
}
List<RefTypeOrTPH> params = new ArrayList<>();
if(type instanceof ParameterizedType){
for(Type t : ((ParameterizedType)type).getActualTypeArguments()){
params.add(createType(t));
}
}
RefType ret = new RefType(this.names.getName(type.getTypeName()), params, new NullToken());
return ret;
public RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type){
if(type.getTypeName().equals("void")){
return new Void(new NullToken());
}else if(type.getTypeName().equals("int")){
return new RefType(this.names.getName("java.lang.Integer"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("byte")){
return new RefType(this.names.getName("java.lang.Byte"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("boolean")){
return new RefType(this.names.getName("java.lang.Boolean"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("char")){
return new RefType(this.names.getName("java.lang.Char"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("short")){
return new RefType(this.names.getName("java.lang.Short"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("double")){
return new RefType(this.names.getName("java.lang.Double"), new ArrayList<>(), new NullToken());
}else if(type.getTypeName().equals("long")){
return new RefType(this.names.getName("java.lang.Long"), new ArrayList<>(), new NullToken());
}else{
if(type instanceof TypeVariable){
//GTVDeclarationContext via "(TypeVariable) type).getGenericDeclaration()"
return new GenericRefType(new GenericTypeName(type.getTypeName()), new NullToken());
}
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
if(type instanceof ParameterizedType){
for(Type t : ((ParameterizedType)type).getActualTypeArguments()){
params.add(createType(t));
}
}
RefType ret = new RefType(this.names.getName(type.getTypeName()), params, new NullToken());
return ret;
}
}
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, String name){
public de.dhbwstuttgart.syntaxtree.GenericTypeVar createGeneric(TypeVariable jreTypeVar, String name){
List<RefType> genericBounds = new ArrayList<>();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){
genericBounds.add(createType(bound));
genericBounds.add((RefType) createType(bound));
}
}
return new GenericTypeVar(name, genericBounds, new NullToken(), new NullToken());
return new de.dhbwstuttgart.syntaxtree.GenericTypeVar(name, genericBounds, new NullToken(), new NullToken());
}
public ClassOrInterface createObjectClass() {

View File

@ -0,0 +1,192 @@
package de.dhbwstuttgart.syntaxtree.factory;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
import de.dhbwstuttgart.typeinference.unify.model.FunNType;
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
public class UnifyTypeFactory {
public static FiniteClosure generateFC(List<ClassOrInterface> fromAvailableClasses){
HashSet<UnifyPair> pairs = new HashSet<>();
for(ClassOrInterface cl : fromAvailableClasses){
UnifyType t1 = UnifyTypeFactory.convert(cl.getType());
UnifyType t2 = UnifyTypeFactory.convert(cl.getSuperClass());
pairs.add(generateSmallerPair(t1, t2));
}
return new FiniteClosure(pairs);
}
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){
return new UnifyPair(tl, tr, PairOperator.SMALLER);
}
public static UnifyPair generateSmallerDotPair(UnifyType tl, UnifyType tr){
return new UnifyPair(tl, tr, PairOperator.SMALLERDOT);
}
public static UnifyPair generateEqualDotPair(UnifyType tl, UnifyType tr){
return new UnifyPair(tl, tr, PairOperator.EQUALSDOT);
}
/**
* Convert from
* ASTType -> UnifyType
*/
public static UnifyType convert(RefTypeOrTPHOrWildcardOrGeneric t){
if(t instanceof GenericRefType){
return UnifyTypeFactory.convert((GenericRefType)t);
}else
if(t instanceof FunN){
return UnifyTypeFactory.convert((FunN)t);
}else if(t instanceof TypePlaceholder){
return UnifyTypeFactory.convert((TypePlaceholder)t);
}else if(t instanceof ExtendsWildcardType){
return UnifyTypeFactory.convert((ExtendsWildcardType)t);
}else if(t instanceof SuperWildcardType){
return UnifyTypeFactory.convert((SuperWildcardType)t);
}else if(t instanceof RefType){
return UnifyTypeFactory.convert((RefType)t);
}
//Es wurde versucht ein Typ umzuwandeln, welcher noch nicht von der Factory abgedeckt ist
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
}
public static UnifyType convert(RefType t){
UnifyType ret;
if(t.getParaList() != null && t.getParaList().size() > 0){
List<UnifyType> params = new ArrayList<>();
for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){
params.add(UnifyTypeFactory.convert(pT));
}
ret = new ReferenceType(t.getName().toString(),new TypeParams(params));
}else{
ret = new ReferenceType(t.getName().toString());
}
return ret;
}
public static UnifyType convert(FunN t){
UnifyType ret;
List<UnifyType> params = new ArrayList<>();
if(t.getParaList() != null && t.getParaList().size() > 0){
for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){
params.add(UnifyTypeFactory.convert(pT));
}
}
ret = FunNType.getFunNType(new TypeParams(params));
return ret;
}
public static UnifyType convert(TypePlaceholder tph){
return new PlaceholderType(tph.getName());
}
public static UnifyType convert(GenericRefType t){
return new PlaceholderType(TypePlaceholder.fresh(t.getOffset()).getName());
}
public static UnifyType convert(WildcardType t){
if(t.isExtends())
return new ExtendsType(UnifyTypeFactory.convert(t.getInnerType()));
else if(t.isSuper())
return new SuperType(UnifyTypeFactory.convert(t.getInnerType()));
else throw new NotImplementedException();
}
public static ConstraintSet<UnifyPair> convert(ConstraintSet<Pair> constraints) {
return constraints.map(UnifyTypeFactory::convert);
}
public static UnifyPair convert(Pair p) {
if(p.OperatorSmaller()) {
UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1)
, UnifyTypeFactory.convert(p.TA2));
return ret;
}else if(p.OperatorEqual()){
UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1)
, UnifyTypeFactory.convert(p.TA2));
return ret;
}else throw new NotImplementedException();
}
/**
* Convert from
* UnifyType -> ASTType
*/
/*
public static Pair convert(UnifyPair mp) {
Type tl = UnifyTypeFactory.convert(mp.getLhsType());
Type tr = UnifyTypeFactory.convert(mp.getRhsType());
return new Pair(tl, tr, mp.getPairOp());
}
public static Type convert(ReferenceType t) {
//TODO: Hier kann man die GTVs extrahieren
if(t.getName().toString().equals(Void.VOID_NAME))return new Void( 0);
RefType ret = new RefType(t.getName(),0);
ret.set_ParaList(convert(t.getTypeParams()));
return ret;
}
public static Type convert(FunNType t) {
RefType ret = new RefType(t.getName(),0);
ret.set_ParaList(convert(t.getTypeParams()));
return ret;
}
public static Type convert(SuperType t) {
RefType innerType = new RefType(t.getSuperedType().getName(),0);
return new SuperWildcardType(innerType);
}
public static Type convert(ExtendsType t) {
RefType innerType = new RefType(t.getExtendedType().getName(),0);
return new ExtendsWildcardType(innerType);
}
public static Type convert(PlaceholderType t) {
TypePlaceholder ret = TypePlaceholder.getInstance(t.getName());
if(ret == null){ //Dieser TPH wurde vom Unifikationsalgorithmus erstellt
ret = TypePlaceholder.fresh(t.getName(), NULL_NODE);
}
return ret;
}
public static Type convert(UnifyType t) {
if(t instanceof FunNType)return convert((FunNType) t);
if(t instanceof ReferenceType)return convert((ReferenceType) t);
if(t instanceof SuperType)return convert((SuperType) t);
if(t instanceof ExtendsType)return convert((ExtendsType) t);
if(t instanceof PlaceholderType)return convert((PlaceholderType) t);
throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden");
}
private static List<Type> convert(TypeParams typeParams) {
List<Type> ret = new ArrayList<>();
for(UnifyType uT : typeParams){
Type toAdd = convert(uT);
ret.add(toAdd);
}
return ret;
}
*/
}

View File

@ -1,8 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
@ -19,10 +20,10 @@ public class Assign extends Statement
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = lefSide.getConstraints(info);
ret.addAll(rightSide.getConstraints(info));
ret.add(new Pair(rightSide.getType(), lefSide.getType()));
ret.addUndConstraint(new Pair(rightSide.getType(), lefSide.getType()));
return ret;
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.operator.Operator;
@ -15,7 +16,7 @@ public class Binary extends Expression
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,15 +1,16 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.*;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token;
public class Block extends Statement
{
public Block(List<Statement> statements, Token offset) {
super(null, offset);
super(TypePlaceholder.fresh(offset), offset);
this.statements = statements;
}
@ -23,7 +24,7 @@ public class Block extends Statement
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = new ConstraintSet();
for(Statement stmt : getStatements()){
ret.addAll(stmt.getConstraints(info));

View File

@ -1,14 +1,14 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class CastExpr extends Expression
{
public CastExpr(RefTypeOrTPH castType, Expression expr, int offset)
public CastExpr(RefTypeOrTPHOrWildcardOrGeneric castType, Expression expr, int offset)
{
super(null, null);
}
@ -16,7 +16,7 @@ public class CastExpr extends Expression
public Expression expr;
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
@ -13,7 +14,7 @@ public class EmptyStmt extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
return new ConstraintSet();
}
}

View File

@ -2,24 +2,26 @@
package de.dhbwstuttgart.syntaxtree.statement;
import com.sun.istack.internal.NotNull;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token;
public abstract class Expression extends SyntaxTreeNode
{
private RefTypeOrTPH type;
private RefTypeOrTPHOrWildcardOrGeneric type;
public Expression(RefTypeOrTPH type, Token offset){
public Expression(@NotNull RefTypeOrTPHOrWildcardOrGeneric type, Token offset){
super(offset);
if(type == null)throw new NullPointerException();
this.type = type;
}
public RefTypeOrTPH getType(){
public RefTypeOrTPHOrWildcardOrGeneric getType(){
return type;
}
public abstract ConstraintSet getConstraints(TypeInferenceInformation info);
public abstract ConstraintSet getConstraints(TypeInferenceBlockInformation info);
}

View File

@ -1,22 +1,43 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.FieldAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.HashSet;
import java.util.Set;
public class FieldVar extends Expression {
public FieldVar(Expression receiver, String fieldVarName, RefTypeOrTPH type, Token offset) {
private String fieldVarName;
public Expression receiver;
public FieldVar(Expression receiver, String fieldVarName, RefTypeOrTPHOrWildcardOrGeneric type, Token offset) {
super(type, offset);
this.fieldVarName = fieldVarName;
this.receiver = receiver;
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
//for(FieldAssumption fieldAssumption : info.getFields(fieldVarName)){
//}
throw new NotImplementedException();
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = new ConstraintSet();
Set<Constraint> oderConstraints = new HashSet<>();
ret.addAll(receiver.getConstraints(info));
for(FieldAssumption fieldAssumption : info.getFields(fieldVarName)){
Constraint constraint = new Constraint();
constraint.add(new Pair(receiver.getType(),fieldAssumption.getReceiverType()));
constraint.add(new Pair(this.getType(),fieldAssumption.getType()));
oderConstraints.add(constraint);
}
if(oderConstraints.size() == 0)
throw new TypeinferenceException("Kein Feld "+fieldVarName+ " gefunden", getOffset());
ret.addOderConstraint(oderConstraints);
return ret;
}
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -23,7 +24,7 @@ public class ForStmt extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
@ -17,7 +18,7 @@ public class IfStmt extends Statement
public Statement else_block;
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
return null;
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -16,7 +17,7 @@ public class InstVar extends Expression
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,15 +1,15 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class InstanceOf extends BinaryExpr
{
public Expression expr;
private RefTypeOrTPH reftype;
private RefTypeOrTPHOrWildcardOrGeneric reftype;
public InstanceOf(int offset,int variableLength)
{
@ -18,7 +18,7 @@ public class InstanceOf extends BinaryExpr
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -2,7 +2,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.type.FunN;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -30,7 +31,7 @@ public class LambdaExpression extends Expression{
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,10 +1,11 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class LocalVar extends Statement{
@ -23,7 +24,8 @@ public class LocalVar extends Statement{
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
//throw new NotImplementedException();
return new ConstraintSet();
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -14,7 +15,7 @@ public class LocalVarBunchDeclaration extends Statement {
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,9 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -12,14 +12,14 @@ public class LocalVarDecl extends Statement
private String name;
public LocalVarDecl(String name, RefTypeOrTPH type, Token offset)
public LocalVarDecl(String name, RefTypeOrTPHOrWildcardOrGeneric type, Token offset)
{
super(type, offset);
this.name = name;
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,15 +1,17 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.OderConstraint;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import org.antlr.v4.runtime.Token;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import java.util.HashSet;
import java.util.Set;
public class MethodCall extends Statement
@ -44,21 +46,28 @@ public class MethodCall extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = receiver.getConstraints(info);
//Overloading:
OderConstraint overloading = new OderConstraint();
for(MethodAssumption m : info.getMethods(name, arglist)){
UndConstraint methodConstraints = new UndConstraint();
methodConstraints.addConstraint(receiver.getType(), m.getReceiverType());
methodConstraints.addConstraint(m.getReturnType(), this.getType());
for(int i = 0;i<arglist.getArguments().size();i++){
methodConstraints.addConstraint(m.getArgTypes().get(i),
arglist.getArguments().get(i).getType());
}
overloading.addConstraint(methodConstraints);
ret.addAll(receiver.getConstraints(info));
for(int i = 0;i<arglist.getArguments().size();i++){
ret.addAll(arglist.getArguments().get(i).getConstraints(info));
}
ret.add(overloading);
//Overloading:
Set<Constraint> methodConstraints = new HashSet<>();
for(MethodAssumption m : info.getMethods(name, arglist)){
Constraint methodConstraint = new Constraint();
methodConstraint.add(new Pair(receiver.getType(), m.getReceiverType()));
methodConstraint.add(new Pair(m.getReturnType(), this.getType()));
for(int i = 0;i<arglist.getArguments().size();i++){
methodConstraint.add(new Pair(m.getArgTypes().get(i),
arglist.getArguments().get(i).getType()));
}
methodConstraints.add(methodConstraint);
}
if(methodConstraints.size()<1){
throw new TypeinferenceException("Methode "+name+" ist nicht vorhanden!",getOffset());
}
ret.addOderConstraint(methodConstraints);
return ret;
}
}

View File

@ -1,9 +1,9 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -13,12 +13,12 @@ public class NewArray extends Expression
{
super(null,null);
}
private RefTypeOrTPH type;
private RefTypeOrTPHOrWildcardOrGeneric type;
public List<Expression> expr;
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -2,9 +2,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -17,7 +17,7 @@ public class NewClass extends Statement
private ArgumentList arglist;
private boolean isStatement = false;
private List<RefTypeOrTPH> parameterList = new ArrayList<>();
private List<RefTypeOrTPHOrWildcardOrGeneric> parameterList = new ArrayList<>();
public ArgumentList getArgumentList()
@ -27,7 +27,7 @@ public class NewClass extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -13,7 +14,7 @@ public class PostIncExpr extends UnaryExpr
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
public class Receiver extends Expression
@ -24,7 +25,7 @@ public class Receiver extends Expression
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
return expr.getConstraints(info);
}
}

View File

@ -1,11 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class Return extends Statement
{
@ -19,7 +18,7 @@ public class Return extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
return retexpr.getConstraints(info);
}

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
@ -8,7 +8,7 @@ public abstract class Statement extends Expression
{
public Statement(RefTypeOrTPH type, Token offset)
public Statement(RefTypeOrTPHOrWildcardOrGeneric type, Token offset)
{
super(type, offset);
}

View File

@ -2,7 +2,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
@ -12,7 +13,7 @@ public class StaticClassName extends Expression {
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
return new ConstraintSet();
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -13,7 +14,7 @@ public class Super extends Expression
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,21 +1,30 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.syntaxtree.operator.Operator;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.atn.SemanticContext;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class This extends Expression
{
public This(Token offset)
{
super(null,null);
super(TypePlaceholder.fresh(offset),offset);
}
public ArgumentList arglist;
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
throw new NotImplementedException();
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = new ConstraintSet();
ret.addUndConstraint(new Pair( this.getType(), info.getCurrentClass().getType(), PairOperator.EQUALSDOT));
return ret;
}
}

View File

@ -1,6 +1,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -12,7 +13,7 @@ public class UnaryPlus extends Expression
}
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -26,7 +27,7 @@ public class WhileStmt extends Statement
@Override
public ConstraintSet getConstraints(TypeInferenceInformation info) {
public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException();
}
}

View File

@ -1,7 +1,6 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
@ -10,7 +9,7 @@ public class BoolLiteral extends Literal
private boolean value;
public BoolLiteral(RefTypeOrTPH type, boolean value, Token offset)
public BoolLiteral(RefTypeOrTPHOrWildcardOrGeneric type, boolean value, Token offset)
{
super(type,offset);
this.value = value;

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
@ -8,7 +7,7 @@ public class CharLiteral extends Literal
{
private char value;
public CharLiteral(RefTypeOrTPH type, char value, Token offset)
public CharLiteral(RefTypeOrTPHOrWildcardOrGeneric type, char value, Token offset)
{
super(type,offset);
this.value = value;

View File

@ -2,18 +2,18 @@ package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token;
public abstract class Literal extends Expression
{
public Literal(RefTypeOrTPH type, Token offset) {
public Literal(RefTypeOrTPHOrWildcardOrGeneric type, Token offset) {
super(type, offset);
}
public ConstraintSet getConstraints(TypeInferenceInformation info){
public ConstraintSet getConstraints(TypeInferenceBlockInformation info){
return new ConstraintSet();
}
}

View File

@ -1,14 +1,13 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class Null extends Literal
{
public Null(RefTypeOrTPH type, Token offset)
public Null(RefTypeOrTPHOrWildcardOrGeneric type, Token offset)
{
super(type,offset);
}

View File

@ -1,7 +1,6 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
@ -9,7 +8,7 @@ public class NumberLiteral extends Literal
{
private Number value;
public NumberLiteral(RefTypeOrTPH type, Number value, Token offset)
public NumberLiteral(RefTypeOrTPHOrWildcardOrGeneric type, Number value, Token offset)
{
super(type,offset);
this.value = value;

View File

@ -2,7 +2,6 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import org.antlr.v4.runtime.Token;

View File

@ -22,5 +22,15 @@ public class ExtendsWildcardType extends WildcardType{
super(extendsType, offset);
}
@Override
public boolean isExtends() {
return true;
}
@Override
public boolean isSuper() {
return false;
}
}

View File

@ -14,8 +14,8 @@ import java.util.List;
*/
public class FunN extends RefType {
private RefTypeOrTPH R;
private List<? extends RefTypeOrTPH> T;
private RefTypeOrTPHOrWildcardOrGeneric R;
private List<? extends RefTypeOrTPHOrWildcardOrGeneric> T;
/**
* @author Andreas Stadelmeier, a10023
@ -25,7 +25,7 @@ public class FunN extends RefType {
* @param T
* @return
*/
public FunN(RefTypeOrTPH R, List<? extends RefTypeOrTPH> T) {
public FunN(RefTypeOrTPHOrWildcardOrGeneric R, List<? extends RefTypeOrTPHOrWildcardOrGeneric> T) {
super(null,null);
}

View File

@ -13,8 +13,8 @@ import java.util.List;
*/
public class FunVoidN extends FunN {
private RefTypeOrTPH R;
private List<RefTypeOrTPH> T;
private RefTypeOrTPHOrWildcardOrGeneric R;
private List<RefTypeOrTPHOrWildcardOrGeneric> T;
/**
* @author Andreas Stadelmeier, a10023
@ -23,7 +23,7 @@ public class FunVoidN extends FunN {
* @param T
* @return
*/
public FunVoidN(List<RefTypeOrTPH> T) {
public FunVoidN(List<RefTypeOrTPHOrWildcardOrGeneric> T) {
super(null,T);
}
@ -34,7 +34,7 @@ public class FunVoidN extends FunN {
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig ¼r den Typinferenzalgorithmus.
*/
private void calculateNewParalist(){
List<RefTypeOrTPH> t = new ArrayList<>();
List<RefTypeOrTPHOrWildcardOrGeneric> t = new ArrayList<>();
if(T!=null)t.addAll(T);
this.parameter = t;
}

View File

@ -1,13 +1,16 @@
package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.typecheck.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName;
import org.antlr.v4.runtime.Token;
public class GenericRefType extends RefType
public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric
{
public GenericRefType(JavaClassName fullyQualifiedName, Token offset)
private GenericTypeName name;
public GenericRefType(GenericTypeName name, Token offset)
{
super(fullyQualifiedName, offset);
super(offset);
this.name = name;
}
}

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typecheck.JavaClassName;
import org.antlr.v4.runtime.Token;
@ -8,7 +7,7 @@ import java.util.ArrayList;
import java.util.List;
public class RefType extends RefTypeOrTPH
public class RefType extends RefTypeOrTPHOrWildcardOrGeneric
{
/**
* Ist IsArray auf true, muss beim Codegen ein Zeichen [ gesetzt werden
@ -18,7 +17,7 @@ public class RefType extends RefTypeOrTPH
*/
private boolean IsArray = false;
protected JavaClassName name;
protected List<RefTypeOrTPH> parameter = null;
protected List<RefTypeOrTPHOrWildcardOrGeneric> parameter = null;
/**
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
* den primitiven Datentyp ersetzt werden
@ -41,7 +40,7 @@ public class RefType extends RefTypeOrTPH
return hash;
}
public RefType(JavaClassName fullyQualifiedName, List<RefTypeOrTPH> parameter, Token offset)
public RefType(JavaClassName fullyQualifiedName, List<RefTypeOrTPHOrWildcardOrGeneric> parameter, Token offset)
{
this(fullyQualifiedName, offset);
if(parameter != null && parameter.size()>0)this.parameter = parameter;
@ -52,7 +51,7 @@ public class RefType extends RefTypeOrTPH
return name;
}
public List<RefTypeOrTPH> getParaList(){
public List<RefTypeOrTPHOrWildcardOrGeneric> getParaList(){
if(this.parameter==null)return new ArrayList<>();
return this.parameter;
}

View File

@ -7,9 +7,9 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import org.antlr.v4.runtime.Token;
public abstract class RefTypeOrTPH extends SyntaxTreeNode
public abstract class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode
{
public RefTypeOrTPH(Token offset) {
public RefTypeOrTPHOrWildcardOrGeneric(Token offset) {
super(offset);
}
}

View File

@ -28,9 +28,18 @@ public class SuperWildcardType extends WildcardType{
* Beispiel: ? super Integer.
* Integer wird zurückgegeben.
*/
public RefTypeOrTPH get_SuperType()
public RefTypeOrTPHOrWildcardOrGeneric get_SuperType()
{
return this.innerType;
}
@Override
public boolean isExtends() {
return false;
}
@Override
public boolean isSuper() {
return true;
}
}

View File

@ -2,6 +2,7 @@ package de.dhbwstuttgart.syntaxtree.type;
import java.util.Hashtable;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import org.antlr.v4.runtime.Token;
/**
@ -12,7 +13,7 @@ import org.antlr.v4.runtime.Token;
* @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/06/19 12:45:37 $
*/
public class TypePlaceholder extends RefTypeOrTPH
public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
{
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
@ -38,12 +39,13 @@ public class TypePlaceholder extends RefTypeOrTPH
* @param name Der Name des TypePlaceholders
* @return Der TypePlaceholder oder <code>null</code>, falls er nicht in der
* Registry existiert
*/
public static TypePlaceholder getInstance(String name)
{
return m_TypePlaceholdersRegistry.get(name);
}
*/
/**
* Generiert einen neuen TPH mit einem bestimmten Namen.
* Wird benÃtigt, wenn aus Generischen Variablen TPH generiert werden.
@ -63,7 +65,7 @@ public class TypePlaceholder extends RefTypeOrTPH
* @return
*/
public static TypePlaceholder fresh(Token position){
return null;
return new TypePlaceholder(NameGenerator.makeNewName(), position);
}
@ -87,4 +89,7 @@ public class TypePlaceholder extends RefTypeOrTPH
return "TPH " + this.name;
}
public String getName() {
return name;
}
}

View File

@ -9,9 +9,9 @@ import org.antlr.v4.runtime.Token;
*
*/
public abstract class WildcardType extends RefType {
public abstract class WildcardType extends RefTypeOrTPHOrWildcardOrGeneric {
protected RefTypeOrTPH innerType = null;
protected RefType innerType = null;
/**
* Author: Arne ¼dtke<br/>
@ -19,9 +19,13 @@ public abstract class WildcardType extends RefType {
*/
public WildcardType(RefType innerType, Token offset)
{
super(innerType.getName(), offset);
super(offset);
this.innerType = innerType;
}
public RefType getInnerType(){
return innerType;
}
/**
* Author: Arne ¼dtke<br/>
@ -31,15 +35,8 @@ public abstract class WildcardType extends RefType {
{
return "?";
}
/**
* Author: Arne ¼dtke<br/>
* Die Allgemeine Wildcard enthält keinen Typen.
*/
public RefTypeOrTPH GetWildcardType()
{
return null;
}
public abstract boolean isExtends();
public abstract boolean isSuper();
}

View File

@ -3,7 +3,7 @@ package de.dhbwstuttgart.typecheck;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
public class GenericTypeName extends JavaClassName {
public GenericTypeName(String name, GTVDeclarationContext declarationContext) {
public GenericTypeName(String name) {
super(name);
}
}

View File

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

View File

@ -1,39 +0,0 @@
package de.dhbwstuttgart.typeinference;
import java.util.Set;
import java.util.TreeSet;
public class EinzelElement<A> implements KomplexeMenge<A>{
private A item;
public EinzelElement(A element){
item = element;
}
public Set<KomplexeMenge<A>> getSet(){
Set<KomplexeMenge<A>> ret = new TreeSet<>();
ret.add(this);
return ret;
}
@Override
public Set<Set<A>> cartesianProduct() {
Set<Set<A>> ret = new TreeSet<>();
Set<A> i = new TreeSet<>();
i.add(item);
ret.add(i);
return ret;
//throw new NotImplementedException();
}
@Override
public String toString(){
return item.toString();
}
public A getItem(){
return item;
}
}

View File

@ -1,8 +0,0 @@
package de.dhbwstuttgart.typeinference;
import java.util.Set;
public interface KomplexeMenge<A>{
Set<? extends KomplexeMenge<A>> getSet();
Set<Set<A>> cartesianProduct();
}

View File

@ -1,66 +0,0 @@
package de.dhbwstuttgart.typeinference;
import java.util.*;
public class OderConstraint extends OderMenge<Pair>{
private Set<UndConstraint> oderConstraintPairs;
public OderConstraint(){
oderConstraintPairs = new HashSet<>();
}
/**
* Liefert alle in diesem OderConstraint enthaltene Constraints. Dabei gehen die Verkn<EFBFBD>pfungen (Oder/Und) verloren.
* @return
*/
public Set<Pair> getConstraintPairs(){
Set<Pair> ret = new TreeSet<>();
for(UndConstraint oC : this.oderConstraintPairs){
ret.addAll(oC.getConstraintPairs());
}
return ret;
}
/**
* Falls die Type des toAdd-Pairs nicht vom Typ RefType bzw. TypePlaceholder sind, so werden sie in einen RefType umgewandelt.
* @param toAdd
*/
public void addConstraint(Pair toAdd){
UndConstraint uCons = new UndConstraint();
uCons.addConstraint(toAdd);
oderConstraintPairs.add(uCons);
}
@Override
public String toString(){
String ret = "[";
for(UndConstraint p : this.getUndConstraints()){
ret += p.toString()+ "| ";
}
return ret+"]";
}
public Set<UndConstraint> getUndConstraints() {
return this.oderConstraintPairs;
/*
Vector<UndConstraint> ret = new Vector<UndConstraint>();
for(Pair p : this.getConstraintPairs()){
ret.add(new UndConstraint(p.TA1,p.TA2));
}
return ret;
*/
}
public void addConstraint(UndConstraint constraint) {
oderConstraintPairs.add(constraint);
}
@Override
public Set<? extends KomplexeMenge<Pair>> getSet() {
return this.oderConstraintPairs;
}
}

View File

@ -1,28 +0,0 @@
package de.dhbwstuttgart.typeinference;
import java.util.Set;
import java.util.TreeSet;
public abstract class OderMenge<A> implements KomplexeMenge<A>{
public abstract Set<? extends KomplexeMenge<A>> getSet();
@Override
public Set<Set<A>> cartesianProduct() {
Set<Set<A>> ret = new TreeSet<>();
for(KomplexeMenge<A> km : this.getSet()){
ret.addAll(km.cartesianProduct());
}
return ret;
}
@Override
public String toString(){
String ret = "[";
for(KomplexeMenge<A> i : this.getSet()){
ret += i.toString() + " | ";
}
return ret + "]";
}
}

View File

@ -1,51 +0,0 @@
package de.dhbwstuttgart.typeinference;
import java.util.*;
import de.dhbwstuttgart.exceptions.DebugException;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus;
/**
* Stellt ein Constraint dar, welches aus mehreren Constraint-Paaren besteht. Diese gelten alle stets gleichzeitig / sind per "Und" miteinander verknüpft.
* @author janulrich
*
*/
public class UndConstraint extends UndMenge<Pair> {
Set<EinzelElement<Pair>> set = new HashSet<>();
@Override
public Set<? extends KomplexeMenge<Pair>> getSet() {
return set;
}
public Set<Pair> getConstraintPairs() {
Set<Set<Pair>> ret = this.cartesianProduct();
if(ret.size() == 0)return new TreeSet<>();
if(ret.size() != 1){
//UndConstraints enthalten nur SingleConstraints, wodurch das Karthesische Produkt nur aus einem Element bestehen kann.
throw new DebugException("Fehler in ConstraintPairs-Bildung");
}
return ret.iterator().next();
}
public void addConstraint(RefTypeOrTPH type, RefTypeOrTPH rT) {
Pair p = new Pair(type, rT);
addConstraint(p);
}
public void addConstraint(Pair toAdd){
this.set.add(new EinzelElement<Pair>(toAdd));
}
@Override
public String toString() {
String ret = this.getConstraintPairs().toString();
return ret;
}
public Set<EinzelElement<Pair>> getPairs(){
return set;
}
}

View File

@ -1,44 +0,0 @@
package de.dhbwstuttgart.typeinference;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
//import com.rits.cloning.Cloner;
public abstract class UndMenge<A> implements KomplexeMenge<A>{
public abstract Set<? extends KomplexeMenge<A>> getSet();
@Override
public Set<Set<A>> cartesianProduct() {
Set<Set<A>> ret = null;
for(KomplexeMenge<A> km : this.getSet()){
if(ret == null){
ret = km.cartesianProduct();
}else{
Set<Set<A>> cartesianProduct = new TreeSet<>();
for(Set<A> r : ret)for(Set<A> m : km.cartesianProduct()){ //¼r jedes Element aus dem Karthesischen Produkt:
Set<A> undElement = new TreeSet<>();
undElement.addAll(r);
undElement.addAll(m);
cartesianProduct.add(undElement);
}
ret = cartesianProduct;
}
}
if(ret == null)return new TreeSet<>();
return ret;
}
public String toString(){
String ret = "[";
for(KomplexeMenge<A> item : this.getSet()){
ret += item.toString() + " , ";
}
return ret + "]";
}
}

View File

@ -0,0 +1,22 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class FieldAssumption {
private RefTypeOrTPHOrWildcardOrGeneric receiverType;
private RefTypeOrTPHOrWildcardOrGeneric type;
public FieldAssumption(RefTypeOrTPHOrWildcardOrGeneric receiverType,
RefTypeOrTPHOrWildcardOrGeneric type){
this.type = type;
this.receiverType = receiverType;
}
public RefTypeOrTPHOrWildcardOrGeneric getReceiverType() {
return receiverType;
}
public RefTypeOrTPHOrWildcardOrGeneric getType() {
return type;
}
}

View File

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

View File

@ -0,0 +1,22 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;
import java.util.Set;
public class TypeInferenceBlockInformation extends TypeInferenceInformation {
private Method methodContext;
private ClassOrInterface currentClass;
public TypeInferenceBlockInformation(Set<ClassOrInterface> availableClasses, ClassOrInterface currentClass, Method methodContext) {
super(availableClasses);
this.methodContext = methodContext;
this.currentClass = currentClass;
}
public ClassOrInterface getCurrentClass() {
return currentClass;
}
}

View File

@ -1,8 +1,15 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import java.util.ArrayList;
import java.util.List;
@ -19,15 +26,18 @@ Zweiteres hat den Vorteil, dass bei der Entwicklung leichter Dinge hinzugefügt
Die ganze Logik steckt in dieser Klasse.
*/
public class TypeInferenceInformation {
private Method methodContext;
private Set<ClassOrInterface> classes;
public TypeInferenceInformation(Set<ClassOrInterface> availableClasses){
classes = availableClasses;
}
public void setMethodContext(Method methodContext) {
this.methodContext = methodContext;
private RefTypeOrTPHOrWildcardOrGeneric checkGTV(RefTypeOrTPHOrWildcardOrGeneric type){
if(type instanceof GenericRefType){
return TypePlaceholder.fresh(new NullToken());
}else{
return type;
}
}
public List<MethodAssumption> getMethods(String name, ArgumentList arglist) {
@ -36,10 +46,33 @@ public class TypeInferenceInformation {
for(Method m : cl.getMethods()){
if(m.getName().equals(name) &&
m.getParameterList().getFormalparalist().size() == arglist.getArguments().size()){
ret.add(new MethodAssumption(cl.getType(), m.getType(), m.getParameterList()));
RefTypeOrTPHOrWildcardOrGeneric retType = checkGTV(m.getType());
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
for(FormalParameter fp : m.getParameterList().getFormalparalist()){
params.add(checkGTV(fp.getType()));
}
ret.add(new MethodAssumption(cl.getType(), retType, params));
}
}
}
return ret;
}
public List<FieldAssumption> getFields(String name){
List<FieldAssumption> ret = new ArrayList<>();
for(ClassOrInterface cl : classes){
for(Field m : cl.getFieldDecl()){
if(m.getName().equals(name)){
ret.add(new FieldAssumption(cl.getType(), checkGTV(m.getType())));
}
}
}
return ret;
}
public Set<ClassOrInterface> getAvailableClasses() {
return classes;
}
}

View File

@ -0,0 +1,10 @@
package de.dhbwstuttgart.typeinference.constraints;
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class Constraint<A> extends HashSet<A> {
}

View File

@ -0,0 +1,55 @@
package de.dhbwstuttgart.typeinference.constraints;
import de.dhbwstuttgart.typeinference.unify.GuavaSetOperations;
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public class ConstraintSet<A> {
Constraint<A> undConstraints = new Constraint<>();
List<Set<Constraint<A>>> oderConstraints = new ArrayList<>();
public void addUndConstraint(A p){
undConstraints.add(p);
}
public void addOderConstraint(Set<Constraint<A>> methodConstraints) {
oderConstraints.add(methodConstraints);
}
public void addAll(ConstraintSet constraints) {
this.undConstraints.addAll(constraints.undConstraints);
this.oderConstraints.addAll(constraints.oderConstraints);
}
@Override
public String toString(){
return cartesianProduct().toString();
}
public Set<List<Constraint<A>>> cartesianProduct(){
Set<Constraint<A>> toAdd = new HashSet<>();
toAdd.add(undConstraints);
List<Set<Constraint<A>>> allConstraints = new ArrayList<>();
allConstraints.add(toAdd);
allConstraints.addAll(oderConstraints);
return new GuavaSetOperations().cartesianProduct(allConstraints);
}
public <B> ConstraintSet<B> map(Function<? super A,? extends B> o) {
ConstraintSet<B> ret = new ConstraintSet<>();
ret.undConstraints = undConstraints.stream().map(o).collect(Collectors.toCollection(Constraint<B>::new));
List<Set<Constraint<B>>> newOder = new ArrayList<>();
for(Set<Constraint<A>> oderConstraint : oderConstraints){
newOder.add(
oderConstraint.parallelStream().map((Constraint<A> as) ->
as.stream().map(o).collect(Collectors.toCollection(Constraint<B>::new))).collect(Collectors.toSet())
);
}
ret.oderConstraints = newOder;
return ret;
}
}

View File

@ -1,28 +1,28 @@
package de.dhbwstuttgart.typeinference;
package de.dhbwstuttgart.typeinference.constraints;
import java.io.Serializable;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import com.sun.istack.internal.NotNull;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
public class Pair implements Serializable
{
public RefTypeOrTPH TA1;
public RefTypeOrTPH TA2;
public RefTypeOrTPHOrWildcardOrGeneric TA1;
public RefTypeOrTPHOrWildcardOrGeneric TA2;
private PairOperator eOperator = PairOperator.SMALLER;
public Pair( RefTypeOrTPH TA1, RefTypeOrTPH TA2 )
public Pair(@NotNull RefTypeOrTPHOrWildcardOrGeneric TA1, @NotNull RefTypeOrTPHOrWildcardOrGeneric TA2 )
{
this.TA1 = TA1;
this.TA2 = TA2;
if(TA1 == null || TA2 == null)
throw new NullPointerException();
eOperator = PairOperator.SMALLER;
}
public Pair( RefTypeOrTPH TA1, RefTypeOrTPH TA2, PairOperator eOp)
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2, PairOperator eOp)
{
// Konstruktor
this(TA1,TA2);

View File

@ -0,0 +1,6 @@
class Generics<B> {
<A> A mt1(A a, B b){
return mt1(a, a);
}
}

View File

@ -9,3 +9,9 @@ class Methods {
mt3(a) {return a.add(); }
}
class Test {
f;
add(){}
add(b){}
sub(b){}
}

View File

@ -2,6 +2,6 @@
class Methods {
mt4(a,b,c) { return a.mt3(b).mt3(c) ; }
mt3(a) {return a.add(); }
mt3(a) {return a.mt3(a); }
}

View File

@ -16,7 +16,8 @@ public class JavaTXCompilerTest {
@Test
public void test() throws IOException, ClassNotFoundException {
JavaTXCompiler compiler = new JavaTXCompiler();
compiler.parse(new File(rootDirectory+"MethodsEasy.jav"));
compiler.parse(new File(rootDirectory+"Methods.jav"));
compiler.parse(new File(rootDirectory+"Generics.jav"));
compiler.typeInference();
}
}