Merge branch 'bigRefactoring' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into plugin

This commit is contained in:
Andreas Stadelmeier 2018-01-31 16:06:21 +01:00
commit 1a1ab2696d
120 changed files with 1558 additions and 919 deletions

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.BoolLiteral</li>
@ -253,7 +253,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.CharLiteral</li>
@ -253,7 +253,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.DoubleLiteral</li>
@ -263,7 +263,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.FloatLiteral</li>
@ -263,7 +263,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.NumberLiteral</li>
@ -263,7 +263,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.Literal</li>
<li>de.dhbwstuttgart.syntaxtree.statement.Literal</li>
</ul>
</li>
</ul>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.LongLiteral</li>
@ -263,7 +263,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.NegativeExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.NegativeExpr</li>
</ul>
</li>
</ul>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.NotExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.NotExpr</li>
</ul>
</li>
</ul>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.Null</li>
@ -245,7 +245,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.PositivExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.PositivExpr</li>
</ul>
</li>
</ul>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.PostDecExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostDecExpr</li>
</ul>
</li>
</ul>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.PostIncExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostIncExpr</li>
</ul>
</li>
</ul>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.PreDecExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreDecExpr</li>
</ul>
</li>
</ul>

View File

@ -115,7 +115,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.UnaryExpr</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.PreIncExpr</li>
<li>de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreIncExpr</li>
</ul>
</li>
</ul>

View File

@ -112,7 +112,7 @@ var activeTableTab = "activeTableTab";
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Expr.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Expr</a></li>
<li>
<ul class="inheritance">
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.literal.Literal</a></li>
<li><a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">de.dhbwstuttgart.syntaxtree.statement.Literal</a></li>
<li>
<ul class="inheritance">
<li>de.dhbwstuttgart.syntaxtree.statement.literal.StringLiteral</li>
@ -253,7 +253,7 @@ extends <a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html"
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.literal.Literal">
<li class="blockList"><a name="methods.inherited.from.class.de.dhbwstuttgart.syntaxtree.statement.Literal">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;de.dhbwstuttgart.syntaxtree.statement.<a href="../../../../de/dhbwstuttgart/syntaxtree/statement/Literal.html" title="class in de.dhbwstuttgart.syntaxtree.statement">Literal</a></h3>

View File

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

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.NegativeExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.NegativeExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.NegativeExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.NegativeExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.NegativeExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.NegativeExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.NegativeExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.NegativeExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.NotExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.NotExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.NotExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.NotExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.NotExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.NotExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.NotExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.NotExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.PositivExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PositivExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.PositivExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PositivExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PositivExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PositivExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.PositivExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.PositivExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.PostDecExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostDecExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.PostDecExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PostDecExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostDecExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PostDecExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.PostDecExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostDecExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.PostIncExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostIncExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.PostIncExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PostIncExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostIncExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PostIncExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.PostIncExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.PostIncExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.PreDecExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreDecExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.PreDecExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PreDecExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreDecExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PreDecExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.PreDecExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreDecExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -3,7 +3,7 @@
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_05) on Tue May 12 19:56:24 CEST 2015 -->
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.PreIncExpr</title>
<title>Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreIncExpr</title>
<meta name="date" content="2015-05-12">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
@ -70,9 +70,9 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.PreIncExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PreIncExpr</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreIncExpr" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.statement.PreIncExpr</h2>
</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.PreIncExpr</div>
<div class="classUseContainer">No usage of de.dhbwstuttgart.syntaxtree.statement.javaInternal.PreIncExpr</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->

View File

@ -23,6 +23,11 @@
<artifactId>antlr4</artifactId>
<version>4.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.bytecode;
import java.util.HashMap;
import java.util.Iterator;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.statement.*;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
@ -11,11 +12,11 @@ import org.objectweb.asm.Opcodes;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.Literal;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -23,7 +24,6 @@ import de.dhbwstuttgart.typeinference.result.ResultSet;
public class BytecodeGen implements ASTVisitor {
ClassWriter cw =new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
// String methDesc;
String type;
@ -34,6 +34,12 @@ public class BytecodeGen implements ASTVisitor {
// stores parameter, local vars and the next index on the local variable table, which use for aload_i, astore_i,...
HashMap<String, Integer> paramsAndLocals = new HashMap<>();
// stores generics and their bounds of class
HashMap<String, String> genericsAndBounds = new HashMap<>();
// stores generics and their bounds of method
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes = new HashMap<>();
byte[] bytecode;
HashMap<String,byte[]> classFiles;
@ -45,14 +51,19 @@ public class BytecodeGen implements ASTVisitor {
@Override
public void visit(SourceFile sourceFile) {
for(ClassOrInterface cl : sourceFile.getClasses()) {
isInterface = (cl.getModifiers()&512)==512;
System.out.println("IS Interface = "+"modifiers= "+cl.getModifiers()+" ->"+(cl.getModifiers()&512) + isInterface);
BytecodeGen classGen = new BytecodeGen(classFiles, resultSet);
cl.accept(classGen);
System.out.println("In CLASS: "+(cl.getClassName().toString()));
classGen.writeClass(cl.getClassName().toString());
}
}
/**
* Associates the bytecode of the class that was build with the classWriter {@link #cw}
* with the class name in the map {@link #classFiles}
*
* @param name name of the class with which the the bytecode is to be associated
*/
private void writeClass(String name) {
bytecode = cw.toByteArray();
classFiles.put(name, bytecode);
@ -62,12 +73,30 @@ public class BytecodeGen implements ASTVisitor {
public HashMap<String,byte[]> getClassFiles() {
return classFiles;
}
@Override
public void visit(ClassOrInterface classOrInterface) {
className = classOrInterface.getClassName().toString();
// access flages??
cw.visit(Opcodes.V1_8, classOrInterface.getModifiers()+Opcodes.ACC_SUPER, classOrInterface.getClassName().toString()
, null, classOrInterface.getSuperClass().toString().replace(".", "/"), null);
isInterface = (classOrInterface.getModifiers()&512)==512;
System.out.println("IS Interface = "+"modifiers= "+classOrInterface.getModifiers()+" ->"+(classOrInterface.getModifiers()&512) + isInterface);
int acc = isInterface?classOrInterface.getModifiers()+Opcodes.ACC_ABSTRACT:classOrInterface.getModifiers()+Opcodes.ACC_SUPER;
String sig = null;
/* if class has generics then creates signature
* Signature looks like:
* <E:Ljava/...>Superclass
*/
if(classOrInterface.getGenerics().iterator().hasNext()) {
Signature signature = new Signature(classOrInterface, genericsAndBounds);
System.out.println(signature.toString());
sig = signature.toString();
}
// needs implemented Interfaces?
cw.visit(Opcodes.V1_8, acc, classOrInterface.getClassName().toString()
, sig, classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()), null);
// for each field in the class
for(Field f : classOrInterface.getFieldDecl()) {
@ -88,13 +117,31 @@ public class BytecodeGen implements ASTVisitor {
@Override
public void visit(Constructor field) {
Descriptor desc = new Descriptor(field, resultSet);
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", desc.getDesc(), null, null);
field.getParameterList().accept(this);
String desc = null;
boolean hasGen = false;
for(String paramName : methodParamsAndTypes.keySet()) {
genericsAndBounds.containsKey(paramName);
hasGen = true;
}
String sig = null;
if(hasGen) {
System.out.println("IM IN CONST HAS Gens");
Signature signature = new Signature(field, genericsAndBounds,methodParamsAndTypes);
sig = signature.toString();
System.out.println(sig);
}
NormalConstructor constructor = new NormalConstructor(field,genericsAndBounds,hasGen);
desc = constructor.accept(new DescriptorToString(resultSet));
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", desc, sig, null);
mv.visitCode();
System.out.println("-----Constructor-----");
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,field, mv,paramsAndLocals,desc.getDesc(),cw,isInterface);
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,field, mv,paramsAndLocals,cw,
genericsAndBoundsMethod,genericsAndBounds,isInterface);
if(!field.getParameterList().iterator().hasNext()) {
mv.visitInsn(Opcodes.RETURN);
}
mv.visitMaxs(0, 0);
mv.visitEnd();
}
@ -104,12 +151,49 @@ public class BytecodeGen implements ASTVisitor {
// TODO: check if the method is static => if static then the first param will be stored in pos 0
// else it will be stored in pos 1 and this will be stored in pos 0
method.getParameterList().accept(this);
Descriptor methDesc = new Descriptor(method,resultSet);
String methDesc = null;
// Method getModifiers() ?
int acc = isInterface?Opcodes.ACC_ABSTRACT:0;
System.out.println("-----Method-----");
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, method.getName(), methDesc.getDesc(), null, null);
boolean hasGenInParameterList = genericsAndBounds.containsKey(method.getReturnType().acceptTV(new TypeToDescriptor()));
if(!hasGenInParameterList) {
for(String paramName : methodParamsAndTypes.keySet()) {
if(genericsAndBounds.containsKey(paramName)) {
hasGenInParameterList = true;
break;
}
}
}
String sig = null;
boolean hasGen = method.getGenerics().iterator().hasNext() || hasGenInParameterList;
// Wenn ReturnType has Generics?? Fun1<...> wie testet man das generic hat??
System.out.println(method.getReturnType().acceptTV(new TypeToString()));
// if(method.getReturnType().acceptTV(new TypeToString()).equals("TPH")) {
// Signature signature = new Signature(method, genericsAndBoundsMethod, methodParamsAndTypes,resultSet);
// sig = signature.toString();
// System.out.println(sig);
// }
/* if method has generics, create signature */
if(hasGen) {
// resultset hier zum testen
Signature signature = new Signature(method, genericsAndBoundsMethod, methodParamsAndTypes,resultSet);
sig = signature.toString();
System.out.println(sig);
}
NormalMethod meth = new NormalMethod(method,genericsAndBounds,genericsAndBoundsMethod,hasGen);
methDesc = meth.accept(new DescriptorToString(resultSet));
System.out.println("methDesc" + methDesc);
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC+acc, method.getName(), methDesc, sig, null);
mv.visitCode();
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,method, mv,paramsAndLocals,methDesc.getDesc(),cw,isInterface);
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,method, mv,paramsAndLocals,cw,genericsAndBounds,genericsAndBounds,isInterface);
mv.visitMaxs(0, 0);
mv.visitEnd();
}
@ -117,11 +201,13 @@ public class BytecodeGen implements ASTVisitor {
@Override
public void visit(ParameterList formalParameters) {
paramsAndLocals = new HashMap<>();
methodParamsAndTypes = new HashMap<>();
Iterator<FormalParameter> itr = formalParameters.iterator();
int i = 1;
while(itr.hasNext()) {
FormalParameter fp = itr.next();
paramsAndLocals.put(fp.getName(), i);
methodParamsAndTypes.put(fp.getName(), fp.getType());
fp.accept(this);
i++;
}
@ -191,8 +277,7 @@ public class BytecodeGen implements ASTVisitor {
}
@Override
public void visit(Binary binary) {
// TODO Auto-generated method stub
public void visit(BinaryExpr binary) {
}
@ -292,12 +377,6 @@ public class BytecodeGen implements ASTVisitor {
}
@Override
public void visit(UnaryPlus unaryPlus) {
// TODO Auto-generated method stub
}
@Override
public void visit(WhileStmt whileStmt) {
// TODO Auto-generated method stub
@ -310,11 +389,6 @@ public class BytecodeGen implements ASTVisitor {
}
@Override
public void visit(Null aNull) {
// TODO Auto-generated method stub
}
// ???
@Override
public void visit(Literal literal) {
@ -363,4 +437,9 @@ public class BytecodeGen implements ASTVisitor {
}
@Override
public void visit(UnaryExpr unaryExpr) {
throw new NotImplementedException();
}
}

View File

@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.statement.*;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Handle;
@ -19,8 +20,7 @@ import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.Literal;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -29,12 +29,13 @@ public class BytecodeGenMethod implements StatementVisitor{
private Method m;
private MethodVisitor mv;
private HashMap<String, Integer> paramsAndLocals = new HashMap<>();
private String desc;
private String className;
private int lamCounter;
private ClassWriter cw;
private ResultSet resultSet;
private boolean isInterface;
HashMap<String, String> genericsAndBoundsMethod;
private HashMap<String,String> genericsAndBounds;
//for tests **
private String fieldName;
@ -46,8 +47,9 @@ public class BytecodeGenMethod implements StatementVisitor{
private ArrayList<RefTypeOrTPHOrWildcardOrGeneric> varsFunInterface;
public BytecodeGenMethod(String className,ResultSet resultSet, Method m, MethodVisitor mv, HashMap<String, Integer> paramsAndLocals,
String desc, ClassWriter cw, boolean isInterface) {
public BytecodeGenMethod(String className,ResultSet resultSet, Method m, MethodVisitor mv,
HashMap<String, Integer> paramsAndLocals, ClassWriter cw,
HashMap<String, String> genericsAndBoundsMethod, HashMap<String,String> genericsAndBounds, boolean isInterface) {
this.where = "<<<<<< NORMAL METHOD >>>>>>";
@ -56,29 +58,32 @@ public class BytecodeGenMethod implements StatementVisitor{
this.m = m;
this.mv = mv;
this.paramsAndLocals = paramsAndLocals;
this.desc = desc;
this.cw = cw;
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
this.genericsAndBounds = genericsAndBounds;
this.isInterface = isInterface;
this.lamCounter = -1;
this.varsFunInterface = new ArrayList<>();
System.out.println("PARAMS = "+this.paramsAndLocals.size());
if(!isInterface)
this.m.block.accept(this);
System.out.println("PARAMS = "+this.paramsAndLocals.size());
for(int i = 0; i<this.paramsAndLocals.size();i++) {
System.out.println(this.paramsAndLocals.keySet().toArray()[i]);
}
// System.out.println("PARAMS = "+this.paramsAndLocals.size());
// for(int i = 0; i<this.paramsAndLocals.size();i++) {
// System.out.println(this.paramsAndLocals.keySet().toArray()[i]);
// }
}
public BytecodeGenMethod(LambdaExpression lambdaExpression,ResultSet resultSet ,MethodVisitor mv,
String desc,int indexOfFirstParamLam, boolean isInterface) {
int indexOfFirstParamLam, boolean isInterface) {
System.out.println("\t\t++++++IN LAMBDA -------");
this.where = "<<<<<< LAMBDA METHOD >>>>>>";
this.resultSet = resultSet;
this.mv = mv;
this.desc = desc;
this.isInterface = isInterface;
this.lamCounter = -1;
this.varsFunInterface = new ArrayList<>();
@ -94,7 +99,8 @@ public class BytecodeGenMethod implements StatementVisitor{
}
private String getResolvedType(RefTypeOrTPHOrWildcardOrGeneric type) {
return resultSet.resolveType(type).resolvedType.toString().replace(".", "/");
// return resultSet.resolveType(type).resolvedType.toString().replace(".", "/");
return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor());
}
@ -113,7 +119,7 @@ public class BytecodeGenMethod implements StatementVisitor{
superCall.receiver.accept(this);
superCall.arglist.accept(this);
// mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", superCall.name, desc,false);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), superCall.name, desc,isInterface);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), superCall.name, "()V",isInterface);
}
// ??
@ -150,13 +156,10 @@ public class BytecodeGenMethod implements StatementVisitor{
assign.rightSide.accept(this);
assign.lefSide.accept(this);
}
}
@Override
public void visit(Binary binary) {
public void visit(BinaryExpr binary) {
System.out.println("\t++ In Binary: ");
}
@ -164,7 +167,11 @@ public class BytecodeGenMethod implements StatementVisitor{
public void visit(LambdaExpression lambdaExpression) {
System.out.println("\n++ In Lambda: ");
this.lamCounter++;
Descriptor lamDesc = new Descriptor(lambdaExpression, resultSet);
System.out.println("Lam Hs Gens: " + lambdaExpression.getGenerics().iterator().hasNext());
System.out.println("Lam Hs Gens: " + lambdaExpression.getReturnType().acceptTV(new TypeToString()));
Lambda lam = new Lambda(lambdaExpression);
String lamDesc = lam.accept(new DescriptorToString(resultSet));
//Call site, which, when invoked, returns an instance of the functional interface to which
//the lambda is being converted
MethodType mt = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
@ -174,10 +181,12 @@ public class BytecodeGenMethod implements StatementVisitor{
Handle bootstrap = new Handle(Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory",
"metafactory", mt.toMethodDescriptorString(), false);
String methodName = "lambda$new$" + this.lamCounter;
// String typeErasure = "(Ljava/lang/Object;)Ljava/lang/Object;";
// Type erasure
Type arg1 = Type.getMethodType(lamDesc.getDesc());
// Type arg1 = Type.getMethodType(typeErasure);
Type arg1 = Type.getMethodType(lamDesc);
// real Type
Type arg3 = Type.getMethodType(lamDesc.getDesc());
Type arg3 = Type.getMethodType(lamDesc);
int staticOrSpecial=0;
int staticOrInstance=0;
@ -197,16 +206,16 @@ public class BytecodeGenMethod implements StatementVisitor{
Handle arg2 = new Handle(staticOrSpecial, this.className, methodName,
arg3.toString(),false);
// Descriptor of functional interface methode
Descriptor fiMethodDesc = new Descriptor(kindOfLambda.getArgumentList(), lambdaExpression.getType(),resultSet);
SamMethod samMethod = new SamMethod(kindOfLambda.getArgumentList(), lambdaExpression.getType());
// Desc: (this/nothing)TargetType
mv.visitInvokeDynamicInsn("apply", fiMethodDesc.getDesc(), bootstrap,
String fiMethodDesc = samMethod.accept(new DescriptorToString(resultSet));
mv.visitInvokeDynamicInsn("apply", fiMethodDesc, bootstrap,
arg1, arg2,arg3);
MethodVisitor mvLambdaBody = cw.visitMethod(Opcodes.ACC_PRIVATE+ staticOrInstance + Opcodes.ACC_SYNTHETIC,
methodName, arg3.toString(), null, null);
new BytecodeGenMethod(lambdaExpression,this.resultSet,mvLambdaBody,arg3.toString(),indexOfFirstParamLam,isInterface);
new BytecodeGenMethod(lambdaExpression,this.resultSet,mvLambdaBody,indexOfFirstParamLam,isInterface);
mvLambdaBody.visitMaxs(0, 0);
mvLambdaBody.visitEnd();
@ -274,17 +283,20 @@ public class BytecodeGenMethod implements StatementVisitor{
methodCall.receiver.accept(this);
methodCall.arglist.accept(this);
Descriptor mDesc = new Descriptor(methodCall.arglist, methodCall.getType(),resultSet);
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
genericsAndBoundsMethod,genericsAndBounds);
String mDesc = method.accept(new DescriptorToString(resultSet));
System.out.println("is Vars empty: "+varsFunInterface.isEmpty());
// is methodCall.receiver functional Interface)?
if(varsFunInterface.contains(methodCall.receiver.getType())) {
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, getResolvedType(methodCall.receiver.getType()),
methodCall.name, mDesc.getDesc(), false);
methodCall.name, mDesc, false);
}else {
System.out.println("mDesc = " + mDesc);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getResolvedType(methodCall.receiver.getType()),
methodCall.name, mDesc.getDesc(), isInterface);
methodCall.name, mDesc, isInterface);
}
// test
// if(!methodCall.getType().toString().equals("V")) {
@ -303,7 +315,7 @@ public class BytecodeGenMethod implements StatementVisitor{
methodCall.arglist.accept(this);
String d = "(";
for(Expression e : methodCall.arglist.getArguments()) {
d = d + "L"+e.getType().toString().replace(".", "/") + ";";
d = d + "L"+getResolvedType(e.getType()) + ";";
}
d += ")V";
@ -323,6 +335,11 @@ public class BytecodeGenMethod implements StatementVisitor{
receiver.expr.accept(this);
}
@Override
public void visit(UnaryExpr unaryExpr) {
throw new NotImplementedException();
}
@Override
public void visit(Return aReturn) {
aReturn.retexpr.accept(this);
@ -339,7 +356,7 @@ public class BytecodeGenMethod implements StatementVisitor{
System.out.println("In StaticClassName: ");
// mv.visitMethodInsn(Opcodes.INVOKESTATIC, staticClassName.getType().toString().replace(".", "/"),
// staticClassName.toString(), staticClassName.getType().toString(), false);
mv.visitFieldInsn(Opcodes.GETSTATIC, staticClassName.getType().toString().replace(".", "/"),
mv.visitFieldInsn(Opcodes.GETSTATIC, getResolvedType(staticClassName.getType()),
fieldName, fieldDesc);
}
@ -354,11 +371,6 @@ public class BytecodeGenMethod implements StatementVisitor{
mv.visitVarInsn(Opcodes.ALOAD, 0);
}
@Override
public void visit(UnaryPlus unaryPlus) {
System.out.println("++ In UnaryPlus: ");
}
@Override
public void visit(WhileStmt whileStmt) {
// TODO Auto-generated method stub
@ -371,15 +383,10 @@ public class BytecodeGenMethod implements StatementVisitor{
}
@Override
public void visit(Null aNull) {
mv.visitInsn(Opcodes.ACONST_NULL);
}
@Override
public void visit(Literal literal) {
// value?
mv.visitLdcInsn(literal.getType().toString());
mv.visitLdcInsn(getResolvedType(literal.getType()));
}
@Override
@ -393,14 +400,16 @@ public class BytecodeGenMethod implements StatementVisitor{
@Override
public void visit(AssignToField assignLeftSide) {
// temporäre Lösung für testen, bis ich weiss wie man funktionale
// interfaces erkennt
if(isRightSideALambda)
varsFunInterface.add(assignLeftSide.field.getType());
// Loads the an object reference from the local variable
// array slot onto the top of the operand stack.
assignLeftSide.field.receiver.accept(this);
this.rightSideTemp.accept(this);
mv.visitFieldInsn(Opcodes.PUTFIELD, assignLeftSide.field.receiver.getType().toString(),
assignLeftSide.field.fieldVarName, assignLeftSide.field.getType().toString());
mv.visitFieldInsn(Opcodes.PUTFIELD, getResolvedType(assignLeftSide.field.receiver.getType()),
assignLeftSide.field.fieldVarName, getResolvedType(assignLeftSide.field.getType()));
}
@Override

View File

@ -1,112 +0,0 @@
package de.dhbwstuttgart.bytecode;
import java.util.List;
import java.util.Iterator;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.result.ResultSet;
public class Descriptor {
String desc;
public Descriptor(Method method, ResultSet resultSet) {
desc = "(";
Iterator<FormalParameter> itr = method.getParameterList().iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
desc = desc + "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
desc = addReturnType(desc,method.getReturnType(), resultSet);
}
private class TypeToDescriptor implements TypeVisitor<String>{
@Override
public String visit(RefType refType) {
return refType.getName().toString().replace(".", "/");
}
@Override
public String visit(SuperWildcardType superWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(TypePlaceholder typePlaceholder) {
return typePlaceholder.toString();
}
@Override
public String visit(ExtendsWildcardType extendsWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(GenericRefType genericRefType) {
return genericRefType.getParsedName();
}
}
private String addReturnType(String desc2, RefTypeOrTPHOrWildcardOrGeneric returnType, ResultSet resultSet) {
System.out.println("DescType = "+returnType.toString());
if(resultSet.resolveType(returnType).resolvedType.toString().equals("void")){
desc = desc + ")V";
}else {
desc = desc + ")" + "L"+resultSet.resolveType(returnType).resolvedType.toString().replace(".", "/")+";";
}
return desc;
}
public Descriptor(Constructor constructor, ResultSet resultSet) {
desc = "(";
Iterator<FormalParameter> itr = constructor.getParameterList().iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
desc = desc + "L"+resultSet.resolveType(fp.getType()).resolvedType.toString().replace(".", "/") + ";";
}
desc = desc + ")V";
}
public Descriptor(LambdaExpression lambdaExpr, ResultSet resultSet) {
desc = "(";
Iterator<FormalParameter> itr = lambdaExpr.params.iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
desc = desc + "L"+resultSet.resolveType(fp.getType()).resolvedType.toString().replace(".", "/") + ";";
}
desc = addReturnType(desc, lambdaExpr.getReturnType(), resultSet);
}
public Descriptor(ArgumentList argList, RefTypeOrTPHOrWildcardOrGeneric returnType, ResultSet resultSet) {
desc = "(";
for(Expression e : argList.getArguments()) {
desc = desc + "L"+resultSet.resolveType(e.getType()).resolvedType.toString().replace(".", "/") + ";";
}
desc = addReturnType(desc, returnType, resultSet);
}
public Descriptor(List<RefTypeOrTPHOrWildcardOrGeneric> argumentList,RefTypeOrTPHOrWildcardOrGeneric returnType ,ResultSet resultSet) {
desc = "(";
Iterator<RefTypeOrTPHOrWildcardOrGeneric> itr = argumentList.iterator();
while(itr.hasNext()) {
RefTypeOrTPHOrWildcardOrGeneric rt = itr.next();
desc = desc + "L"+resultSet.resolveType(rt).resolvedType.toString().replace(".", "/")+";";
}
desc = desc + ")"+"L"+resultSet.resolveType(returnType).resolvedType.toString().replace(".", "/")+";";
}
public String getDesc() {
return this.desc;
}
}

View File

@ -0,0 +1,146 @@
package de.dhbwstuttgart.bytecode;
import java.util.Iterator;
import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.result.ResultSet;
public class DescriptorToString implements DescriptorVisitor{
ResultSet resultSet;
public DescriptorToString(ResultSet resultSet) {
this.resultSet = resultSet;
}
private String addReturnType(String desc, RefTypeOrTPHOrWildcardOrGeneric returnType, ResultSet resultSet) {
if(resultSet.resolveType(returnType).resolvedType.toString().equals("void")){
desc = desc + ")V";
}else {
desc = desc + ")" + "L"+resultSet.resolveType(returnType).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
return desc;
}
@Override
public String visit(NormalMethod method) {
String desc = "(";
Iterator<FormalParameter> itr = method.getParameterList().iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
if(method.hasGen()) {
String fpDesc = fp.getType().acceptTV(new TypeToDescriptor());
if(method.getGenericsAndBoundsMethod().containsKey(fpDesc)) {
desc += "L"+method.getGenericsAndBoundsMethod().get(fpDesc)+ ";";
}else if(method.getGenericsAndBounds().containsKey(fpDesc)){
desc += "L"+method.getGenericsAndBounds().get(fpDesc)+ ";";
}else {
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}else {
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}
if(resultSet.resolveType(method.getReturnType()).resolvedType.toString().equals("void")) {
desc += ")V";
}else {
if(method.hasGen()) {
String ret = method.getReturnType().acceptTV(new TypeToDescriptor());
if(method.getGenericsAndBoundsMethod().containsKey(ret)) {
desc += ")L"+method.getGenericsAndBoundsMethod().get(ret)+ ";";
}else if(method.getGenericsAndBounds().containsKey(ret)){
desc += ")L"+method.getGenericsAndBounds().get(ret)+ ";";
}else {
desc += ")" + "L"+resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}else {
desc += ")" + "L"+resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}
// desc = addReturnType(desc,method.getReturnType(), resultSet);
return desc;
}
@Override
public String visit(NormalConstructor constructor) {
String desc = "(";
Iterator<FormalParameter> itr = constructor.getParameterList().iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
if(constructor.hasGen()) {
System.out.println("Cons has Gens");
String fpDesc = fp.getType().acceptTV(new TypeToDescriptor());
System.out.println(fpDesc);
if(constructor.getGenericsAndBounds().containsKey(fpDesc)){
desc += "L"+constructor.getGenericsAndBounds().get(fpDesc)+ ";";
}else {
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}else {
System.out.println("Cons has NOT Gens");
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}
desc = desc + ")V";
return desc;
}
@Override
public String visit(Lambda lambdaExpression) {
String desc = "(";
Iterator<FormalParameter> itr = lambdaExpression.getParams().iterator();
while(itr.hasNext()) {
FormalParameter fp = itr.next();
desc = desc + "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor()) + ";";
}
System.out.println("LamReturnType: "+lambdaExpression.getReturnType().acceptTV(new TypeToString()));
desc = addReturnType(desc, lambdaExpression.getReturnType(), resultSet);
return desc;
}
@Override
public String visit(SamMethod samMethod) {
String desc = "(";
Iterator<RefTypeOrTPHOrWildcardOrGeneric> itr = samMethod.getArgumentList().iterator();
while(itr.hasNext()) {
RefTypeOrTPHOrWildcardOrGeneric rt = itr.next();
desc = desc + "L"+resultSet.resolveType(rt).resolvedType.acceptTV(new TypeToDescriptor())+";";
}
desc = desc + ")"+"L"+resultSet.resolveType(samMethod.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
return desc;
}
@Override
public String visit(MethodFromMethodCall methodFromMethodCall) {
String desc = "(";
for(Expression e : methodFromMethodCall.getArgList().getArguments()) {
String d = e.getType().acceptTV(new TypeToDescriptor());
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(d)) {
desc += "L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(d)+ ";";
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(d)) {
desc += "L"+methodFromMethodCall.getGenericsAndBounds().get(d)+ ";";
}else {
desc += "L"+resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}
if(resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.toString().equals("void")) {
desc += ")V";
}else {
String ret = resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(ret)) {
desc += ")L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(ret)+ ";";
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(ret)){
desc += ")L"+methodFromMethodCall.getGenericsAndBounds().get(ret)+ ";";
}else {
desc += ")" + "L"+resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
}
}
// desc = addReturnType(desc, methodFromMethodCall.getReturnType(), resultSet);
return desc;
}
}

View File

@ -0,0 +1,9 @@
package de.dhbwstuttgart.bytecode;
public interface DescriptorVisitor {
public String visit(NormalMethod method);
public String visit(NormalConstructor constructor);
public String visit(Lambda lambdaExpression);
public String visit(SamMethod samMethod);
public String visit(MethodFromMethodCall methodFromMethodCall);
}

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.statement.*;
import java.util.ArrayList;
@ -7,8 +8,7 @@ import java.util.List;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.Literal;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class KindOfLambda implements StatementVisitor{
@ -45,7 +45,7 @@ public class KindOfLambda implements StatementVisitor{
}
@Override
public void visit(Binary binary) {
public void visit(BinaryExpr binary) {
// TODO Auto-generated method stub
}
@ -126,6 +126,11 @@ public class KindOfLambda implements StatementVisitor{
receiver.expr.accept(this);
}
@Override
public void visit(UnaryExpr unaryExpr) {
throw new NotImplementedException();
}
@Override
public void visit(Return aReturn) {
aReturn.retexpr.accept(this);
@ -155,12 +160,6 @@ public class KindOfLambda implements StatementVisitor{
this.argumentList.add(aThis.getType());
}
@Override
public void visit(UnaryPlus unaryPlus) {
// TODO Auto-generated method stub
}
@Override
public void visit(WhileStmt whileStmt) {
// TODO Auto-generated method stub
@ -173,12 +172,6 @@ public class KindOfLambda implements StatementVisitor{
}
@Override
public void visit(Null aNull) {
// TODO Auto-generated method stub
}
@Override
public void visit(Literal literal) {
// TODO Auto-generated method stub

View File

@ -0,0 +1,25 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class Lambda {
private LambdaExpression lambdaExpression;
public Lambda(LambdaExpression lambdaExpression) {
this.lambdaExpression = lambdaExpression;
}
public ParameterList getParams() {
return lambdaExpression.params;
}
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return lambdaExpression.getReturnType();
}
public String accept(DescriptorVisitor descVisitor) {
return descVisitor.visit(this);
}
}

View File

@ -0,0 +1,41 @@
package de.dhbwstuttgart.bytecode;
import java.util.HashMap;
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class MethodFromMethodCall {
private ArgumentList argList;
private RefTypeOrTPHOrWildcardOrGeneric returnType;
private HashMap<String, String> genericsAndBoundsMethod;
private HashMap<String,String> genericsAndBounds;
public MethodFromMethodCall(ArgumentList argList,RefTypeOrTPHOrWildcardOrGeneric returnType,
HashMap<String, String> genericsAndBoundsMethod,HashMap<String,String> genericsAndBounds) {
this.argList = argList;
this.returnType = returnType;
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
this.genericsAndBounds = genericsAndBounds;
}
public ArgumentList getArgList() {
return argList;
}
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return returnType;
}
public HashMap<String, String> getGenericsAndBoundsMethod(){
return genericsAndBoundsMethod;
}
public HashMap<String,String> getGenericsAndBounds(){
return genericsAndBounds;
}
public String accept(DescriptorVisitor descVisitor) {
return descVisitor.visit(this);
}
}

View File

@ -0,0 +1,39 @@
package de.dhbwstuttgart.bytecode;
import java.util.HashMap;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.ParameterList;
public class NormalConstructor {
private Constructor constructor;
private HashMap<String, String> genericsAndBounds;
private boolean hasGenerics;
public NormalConstructor(Constructor constructor, boolean hasGenerics) {
this.constructor = constructor;
this.hasGenerics = hasGenerics;
}
public NormalConstructor(Constructor constructor, HashMap<String, String> genericsAndBounds, boolean hasGenerics) {
this.constructor = constructor;
this.genericsAndBounds = genericsAndBounds;
this.hasGenerics = hasGenerics;
}
public HashMap<String, String> getGenericsAndBounds() {
return genericsAndBounds;
}
public boolean hasGen() {
return hasGenerics;
}
public ParameterList getParameterList() {
return constructor.getParameterList();
}
public String accept(DescriptorVisitor descVisitor) {
return descVisitor.visit(this);
}
}

View File

@ -0,0 +1,55 @@
package de.dhbwstuttgart.bytecode;
import java.util.HashMap;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class NormalMethod {
private Method method;
private HashMap<String, String> genericsAndBounds;
private HashMap<String, String> genericsAndBoundsMethod;
private boolean hasGenerics;
public NormalMethod(Method method, boolean hasGenerics) {
this.method = method;
this.hasGenerics = hasGenerics;
}
public NormalMethod(Method method, HashMap<String, String> genericsAndBounds,
HashMap<String, String> genericsAndBoundsMethod,boolean hasGenerics) {
this.method = method;
this.genericsAndBounds = genericsAndBounds;
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
this.hasGenerics = hasGenerics;
}
public Method getMethod() {
return method;
}
public ParameterList getParameterList() {
return method.getParameterList();
}
public HashMap<String, String> getGenericsAndBounds(){
return genericsAndBounds;
}
public HashMap<String, String> getGenericsAndBoundsMethod(){
return genericsAndBoundsMethod;
}
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return method.getReturnType();
}
public boolean hasGen() {
return this.hasGenerics;
}
public String accept(DescriptorVisitor descVisitor) {
return descVisitor.visit(this);
}
}

View File

@ -0,0 +1,31 @@
package de.dhbwstuttgart.bytecode;
import java.util.List;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
public class SamMethod {
private List<RefTypeOrTPHOrWildcardOrGeneric> argumentList;
private RefTypeOrTPHOrWildcardOrGeneric returnType;
public SamMethod(List<RefTypeOrTPHOrWildcardOrGeneric> argumentList, RefTypeOrTPHOrWildcardOrGeneric returnType) {
this.argumentList = argumentList;
this.returnType = returnType;
}
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgumentList() {
return argumentList;
}
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return returnType;
}
public String accept(DescriptorVisitor descVisitor) {
return descVisitor.visit(this);
}
}

View File

@ -0,0 +1,155 @@
package de.dhbwstuttgart.bytecode;
import java.util.HashMap;
import java.util.Iterator;
import org.objectweb.asm.signature.SignatureVisitor;
import org.objectweb.asm.signature.SignatureWriter;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.result.ResultSet;
public class Signature {
private ClassOrInterface classOrInterface;
private HashMap<String, String> genericsAndBounds;
private HashMap<String, String> genericsAndBoundsMethod;
private SignatureWriter sw;
private Constructor constructor;
private Method method;
private HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes;
private ResultSet resultSet;
public Signature(ClassOrInterface classOrInterface, HashMap<String, String> genericsAndBounds) {
this.classOrInterface = classOrInterface;
this.genericsAndBounds = genericsAndBounds;
sw = new SignatureWriter();
createSignatureForClassOrInterface();
}
public Signature(Constructor constructor, HashMap<String, String> genericsAndBounds, HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes) {
this.constructor = constructor;
this.genericsAndBounds = genericsAndBounds;
this.methodParamsAndTypes = methodParamsAndTypes;
sw = new SignatureWriter();
createSignatureForConsOrMethod(this.constructor,true);
}
public Signature(Method method, HashMap<String, String> genericsAndBoundsMethod,
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes, ResultSet resultSet) {
this.method = method;
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
this.methodParamsAndTypes = methodParamsAndTypes;
this.resultSet = resultSet;
sw = new SignatureWriter();
createSignatureForConsOrMethod(this.method,false);
}
/**
* Creates signature for a method or constructor with @see {@link SignatureWriter}
* Signature looks like:
* <typevaliables (K:Ljava/lang/Object "Bounds")>(params L.. OR T.. Or basistape)ReturnType
*
* @param method method or constructor
* @param isConstructor true if constructor
*/
private void createSignatureForConsOrMethod(Method method, boolean isConstructor) {
Iterator<? extends GenericTypeVar> itr = method.getGenerics().iterator();
// visits all formal type parameter and visits their bounds <T:...;B:...;...>
while(itr.hasNext()) {
GenericTypeVar g = itr.next();
getBoundsOfTypeVar(g,genericsAndBoundsMethod);
}
// visits each method-parameter to create the signature
for(String paramName : methodParamsAndTypes.keySet()) {
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
// parameter type deswegen ist true
doVisitParamsOrReturn(t,true);
}
if(isConstructor) {
sw.visitReturnType().visitBaseType('V');
}else {
RefTypeOrTPHOrWildcardOrGeneric returnType = method.getReturnType();
// return type deswegen ist false
doVisitParamsOrReturn(returnType, false);
}
// sw.visitEnd();
}
/**
* Visits parameter type or return type with {@link SignatureVisitor} to create
* the method signature
* @param t type of parameter or return type
* @param isParameterType true if t is type of parameter
*/
private void doVisitParamsOrReturn(RefTypeOrTPHOrWildcardOrGeneric t, boolean isParameterType) {
String type = t.acceptTV(new TypeToString());
SignatureVisitor sv;
if(isParameterType) {
sv = sw.visitParameterType();
}
else {
sv = sw.visitReturnType();
}
switch (type) {
case "RT":
sv.visitClassType(t.acceptTV(new TypeToDescriptor()));
break;
case "GRT":
GenericRefType g = (GenericRefType) t;
sv.visitTypeVariable(g.getParsedName());
break;
case "TPH":
System.out.println(resultSet.resolveType(t).resolvedType.acceptTV(new TypeToDescriptor()));
// sv.visitInterface().visitClassType(resultSet.resolveType(t).resolvedType.acceptTV(new TypeToDescriptor())+"<Ljava/lang/Integer;Ljava/lang/Integer;>;");
break;
default:
if(!isParameterType)
sv.visitBaseType('V');
break;
}
}
/**
* Creates signature for class or interface with {@link SignatureWriter}
* Signature looks like:
* <typevaliables (K:Ljava/lang/Object "Bounds")>superclass
*/
private void createSignatureForClassOrInterface() {
Iterator<GenericTypeVar> itr = classOrInterface.getGenerics().iterator();
while(itr.hasNext()) {
GenericTypeVar g = itr.next();
getBoundsOfTypeVar(g,genericsAndBounds);
}
sw.visitSuperclass().visitClassType(classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()));;
sw.visitEnd();
}
/**
* Get bounds of type variable
* @param g type variable
* @param genAndBounds
*/
private void getBoundsOfTypeVar(GenericTypeVar g, HashMap<String, String> genAndBounds) {
sw.visitFormalTypeParameter(g.getParsedName());
Iterator<? extends RefTypeOrTPHOrWildcardOrGeneric> bItr = g.getBounds().iterator();
while(bItr.hasNext()) {
RefTypeOrTPHOrWildcardOrGeneric b =bItr.next();
String boundDesc = b.acceptTV(new TypeToDescriptor());
// Ensure that <...> extends java.lang.Object OR ...
sw.visitClassBound().visitClassType(boundDesc);
genAndBounds.put(g.getParsedName(), boundDesc);
}
sw.visitClassBound().visitEnd();
}
public String toString() {
return sw.toString();
}
}

View File

@ -0,0 +1,37 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.TypeVisitor;
public class TypeToDescriptor implements TypeVisitor<String>{
@Override
public String visit(RefType refType) {
return refType.getName().toString().replace(".", "/");
}
@Override
public String visit(SuperWildcardType superWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(TypePlaceholder typePlaceholder) {
return typePlaceholder.toString().replace(".", "/");
}
@Override
public String visit(ExtendsWildcardType extendsWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(GenericRefType genericRefType) {
return genericRefType.getParsedName().replace(".", "/");
}
}

View File

@ -0,0 +1,38 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.TypeVisitor;
public class TypeToString implements TypeVisitor<String>{
@Override
public String visit(RefType refType) {
return "RT";
}
@Override
public String visit(SuperWildcardType superWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(TypePlaceholder typePlaceholder) {
return "TPH";
}
@Override
public String visit(ExtendsWildcardType extendsWildcardType) {
throw new NotImplementedException();
}
@Override
public String visit(GenericRefType genericRefType) {
return "GRT";
}
}

View File

@ -82,13 +82,14 @@ public class JavaTXCompiler {
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for(SourceFile sf : this.sourceFiles.values()) {
//allClasses.addAll(getAvailableClasses(sf));
allClasses.addAll(getAvailableClasses(sf));
allClasses.addAll(sf.getClasses());
}
final ConstraintSet<Pair> cons = getConstraints();
FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses);
System.out.println(finiteClosure);
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
TypeUnify unify = new TypeUnify();

View File

@ -42,6 +42,7 @@ public class CompilationEnvironment {
public CompilationEnvironment(List<File> sourceFiles) {
String bootClassPath = System.getProperty("sun.boot.class.path");
librarys = new ArrayList<>();
if(bootClassPath != null){
for(String path : bootClassPath.split(File.pathSeparator)) {
try {
librarys.add(new URL("file:"+path));
@ -49,6 +50,7 @@ public class CompilationEnvironment {
new DebugException("Fehler im Classpath auf diesem System");
}
}
}
this.sourceFiles = sourceFiles;
this.packageCrawler = new PackageCrawler(librarys);
}

View File

@ -29,7 +29,7 @@ public class JavaTXParser {
*/
}
/* Für das Typsystem ist es notwendig, dass sich der Source in einer Datei befindet:
/* Für das Typsystem ist es notwendig, dass sich der Source in einer Datei befindet:
public SourceFile parse(String fileContent) throws IOException, java.lang.ClassNotFoundException {
return this.parse(new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
}

View File

@ -0,0 +1,150 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import de.dhbwstuttgart.exceptions.DebugException;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.*;
import java.util.*;
public class FCGenerator {
/**
* Baut die FiniteClosure aus availableClasses.
* Klassen welche nicht in availableClasses vorkommen werden im Java Classpath nachgeschlagen.
*
* @param availableClasses - Alle geparsten Klassen
*/
public static Set<UnifyPair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
HashSet<UnifyPair> pairs = new HashSet<>();
for(ClassOrInterface cly : availableClasses){
pairs.addAll(getSuperTypes(cly, availableClasses));
}
System.out.println(pairs);
return pairs;
}
/**
* Bildet eine Kette vom übergebenen Typ bis hin zum höchsten bekannten Typ
* Als Generics werden TPHs benutzt, welche der Unifikationsalgorithmus korrekt interpretieren muss.
* Die verwendeten TPHs werden in der Kette nach oben gereicht, so erhält der selbe GTV immer den selben TPH
* @param forType
* @return
*/
private static List<UnifyPair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
return getSuperTypes(forType, availableClasses, new HashMap<>());
}
//TODO: implements Interface auch als superklassen beachten
private static List<UnifyPair> getSuperTypes(ClassOrInterface forType, Collection<ClassOrInterface> availableClasses, HashMap<String, UnifyType> gtvs) throws ClassNotFoundException {
List<UnifyType> params = new ArrayList<>();
//Die GTVs, die in forType hinzukommen:
HashMap<String, UnifyType> newGTVs = new HashMap<>();
//Generics mit gleichem Namen müssen den selben TPH bekommen
for(GenericTypeVar gtv : forType.getGenerics()){
if(!gtvs.containsKey(gtv.getParsedName())){
gtvs.put(gtv.getParsedName(), PlaceholderType.freshPlaceholder());
newGTVs.put(gtv.getParsedName(), PlaceholderType.freshPlaceholder());
}
params.add(gtvs.get(gtv.getParsedName()));
}
Optional<ClassOrInterface> hasSuperclass = availableClasses.stream().filter(cl -> forType.getSuperClass().getName().equals(cl.getClassName())).findAny();
ClassOrInterface superClass;
if(!hasSuperclass.isPresent()) //Wenn es die Klasse in den available Klasses nicht gibt wird sie im Classpath gesucht. Ansonsten Exception
{
superClass = ASTFactory.createClass(ClassLoader.getSystemClassLoader().loadClass(forType.getSuperClass().getName().toString()));
}else{
superClass = hasSuperclass.get();
}
/*
Die Parameter der superklasse müssen jetzt nach den Angaben in der Subklasse
modifiziert werden
Beispie: Matrix<A> extends Vector<Vector<A>>
Den ersten Parameter mit Vector<A> austauschen und dort alle Generics zu den Typplaceholdern in gtvs austauschen
*/
//Hier vermerken, welche Typen im der Superklasse ausgetauscht werden müssen
Iterator<GenericTypeVar> itGenParams = superClass.getGenerics().iterator();
Iterator<RefTypeOrTPHOrWildcardOrGeneric> itSetParams = forType.getSuperClass().getParaList().iterator();
while(itGenParams.hasNext()){
RefTypeOrTPHOrWildcardOrGeneric setType = itSetParams.next();
//In diesem Typ die GTVs durch TPHs und Einsetzungen austauschen:
UnifyType setSetType = setType.acceptTV(new TypeExchanger(gtvs));
newGTVs.put(itGenParams.next().getParsedName(), setSetType);
}
UnifyType superType = forType.getSuperClass().acceptTV(new TypeExchanger(newGTVs));
TypeParams paramList = new TypeParams(params);
UnifyType t1 = new ReferenceType(forType.getClassName().toString(), paramList);
UnifyType t2 = superType;
UnifyPair ret = UnifyTypeFactory.generateSmallerPair(t1, t2);
List<UnifyPair> superTypes;
//Rekursiver Aufruf. Abbruchbedingung ist Object als Superklasse:
if(superClass.getClassName().equals(ASTFactory.createObjectClass().getClassName())){
superTypes = Arrays.asList(UnifyTypeFactory.generateSmallerPair(UnifyTypeFactory.convert(ASTFactory.createObjectType()), UnifyTypeFactory.convert(ASTFactory.createObjectType())));
}else{
superTypes = getSuperTypes(superClass, availableClasses, newGTVs);
}
List<UnifyPair> retList = new ArrayList<>();
retList.add(ret);
retList.addAll(superTypes);
return retList;
}
/**
* Tauscht die GTVs in einem Typ gegen die entsprechenden Typen in der übergebenen Map aus.
*/
private static class TypeExchanger implements TypeVisitor<UnifyType>{
private final HashMap<String, UnifyType> gtvs;
TypeExchanger(HashMap<String, UnifyType> gtvs){
this.gtvs = gtvs;
}
@Override
public UnifyType visit(RefType refType) {
List<UnifyType> params = new ArrayList<>();
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
params.add(param.acceptTV(this));
}
TypeParams paramList = new TypeParams(params);
UnifyType ret = new ReferenceType(refType.getName().toString(), paramList);
return ret;
}
@Override
public UnifyType visit(SuperWildcardType superWildcardType) {
throw new DebugException("Dieser Fall darf nicht auftreten");
}
@Override
public UnifyType visit(TypePlaceholder typePlaceholder) {
throw new DebugException("Dieser Fall darf nicht auftreten");
}
@Override
public UnifyType visit(ExtendsWildcardType extendsWildcardType) {
throw new DebugException("Dieser Fall darf nicht auftreten");
}
@Override
public UnifyType visit(GenericRefType genericRefType) {
if(! gtvs.containsKey(genericRefType.getParsedName()))
throw new DebugException("Dieser Fall darf nicht auftreten");
//TODO: Diesen Dirty-Hack beseitigen. Fehler tritt bei java.lang.invoke.LambdaFormEditor$Transform$Kind auf.
//return UnifyTypeFactory.convert(ASTFactory.createObjectType());
return gtvs.get(genericRefType.getParsedName());
}
}
}

View File

@ -7,7 +7,6 @@ import de.dhbwstuttgart.parser.scope.GenericsRegistry;
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.*;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
@ -95,7 +94,7 @@ public class StatementGenerator {
private Statement convert(Java8Parser.StatementWithoutTrailingSubstatementContext stmt) {
if(stmt.block() != null){
return convert(stmt.block());
return convert(stmt.block(), false);
}else if(stmt.emptyStatement() != null){
return new EmptyStmt(stmt.getStart());
}else if(stmt.expressionStatement() != null){
@ -121,14 +120,14 @@ public class StatementGenerator {
}else throw new NotImplementedException();
}
public Block convert(Java8Parser.BlockContext block) {
public Block convert(Java8Parser.BlockContext block, boolean addTrailingReturn) {
List<Statement> statements = new ArrayList<>();
if(block.blockStatements() != null)
for(Java8Parser.BlockStatementContext statementContext : block.blockStatements().blockStatement()){
List<Statement> stmt = convert(statementContext);
statements.addAll(stmt);
}
statements = SyntacticSugar.addTrailingReturn(statements);
if(addTrailingReturn)statements = SyntacticSugar.addTrailingReturn(statements);
return new Block(statements, block.getStart());
}
@ -289,8 +288,8 @@ public class StatementGenerator {
}
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
//TODO
throw new NotImplementedException();
return new UnaryExpr(UnaryExpr.Operation.POSTINCREMENT, convert(stmt.postfixExpression()),
TypePlaceholder.fresh(stmt.getStart()), stmt.getStart());
}
private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) {
@ -316,8 +315,10 @@ public class StatementGenerator {
}
private Statement convert(Java8Parser.IfThenElseStatementContext stmt){
//TODO
throw new NotImplementedException();
Expression expr = convert(stmt.expression());
Statement thenBlock = convert(stmt.statementNoShortIf());
Statement elseBlock = convert(stmt.statement());
return new IfStmt(TypePlaceholder.fresh(stmt.getStart()), expr, thenBlock, elseBlock, stmt.getStart());
}
private Statement convert(Java8Parser.IfThenElseStatementNoShortIfContext stmt){
@ -541,8 +542,7 @@ public class StatementGenerator {
if(expression.conditionalOrExpression() == null){
return convert(expression.conditionalAndExpression());
}else{
return new Binary(convert(expression.conditionalOrExpression()),
convert(expression.conditionalAndExpression()), Binary.Operator.OR);
throw new NotImplementedException();
}
}
@ -550,8 +550,7 @@ public class StatementGenerator {
if(expression.conditionalAndExpression() == null){
return convert(expression.inclusiveOrExpression());
}else{
return new Binary(convert(expression.conditionalAndExpression()),
convert(expression.inclusiveOrExpression()), Binary.Operator.AND);
throw new NotImplementedException();
}
}
@ -588,11 +587,20 @@ public class StatementGenerator {
}
private Expression convert(Java8Parser.RelationalExpressionContext expression) {
if(expression.relationalExpression() == null){
if(expression.relationalExpression() == null) {
return convert(expression.shiftExpression());
}else{
throw new NotImplementedException();
}else {
String operator = expression.getChild(1).getText();
return new BinaryExpr(convertBinaryOperator(operator), TypePlaceholder.fresh(expression.getStart()),
convert(expression.relationalExpression()),
convert(expression.shiftExpression()), expression.getStart());
}
//}else throw new NotImplementedException();
}
private BinaryExpr.Operator convertBinaryOperator(String operator) {
return null;
}
private Expression convert(Java8Parser.ShiftExpressionContext expression) {
@ -604,7 +612,9 @@ public class StatementGenerator {
}
private Expression convert(Java8Parser.AdditiveExpressionContext expression) {
if(expression.additiveExpression() == null){
if(expression.additiveExpression() != null){
return convert(expression.additiveExpression());
}else if(expression.multiplicativeExpression() != null){
return convert(expression.multiplicativeExpression());
}else{
throw new NotImplementedException();
@ -627,9 +637,11 @@ public class StatementGenerator {
}else if(expression.unaryExpressionNotPlusMinus() != null){
return convert(expression.unaryExpressionNotPlusMinus());
}else if(expression.getText().startsWith("+")){
return new UnaryPlus(convert(expression.unaryExpression()));
return new UnaryExpr(UnaryExpr.Operation.PLUS, convert(expression.unaryExpression()),
TypePlaceholder.fresh(expression.getStart()), expression.getStart());
}else if(expression.getText().startsWith("-")){
return new UnaryMinus(convert(expression.unaryExpression()));
return new UnaryExpr(UnaryExpr.Operation.MINUS, convert(expression.unaryExpression()),
TypePlaceholder.fresh(expression.getStart()), expression.getStart());
}else{
//Diese Exceptions sollte nie geworfen werden.
//Der Code wurde nur noch nicht getestet. Sollte zur Sicherheit drin bleiben.
@ -672,10 +684,10 @@ public class StatementGenerator {
}
for(Java8Parser.PostIncrementExpression_lf_postfixExpressionContext inc : expression.postIncrementExpression_lf_postfixExpression()){
expr = new PostIncExpr(expr);
expr = new UnaryExpr(UnaryExpr.Operation.POSTINCREMENT, expr, TypePlaceholder.fresh(inc.getStart()), inc.getStart());
}
for(Java8Parser.PostDecrementExpression_lf_postfixExpressionContext dec : expression.postDecrementExpression_lf_postfixExpression()){
expr = new PostDecExpr(expr);
expr = new UnaryExpr(UnaryExpr.Operation.POSTDECREMENT, expr, TypePlaceholder.fresh(dec.getStart()), dec.getStart());
}
return expr;
@ -771,25 +783,25 @@ public class StatementGenerator {
private Expression convert(Java8Parser.LiteralContext literal) {
if(literal.IntegerLiteral() != null || literal.FloatingPointLiteral()!= null){
Number value = Double.parseDouble(literal.IntegerLiteral().getText());
return new NumberLiteral(TypePlaceholder.fresh(literal.getStart()),
return new Literal(TypePlaceholder.fresh(literal.getStart()),
value, literal.getStart());
}else if(literal.BooleanLiteral() != null){
RefType type = new RefType(reg.getName("java.lang.Boolean"),literal.getStart());
return new BoolLiteral(type,
return new Literal(type,
Boolean.parseBoolean(literal.BooleanLiteral().getText()),
literal.getStart());
}else if(literal.CharacterLiteral() != null){
RefType type = new RefType(reg.getName("java.lang.Character"),literal.getStart());
return new CharLiteral(type,
return new Literal(type,
literal.CharacterLiteral().getText().charAt(0),
literal.getStart());
}else if(literal.StringLiteral()!=null){
RefType type = new RefType(reg.getName("java.lang.String"),literal.getStart());
return new StringLiteral(type,
return new Literal(type,
literal.StringLiteral().getText(),
literal.getStart());
}else if(literal.NullLiteral() != null){
return new Null(TypePlaceholder.fresh(literal.getStart()),
return new Literal(TypePlaceholder.fresh(literal.getStart()), null,
literal.getStart());
}else {
throw new NotImplementedException();
@ -850,7 +862,7 @@ public class StatementGenerator {
expression.lambdaBody().expression().getStart()));
block = new Block(statements, expression.lambdaBody().getStart());
}else{
block = lambdaGenerator.convert(expression.lambdaBody().block());
block = lambdaGenerator.convert(expression.lambdaBody().block(), true);
}
List<RefTypeOrTPHOrWildcardOrGeneric> funNParams = new ArrayList<>();
funNParams.add(TypePlaceholder.fresh(expression.getStart()));//ret-Type

View File

@ -1,6 +1,9 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.statement.*;
import java.util.List;
@ -10,22 +13,27 @@ public class SyntacticSugar {
public static List<Statement> addTrailingReturn(List<Statement> statements){
if(statements.size()!=0) {
Statement lastStmt = statements.get(statements.size() - 1);
if (lastStmt instanceof Return) return statements;
if (lastStmt instanceof WhileStmt) {
//TODO
//if (hasReturn(((WhileStmt) lastStmt).loopBlock)) return statements;
} else if (lastStmt instanceof IfStmt) {
if (hasReturn(((IfStmt) lastStmt).then_block)
&& hasReturn(((IfStmt) lastStmt).else_block)) return statements;
} else if (lastStmt instanceof ForStmt) {
if (hasReturn(((ForStmt) lastStmt).body_Loop_block)) return statements;
} else {
}
ReturnFinder hasReturn = new ReturnFinder();
lastStmt.accept(hasReturn);
if(hasReturn.hasReturn)return statements;
}
statements.add(new ReturnVoid(new NullToken()));
return statements;
}
private static class ReturnFinder extends AbstractASTWalker{
public boolean hasReturn = false;
@Override
public void visit(Return aReturn) {
hasReturn = true;
}
@Override
public void visit(ReturnVoid aReturn) {
hasReturn = true;
}
}
private static boolean hasReturn(Block block){
for(Statement s : block.getStatements())
if(s instanceof Return)return true;

View File

@ -136,12 +136,12 @@ public class SyntaxTreeGenerator{
//TODO: Error! Abstrakte Methode ohne abstrakt Keyword
}
}else{
block = stmtGen.convert(body.block());
block = stmtGen.convert(body.block(),true);
}
if(parentClass.equals(new JavaClassName(name))){
return new Constructor(modifiers, name, retType, modifiers, parameterList, block, gtvDeclarations, header.getStart(), fieldInitializations);
return new Constructor(modifiers, name, retType, parameterList, block, gtvDeclarations, header.getStart(), fieldInitializations);
}else{
return new Method(modifiers, name, retType, modifiers, parameterList,block, gtvDeclarations, header.getStart());
return new Method(modifiers, name, retType, parameterList,block, gtvDeclarations, header.getStart());
}
}
@ -221,10 +221,9 @@ public class SyntaxTreeGenerator{
*/
private Constructor generateStandardConstructor(String className, JavaClassName parentClass, RefType superClass, GenericDeclarationList classGenerics, Token offset){
RefType classType = ClassOrInterface.generateTypeOfClass(reg.getName(className), classGenerics, offset);
int modifiers = 0;
ParameterList params = new ParameterList(new ArrayList<>(), offset);
Block block = new Block(new ArrayList<>(), offset);
return new Constructor(Modifier.PUBLIC, className, classType, modifiers, params, block, classGenerics, offset, fieldInitializations);
return new Constructor(Modifier.PUBLIC, className, classType, params, block, classGenerics, offset, fieldInitializations);
}
private RefType convert(Java8Parser.SuperclassContext superclass) {

View File

@ -40,7 +40,12 @@ public class TypeGenerator {
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannTypeContext unannTypeContext, JavaClassRegistry reg, GenericsRegistry genericsRegistry) {
if(unannTypeContext.unannPrimitiveType()!=null){
if(unannTypeContext.unannPrimitiveType().getText().equals("boolean")){
return new RefType(ASTFactory.createClass(Boolean.class).getClassName(), unannTypeContext.getStart());
}else{
Java8Parser.NumericTypeContext numericType = unannTypeContext.unannPrimitiveType().numericType();
throw new NotImplementedException();
}
}else
if(unannTypeContext.unannReferenceType().unannArrayType()!=null){
//System.out.println(unannTypeContext.getText());

View File

@ -0,0 +1,46 @@
package de.dhbwstuttgart.sat.asp;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class Clingo {
private final List<File> input;
private static final List<File> programFiles = new ArrayList<>();
static{
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/basis.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/subst.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce1.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce2.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/unify.lp"));
}
public Clingo(List<File> inputFiles){
this.input = inputFiles;
}
public String runClingo() throws IOException, InterruptedException {
String pathToClingo =
"/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/clingo-5.2.1-linux-x86_64/clingo";
List<String> commands = new ArrayList<>();
commands.add(pathToClingo);
commands.add("--outf=2"); //use JSON-Output
for(File file : input){
commands.add(file.getPath());
}
commands.addAll(programFiles.stream().map(f->f.getPath()).collect(Collectors.toList()));
Process clingo = new ProcessBuilder( commands.toArray(new String[0])).start();
InputStream output = clingo.getInputStream();
clingo.waitFor();
String result = IOUtils.toString(output, StandardCharsets.UTF_8);
return result;
}
}

View File

@ -0,0 +1,24 @@
package de.dhbwstuttgart.sat.asp.model;
public enum ASPRule {
ASP_GENERIC_TYPE_NAME("genericType"),
ASP_PAIR_EQUALS_NAME("equals"),
ASP_PAIR_SMALLER_NAME("smaller"),
ASP_PAIR_SMALLER_DOT_NAME("smallerDot"),
ASP_PARAMLIST_NAME("param"),
ASP_PARAMLISTNUMERATION_NAME("paramNum"),
ASP_PARAMLIST_END_POINTER("null"),
ASP_TYPE("type")
;
private final String text;
private ASPRule(final String text) {
this.text = text;
}
@Override
public String toString() {
return text;
}
}

View File

@ -1,4 +0,0 @@
package de.dhbwstuttgart.sat.asp.model;
public interface ASPType {
}

View File

@ -0,0 +1,17 @@
package de.dhbwstuttgart.sat.asp.parser;
import de.dhbwstuttgart.typeinference.result.ResultPair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import java.util.HashSet;
import java.util.Set;
public class ASPParser {
ResultSet parse(String result){
Set<ResultPair> ret = new HashSet<>();
for(String pair : result.split(",")){
}
return new ResultSet(ret);
}
}

View File

@ -0,0 +1,7 @@
package de.dhbwstuttgart.sat.asp.parser.model;
public class ParsedASPStatement {
public ParsedASPStatement(String statement){
}
}

View File

@ -1,9 +1,8 @@
package de.dhbwstuttgart.sat.asp;
package de.dhbwstuttgart.sat.asp.writer;
import de.dhbwstuttgart.exceptions.DebugException;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.sat.asp.model.*;
import de.dhbwstuttgart.sat.asp.writer.model.*;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
@ -11,13 +10,10 @@ import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
import java.sql.Ref;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
public class ASPGenerator {
ASPWriter writer = new ASPWriter();

View File

@ -1,8 +1,6 @@
package de.dhbwstuttgart.sat.asp;
package de.dhbwstuttgart.sat.asp.writer;
import de.dhbwstuttgart.sat.asp.model.ASPRefType;
import de.dhbwstuttgart.sat.asp.model.ASPStatement;
import de.dhbwstuttgart.sat.asp.model.ASPType;
import de.dhbwstuttgart.sat.asp.writer.model.ASPStatement;
import java.util.HashSet;

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
public class ASPGenericType implements ASPType{
public static final String ASP_GENERIC_TYPE_NAME = "genericType";
private final String name;
public ASPGenericType(String name){
@ -9,6 +10,6 @@ public class ASPGenericType implements ASPType{
}
public String toString(){
return ASP_GENERIC_TYPE_NAME + "(" + name + ")";
return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")";
}
}

View File

@ -1,4 +1,4 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
public abstract class ASPPair {
public final ASPType leftSide;

View File

@ -1,13 +1,14 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
public class ASPPairEquals extends ASPPair{
private final static String ASP_PAIR_EQUALS_NAME = "equals";
public ASPPairEquals(ASPType ls, ASPType rs){
super(ls, rs);
}
@Override
protected String getRuleName() {
return ASP_PAIR_EQUALS_NAME;
return ASPRule.ASP_PAIR_EQUALS_NAME.toString();
}
}

View File

@ -1,13 +1,16 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
import java.util.Map;
public class ASPPairSmaller extends ASPPair{
private final static String ASP_PAIR_SMALLER_NAME = "smaller";
public ASPPairSmaller(ASPType ls, ASPType rs){
super(ls, rs);
}
@Override
protected String getRuleName() {
return ASP_PAIR_SMALLER_NAME;
return ASPRule.ASP_PAIR_SMALLER_NAME.toString();
}
}

View File

@ -1,13 +1,14 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
public class ASPPairSmallerDot extends ASPPair{
private final static String ASP_PAIR_SMALLER_NAME = "smallerDot";
public ASPPairSmallerDot(ASPType ls, ASPType rs){
super(ls, rs);
}
@Override
protected String getRuleName() {
return ASP_PAIR_SMALLER_NAME;
return ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString();
}
}

View File

@ -1,24 +1,22 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.ASPGenerator;
import de.dhbwstuttgart.sat.asp.ASPWriter;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.writer.ASPGenerator;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class ASPParameterList {
private final static String ASP_PARAMLIST_NAME = "param";
private final static String ASP_PARAMLIST_END_POINTER = "null";
public final String name;
private final List<ASPType> types;
public ASPParameterList(List<ASPType> types, ASPWriter writer){
int paramNum = 0;
this.types = types;
if(types.size() == 0){
name = ASP_PARAMLIST_END_POINTER;
name = ASPRule.ASP_PARAMLIST_END_POINTER.toString();
}else{
name = newName();
String nextPointer = name;
@ -27,9 +25,11 @@ public class ASPParameterList {
ASPType t = it.next();
String param = nextPointer + "," + t.toString() + ",";
nextPointer = newName();
if(! it.hasNext())nextPointer = ASP_PARAMLIST_END_POINTER;
if(! it.hasNext())nextPointer = ASPRule.ASP_PARAMLIST_END_POINTER.toString();
param += nextPointer;
writer.add(new ASPStatement(ASP_PARAMLIST_NAME + "(" + param + ")"));
writer.add(new ASPStatement(ASPRule.ASP_PARAMLIST_NAME + "(" + param + ")"));
writer.add(new ASPStatement(ASPRule.ASP_PARAMLISTNUMERATION_NAME + "(" + name + "," +t + "," + paramNum + ")"));
paramNum++;
//paramDefinitions.add(new ASPStatement(ASP_PARAMLIST_NAME + "(" + param + ")"));
}
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
public class ASPRefType implements ASPType {
public static final String ASP_TYPE = "type";
private final ASPParameterList params;
private final String name;
@ -15,6 +16,6 @@ public class ASPRefType implements ASPType {
}
public String toString(){
return ASP_TYPE + "(" + name +"," + params.name + ")";
return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")";
}
}

View File

@ -1,4 +1,4 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
public class ASPStatement {
private final String stmt;

View File

@ -0,0 +1,4 @@
package de.dhbwstuttgart.sat.asp.writer.model;
public interface ASPType {
}

View File

@ -1,4 +1,4 @@
package de.dhbwstuttgart.sat.asp.model;
package de.dhbwstuttgart.sat.asp.writer.model;
public class ASPTypeVar implements ASPType{
private final String name;

View File

@ -1,12 +1,6 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import java.lang.reflect.Type;
public interface ASTVisitor extends StatementVisitor{

View File

@ -1,13 +1,10 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.Literal;
import de.dhbwstuttgart.syntaxtree.type.*;
import java.lang.reflect.Modifier;
import java.util.Iterator;
public abstract class AbstractASTWalker implements ASTVisitor{
@ -61,7 +58,7 @@ public abstract class AbstractASTWalker implements ASTVisitor{
}
private void visitMethod(Method method){
method.getType().accept(this);
method.getReturnType().accept(this);
method.getParameterList().accept(this);
if(method.block != null)
method.block.accept(this);
@ -129,7 +126,7 @@ public abstract class AbstractASTWalker implements ASTVisitor{
}
@Override
public void visit(Binary binary) {
public void visit(BinaryExpr binary) {
}
@ -157,12 +154,13 @@ public abstract class AbstractASTWalker implements ASTVisitor{
@Override
public void visit(ForStmt forStmt) {
forStmt.body_Loop_block.accept(this);
}
@Override
public void visit(IfStmt ifStmt) {
ifStmt.then_block.accept(this);
ifStmt.else_block.accept(this);
}
@Override
@ -202,6 +200,11 @@ public abstract class AbstractASTWalker implements ASTVisitor{
receiver.expr.accept(this);
}
@Override
public void visit(UnaryExpr unaryExpr) {
unaryExpr.expr.accept(this);
}
@Override
public void visit(Return aReturn) {
aReturn.retexpr.accept(this);
@ -227,24 +230,14 @@ public abstract class AbstractASTWalker implements ASTVisitor{
}
@Override
public void visit(UnaryPlus unaryPlus) {
}
@Override
public void visit(WhileStmt whileStmt) {
whileStmt.loopBlock.accept(this);
}
@Override
public void visit(DoStmt whileStmt) {
}
@Override
public void visit(Null aNull) {
whileStmt.loopBlock.accept(this);
}
@Override

View File

@ -14,9 +14,9 @@ public class Constructor extends Method {
//TODO: Constructor braucht ein super-Statement
public Constructor(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, int modifiers, ParameterList parameterList, Block codeInsideConstructor,
public Constructor(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block codeInsideConstructor,
GenericDeclarationList gtvDeclarations, Token offset, List<Statement> fieldInitializations) {
super(modifier, name, returnType, modifiers, parameterList, prepareBlock(codeInsideConstructor,fieldInitializations), gtvDeclarations, offset);
super(modifier, name, returnType, parameterList, prepareBlock(codeInsideConstructor,fieldInitializations), gtvDeclarations, offset);
}

View File

@ -7,6 +7,7 @@ import java.util.ArrayList;
public class Field extends SyntaxTreeNode implements TypeScope{
public final int modifier;
private String name;
private RefTypeOrTPHOrWildcardOrGeneric type;
@ -14,6 +15,7 @@ public class Field extends SyntaxTreeNode implements TypeScope{
super(offset);
this.name = name;
this.type = type;
this.modifier = modifier;
}
public String getName(){

View File

@ -22,16 +22,22 @@ import de.dhbwstuttgart.syntaxtree.statement.Block;
* @author janulrich
*
*/
public class Method extends Field implements IItemWithOffset
public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
{
public final Block block;
public final int modifier;
public final String name;
private ParameterList parameterlist = new ParameterList(new ArrayList<>(), new NullToken());
private ExceptionList exceptionlist;
private GenericDeclarationList generics;
private final RefTypeOrTPHOrWildcardOrGeneric returnType;
public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, int modifiers, ParameterList parameterList, Block block,
public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block block,
GenericDeclarationList gtvDeclarations, Token offset) {
super(name, returnType, modifiers, offset);
super(offset);
this.name = name;
this.modifier = modifier;
this.returnType = returnType;
this.parameterlist = parameterList;
this.block = block;
this.generics = gtvDeclarations;
@ -47,11 +53,20 @@ public class Method extends Field implements IItemWithOffset
@Override
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
return this.getType();
return this.returnType;
}
@Override
public void accept(ASTVisitor visitor) {
visitor.visit(this);
}
@Override
public Token getOffset() {
return null;
}
public String getName() {
return name;
}
}

View File

@ -2,9 +2,6 @@ package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.literal.StringLiteral;
public interface StatementVisitor {
@ -14,7 +11,7 @@ public interface StatementVisitor {
void visit(Assign assign);
void visit(Binary binary);
void visit(BinaryExpr binary);
void visit(Block block);
@ -50,16 +47,10 @@ public interface StatementVisitor {
void visit(This aThis);
void visit(UnaryPlus unaryPlus);
void visit(WhileStmt whileStmt);
void visit(DoStmt whileStmt);
void visit(Null aNull);
void visit(Literal literal);
void visit(AssignToField assignLeftSide);
void visit(AssignToLocal assignLeftSide);
@ -67,4 +58,8 @@ public interface StatementVisitor {
void visit(SuperCall superCall);
void visit(ExpressionReceiver expressionReceiver);
void visit(UnaryExpr unaryExpr);
void visit(Literal literal);
}

View File

@ -48,7 +48,7 @@ public class ASTFactory {
if(superjreClass != null){
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
for(TypeVariable tv : superjreClass.getTypeParameters()){
params.add(new RefType(new GenericTypeName(new GenericContext( name, null),tv.getName()), new NullToken()));
params.add(new GenericRefType(new GenericTypeName(new GenericContext( name, null),tv.getName()), new NullToken()));
}
superClass = new RefType(new JavaClassName(superjreClass.getName()), params, new NullToken());
}else{//Jede Klasse und jedes Interface erbt von Object: (auch Object selbst!)
@ -88,7 +88,7 @@ public class ASTFactory {
return null;
}
return new de.dhbwstuttgart.syntaxtree.Constructor(constructor.getModifiers(), name,returnType, modifier, parameterList, block, gtvDeclarations, offset, new ArrayList<>());
return new de.dhbwstuttgart.syntaxtree.Constructor(modifier, name,returnType, parameterList, block, gtvDeclarations, offset, new ArrayList<>());
}
//private static RefType createType(Class classType) {
@ -109,9 +109,8 @@ public class ASTFactory {
Block block = new Block(new ArrayList<Statement>(), new NullToken());
GenericDeclarationList gtvDeclarations = createGenerics(jreMethod.getTypeParameters(), inClass, jreMethod.getName());
Token offset = new NullToken();
int modifier = jreMethod.getModifiers();
return new Method(jreMethod.getModifiers(), name,returnType, modifier, parameterList, block, gtvDeclarations, offset);
return new Method(jreMethod.getModifiers(), name,returnType, parameterList, block, gtvDeclarations, offset);
}
public static GenericDeclarationList createGenerics(TypeVariable[] typeParameters, Class context, String methodName){
@ -134,7 +133,7 @@ public class ASTFactory {
}
*/
public static RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type, JavaClassName parentClass, String parentMethod){
private static RefTypeOrTPHOrWildcardOrGeneric createType(java.lang.reflect.Type type, JavaClassName parentClass, String parentMethod){
if(type.getTypeName().equals("void")){
return new Void(new NullToken());
}else if(type.getTypeName().equals("int")){

View File

@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import de.dhbwstuttgart.exceptions.DebugException;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
@ -25,7 +26,6 @@ public class UnifyTypeFactory {
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses) throws ClassNotFoundException {
/*
TODO: Generics werden zu TPHs
Die transitive Hülle muss funktionieren.
Man darf schreiben List<A> extends AL<A>
und Vector<B> extends List<B>
@ -35,57 +35,7 @@ public class UnifyTypeFactory {
Generell dürfen sie immer die gleichen Namen haben.
TODO: die transitive Hülle bilden
*/
HashSet<UnifyPair> pairs = new HashSet<>();
for(ClassOrInterface cly : fromClasses){
pairs.addAll(getSuperTypes(cly, fromClasses));
}
return new FiniteClosure(pairs);
}
/**
* Bildet eine Kette vom übergebenen Typ bis hin zum höchsten bekannten Typ
* Als Generics werden TPHs benutzt, welche der Unifikationsalgorithmus korrekt interpretieren muss.
* Die verwendeten TPHs werden in der Kette nach oben gereicht, so erhält der selbe GTV immer den selben TPH
* @param forType
* @return
*/
private static List<UnifyPair> getSuperTypes(ClassOrInterface forType, List<ClassOrInterface> availableClasses) throws ClassNotFoundException {
return getSuperTypes(forType, availableClasses, new HashMap<>());
}
private static List<UnifyPair> getSuperTypes(ClassOrInterface forType, List<ClassOrInterface> availableClasses, HashMap<String, PlaceholderType> gtvs) throws ClassNotFoundException {
List<UnifyType> params = new ArrayList<>();
//Generics mit gleichem Namen müssen den selben TPH bekommen
for(GenericTypeVar gtv : forType.getGenerics()){
if(!gtvs.containsKey(gtv.getParsedName()))
gtvs.put(gtv.getParsedName(), PlaceholderType.freshPlaceholder());
params.add(gtvs.get(gtv.getParsedName()));
}
Optional<ClassOrInterface> hasSuperclass = availableClasses.stream().filter(cl -> forType.getSuperClass().getName().equals(cl.getClassName())).findAny();
ClassOrInterface superClass;
if(!hasSuperclass.isPresent()) //TODO: Wenn es die Object-Klasse ist, dann ist es in Ordnung, ansonsten Fehler ausgeben:
{
superClass = ASTFactory.createClass(ClassLoader.getSystemClassLoader().loadClass(forType.getSuperClass().getName().toString()));
}else{
superClass = hasSuperclass.get();
}
List<UnifyPair> superTypes;
if(superClass.getClassName().equals(ASTFactory.createObjectClass().getClassName())){
superTypes = Arrays.asList(generateSmallerPair(convert(ASTFactory.createObjectType()), convert(ASTFactory.createObjectType())));
}else{
superTypes = getSuperTypes(superClass, availableClasses, gtvs);
}
TypeParams paramList = new TypeParams(params);
UnifyType t1 = new ReferenceType(forType.getClassName().toString(), paramList);
UnifyType t2 = superTypes.get(0).getLhsType();
UnifyPair ret = generateSmallerPair(t1, t2);
List<UnifyPair> retList = new ArrayList<>();
retList.add(ret);
retList.addAll(superTypes);
return retList;
return new FiniteClosure(FCGenerator.toFC(fromClasses));
}
public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){

View File

@ -1,27 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
// neu von Felix
public class Binary extends Expression
{
public enum Operator{
ADD,
SUB,
MUL,
AND, OR, DIV
}
public Binary(Expression expr1, Expression expr2, Operator op){
super(null, null);
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,14 +1,41 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public abstract class BinaryExpr extends Expression
public class BinaryExpr extends Expression
{
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
public BinaryExpr(Token offset)
public enum Operator{
ADD,
SUB,
MUL,
AND,
OR,
DIV,
LESSTHAN,
BIGGERTHAN,
LESSEQUAL,
BIGGEREQUAL
}
public final Operator operation;
public final Expression lexpr;
public final Expression rexpr;
public BinaryExpr(Operator operation, RefTypeOrTPHOrWildcardOrGeneric type, Expression lexpr, Expression rexpr, Token offset)
{
super(null,null);
super(type,offset);
this.operation = operation;
this.lexpr = lexpr;
this.rexpr = rexpr;
}
}

View File

@ -11,11 +11,11 @@ import org.antlr.v4.runtime.Token;
public class IfStmt extends Statement
{
public final Expression expr;
public final Block then_block;
public final Block else_block;
public final Statement then_block;
public final Statement else_block;
public IfStmt(RefTypeOrTPHOrWildcardOrGeneric type,
Expression expr, Block thenBlock, Block elseBlock, Token offset)
Expression expr, Statement thenBlock, Statement elseBlock, Token offset)
{
super(type,offset);
this.expr = expr;

View File

@ -3,8 +3,6 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
public class InstanceOf extends BinaryExpr
@ -14,7 +12,8 @@ public class InstanceOf extends BinaryExpr
public InstanceOf(int offset,int variableLength)
{
super(null);
super(null, null, null, null, null);
throw new NotImplementedException();
// #JB# 20.04.2005
}

View File

@ -0,0 +1,12 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
import java.nio.charset.StandardCharsets;
public abstract class JavaInternalExpression extends Statement{
public JavaInternalExpression(RefTypeOrTPHOrWildcardOrGeneric retType, Token offset){
super(retType, offset);
}
}

View File

@ -0,0 +1,24 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.antlr.v4.runtime.Token;
public class Literal extends Expression
{
public final Object value;
public Literal(RefTypeOrTPHOrWildcardOrGeneric type, Object value, Token offset) {
super(type, offset);
this.value = value;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -2,7 +2,6 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;

View File

@ -1,18 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
import org.antlr.v4.runtime.Token;
public class NegativeExpr extends UnaryExpr
{
public NegativeExpr(Token offset)
{
super(offset);
}
private UnaryMinus neg;
public Expression expr;
}

View File

@ -1,14 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import org.antlr.v4.runtime.Token;
public class NotExpr extends UnaryExpr
{
public NotExpr(Token offset)
{
super(offset);
}
private UnaryNot not;
public Expression expr;
}

View File

@ -1,15 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import org.antlr.v4.runtime.Token;
public class PositivExpr extends UnaryExpr
{
public PositivExpr(Token offset)
{
super(offset);
}
protected UnaryPlus plus;
public Expression expr;
}

View File

@ -1,17 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
import de.dhbwstuttgart.parser.antlr.Java8Parser;
public class PostDecExpr extends PostIncExpr
{
public PostDecExpr(Expression expr) {
super(expr);
}
}

View File

@ -1,15 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.NotImplementedException;
public class PostIncExpr extends UnaryExpr
{
public PostIncExpr(Expression expr) {
super(null);
}
}

View File

@ -1,17 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
import org.antlr.v4.runtime.Token;
public class PreDecExpr extends UnaryExpr
{
public PreDecExpr(Token offset)
{
super(offset);
}
}

View File

@ -1,12 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import org.antlr.v4.runtime.Token;
public class PreIncExpr extends UnaryExpr
{
public PreIncExpr(Token offset)
{
super(offset);
}
}

View File

@ -1,14 +1,37 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.statement.JavaInternalExpression;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public abstract class UnaryExpr extends MethodCall
public class UnaryExpr extends JavaInternalExpression
{
public enum Operation{
NOT,
MINUS,
PREINCREMENT,
PREDECREMENT,
POSTINCREMENT,
PLUS, POSTDECREMENT
}
public final Operation operation;
public Expression expr;
public UnaryExpr(Token offset)
public UnaryExpr(Operation operation, Expression argument, RefTypeOrTPHOrWildcardOrGeneric retType, Token offset)
{
super(null,null,null,null,null);
super(retType, offset);
this.expr = argument;
this.operation = operation;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,12 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
public class UnaryMinus extends UnaryPlus
{
public UnaryMinus(Expression expression) {
super(expression);
}
}

View File

@ -1,7 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
public class UnaryNot
{
}

View File

@ -1,20 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.NotImplementedException;
public class UnaryPlus extends Expression
{
public UnaryPlus(Expression expression){
super(expression.getType(),expression.getOffset());
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,26 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class BoolLiteral extends Literal
{
private boolean value;
public BoolLiteral(RefTypeOrTPHOrWildcardOrGeneric type, boolean value, Token offset)
{
super(type,offset);
this.value = value;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,21 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class CharLiteral extends Literal
{
private char value;
public CharLiteral(RefTypeOrTPHOrWildcardOrGeneric type, char value, Token offset)
{
super(type,offset);
this.value = value;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

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

View File

@ -1,21 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class Null extends Literal
{
public Null(RefTypeOrTPHOrWildcardOrGeneric type, Token offset)
{
super(type,offset);
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,22 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import org.antlr.v4.runtime.Token;
public class NumberLiteral extends Literal
{
private Number value;
public NumberLiteral(RefTypeOrTPHOrWildcardOrGeneric type, Number value, Token offset)
{
super(type,offset);
this.value = value;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -1,23 +0,0 @@
package de.dhbwstuttgart.syntaxtree.statement.literal;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.antlr.v4.runtime.Token;
public class StringLiteral extends Literal
{
private String value;
public StringLiteral(RefType type, String value, Token offset)
{
super(type,offset);
this.value = value;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}

View File

@ -6,6 +6,7 @@ import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
import org.antlr.v4.runtime.Token;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -28,7 +29,15 @@ public class RefType extends RefTypeOrTPHOrWildcardOrGeneric
@Override
public String toString(){
return this.name.toString();
String params = "<";
Iterator<RefTypeOrTPHOrWildcardOrGeneric> it = parameter.iterator();
while(it.hasNext()){
RefTypeOrTPHOrWildcardOrGeneric param = it.next();
params += param.toString();
if(it.hasNext())params += ", ";
}
params += ">";
return this.name.toString() + params;
}
@Override

View File

@ -1,13 +1,6 @@
package de.dhbwstuttgart.syntaxtree.visual;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.type.*;
import java.lang.reflect.Modifier;
import java.util.Iterator;
public class ASTTypePrinter extends ASTPrinter{

View File

@ -4,8 +4,6 @@ import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.type.*;
import java.lang.reflect.Modifier;
@ -81,7 +79,7 @@ public class OutputGenerator implements ASTVisitor{
@Override
public void visit(Method method) {
method.getType().accept(this);
method.getReturnType().accept(this);
out.append(" " + method.getName());
method.getParameterList().accept(this);
if(method.block != null)
@ -191,8 +189,10 @@ public class OutputGenerator implements ASTVisitor{
}
@Override
public void visit(Binary binary) {
public void visit(BinaryExpr binary) {
binary.lexpr.accept(this);
out.append(" op ");
binary.rexpr.accept(this);
}
@Override
@ -296,11 +296,6 @@ public class OutputGenerator implements ASTVisitor{
out.append("this");
}
@Override
public void visit(UnaryPlus unaryPlus) {
}
@Override
public void visit(WhileStmt whileStmt) {
out.append("while(");
@ -318,16 +313,6 @@ public class OutputGenerator implements ASTVisitor{
out.append(");");
}
@Override
public void visit(Null aNull) {
}
@Override
public void visit(Literal literal) {
}
@Override
public void visit(AssignToField assignLeftSide) {
assignLeftSide.field.accept(this);
@ -349,4 +334,32 @@ public class OutputGenerator implements ASTVisitor{
public void visit(ExpressionReceiver receiver) {
receiver.expr.accept(this);
}
@Override
public void visit(UnaryExpr unaryExpr) {
if(unaryExpr.operation == UnaryExpr.Operation.MINUS){
out.append("-");
}
if(unaryExpr.operation == UnaryExpr.Operation.PLUS){
out.append("+");
}
if(unaryExpr.operation == UnaryExpr.Operation.PREDECREMENT){
out.append("--");
}
if(unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT){
out.append("++");
}
unaryExpr.expr.accept(this);
if(unaryExpr.operation == UnaryExpr.Operation.POSTDECREMENT){
out.append("--");
}
if(unaryExpr.operation == UnaryExpr.Operation.POSTINCREMENT){
out.append("++");
}
}
@Override
public void visit(de.dhbwstuttgart.syntaxtree.statement.Literal literal) {
out.append(literal.value);
}
}

View File

@ -2,13 +2,9 @@ package de.dhbwstuttgart.syntaxtree.visual;
import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
import de.dhbwstuttgart.syntaxtree.statement.Literal;
import de.dhbwstuttgart.syntaxtree.type.*;
import java.lang.reflect.Modifier;
import java.util.Iterator;
public class TypeOutputGenerator extends OutputGenerator {
TypeOutputGenerator(StringBuilder out){
@ -100,8 +96,10 @@ public class TypeOutputGenerator extends OutputGenerator {
}
@Override
public void visit(Binary binary) {
super.visit(binary);
public void visit(BinaryExpr binary) {
binary.lexpr.accept(this);
out.append(" | ");
binary.rexpr.accept(this);
}
@Override
@ -214,21 +212,11 @@ public class TypeOutputGenerator extends OutputGenerator {
aThis.getType().accept(this);
}
@Override
public void visit(UnaryPlus unaryPlus) {
super.visit(unaryPlus);
}
@Override
public void visit(WhileStmt whileStmt) {
super.visit(whileStmt);
}
@Override
public void visit(Null aNull) {
super.visit(aNull);
}
@Override
public void visit(Literal literal) {
super.visit(literal);

Some files were not shown because too many files have changed in this diff Show More