mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 17:08:03 +00:00
update the typeCheck of TypedParameter
This commit is contained in:
parent
9f4b158237
commit
e49691ff29
@ -6,7 +6,6 @@ import de.maishai.typedast.TypedNode;
|
|||||||
import de.maishai.typedast.Type;
|
import de.maishai.typedast.Type;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -24,15 +23,23 @@ public class TypedParameter implements TypedNode {
|
|||||||
public void convertToTypedParameter(Map<String, Type> localVar, TypedClass clas, Parameter unTypedParameter) {
|
public void convertToTypedParameter(Map<String, Type> localVar, TypedClass clas, Parameter unTypedParameter) {
|
||||||
paraName = unTypedParameter.name();
|
paraName = unTypedParameter.name();
|
||||||
type = unTypedParameter.type();
|
type = unTypedParameter.type();
|
||||||
localVar.put(paraName, type);
|
//localVar.put(paraName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
||||||
if (localVar.containsKey(paraName)) {
|
|
||||||
|
if(clas.isCurrentMethodPresent()){
|
||||||
|
if(clas.isParameterWitNameInMethod(paraName)) {
|
||||||
throw new RuntimeException("Parameter " + paraName + " already exists");
|
throw new RuntimeException("Parameter " + paraName + " already exists");
|
||||||
}
|
}
|
||||||
localVar.put(paraName, type);
|
}else if(clas.isCurrentConstructorPresent()){
|
||||||
|
if(clas.isParameterWitNameInConstructor(paraName)) {
|
||||||
|
throw new RuntimeException("Parameter " + paraName + " already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user