Class SymTypeOfFunction

java.lang.Object
de.monticore.types.check.SymTypeExpression
de.monticore.types.check.SymTypeOfFunction
All Implemented Interfaces:
Comparable<SymTypeExpression>

public class SymTypeOfFunction extends SymTypeExpression
SymTypeOfFunction stores any kind of Function, such as List<Person>::get, obj::<Integer>getX, i -> i + 2
  • Field Details

    • TYPESYMBOL_NAME

      @Deprecated(forRemoval=true) public static final String TYPESYMBOL_NAME
      Deprecated, for removal: This API element is subject to removal in a future version.
      only required for the deprecated type symbol
      See Also:
    • functionSymbol

      protected 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 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 Details

  • Method Details

    • isFunctionType

      public boolean isFunctionType()
      Description copied from class: SymTypeExpression
      Am I a function type (e.g. "String -> Integer")
      Overrides:
      isFunctionType in class SymTypeExpression
    • asFunctionType

      public SymTypeOfFunction asFunctionType()
      Overrides:
      asFunctionType in class SymTypeExpression
    • deepClone

      public SymTypeOfFunction deepClone()
      Overrides:
      deepClone in class SymTypeExpression
    • deepEquals

      public boolean deepEquals(SymTypeExpression sym)
      Specified by:
      deepEquals in class SymTypeExpression
    • 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...) -> int can 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...) -> int with arity of 3 is (P, int, int) -> int
    • getDeclaredType

      public SymTypeOfFunction getDeclaredType()
      returns the declared type
    • getTypeVariableReplaceMap

      protected Map<SymTypeVariable,SymTypeExpression> getTypeVariableReplaceMap()
    • getTypeArguments

      public 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:
      accept in class SymTypeExpression
    • containsArgumentType

      public boolean containsArgumentType(Object element)
    • containsAllArgumentTypes

      public boolean containsAllArgumentTypes(Collection<?> collection)
    • isEmptyArgumentTypes

      public boolean isEmptyArgumentTypes()
    • iteratorArgumentTypes

      public Iterator<SymTypeExpression> iteratorArgumentTypes()
    • sizeArgumentTypes

      public int sizeArgumentTypes()
    • toArrayArgumentTypes

      public SymTypeExpression[] toArrayArgumentTypes(SymTypeExpression[] array)
    • toArrayArgumentTypes

      public Object[] toArrayArgumentTypes()
    • spliteratorArgumentTypes

      public Spliterator<SymTypeExpression> spliteratorArgumentTypes()
    • streamArgumentTypes

      public Stream<SymTypeExpression> streamArgumentTypes()
    • parallelStreamArgumentTypes

      public Stream<SymTypeExpression> parallelStreamArgumentTypes()
    • getArgumentType

      public SymTypeExpression getArgumentType(int index)
    • indexOfArgumentType

      public int indexOfArgumentType(Object element)
    • lastIndexOfArgumentType

      public int lastIndexOfArgumentType(Object element)
    • equalsArgumentTypeTypes

      public boolean equalsArgumentTypeTypes(Object o)
    • hashCodeArgumentTypes

      public int hashCodeArgumentTypes()
    • listIteratorArgumentTypes

      public ListIterator<SymTypeExpression> listIteratorArgumentTypes()
    • listIteratorArgumentTypes

      public ListIterator<SymTypeExpression> listIteratorArgumentTypes(int index)
    • subListArgumentTypes

      public List<SymTypeExpression> subListArgumentTypes(int start, int end)
    • getArgumentTypeList

      public List<SymTypeExpression> getArgumentTypeList()
    • clearArgumentTypes

      public void clearArgumentTypes()
    • addArgumentType

      public boolean addArgumentType(SymTypeExpression element)
    • addAllArgumentTypes

      public boolean addAllArgumentTypes(Collection<? extends SymTypeExpression> collection)
    • removeArgumentType

      public boolean removeArgumentType(Object element)
    • removeAllArgumentTypes

      public boolean removeAllArgumentTypes(Collection<?> collection)
    • retainAllArgumentTypes

      public boolean retainAllArgumentTypes(Collection<?> collection)
    • removeIfArgumentType

      public boolean removeIfArgumentType(Predicate<? super SymTypeExpression> filter)
    • forEachArgumentTypes

      public void forEachArgumentTypes(Consumer<? super SymTypeExpression> action)
    • addArgumentType

      public void addArgumentType(int index, SymTypeExpression element)
    • addAllArgumentTypes

      public boolean addAllArgumentTypes(int index, Collection<? extends SymTypeExpression> collection)
    • removeArgumentType

      public SymTypeExpression removeArgumentType(int index)
    • setArgumentType

      public SymTypeExpression setArgumentType(int index, SymTypeExpression element)
    • replaceAllArgumentTypes

      public void replaceAllArgumentTypes(UnaryOperator<SymTypeExpression> operator)
    • sortArgumentTypes

      public void sortArgumentTypes(Comparator<? super SymTypeExpression> comparator)
    • setArgumentTypeList

      public void setArgumentTypeList(List<SymTypeExpression> argumentTypes)