mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 08:58:02 +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 lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
@ -24,15 +23,23 @@ public class TypedParameter implements TypedNode {
|
||||
public void convertToTypedParameter(Map<String, Type> localVar, TypedClass clas, Parameter unTypedParameter) {
|
||||
paraName = unTypedParameter.name();
|
||||
type = unTypedParameter.type();
|
||||
localVar.put(paraName, type);
|
||||
//localVar.put(paraName, type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
||||
if (localVar.containsKey(paraName)) {
|
||||
throw new RuntimeException("Parameter " + paraName + " already exists");
|
||||
|
||||
if(clas.isCurrentMethodPresent()){
|
||||
if(clas.isParameterWitNameInMethod(paraName)) {
|
||||
throw new RuntimeException("Parameter " + paraName + " already exists");
|
||||
}
|
||||
}else if(clas.isCurrentConstructorPresent()){
|
||||
if(clas.isParameterWitNameInConstructor(paraName)) {
|
||||
throw new RuntimeException("Parameter " + paraName + " already exists");
|
||||
}
|
||||
}
|
||||
localVar.put(paraName, type);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user