diff --git a/src/mycompiler/MyCompiler.java b/src/mycompiler/MyCompiler.java index 7b566e9e..602ae2ee 100755 --- a/src/mycompiler/MyCompiler.java +++ b/src/mycompiler/MyCompiler.java @@ -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�r den Compiler - *
Autor: J�rg B�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 diff --git a/src/mycompiler/myclass/Class.java b/src/mycompiler/myclass/Class.java index 90988cf6..49e01d96 100755 --- a/src/mycompiler/myclass/Class.java +++ b/src/mycompiler/myclass/Class.java @@ -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; } diff --git a/src/mycompiler/myclass/FieldDeclaration.java b/src/mycompiler/myclass/FieldDeclaration.java index 70edf82f..d04969b5 100644 --- a/src/mycompiler/myclass/FieldDeclaration.java +++ b/src/mycompiler/myclass/FieldDeclaration.java @@ -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)); } diff --git a/test/mycompiler/test/lambda/testResults/LambdaTest.log b/test/mycompiler/test/lambda/testResults/LambdaTest.log index f4fd1484..34982e52 100644 --- a/test/mycompiler/test/lambda/testResults/LambdaTest.log +++ b/test/mycompiler/test/lambda/testResults/LambdaTest.log @@ -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 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