Fix #285
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m37s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m37s
This commit is contained in:
parent
73ca790711
commit
e27eb3a3fe
@ -8,12 +8,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
import de.dhbwstuttgart.target.tree.expression.TargetClassName;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
@ -101,6 +101,7 @@ import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import org.stringtemplate.v4.ST;
|
||||
|
||||
public class StatementGenerator {
|
||||
|
||||
@ -756,6 +757,13 @@ public class StatementGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private StaticClassName generateStaticClassName(String name, Token offset) {
|
||||
var className = reg.getName(name);
|
||||
var numberOfGenerics = reg.getNumberOfGenerics(name);
|
||||
var refType = new RefType(className, Stream.generate(() -> (RefTypeOrTPHOrWildcardOrGeneric) TypePlaceholder.fresh(offset)).limit(numberOfGenerics).toList(), offset);
|
||||
return new StaticClassName(refType, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Parser kann nicht zwischen einer lokalen Variable, einem Feldzugriff und einer Klassenangabe unterscheiden.
|
||||
*
|
||||
@ -774,7 +782,7 @@ public class StatementGenerator {
|
||||
var field = fields.get(expression);
|
||||
return new FieldVar(new This(offset), Modifier.isStatic(field.modifiers()), expression, fields.get(expression).type(), offset);
|
||||
} else if (reg.contains(expression)) {
|
||||
return new StaticClassName(reg.getName(expression), offset);
|
||||
return generateStaticClassName(expression, offset);
|
||||
} else {
|
||||
// lokale Variable wurde ohne "var"-Keyword deklariert und direkt mit Wert versehen
|
||||
localVars.put(expression, TypePlaceholder.fresh(offset));
|
||||
@ -792,7 +800,7 @@ public class StatementGenerator {
|
||||
whole += part;
|
||||
// Check for Classname:
|
||||
if (reg.contains(whole)) {
|
||||
receiver = new StaticClassName(reg.getName(whole), offset);
|
||||
receiver = generateStaticClassName(whole, offset);
|
||||
}
|
||||
whole += ".";
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class StaticClassName extends Receiver {
|
||||
public StaticClassName(JavaClassName className, Token offset) {
|
||||
super(new RefType(className, offset), offset);
|
||||
public StaticClassName(RefTypeOrTPHOrWildcardOrGeneric type, Token offset) {
|
||||
super(type, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user