From 55d40d14ad1cfcab26bb542949eb8199a9214ebf Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 28 Aug 2014 19:05:57 +0200 Subject: [PATCH] =?UTF-8?q?UnaryExpr=20ver=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mycompiler/myclass/FormalParameter.java | 2 +- src/mycompiler/mystatement/PostDecExpr.java | 9 ----- src/mycompiler/mystatement/PostIncExpr.java | 34 +--------------- src/mycompiler/mystatement/PreDecExpr.java | 9 +---- src/mycompiler/mystatement/PreIncExpr.java | 9 ----- src/mycompiler/mystatement/UnaryExpr.java | 43 ++++++++++++++++++++- 6 files changed, 45 insertions(+), 61 deletions(-) diff --git a/src/mycompiler/myclass/FormalParameter.java b/src/mycompiler/myclass/FormalParameter.java index c3ef09f7c..cef327a54 100755 --- a/src/mycompiler/myclass/FormalParameter.java +++ b/src/mycompiler/myclass/FormalParameter.java @@ -60,7 +60,7 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL @Override public boolean equals(Object object) { - if(!super.equals(object))return false; + //if(!super.equals(object))return false; //Nicht die Position im SyntaxBaum prüfen. if(!(object instanceof FormalParameter))return false; FormalParameter equals = (FormalParameter)object; if((this.type==null)!=(equals.type == null))return false; diff --git a/src/mycompiler/mystatement/PostDecExpr.java b/src/mycompiler/mystatement/PostDecExpr.java index 2e9a10946..91c0f37c6 100755 --- a/src/mycompiler/mystatement/PostDecExpr.java +++ b/src/mycompiler/mystatement/PostDecExpr.java @@ -54,9 +54,6 @@ public class PostDecExpr extends UnaryExpr super(offset,variableLength); } // ino.end - // ino.attribute.expr.25994.declaration - public Expr expr; - // ino.end // ino.attribute.parserlog.25997.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end @@ -172,12 +169,6 @@ public class PostDecExpr extends UnaryExpr expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); } - @Override - public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - // TODO Auto-generated method stub - return null; - } - @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { // TODO Auto-generated method stub diff --git a/src/mycompiler/mystatement/PostIncExpr.java b/src/mycompiler/mystatement/PostIncExpr.java index 69d520b57..c17300d04 100755 --- a/src/mycompiler/mystatement/PostIncExpr.java +++ b/src/mycompiler/mystatement/PostIncExpr.java @@ -60,9 +60,7 @@ public class PostIncExpr extends UnaryExpr super(offset,variableLength); } // ino.end - // ino.attribute.expr.26028.declaration - public Expr expr; - // ino.end + // ino.attribute.parserlog.26031.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end @@ -178,36 +176,6 @@ public class PostIncExpr extends UnaryExpr expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); } - private Vector getNumericTypes(){ - Vector ret = new Vector<>(); - ret.add(new RefType("Integer",-1)); - ret.add(new RefType("Long",-1)); - ret.add(new RefType("Double",-1)); - return ret ; - } - - @Override - public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - if(this.getType() == null)this.setType(TypePlaceholder.fresh(this)); - ConstraintsSet ret = new ConstraintsSet(); - OderConstraint oderConstraint = new OderConstraint(); - ret.add(this.expr.TYPEExpr(assumptions)); - for(RefType t : getNumericTypes()){ - UndConstraint undConstraint = new UndConstraint(); - undConstraint.addConstraint(this.getType(), t); - undConstraint.addConstraint(this.expr.getType(), t); - - oderConstraint.addConstraint(undConstraint); - } - ret.add(oderConstraint); - return ret; - } - - @Override - public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { - return this.TYPEExpr(assumptions); - } - @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { JavaCodeResult ret = new JavaCodeResult(); diff --git a/src/mycompiler/mystatement/PreDecExpr.java b/src/mycompiler/mystatement/PreDecExpr.java index 0576c46de..5f0c07183 100755 --- a/src/mycompiler/mystatement/PreDecExpr.java +++ b/src/mycompiler/mystatement/PreDecExpr.java @@ -55,9 +55,6 @@ public class PreDecExpr extends UnaryExpr } // ino.end - // ino.attribute.expr.26062.declaration - public Expr expr; - // ino.end // ino.attribute.parserlog.26065.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end @@ -171,11 +168,7 @@ public class PreDecExpr extends UnaryExpr { expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); } - @Override - public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - // TODO Auto-generated method stub - return null; - } + @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { // TODO Auto-generated method stub diff --git a/src/mycompiler/mystatement/PreIncExpr.java b/src/mycompiler/mystatement/PreIncExpr.java index 839b154fc..de1e4de5e 100755 --- a/src/mycompiler/mystatement/PreIncExpr.java +++ b/src/mycompiler/mystatement/PreIncExpr.java @@ -54,9 +54,6 @@ public class PreIncExpr extends UnaryExpr super(offset,variableLength); } // ino.end - // ino.attribute.expr.26096.declaration - public Expr expr; - // ino.end // ino.attribute.parserlog.26099.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end @@ -173,12 +170,6 @@ public class PreIncExpr extends UnaryExpr expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); } - @Override - public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - // TODO Auto-generated method stub - return null; - } - @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { // TODO Auto-generated method stub diff --git a/src/mycompiler/mystatement/UnaryExpr.java b/src/mycompiler/mystatement/UnaryExpr.java index 6b990df1b..86b32dd3b 100755 --- a/src/mycompiler/mystatement/UnaryExpr.java +++ b/src/mycompiler/mystatement/UnaryExpr.java @@ -3,10 +3,17 @@ package mycompiler.mystatement; // ino.end // ino.module.UnaryExpr.8655.import import java.util.Vector; + +import typinferenz.ConstraintsSet; +import typinferenz.OderConstraint; +import typinferenz.UndConstraint; +import typinferenz.assumptions.TypeAssumptions; import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.CodeAttribute; import mycompiler.myexception.JVMCodeException; // ino.end +import mycompiler.mytype.RefType; +import mycompiler.mytype.TypePlaceholder; @@ -16,7 +23,9 @@ public abstract class UnaryExpr extends Expr // ino.end // ino.class.UnaryExpr.26298.body { - // ino.method.UnaryExpr.26302.definition + public Expr expr; + + // ino.method.UnaryExpr.26302.definition public UnaryExpr(int offset,int variableLength) // ino.end // ino.method.UnaryExpr.26302.body @@ -29,5 +38,37 @@ public abstract class UnaryExpr extends Expr public abstract void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException; // ino.end + + private Vector getNumericTypes(){ + Vector ret = new Vector<>(); + ret.add(new RefType("Integer",-1)); + ret.add(new RefType("Long",-1)); + ret.add(new RefType("Double",-1)); + return ret ; + } + + @Override + public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { + if(this.getType() == null)this.setType(TypePlaceholder.fresh(this)); + ConstraintsSet ret = new ConstraintsSet(); + OderConstraint oderConstraint = new OderConstraint(); + ret.add(this.expr.TYPEExpr(assumptions)); + for(RefType t : getNumericTypes()){ + UndConstraint undConstraint = new UndConstraint(); + undConstraint.addConstraint(this.getType(), t); + undConstraint.addConstraint(this.expr.getType(), t); + + oderConstraint.addConstraint(undConstraint); + } + ret.add(oderConstraint); + return ret; + } + + @Override + public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { + return this.TYPEExpr(assumptions); + } + + } // ino.end