createTypeAssumptions für Field generiert

This commit is contained in:
JanUlrich 2014-02-19 14:16:28 +01:00
parent e31725f255
commit bf341ab4f3
4 changed files with 14 additions and 50 deletions

View File

@ -80,15 +80,6 @@ public class MyCompiler implements MyCompilerAPI
protected String OutputDir = "";
// ino.end
// ino.attribute.m_Singleton.21277.decldescription type=javadoc
/**
* Die Singleton-Instanz f<EFBFBD>r den Compiler
* <br/>Autor: J<EFBFBD>rg B<EFBFBD>uerle
*/
// ino.end
// ino.attribute.m_Singleton.21277.declaration
private static MyCompiler m_Singleton = null;
// ino.end
// ino.attribute.m_AbstractSyntaxTree.21280.decldescription type=javadoc
/**
@ -130,10 +121,7 @@ public class MyCompiler implements MyCompilerAPI
// ino.end
// ino.method.getAPI.21286.body
{
if(m_Singleton==null){
m_Singleton = new MyCompiler();
}
return m_Singleton;
return new MyCompiler();
}
// ino.end

View File

@ -1258,6 +1258,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
*/
public TypeAssumptions getPublicFieldAssumptions() {
TypeAssumptions ret = this.getTypeAssumptions();
for(Field f : this.getFields()){
ret.add(f.createTypeAssumptions(this));
}
return ret;
}

View File

@ -7,6 +7,8 @@ import typinferenz.JavaCodeResult;
import typinferenz.OderConstraint;
import typinferenz.ResultSet;
import typinferenz.SingleConstraint;
import typinferenz.TypinferenzException;
import typinferenz.assumptions.FieldAssumption;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile;
@ -71,15 +73,16 @@ public class FieldDeclaration extends Field{
* TODO: Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
* Wird das Feld mit einem Typ initialisiert so muss dieser auch in die Assumptions.
*/
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
if(this.getType() == null)throw new TypinferenzException("Der Typ eines Feldes darf nicht null sein");
//assumptions.add(TypeAssumptions.createFieldVarAssumption(classmember.getName(), this.getName(), this.getType()));
assumptions.addFieldAssumption(new FieldAssumption(this,classmember));
return assumptions;
}
@Override
public void parserPostProcessing(SyntaxTreeNode parent){
super.parserPostProcessing(parent);
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
}

View File

@ -1,41 +1,11 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: WhileTestMethod Assumptions:
[typinferenz.assumptions.MethodAssumption@33e8c1e4, typinferenz.assumptions.MethodAssumption@76117a5b]
Class DEBUG [Typeinference] Erstellte Assumptions: this: LambdaTest1Method Assumptions:
[typinferenz.assumptions.MethodAssumption@1e54f9f6, typinferenz.assumptions.MethodAssumption@5ce69508]
FieldVar Assumptions:
[]
[typinferenz.assumptions.FieldAssumption@26426fde]
LocalVar Assumptions:
[]
Parameter Assumptions:
[]
Block DEBUG [Typeinference] Prozessing statement: no type [var]
Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@25cc8345)]
Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@25cc8345)
Block DEBUG [Typeinference] Prozessing statement: void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345)
Block DEBUG [Typeinference] Prozessing statement: WHILE void { [void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345)]
Block DEBUG [Typeinference] Prozessing statement: TPH C [var]
Class DEBUG [Typeinference] Erstellte Constraints: boolean < boolean
String < TPH C
TPH C < TPH D
void < TPH A
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(boolean <. boolean), (String <. TPH C), (TPH C <. TPH D), (void <. TPH A)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH D = String), (TPH C = String), (TPH A = void)]]
SourceFile DEBUG [Typeinference]
JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH D = String), (TPH C = String), (TPH A = void)]
SourceFile DEBUG [Typeinference] class <B>WhileTest extends Object
{
void method()
{
String var;
while(true){
var = "String";
}
}
B WhileTest()
{
}
}
Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ String text, ]) -> null { [null Return toAppend])
Block DEBUG [Typeinference] Prozessing statement: null Return toAppend