2013-10-18 11:33:46 +00:00
|
|
|
// ino.module.WhileStmt.8659.package
|
2014-09-02 08:33:54 +00:00
|
|
|
package de.dhbwstuttgart.syntaxtree.statement;
|
2013-10-18 11:33:46 +00:00
|
|
|
// ino.end
|
|
|
|
// ino.module.WhileStmt.8659.import
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.Hashtable;
|
|
|
|
import java.util.Iterator;
|
2014-02-09 15:07:31 +00:00
|
|
|
|
2015-09-02 15:11:32 +00:00
|
|
|
import org.apache.commons.bcel6.generic.ClassGen;
|
2015-10-13 17:25:51 +00:00
|
|
|
import org.apache.commons.bcel6.generic.InstructionList;
|
2014-09-08 13:12:47 +00:00
|
|
|
|
2015-06-16 12:58:27 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
2015-10-13 17:25:51 +00:00
|
|
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
2015-06-16 12:58:27 +00:00
|
|
|
import de.dhbwstuttgart.logger.Logger;
|
2014-09-04 14:35:44 +00:00
|
|
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
|
|
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
|
|
|
import de.dhbwstuttgart.myexception.SCExcept;
|
|
|
|
import de.dhbwstuttgart.myexception.SCStatementException;
|
2014-09-02 08:33:54 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.Class;
|
2014-09-04 14:35:44 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
2014-09-02 08:33:54 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.operator.LogOp;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.operator.Operator;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.operator.RelOp;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
|
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
|
|
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
2014-09-08 13:12:47 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.Pair;
|
2014-09-02 08:33:54 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
|
|
|
import de.dhbwstuttgart.typeinference.SingleConstraint;
|
2015-11-27 15:10:35 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
2014-09-02 08:33:54 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
2014-10-07 13:36:18 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
2014-09-02 09:07:16 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.unify.Unify;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.class.WhileStmt.26326.declaration
|
|
|
|
public class WhileStmt extends Statement
|
|
|
|
// ino.end
|
|
|
|
// ino.class.WhileStmt.26326.body
|
|
|
|
{
|
|
|
|
// ino.method.WhileStmt.26330.definition
|
|
|
|
public WhileStmt(int offset, int variableLength)
|
|
|
|
// ino.end
|
|
|
|
// ino.method.WhileStmt.26330.body
|
|
|
|
{
|
|
|
|
super(offset,variableLength);
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.attribute.expr.26333.declaration
|
|
|
|
public Expr expr;
|
|
|
|
// ino.end
|
|
|
|
// ino.attribute.loop_block.26336.declaration
|
|
|
|
public Statement loop_block;
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.attribute.parserlog.26339.declaration
|
|
|
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.set_Expr.26342.definition
|
|
|
|
public void set_Expr(Expr exp)
|
|
|
|
// ino.end
|
|
|
|
// ino.method.set_Expr.26342.body
|
|
|
|
{
|
|
|
|
this.expr = exp;
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.set_Loop_block.26345.definition
|
|
|
|
public void set_Loop_block(Statement blk)
|
|
|
|
// ino.end
|
|
|
|
// ino.method.set_Loop_block.26345.body
|
|
|
|
{
|
|
|
|
this.loop_block = blk;
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.toString.26360.defdescription type=javadoc
|
|
|
|
/**
|
2015-05-12 17:49:27 +00:00
|
|
|
* <br/>Author: Martin Pl�micke
|
2013-10-18 11:33:46 +00:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
// ino.end
|
|
|
|
// ino.method.toString.26360.definition
|
|
|
|
public String toString()
|
|
|
|
// ino.end
|
|
|
|
// ino.method.toString.26360.body
|
|
|
|
{
|
|
|
|
return "WHILE " + loop_block.toString();
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.26363.definition
|
2015-04-22 19:40:22 +00:00
|
|
|
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
|
2013-10-18 11:33:46 +00:00
|
|
|
// ino.end
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.26363.body
|
|
|
|
{
|
|
|
|
if(loop_block!=null){
|
|
|
|
loop_block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
|
|
|
ConstraintsSet ret = new ConstraintsSet();
|
|
|
|
ret.add(expr.TYPEExpr(assumptions));
|
2015-03-31 10:37:45 +00:00
|
|
|
SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType().TYPE(assumptions, this), new RefType("Boolean",this, 0).TYPE(assumptions, this)); // while(expr){}; expr <. boolean
|
2013-10-18 11:33:46 +00:00
|
|
|
ret.add(exprMustBeBool);
|
|
|
|
ret.add(this.loop_block.TYPEStmt(assumptions));
|
2014-02-11 15:30:38 +00:00
|
|
|
this.setType(loop_block.getType());
|
2013-10-18 11:33:46 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTypeLineNumber() {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
return new JavaCodeResult().attach("while(").attach(this.expr.printJavaCode(resultSet)).attach(")").attach(this.loop_block.printJavaCode(resultSet));
|
|
|
|
}
|
2014-02-22 03:58:49 +00:00
|
|
|
|
|
|
|
@Override
|
2015-04-22 19:40:22 +00:00
|
|
|
public Menge<SyntaxTreeNode> getChildren() {
|
|
|
|
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
|
2014-02-22 03:58:49 +00:00
|
|
|
ret.add(this.expr);
|
|
|
|
ret.add(this.loop_block);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-06-16 12:58:27 +00:00
|
|
|
|
|
|
|
@Override
|
2015-11-27 15:10:35 +00:00
|
|
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
2015-10-13 17:25:51 +00:00
|
|
|
// TODO Bytecode
|
|
|
|
throw new NotImplementedException();
|
2015-06-16 12:58:27 +00:00
|
|
|
}
|
2013-10-18 11:33:46 +00:00
|
|
|
}
|
|
|
|
// ino.end
|