Bug im convert(Feld) gefixt

This commit is contained in:
JanUlrich 2017-03-22 16:16:38 +01:00
parent 47f1f9ad54
commit c480e25805
5 changed files with 10 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.statement.*; import de.dhbwstuttgart.syntaxtree.statement.*;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.*; import de.dhbwstuttgart.typecheck.*;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -265,7 +266,12 @@ public class SyntaxTreeGenerator{
for(Java8Parser.FieldModifierContext fieldModifierContext : fieldDeclarationContext.fieldModifier()){ for(Java8Parser.FieldModifierContext fieldModifierContext : fieldDeclarationContext.fieldModifier()){
modifiers+=(convert(fieldModifierContext)); modifiers+=(convert(fieldModifierContext));
} }
RefTypeOrTPHOrWildcardOrGeneric fieldType = TypeGenerator.convert(fieldDeclarationContext.unannType(), reg, generics); RefTypeOrTPHOrWildcardOrGeneric fieldType;
if(fieldDeclarationContext.unannType() != null){
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannType(), reg, generics);
}else{
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.getStart());
}
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){ for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
String fieldName = convert(varCtx.variableDeclaratorId()); String fieldName = convert(varCtx.variableDeclaratorId());
if(varCtx.variableInitializer() != null){ if(varCtx.variableInitializer() != null){

View File

@ -10,6 +10,7 @@ import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType; import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typecheck.GenericTypeName; import de.dhbwstuttgart.typecheck.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typecheck.JavaClassRegistry; import de.dhbwstuttgart.typecheck.JavaClassRegistry;

View File

@ -1,12 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.exceptions.TypeinferenceException; import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
import org.antlr.v4.runtime.Token; import org.antlr.v4.runtime.Token;

View File

@ -10,7 +10,7 @@ class Methods {
} }
class Test { class Test {
String f; f;
add(){} add(){}
add(b){} add(b){}
sub(b){} sub(b){}

View File

@ -16,7 +16,7 @@ public class JavaTXCompilerTest {
@Test @Test
public void test() throws IOException, ClassNotFoundException { public void test() throws IOException, ClassNotFoundException {
JavaTXCompiler compiler = new JavaTXCompiler(); JavaTXCompiler compiler = new JavaTXCompiler();
//compiler.parse(new File(rootDirectory+"Methods.jav")); compiler.parse(new File(rootDirectory+"Methods.jav"));
compiler.parse(new File(rootDirectory+"Generics.jav")); compiler.parse(new File(rootDirectory+"Generics.jav"));
compiler.typeInference(); compiler.typeInference();
} }