Package de.monticore.types.check
Class SymTypeOfFunction
- java.lang.Object
-
- de.monticore.types.check.SymTypeExpression
-
- de.monticore.types.check.SymTypeOfFunction
-
public class SymTypeOfFunction extends SymTypeExpression
SymTypeOfFunction stores any kind of Function, such asList<Person>::get,obj::<Integer>getX,i -> i + 2
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<SymTypeExpression>argumentTypesList of argument types of the function e.g.protected booleanellipticWhether the function supports varargs e.g.protected java.util.Optional<FunctionSymbol>functionSymbolSymbol of the function may not be present (e.g., for lambdas)protected SymTypeExpressionreturnTypeType of return value returned when the function is calledstatic java.lang.StringTYPESYMBOL_NAMEDeprecated.only required for the deprecated type symbol-
Fields inherited from class de.monticore.types.check.SymTypeExpression
functionList, LOG_NAME, sourceInfo, typeSymbol
-
-
Constructor Summary
Constructors Constructor Description SymTypeOfFunction(FunctionSymbol functionSymbol, SymTypeExpression returnType, java.util.List<? extends SymTypeExpression> argumentTypes, boolean elliptic)Constructor with all parameters that are stored: FunctionSymbol can be nullSymTypeOfFunction(SymTypeExpression returnType, java.util.List<SymTypeExpression> argumentTypes, boolean elliptic)Deprecated.the other constructor is to be used
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ISymTypeVisitor visitor)booleanaddAllArgumentTypes(int index, java.util.Collection<? extends SymTypeExpression> collection)booleanaddAllArgumentTypes(java.util.Collection<? extends SymTypeExpression> collection)voidaddArgumentType(int index, SymTypeExpression element)booleanaddArgumentType(SymTypeExpression element)SymTypeOfFunctionasFunctionType()booleancanHaveArity(int arity)returns whether the specified amount of arguments can be accepted E.g.,(P, int...) -> intcan accept 1,2,3,...voidclearArgumentTypes()booleancontainsAllArgumentTypes(java.util.Collection<?> collection)booleancontainsArgumentType(java.lang.Object element)SymTypeOfFunctiondeepClone()booleandeepEquals(SymTypeExpression sym)booleandeepEqualsSignature(SymTypeExpression other)deepEquals, but ignoring the return type s.a.booleanequalsArgumentTypeTypes(java.lang.Object o)voidforEachArgumentTypes(java.util.function.Consumer<? super SymTypeExpression> action)SymTypeExpressiongetArgumentType(int index)java.util.List<SymTypeExpression>getArgumentTypeList()SymTypeOfFunctiongetDeclaredType()returns the declared typeFunctionSymbolgetSymbol()SymTypeExpressiongetType()java.util.List<SymTypeExpression>getTypeArguments()returns the type arguments for a generic function.protected java.util.Map<SymTypeVariable,SymTypeExpression>getTypeVariableReplaceMap()SymTypeOfFunctiongetWithFixedArity(int arity)returns a clone, with the arity fixed to the specified number E.g.,(P, int...) -> intwith arity of 3 is(P, int, int) -> intinthashCodeArgumentTypes()booleanhasSymbol()intindexOfArgumentType(java.lang.Object element)booleanisElliptic()iff true, the last argument type is accepted any amount of timesbooleanisEmptyArgumentTypes()booleanisFunctionType()Am I a function type (e.g.java.util.Iterator<SymTypeExpression>iteratorArgumentTypes()intlastIndexOfArgumentType(java.lang.Object element)java.util.ListIterator<SymTypeExpression>listIteratorArgumentTypes()java.util.ListIterator<SymTypeExpression>listIteratorArgumentTypes(int index)java.util.stream.Stream<SymTypeExpression>parallelStreamArgumentTypes()booleanremoveAllArgumentTypes(java.util.Collection<?> collection)SymTypeExpressionremoveArgumentType(int index)booleanremoveArgumentType(java.lang.Object element)booleanremoveIfArgumentType(java.util.function.Predicate<? super SymTypeExpression> filter)voidreplaceAllArgumentTypes(java.util.function.UnaryOperator<SymTypeExpression> operator)booleanretainAllArgumentTypes(java.util.Collection<?> collection)SymTypeExpressionsetArgumentType(int index, SymTypeExpression element)voidsetArgumentTypeList(java.util.List<SymTypeExpression> argumentTypes)voidsetElliptic(boolean elliptic)intsizeArgumentTypes()voidsortArgumentTypes(java.util.Comparator<? super SymTypeExpression> comparator)java.util.Spliterator<SymTypeExpression>spliteratorArgumentTypes()java.util.stream.Stream<SymTypeExpression>streamArgumentTypes()java.util.List<SymTypeExpression>subListArgumentTypes(int start, int end)java.lang.Object[]toArrayArgumentTypes()SymTypeExpression[]toArrayArgumentTypes(SymTypeExpression[] array)-
Methods inherited from class de.monticore.types.check.SymTypeExpression
_internal_setSourceInfo, asArrayType, asGenericType, asInferenceVariable, asIntersectionType, asNullType, asNumericWithSIUnitType, asObjectType, asObscureType, asPrimitive, asRegExType, asSIUnitType, asTupleType, asTypeVariable, asUnionType, asVoidType, asWildcard, getCorrectFields, getCorrectFields, getCorrectMethods, getCorrectMethods, getFieldList, getFieldList, getFieldList, getFieldList, getMethodList, getMethodList, getMethodList, getMethodList, getSourceInfo, getTypeInfo, hasTypeInfo, isArrayType, isGenericType, isInferenceVariable, isIntersectionType, isNullType, isNumericWithSIUnitType, isObjectType, isObscureType, isPrimitive, isRegExType, isSIUnitType, isTupleType, isTypeVariable, isUnionType, isValidType, isVoidType, isWildcard, print, printAsJson, printFullName, replaceTypeVariables, transformFieldList, transformMethodList
-
-
-
-
Field Detail
-
TYPESYMBOL_NAME
@Deprecated public static final java.lang.String TYPESYMBOL_NAME
Deprecated.only required for the deprecated type symbol- See Also:
- Constant Field Values
-
functionSymbol
protected java.util.Optional<FunctionSymbol> functionSymbol
Symbol of the function may not be present (e.g., for lambdas)
-
returnType
protected SymTypeExpression returnType
Type of return value returned when the function is called
-
argumentTypes
protected java.util.List<SymTypeExpression> argumentTypes
List of argument types of the function e.g. "Integer f(Float t)" has "Float" as its argument type a this-pointer is the first argument
-
elliptic
protected boolean elliptic
Whether the function supports varargs e.g.Integer f(Float... t)
-
-
Constructor Detail
-
SymTypeOfFunction
public SymTypeOfFunction(FunctionSymbol functionSymbol, SymTypeExpression returnType, java.util.List<? extends SymTypeExpression> argumentTypes, boolean elliptic)
Constructor with all parameters that are stored: FunctionSymbol can be null
-
SymTypeOfFunction
@Deprecated public SymTypeOfFunction(SymTypeExpression returnType, java.util.List<SymTypeExpression> argumentTypes, boolean elliptic)
Deprecated.the other constructor is to be used
-
-
Method Detail
-
isFunctionType
public boolean isFunctionType()
Description copied from class:SymTypeExpressionAm I a function type (e.g."String -> Integer")- Overrides:
isFunctionTypein classSymTypeExpression
-
asFunctionType
public SymTypeOfFunction asFunctionType()
- Overrides:
asFunctionTypein classSymTypeExpression
-
deepClone
public SymTypeOfFunction deepClone()
- Overrides:
deepClonein classSymTypeExpression
-
deepEquals
public boolean deepEquals(SymTypeExpression sym)
- Specified by:
deepEqualsin classSymTypeExpression
-
deepEqualsSignature
public boolean deepEqualsSignature(SymTypeExpression other)
deepEquals, but ignoring the return type s.a. Java Spec 20 8.4.2
-
getType
public SymTypeExpression getType()
- Returns:
- the return type of the function NOT the actual type of the function itself
-
isElliptic
public boolean isElliptic()
iff true, the last argument type is accepted any amount of times
-
setElliptic
public void setElliptic(boolean elliptic)
-
hasSymbol
public boolean hasSymbol()
-
getSymbol
public FunctionSymbol getSymbol()
-
canHaveArity
public boolean canHaveArity(int arity)
returns whether the specified amount of arguments can be accepted E.g.,(P, int...) -> intcan accept 1,2,3,... arguments, but not 0
-
getWithFixedArity
public SymTypeOfFunction getWithFixedArity(int arity)
returns a clone, with the arity fixed to the specified number E.g.,(P, int...) -> intwith arity of 3 is(P, int, int) -> int
-
getDeclaredType
public SymTypeOfFunction getDeclaredType()
returns the declared type
-
getTypeVariableReplaceMap
protected java.util.Map<SymTypeVariable,SymTypeExpression> getTypeVariableReplaceMap()
-
getTypeArguments
public java.util.List<SymTypeExpression> getTypeArguments()
returns the type arguments for a generic function. E.g., given asList, which has the declared Type<T> (T...) -> List<T>and this is the instantiation(int, int) -> List<int>, This will return the argument list [int].Warning: if the instantiation is, e.g.,
(Person, Car) -> List<int>, no correct list of arguments can be calculated.Not to be confused with getArgumentTypes, which in turn returns the parameter types (a.k.a. the types the arguments need to be compatible to). Naming is confusing due to legacy reasons.
-
accept
public void accept(ISymTypeVisitor visitor)
- Overrides:
acceptin classSymTypeExpression
-
containsArgumentType
public boolean containsArgumentType(java.lang.Object element)
-
containsAllArgumentTypes
public boolean containsAllArgumentTypes(java.util.Collection<?> collection)
-
isEmptyArgumentTypes
public boolean isEmptyArgumentTypes()
-
iteratorArgumentTypes
public java.util.Iterator<SymTypeExpression> iteratorArgumentTypes()
-
sizeArgumentTypes
public int sizeArgumentTypes()
-
toArrayArgumentTypes
public SymTypeExpression[] toArrayArgumentTypes(SymTypeExpression[] array)
-
toArrayArgumentTypes
public java.lang.Object[] toArrayArgumentTypes()
-
spliteratorArgumentTypes
public java.util.Spliterator<SymTypeExpression> spliteratorArgumentTypes()
-
streamArgumentTypes
public java.util.stream.Stream<SymTypeExpression> streamArgumentTypes()
-
parallelStreamArgumentTypes
public java.util.stream.Stream<SymTypeExpression> parallelStreamArgumentTypes()
-
getArgumentType
public SymTypeExpression getArgumentType(int index)
-
indexOfArgumentType
public int indexOfArgumentType(java.lang.Object element)
-
lastIndexOfArgumentType
public int lastIndexOfArgumentType(java.lang.Object element)
-
equalsArgumentTypeTypes
public boolean equalsArgumentTypeTypes(java.lang.Object o)
-
hashCodeArgumentTypes
public int hashCodeArgumentTypes()
-
listIteratorArgumentTypes
public java.util.ListIterator<SymTypeExpression> listIteratorArgumentTypes()
-
listIteratorArgumentTypes
public java.util.ListIterator<SymTypeExpression> listIteratorArgumentTypes(int index)
-
subListArgumentTypes
public java.util.List<SymTypeExpression> subListArgumentTypes(int start, int end)
-
getArgumentTypeList
public java.util.List<SymTypeExpression> getArgumentTypeList()
-
clearArgumentTypes
public void clearArgumentTypes()
-
addArgumentType
public boolean addArgumentType(SymTypeExpression element)
-
addAllArgumentTypes
public boolean addAllArgumentTypes(java.util.Collection<? extends SymTypeExpression> collection)
-
removeArgumentType
public boolean removeArgumentType(java.lang.Object element)
-
removeAllArgumentTypes
public boolean removeAllArgumentTypes(java.util.Collection<?> collection)
-
retainAllArgumentTypes
public boolean retainAllArgumentTypes(java.util.Collection<?> collection)
-
removeIfArgumentType
public boolean removeIfArgumentType(java.util.function.Predicate<? super SymTypeExpression> filter)
-
forEachArgumentTypes
public void forEachArgumentTypes(java.util.function.Consumer<? super SymTypeExpression> action)
-
addArgumentType
public void addArgumentType(int index, SymTypeExpression element)
-
addAllArgumentTypes
public boolean addAllArgumentTypes(int index, java.util.Collection<? extends SymTypeExpression> collection)
-
removeArgumentType
public SymTypeExpression removeArgumentType(int index)
-
setArgumentType
public SymTypeExpression setArgumentType(int index, SymTypeExpression element)
-
replaceAllArgumentTypes
public void replaceAllArgumentTypes(java.util.function.UnaryOperator<SymTypeExpression> operator)
-
sortArgumentTypes
public void sortArgumentTypes(java.util.Comparator<? super SymTypeExpression> comparator)
-
setArgumentTypeList
public void setArgumentTypeList(java.util.List<SymTypeExpression> argumentTypes)
-
-