Syntaxbaum anpassen

This commit is contained in:
JanUlrich 2016-09-30 12:46:02 +02:00
parent a1227a8b1b
commit b05b0ea5df
7 changed files with 11 additions and 21 deletions

View File

@ -4,5 +4,4 @@ package de.dhbwstuttgart.core;
public interface IItemWithOffset public interface IItemWithOffset
{ {
public int getOffset(); public int getOffset();
public int getVariableLength();
} }

View File

@ -298,16 +298,16 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
* Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt. * Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
* @return Java-Sourcefile * @return Java-Sourcefile
*/ */
public String printJavaCode(TypeinferenceResultSet reconstructionResult){ public JavaCodeResult printJavaCode(ResultSet reconstructionResult){
JavaCodeResult ret = new JavaCodeResult("class "); JavaCodeResult ret = new JavaCodeResult("class ");
JavaCodeResult classBodyCode = new JavaCodeResult(); JavaCodeResult classBodyCode = new JavaCodeResult();
if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach(" "); if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult)).attach(" ");
classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach("\n"); classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult)).attach("\n");
JavaCodeResult bodyString = new JavaCodeResult("{\n"); JavaCodeResult bodyString = new JavaCodeResult("{\n");
for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult.getUnifiedConstraints()) ).attach( "\n" ); for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult) ).attach( "\n" );
bodyString.attach("}\n"); bodyString.attach("}\n");
classBodyCode.attach(bodyString); classBodyCode.attach(bodyString);
@ -321,7 +321,7 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
Iterator<GenericTypeVar> it = this.genericClassParameters.iterator(); Iterator<GenericTypeVar> it = this.genericClassParameters.iterator();
while(it.hasNext()){ while(it.hasNext()){
GenericTypeVar tph = it.next(); GenericTypeVar tph = it.next();
ret.attach(tph.printJavaCode(reconstructionResult.getUnifiedConstraints())); ret.attach(tph.printJavaCode(reconstructionResult));
if(it.hasNext())ret.attach(", "); if(it.hasNext())ret.attach(", ");
} }
ret.attach(">"); ret.attach(">");
@ -329,7 +329,7 @@ public class Class extends GTVDeclarationContext implements IItemWithOffset, Gen
String stringReturn = ret.attach(classBodyCode).toString(); String stringReturn = ret.attach(classBodyCode).toString();
return stringReturn; return new JavaCodeResult(stringReturn);
} }
/** /**

View File

@ -72,7 +72,7 @@ public class FieldDeclaration extends Field{
} }
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(TypeinferenceResultSet resultSet) {
JavaCodeResult ret = new JavaCodeResult(); JavaCodeResult ret = new JavaCodeResult();
JavaCodeResult toAttach = this.getType().printJavaCode(resultSet).attach(" ").attach( this.getIdentifier()); JavaCodeResult toAttach = this.getType().printJavaCode(resultSet).attach(" ").attach( this.getIdentifier());
if(this.wert!=null)toAttach.attach(" = ").attach(this.getWert().printJavaCode(resultSet) ); if(this.wert!=null)toAttach.attach(" = ").attach(this.getWert().printJavaCode(resultSet) );

View File

@ -71,15 +71,6 @@ public class ArgumentList extends SyntaxTreeNode
return 0; return 0;
} }
@Override
public int getVariableLength() {
return 0;
}
@Override @Override
public Menge<? extends SyntaxTreeNode> getChildren() { public Menge<? extends SyntaxTreeNode> getChildren() {
return expr; return expr;

View File

@ -118,12 +118,12 @@ public class Assign extends ExprStmt
} }
// ino.end // ino.end
/*
@Override @Override
public String getTypeInformation(){ public String getTypeInformation(){
return "(" + expr1.getTypeInformation() + " = " + expr2.getTypeInformation() + ") : "+this.getType(); return "(" + expr1.getTypeInformation() + " = " + expr2.getTypeInformation() + ") : "+this.getType();
} }
*/
@Override @Override
public JavaCodeResult printJavaCode(ResultSet resultSet){ public JavaCodeResult printJavaCode(ResultSet resultSet){
JavaCodeResult ret = new JavaCodeResult().attach(this.expr1.printJavaCode(resultSet) ).attach( " = " ).attach( this.expr2.printJavaCode(resultSet)); JavaCodeResult ret = new JavaCodeResult().attach(this.expr1.printJavaCode(resultSet) ).attach( " = " ).attach( this.expr2.printJavaCode(resultSet));

View File

@ -180,7 +180,7 @@ public class Binary extends BinaryExpr
* @param expr2 * @param expr2
* @return * @return
*/ */
if(this.getType()==null)this.set_Type(TypePlaceholder.fresh(this)); //if(this.getType()==null)this.set_Type(TypePlaceholder.fresh(this));
OderConstraint oderCons = new OderConstraint(); OderConstraint oderCons = new OderConstraint();
HashMap<Type,Type> rMap = this.op.getReturnTypes(assumptions); HashMap<Type,Type> rMap = this.op.getReturnTypes(assumptions);
for(Type rT : rMap.keySet()){ for(Type rT : rMap.keySet()){

View File

@ -32,5 +32,5 @@ public abstract class Executeable extends SyntaxTreeNode implements Typeable
public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs); public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs);
public abstract String getTypeInformation(); //public abstract String getTypeInformation();
} }