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><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.GenericTypeVar</li> <li>de.dhbwstuttgart.syntaxtree.GenericTypeVar</li>
@ -174,7 +174,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.htm
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.type.GenericTypeVar</li> <li>de.dhbwstuttgart.syntaxtree.type.GenericRefType</li>
</ul> </ul>
</li> </li>
</ul> </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><a href="../../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.type.Void</li> <li>de.dhbwstuttgart.syntaxtree.type.Void</li>
@ -219,7 +219,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" titl
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script> <script type="text/javascript" src="../../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script> <script type="text/javascript" src="../../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li> <li>java.lang.Object</li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.ConstraintsSet</li> <li>de.dhbwstuttgart.typeinference.ConstraintsSet</li>
@ -148,7 +148,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/UndMenge.html" title="c
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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><a href="../../../de/dhbwstuttgart/syntaxtree/type/ObjectType.html" title="class in de.dhbwstuttgart.syntaxtree.type">de.dhbwstuttgart.syntaxtree.type.ObjectType</a></li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.FunN</li> <li>de.dhbwstuttgart.typeinference.FunN</li>
@ -245,7 +245,7 @@ extends <a href="../../../de/dhbwstuttgart/syntaxtree/type/RefType.html" title="
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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>java.lang.Object</li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.OderConstraint</li> <li>de.dhbwstuttgart.typeinference.constraints.OderConstraint</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -144,7 +144,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/OderMenge.html" title="
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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>java.lang.Enum&lt;<a href="../../../de/dhbwstuttgart/typeinference/Pair.PairOperator.html" title="enum in de.dhbwstuttgart.typeinference">Pair.PairOperator</a>&gt;</li>
<li> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.Pair.PairOperator</li> <li>de.dhbwstuttgart.typeinference.constraints.Pair.PairOperator</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

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

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li> <li>java.lang.Object</li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.SingleConstraint</li> <li>de.dhbwstuttgart.typeinference.SingleConstraint</li>
@ -178,7 +178,7 @@ extends <a href="../../../de/dhbwstuttgart/typeinference/EinzelElement.html" tit
</tr> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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"> <ul class="subNavList">
<li>Summary:&nbsp;</li> <li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&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="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li> <li><a href="#method.summary">Method</a></li>
</ul> </ul>
@ -100,10 +100,10 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li> <li>java.lang.Object</li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li>de.dhbwstuttgart.typeinference.UndConstraint</li> <li>de.dhbwstuttgart.typeinference.constraints.UndConstraint</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -139,7 +139,7 @@ implements java.lang.Iterable&lt;<a href="../../../de/dhbwstuttgart/typeinferenc
</a> </a>
<h3>Field Summary</h3> <h3>Field Summary</h3>
<ul class="blockList"> <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> </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> <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> </tr>
</table> </table>
<ul class="blockList"> <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> </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> <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"> <ul class="subNavList">
<li>Summary:&nbsp;</li> <li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&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="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li> <li><a href="#method.summary">Method</a></li>
</ul> </ul>

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<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 ====== --> <!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom"> <div class="bottomNav"><a name="navbar.bottom">
<!-- --> <!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -12,13 +12,12 @@
<script type="text/javascript"><!-- <script type="text/javascript"><!--
try { try {
if (location.href.indexOf('is-external=true') == -1) { 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) { catch(err) {
} }
//--> //--></script>
</script>
<noscript> <noscript>
<div>JavaScript is disabled on your browser.</div> <div>JavaScript is disabled on your browser.</div>
</noscript> </noscript>
@ -70,7 +69,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -3,7 +3,7 @@
<html lang="de"> <html lang="de">
<head> <head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 --> <!-- 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"> <meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script> <script type="text/javascript" src="../../../../script.js"></script>
@ -70,7 +70,7 @@
</a></div> </a></div>
<!-- ========= END OF TOP NAVBAR ========= --> <!-- ========= END OF TOP NAVBAR ========= -->
<div class="header"> <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>
<div class="classUseContainer"> <div class="classUseContainer">
<ul class="blockList"> <ul class="blockList">

View File

@ -100,7 +100,7 @@ var activeTableTab = "activeTableTab";
<li>java.lang.Object</li> <li>java.lang.Object</li>
<li> <li>
<ul class="inheritance"> <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> <li>
<ul class="inheritance"> <ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/typeinference/ConstraintsSet.html" title="class in de.dhbwstuttgart.typeinference">de.dhbwstuttgart.typeinference.ConstraintsSet</a></li> <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> <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>
<ul class="blockList"> <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> </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> <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; package de.dhbwstuttgart.core;
import de.dhbwstuttgart.parser.JavaTXParser; import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; 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.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
public class JavaTXCompiler { public class JavaTXCompiler {
@ -17,10 +23,26 @@ public class JavaTXCompiler {
public void typeInference(){ public void typeInference(){
ConstraintSet cons = new ConstraintSet(); 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){ for(SourceFile sf : sourceFiles){
cons.addAll(sf.getConstraints(sf.getTypeInferenceInformation(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 { public void parse(File sourceFile) throws IOException, ClassNotFoundException {

View File

@ -31,7 +31,8 @@ public class JavaTXParser {
for(Class cl : PackageCrawler.getClassesInPackage("java.lang")){ for(Class cl : PackageCrawler.getClassesInPackage("java.lang")){
ret.add(cl.getName()); ret.add(cl.getName());
} }
//TODO: Wieso muss man das händisch anhängen?
ret.add("java.lang.Object");
return ret; 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.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.*; import de.dhbwstuttgart.syntaxtree.statement.literal.*;
import de.dhbwstuttgart.syntaxtree.type.RefType; 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.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry; import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.tree.TerminalNode; import org.antlr.v4.runtime.tree.TerminalNode;
@ -26,20 +25,25 @@ public class StatementGenerator {
private JavaClassRegistry reg; private JavaClassRegistry reg;
private Set<String> localVars = new HashSet<>(); private Set<String> localVars = new HashSet<>();
private GenericsRegistry generics;
public StatementGenerator(JavaClassRegistry reg){ public StatementGenerator(JavaClassRegistry reg, GenericsRegistry generics){
this.reg = reg; this.reg = reg;
this.generics = generics;
} }
public Method convert(Java8Parser.MethodDeclarationContext methodDeclarationContext) { public Method convert(Java8Parser.MethodDeclarationContext methodDeclarationContext) {
Java8Parser.MethodHeaderContext header = methodDeclarationContext.methodHeader(); Java8Parser.MethodHeaderContext header = methodDeclarationContext.methodHeader();
String name = header.methodDeclarator().Identifier().getText(); String name = header.methodDeclarator().Identifier().getText();
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), methodDeclarationContext.methodHeader().getStart());
RefTypeOrTPH retType; if(methodDeclarationContext.methodHeader().typeParameters() != null){
gtvDeclarations = TypeGenerator.convert(methodDeclarationContext.methodHeader().typeParameters(), reg, generics);
}
RefTypeOrTPHOrWildcardOrGeneric retType;
if(header.result() != null){ if(header.result() != null){
if(header.result().unannType() != 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 retType = new de.dhbwstuttgart.syntaxtree.type.Void(header.result().getStart());
}else{ }else{
@ -55,10 +59,6 @@ public class StatementGenerator {
}else{ }else{
block = this.convert(methodDeclarationContext.methodBody().block()); 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()); return new Method(name, retType, modifiers, parameterList,block, gtvDeclarations, methodDeclarationContext.getStart());
} }
@ -78,9 +78,9 @@ public class StatementGenerator {
for(Java8Parser.FormalParameterContext fp : fps){ for(Java8Parser.FormalParameterContext fp : fps){
String paramName = SyntaxTreeGenerator.convert(fp.variableDeclaratorId()); String paramName = SyntaxTreeGenerator.convert(fp.variableDeclaratorId());
RefTypeOrTPH type; RefTypeOrTPHOrWildcardOrGeneric type;
if(fp.unannType() != null){ if(fp.unannType() != null){
type = TypeGenerator.convert(fp.unannType(), reg); type = TypeGenerator.convert(fp.unannType(), reg, generics);
}else{ }else{
type = TypePlaceholder.fresh(fp.getStart()); type = TypePlaceholder.fresh(fp.getStart());
} }
@ -285,7 +285,7 @@ public class StatementGenerator {
receiver = new This(offset); receiver = new This(offset);
}else if(receiver == null){ //Handelt es sich um keinen Statischen Klassennamen: }else if(receiver == null){ //Handelt es sich um keinen Statischen Klassennamen:
String part = expression.substring(0,expression.length() - (1 + parts[parts.length-1].length())); 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); 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){ if(declaration.variableModifier() != null && declaration.variableModifier().size() > 0){
//TODO //TODO
} }
RefTypeOrTPH type; RefTypeOrTPHOrWildcardOrGeneric type;
if(declaration.unannType()==null){ if(declaration.unannType()==null){
type = TypePlaceholder.fresh(declaration.getStart()); type = TypePlaceholder.fresh(declaration.getStart());
}else{ }else{
type = TypeGenerator.convert(declaration.unannType(), reg); type = TypeGenerator.convert(declaration.unannType(), reg, generics);
} }
for(Java8Parser.VariableDeclaratorContext varDecl : declaration.variableDeclaratorList().variableDeclarator()){ for(Java8Parser.VariableDeclaratorContext varDecl : declaration.variableDeclaratorList().variableDeclarator()){
TerminalNode name = varDecl.variableDeclaratorId().Identifier(); TerminalNode name = varDecl.variableDeclaratorId().Identifier();
@ -756,7 +756,11 @@ public class StatementGenerator {
receiver = convert(methodInvocationContext.expressionName()); receiver = convert(methodInvocationContext.expressionName());
}else if(methodInvocationContext.toString().startsWith("super")) { }else if(methodInvocationContext.toString().startsWith("super")) {
receiver = new Super(methodInvocationContext.getStart()); 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()); ArgumentList argumentList = convert(methodInvocationContext.argumentList());
MethodCall ret = new MethodCall(new Receiver(receiver), name, argumentList, methodInvocationContext.getStart()); MethodCall ret = new MethodCall(new Receiver(receiver), name, argumentList, methodInvocationContext.getStart());

View File

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

View File

@ -1,22 +1,40 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator; package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.antlr.Java8Parser;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList; 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.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.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry; import de.dhbwstuttgart.typecheck.JavaClassRegistry;
import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.ArrayList;
import java.util.List;
public class TypeGenerator { 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(); 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()); 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){ if(unannTypeContext.unannPrimitiveType()!=null){
throw new NotImplementedException(); throw new NotImplementedException();
}else }else
@ -27,11 +45,38 @@ public class TypeGenerator {
JavaClassName name = reg.getName(unannTypeContext.unannReferenceType().unannTypeVariable().Identifier().toString()); JavaClassName name = reg.getName(unannTypeContext.unannReferenceType().unannTypeVariable().Identifier().toString());
return new RefType(name, unannTypeContext.getStart()); 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) { public static GenericDeclarationList convert(Java8Parser.TypeParametersContext typeParametersContext, JavaClassRegistry reg, GenericsRegistry generics) {
throw new NotImplementedException(); 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.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
@ -21,12 +21,12 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
private List<Method> methods = new ArrayList<>(); private List<Method> methods = new ArrayList<>();
private GenericDeclarationList genericClassParameters; private GenericDeclarationList genericClassParameters;
private Token offset; private Token offset;
private RefTypeOrTPH superClass; private RefTypeOrTPHOrWildcardOrGeneric superClass;
protected boolean isInterface; 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, 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); super(offset);
this.modifiers = modifiers; this.modifiers = modifiers;
if(name != null){ if(name != null){
@ -69,7 +69,7 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceInformation info) {
ConstraintSet ret = new ConstraintSet(); ConstraintSet ret = new ConstraintSet();
for(Method m : this.getMethods()){ for(Method m : this.getMethods()){
m.getConstraints(info); ret.addAll(m.getConstraints(info, this));
} }
return ret; return ret;
} }
@ -77,4 +77,8 @@ public class ClassOrInterface extends GTVDeclarationContext implements IItemWith
public RefType getType() { public RefType getType() {
return new RefType(this.getClassName(), this.getOffset()); return new RefType(this.getClassName(), this.getOffset());
} }
public RefTypeOrTPHOrWildcardOrGeneric getSuperClass() {
return superClass;
}
} }

View File

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

View File

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

View File

@ -1,19 +1,17 @@
package de.dhbwstuttgart.syntaxtree; package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
import java.util.List;
public class Field extends GTVDeclarationContext implements Generic { public class Field extends GTVDeclarationContext implements Generic {
private String name; private String name;
private RefTypeOrTPH type; private RefTypeOrTPHOrWildcardOrGeneric type;
private GenericDeclarationList genericParameters; 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); super(offset);
this.name = name; this.name = name;
this.type = type; this.type = type;
@ -23,7 +21,7 @@ public class Field extends GTVDeclarationContext implements Generic {
return this.name; return this.name;
} }
public RefTypeOrTPH getType() { public RefTypeOrTPHOrWildcardOrGeneric getType() {
return type; return type;
} }
} }

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package de.dhbwstuttgart.syntaxtree; package de.dhbwstuttgart.syntaxtree;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
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.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token; 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 ParameterList parameterlist = new ParameterList(new ArrayList<>(), new NullToken());
private ExceptionList exceptionlist; 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) { GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, offset); super(name, returnType, modifiers, offset);
this.parameterlist = parameterList; this.parameterlist = parameterList;
this.block = block; this.block = block;
} }
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceInformation info, ClassOrInterface currentClass) {
ConstraintSet ret = new ConstraintSet(); ConstraintSet ret = new ConstraintSet();
info.setMethodContext(this); ret.addAll(block.getConstraints(new TypeInferenceBlockInformation(info.getAvailableClasses(), currentClass, this)));
ret.addAll(block.getConstraints(info));
return ret; return ret;
} }

View File

@ -4,7 +4,7 @@ import java.util.*;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; 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.Field;
import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType; 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.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry; 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.statement.Statement;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
/** /**
* Anmerkung: * Anmerkung:
@ -49,13 +48,13 @@ public class ASTFactory {
java.lang.Class superjreClass = jreClass.getSuperclass(); java.lang.Class superjreClass = jreClass.getSuperclass();
RefType superClass; RefType superClass;
if(superjreClass != null){ if(superjreClass != null){
superClass = createType(superjreClass); superClass = (RefType) createType(superjreClass);
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!) }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<>(); List<RefType> implementedInterfaces = new ArrayList<>();
for(java.lang.Class jreInterface : jreClass.getInterfaces()){ for(java.lang.Class jreInterface : jreClass.getInterfaces()){
implementedInterfaces.add(createType(jreInterface)); implementedInterfaces.add((RefType) createType(jreInterface));
} }
GenericDeclarationList genericDeclarationList = createGenerics(jreClass.getTypeParameters(), jreClass, null); 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); return new ClassOrInterface(modifier, name, felder, methoden, genericDeclarationList, superClass,isInterface, implementedInterfaces, offset);
} }
private Method createConstructor(Constructor constructor, Class jreClass) { private de.dhbwstuttgart.syntaxtree.Constructor createConstructor(Constructor constructor, Class inClass) {
throw new NotImplementedException(); String name = constructor.getName();
} RefTypeOrTPHOrWildcardOrGeneric returnType = createType(inClass);
Parameter[] jreParams = constructor.getParameters();
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
RefType returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
List<FormalParameter> params = new ArrayList<>(); List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){ for(Parameter jreParam : jreParams){
RefType paramType = createType(jreParam.getType()); RefTypeOrTPHOrWildcardOrGeneric paramType = createType(jreParam.getType());
params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken())); params.add(new FormalParameter(jreParam.getName(),paramType, new NullToken()));
} }
ParameterList parameterList = new ParameterList(params, new NullToken()); ParameterList parameterList = new ParameterList(params, new NullToken());
Block block = new Block(new ArrayList<Statement>(), 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(); Token offset = new NullToken();
int modifier = jreMethod.getModifiers(); int modifier = jreMethod.getModifiers();
return new Method(name,returnType, modifier, parameterList, block, gtvDeclarations, offset); return new Method(name,returnType, modifier, parameterList, block, gtvDeclarations, offset);
} }
public GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, java.lang.reflect.Method contextM){ public GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, String methodName){
List<GenericTypeVar> gtvs = new ArrayList<>(); List<de.dhbwstuttgart.syntaxtree.GenericTypeVar> gtvs = new ArrayList<>();
for(TypeVariable jreTV : typeParameters){ for(TypeVariable jreTV : typeParameters){
GenericTypeVar gtv = createGeneric(jreTV, jreTV.getName()); de.dhbwstuttgart.syntaxtree.GenericTypeVar gtv = createGeneric(jreTV, jreTV.getName());
gtvs.add(gtv); gtvs.add(gtv);
} }
return new GenericDeclarationList(gtvs,new NullToken()); return new GenericDeclarationList(gtvs,new NullToken());
@ -105,13 +119,29 @@ public class ASTFactory {
} }
*/ */
public RefType createType(java.lang.reflect.Type type){ 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){ if(type instanceof TypeVariable){
//GTVDeclarationContext via "(TypeVariable) type).getGenericDeclaration()" //GTVDeclarationContext via "(TypeVariable) type).getGenericDeclaration()"
return new GenericRefType(new GenericTypeName(type.getTypeName(), return new GenericRefType(new GenericTypeName(type.getTypeName()), new NullToken());
new GTVDeclarationContext(new NullToken()) {}), new NullToken());
} }
List<RefTypeOrTPH> params = new ArrayList<>(); List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
if(type instanceof ParameterizedType){ if(type instanceof ParameterizedType){
for(Type t : ((ParameterizedType)type).getActualTypeArguments()){ for(Type t : ((ParameterizedType)type).getActualTypeArguments()){
params.add(createType(t)); params.add(createType(t));
@ -120,16 +150,17 @@ public class ASTFactory {
RefType ret = new RefType(this.names.getName(type.getTypeName()), params, new NullToken()); RefType ret = new RefType(this.names.getName(type.getTypeName()), params, new NullToken());
return ret; return ret;
} }
}
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, String name){ public de.dhbwstuttgart.syntaxtree.GenericTypeVar createGeneric(TypeVariable jreTypeVar, String name){
List<RefType> genericBounds = new ArrayList<>(); List<RefType> genericBounds = new ArrayList<>();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds(); java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){ if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){ 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() { 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; package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
@ -19,10 +20,10 @@ public class Assign extends Statement
} }
@Override @Override
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
ConstraintSet ret = lefSide.getConstraints(info); ConstraintSet ret = lefSide.getConstraints(info);
ret.addAll(rightSide.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; return ret;
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -2,24 +2,26 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import com.sun.istack.internal.NotNull;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
public abstract class Expression extends SyntaxTreeNode 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); super(offset);
if(type == null)throw new NullPointerException();
this.type = type; this.type = type;
} }
public RefTypeOrTPH getType(){ public RefTypeOrTPHOrWildcardOrGeneric getType(){
return type; 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; package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.FieldAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; 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 org.antlr.v4.runtime.Token;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.HashSet;
import java.util.Set;
public class FieldVar extends Expression { 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); super(type, offset);
this.fieldVarName = fieldVarName;
this.receiver = receiver;
} }
@Override @Override
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
//for(FieldAssumption fieldAssumption : info.getFields(fieldVarName)){ ConstraintSet ret = new ConstraintSet();
Set<Constraint> oderConstraints = new HashSet<>();
//} ret.addAll(receiver.getConstraints(info));
throw new NotImplementedException(); 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; 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.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -23,7 +24,7 @@ public class ForStmt extends Statement
@Override @Override
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token; 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); super(type, offset);
} }

View File

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

View File

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

View File

@ -1,21 +1,30 @@
package de.dhbwstuttgart.syntaxtree.statement; 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.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.Token;
import org.antlr.v4.runtime.atn.SemanticContext;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class This extends Expression public class This extends Expression
{ {
public This(Token offset) public This(Token offset)
{ {
super(null,null); super(TypePlaceholder.fresh(offset),offset);
} }
public ArgumentList arglist; public ArgumentList arglist;
@Override @Override
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException(); 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; 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.typeinference.assumptions.TypeInferenceInformation;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -12,7 +13,7 @@ public class UnaryPlus extends Expression
} }
@Override @Override
public ConstraintSet getConstraints(TypeInferenceInformation info) { public ConstraintSet getConstraints(TypeInferenceBlockInformation info) {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.syntaxtree.statement.literal; package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
@ -8,7 +7,7 @@ public class CharLiteral extends Literal
{ {
private char value; private char value;
public CharLiteral(RefTypeOrTPH type, char value, Token offset) public CharLiteral(RefTypeOrTPHOrWildcardOrGeneric type, char value, Token offset)
{ {
super(type,offset); super(type,offset);
this.value = value; 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.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
public abstract class Literal extends Expression public abstract class Literal extends Expression
{ {
public Literal(RefTypeOrTPH type, Token offset) { public Literal(RefTypeOrTPHOrWildcardOrGeneric type, Token offset) {
super(type, offset); super(type, offset);
} }
public ConstraintSet getConstraints(TypeInferenceInformation info){ public ConstraintSet getConstraints(TypeInferenceBlockInformation info){
return new ConstraintSet(); return new ConstraintSet();
} }
} }

View File

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

View File

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

View File

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

View File

@ -22,5 +22,15 @@ public class ExtendsWildcardType extends WildcardType{
super(extendsType, offset); 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 { public class FunN extends RefType {
private RefTypeOrTPH R; private RefTypeOrTPHOrWildcardOrGeneric R;
private List<? extends RefTypeOrTPH> T; private List<? extends RefTypeOrTPHOrWildcardOrGeneric> T;
/** /**
* @author Andreas Stadelmeier, a10023 * @author Andreas Stadelmeier, a10023
@ -25,7 +25,7 @@ public class FunN extends RefType {
* @param T * @param T
* @return * @return
*/ */
public FunN(RefTypeOrTPH R, List<? extends RefTypeOrTPH> T) { public FunN(RefTypeOrTPHOrWildcardOrGeneric R, List<? extends RefTypeOrTPHOrWildcardOrGeneric> T) {
super(null,null); super(null,null);
} }

View File

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

View File

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

View File

@ -7,9 +7,9 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import org.antlr.v4.runtime.Token; 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); super(offset);
} }
} }

View File

@ -28,9 +28,18 @@ public class SuperWildcardType extends WildcardType{
* Beispiel: ? super Integer. * Beispiel: ? super Integer.
* Integer wird zurückgegeben. * Integer wird zurückgegeben.
*/ */
public RefTypeOrTPH get_SuperType() public RefTypeOrTPHOrWildcardOrGeneric get_SuperType()
{ {
return this.innerType; 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 java.util.Hashtable;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;
/** /**
@ -12,7 +13,7 @@ import org.antlr.v4.runtime.Token;
* @author ¯Â¿Â½rg ¯Â¿Â½uerle * @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/06/19 12:45:37 $ * @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>(); private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
@ -38,11 +39,12 @@ public class TypePlaceholder extends RefTypeOrTPH
* @param name Der Name des TypePlaceholders * @param name Der Name des TypePlaceholders
* @return Der TypePlaceholder oder <code>null</code>, falls er nicht in der * @return Der TypePlaceholder oder <code>null</code>, falls er nicht in der
* Registry existiert * Registry existiert
*/
public static TypePlaceholder getInstance(String name) public static TypePlaceholder getInstance(String name)
{ {
return m_TypePlaceholdersRegistry.get(name); return m_TypePlaceholdersRegistry.get(name);
} }
*/
/** /**
* Generiert einen neuen TPH mit einem bestimmten Namen. * Generiert einen neuen TPH mit einem bestimmten Namen.
@ -63,7 +65,7 @@ public class TypePlaceholder extends RefTypeOrTPH
* @return * @return
*/ */
public static TypePlaceholder fresh(Token position){ 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; 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/> * Author: Arne ¼dtke<br/>
@ -19,10 +19,14 @@ public abstract class WildcardType extends RefType {
*/ */
public WildcardType(RefType innerType, Token offset) public WildcardType(RefType innerType, Token offset)
{ {
super(innerType.getName(), offset); super(offset);
this.innerType = innerType; this.innerType = innerType;
} }
public RefType getInnerType(){
return innerType;
}
/** /**
* Author: Arne ¼dtke<br/> * Author: Arne ¼dtke<br/>
* Gibt String Entsprechung zurück. * Gibt String Entsprechung zurück.
@ -33,13 +37,6 @@ public abstract class WildcardType extends RefType {
} }
/** public abstract boolean isExtends();
* Author: Arne ¼dtke<br/> public abstract boolean isSuper();
* Die Allgemeine Wildcard enthält keinen Typen.
*/
public RefTypeOrTPH GetWildcardType()
{
return null;
}
} }

View File

@ -3,7 +3,7 @@ package de.dhbwstuttgart.typecheck;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext; import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
public class GenericTypeName extends JavaClassName { public class GenericTypeName extends JavaClassName {
public GenericTypeName(String name, GTVDeclarationContext declarationContext) { public GenericTypeName(String name) {
super(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.ParameterList;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.misc.DoubleKeyMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class MethodAssumption { public class MethodAssumption {
private RefType receiver; private RefType receiver;
private RefTypeOrTPH retType; private RefTypeOrTPHOrWildcardOrGeneric retType;
ParameterList params; List<RefTypeOrTPHOrWildcardOrGeneric> params;
public MethodAssumption(RefType receiver, RefTypeOrTPH retType, ParameterList params){ public MethodAssumption(RefType receiver, RefTypeOrTPHOrWildcardOrGeneric retType, List<RefTypeOrTPHOrWildcardOrGeneric> params){
this.receiver = receiver; this.receiver = receiver;
this.retType = retType; this.retType = retType;
this.params = params; this.params = params;
} }
public RefType getReceiverType() { public RefType getReceiverType() {
return null; return receiver;
} }
public RefTypeOrTPH getReturnType() { public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return retType; return retType;
} }
public List<RefTypeOrTPH> getArgTypes() { public List<RefTypeOrTPHOrWildcardOrGeneric> getArgTypes() {
return params.getFormalparalist().stream(). return params;
map(formalParameter -> formalParameter.getType()).collect(Collectors.toList());
} }
} }

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; package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList; 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.ArrayList;
import java.util.List; 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. Die ganze Logik steckt in dieser Klasse.
*/ */
public class TypeInferenceInformation { public class TypeInferenceInformation {
private Method methodContext;
private Set<ClassOrInterface> classes; private Set<ClassOrInterface> classes;
public TypeInferenceInformation(Set<ClassOrInterface> availableClasses){ public TypeInferenceInformation(Set<ClassOrInterface> availableClasses){
classes = availableClasses; classes = availableClasses;
} }
public void setMethodContext(Method methodContext) { private RefTypeOrTPHOrWildcardOrGeneric checkGTV(RefTypeOrTPHOrWildcardOrGeneric type){
this.methodContext = methodContext; if(type instanceof GenericRefType){
return TypePlaceholder.fresh(new NullToken());
}else{
return type;
}
} }
public List<MethodAssumption> getMethods(String name, ArgumentList arglist) { public List<MethodAssumption> getMethods(String name, ArgumentList arglist) {
@ -36,10 +46,33 @@ public class TypeInferenceInformation {
for(Method m : cl.getMethods()){ for(Method m : cl.getMethods()){
if(m.getName().equals(name) && if(m.getName().equals(name) &&
m.getParameterList().getFormalparalist().size() == arglist.getArguments().size()){ 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; 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 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.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 class Pair implements Serializable
{ {
public RefTypeOrTPH TA1; public RefTypeOrTPHOrWildcardOrGeneric TA1;
public RefTypeOrTPH TA2; public RefTypeOrTPHOrWildcardOrGeneric TA2;
private PairOperator eOperator = PairOperator.SMALLER; private PairOperator eOperator = PairOperator.SMALLER;
public Pair( RefTypeOrTPH TA1, RefTypeOrTPH TA2 ) public Pair(@NotNull RefTypeOrTPHOrWildcardOrGeneric TA1, @NotNull RefTypeOrTPHOrWildcardOrGeneric TA2 )
{ {
this.TA1 = TA1; this.TA1 = TA1;
this.TA2 = TA2; this.TA2 = TA2;
if(TA1 == null || TA2 == null)
throw new NullPointerException();
eOperator = PairOperator.SMALLER; eOperator = PairOperator.SMALLER;
} }
public Pair( RefTypeOrTPH TA1, RefTypeOrTPH TA2, PairOperator eOp) public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2, PairOperator eOp)
{ {
// Konstruktor // Konstruktor
this(TA1,TA2); 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(); } mt3(a) {return a.add(); }
} }
class Test {
f;
add(){}
add(b){}
sub(b){}
}

View File

@ -2,6 +2,6 @@
class Methods { class Methods {
mt4(a,b,c) { return a.mt3(b).mt3(c) ; } 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 @Test
public void test() throws IOException, ClassNotFoundException { public void test() throws IOException, ClassNotFoundException {
JavaTXCompiler compiler = new JavaTXCompiler(); 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(); compiler.typeInference();
} }
} }