Unary Expression und while statement anfügen
This commit is contained in:
parent
c7dea4c86b
commit
027538a082
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -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">
|
||||
<!-- -->
|
||||
|
@ -4,6 +4,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.FieldVisitor;
|
||||
@ -382,12 +383,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
|
||||
@ -453,4 +448,9 @@ public class BytecodeGen implements ASTVisitor {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
@ -336,6 +337,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);
|
||||
@ -367,11 +373,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
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.bytecode;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -126,6 +127,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 +161,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
|
||||
|
@ -16,6 +16,7 @@ import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public class StatementGenerator {
|
||||
@ -289,8 +290,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 +317,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){
|
||||
@ -591,7 +594,7 @@ public class StatementGenerator {
|
||||
if(expression.relationalExpression() == null){
|
||||
return convert(expression.shiftExpression());
|
||||
}else{
|
||||
throw new NotImplementedException();
|
||||
return convert(expression.relationalExpression());
|
||||
}
|
||||
}
|
||||
|
||||
@ -604,7 +607,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 +632,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 +679,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;
|
||||
|
@ -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;
|
||||
|
@ -40,7 +40,12 @@ public class TypeGenerator {
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannTypeContext unannTypeContext, JavaClassRegistry reg, GenericsRegistry genericsRegistry) {
|
||||
if(unannTypeContext.unannPrimitiveType()!=null){
|
||||
throw new NotImplementedException();
|
||||
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());
|
||||
|
@ -7,6 +7,7 @@ import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
|
||||
import javax.management.Notification;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -202,6 +203,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,11 +233,6 @@ public abstract class AbstractASTWalker implements ASTVisitor{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryPlus unaryPlus) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
|
||||
|
@ -50,8 +50,6 @@ public interface StatementVisitor {
|
||||
|
||||
void visit(This aThis);
|
||||
|
||||
void visit(UnaryPlus unaryPlus);
|
||||
|
||||
void visit(WhileStmt whileStmt);
|
||||
|
||||
void visit(DoStmt whileStmt);
|
||||
@ -67,4 +65,6 @@ public interface StatementVisitor {
|
||||
void visit(SuperCall superCall);
|
||||
|
||||
void visit(ExpressionReceiver expressionReceiver);
|
||||
|
||||
void visit(UnaryExpr unaryExpr);
|
||||
}
|
||||
|
@ -133,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")){
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
|
||||
public class UnaryNot
|
||||
{
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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(");
|
||||
@ -349,4 +344,9 @@ public class OutputGenerator implements ASTVisitor{
|
||||
public void visit(ExpressionReceiver receiver) {
|
||||
receiver.expr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -214,11 +214,6 @@ 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);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.JavaInternalExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
@ -2,12 +2,14 @@ package de.dhbwstuttgart.typeinference.typeAlgo;
|
||||
|
||||
//import com.sun.org.apache.xpath.internal.Arg;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.literal.Null;
|
||||
@ -193,6 +195,23 @@ public class TYPEStmt implements StatementVisitor{
|
||||
receiver.expr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
if(unaryExpr.operation == UnaryExpr.Operation.POSTDECREMENT ||
|
||||
unaryExpr.operation == UnaryExpr.Operation.POSTINCREMENT ||
|
||||
unaryExpr.operation == UnaryExpr.Operation.PREDECREMENT ||
|
||||
unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT){
|
||||
//@see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.14.2
|
||||
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||
RefType number = new RefType(ASTFactory.createClass(Number.class).getClassName(), unaryExpr.getOffset());
|
||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), number, PairOperator.EQUALSDOT));
|
||||
//The type of the postfix increment expression is the type of the variable
|
||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT));
|
||||
}else{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return returnExpr) {
|
||||
returnExpr.retexpr.accept(this);
|
||||
@ -241,14 +260,11 @@ public class TYPEStmt implements StatementVisitor{
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryPlus unaryPlus) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
RefType booleanType = new RefType(ASTFactory.createClass(java.lang.Boolean.class).getClassName(), new NullToken());
|
||||
constraintsSet.addUndConstraint(new Pair(whileStmt.expr.getType(), booleanType, PairOperator.EQUALSDOT));
|
||||
whileStmt.loopBlock.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,54 +1,24 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
methode(Matrix m) {
|
||||
Vector<Vector<Integer>> i;
|
||||
methode(i);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
import java.util.Vector;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
Matrix mul_rec(Matrix m) {
|
||||
auto v1 = new Vector<Integer>();
|
||||
auto v2 = new Vector<Integer>();
|
||||
auto i = 0;
|
||||
while(i < m.size()) {
|
||||
auto v;
|
||||
v = m.elementAt(i);
|
||||
v2.addElement(v.remove(v.size()-1));
|
||||
i++;
|
||||
}
|
||||
Matrix ret;
|
||||
if (m.elementAt(0).size() > 0) {
|
||||
ret = this.mul_rec(m);
|
||||
}
|
||||
else {
|
||||
ret = new Matrix();
|
||||
i = 0;
|
||||
while (i < this.size()) {
|
||||
ret.addElement(new Vector<Integer>());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
while (i < this.size()) {
|
||||
int erg = 0;
|
||||
auto j;
|
||||
j = 0;
|
||||
while (j < v2.size()) {
|
||||
erg = erg + this.elementAt(i).elementAt(j).intValue()
|
||||
* v2.elementAt(j).intValue();
|
||||
j++;
|
||||
}
|
||||
ret.elementAt(i).addElement(erg);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i <size()) {
|
||||
var v1 = this.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
v2.addElement(new Integer(erg));
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++; }
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
Reference in New Issue
Block a user