Class OperatorNames

java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.expression.tree.OperatorNames

public final class OperatorNames extends Object
Names of operators in printed expressions.
  • Method Details

    • getInfixSymbol

      @Nullable public static String getInfixSymbol(IOperator operator)
      Parameters:
      operator - An operator.
      Returns:
      The symbol to write this operator with between its two inputs, or null. These are the operators whose symbol is one between two values in the text form.
    • getInfixSymbol

      @Nullable public static String getInfixSymbol(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types)
      Parameters:
      node - An operator node.
      path - The path of the node.
      types - The type checking result of the expression that contains the node.
      Returns:
      The symbol to write the node with between its two inputs, or null if the symbol would be read as another operator, such as + for addition of strings, or if the operator has no symbol.
    • getInfixOperator

      @Nullable public static IOperator getInfixOperator(String symbol, @Nullable IValueType<?> leftType, @Nullable IValueType<?> rightType)
      Parameters:
      symbol - A symbol.
      leftType - The type of the first input, or null if unknown.
      rightType - The type of the second input, or null if unknown.
      Returns:
      The operator written with this symbol between inputs of these types, see choose(List, List, boolean), or null. So + is concat if one of the inputs is a string, and addition otherwise.
    • getPrefixSymbol

      @Nullable public static String getPrefixSymbol(IOperator operator)
      Parameters:
      operator - An operator.
      Returns:
      The symbol to write this operator with in front of its single input, or null.
    • getPrefixSymbol

      @Nullable public static String getPrefixSymbol(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types)
      Parameters:
      node - An operator node.
      path - The path of the node.
      types - The type checking result of the expression that contains the node.
      Returns:
      The symbol to write the node with in front of its single input, or null if the symbol would be read as another operator, or if the operator has no symbol.
    • getInfixOperator

      @Nullable public static IOperator getInfixOperator(String symbol)
      Parameters:
      symbol - A symbol.
      Returns:
      The operator written with this symbol between its two inputs when their types are unknown, or null. + is addition here, see getInfixOperator(String, IValueType, IValueType).
    • getPrefixOperator

      @Nullable public static IOperator getPrefixOperator(String symbol, @Nullable IValueType<?> type)
      Parameters:
      symbol - A symbol.
      type - The type of the input, or null if unknown.
      Returns:
      The operator written with this symbol in front of its single input of this type, see choose(List, List, boolean), or null.
    • getSymbolValue

      @Nullable public static IOperator getSymbolValue(String symbol)
      Parameters:
      symbol - A symbol.
      Returns:
      The operator that this symbol in brackets stands for as a value, as in (+), or null.
    • getScopedNameOperators

      public static List<IOperator> getScopedNameOperators(String name)
      Parameters:
      name - A scoped name.
      Returns:
      All operators with this scoped name.
    • getName

      public static String getName(IOperator operator, @Nullable List<IValueType<?>> argumentTypes)
      Parameters:
      operator - An operator.
      argumentTypes - The types of its arguments, null where unknown, or null for an operator used as a value.
      Returns:
      The name to call the operator with: its scoped name if that is read back as the operator, and its global name otherwise.
    • getValueName

      public static String getValueName(IOperator operator)
      Parameters:
      operator - An operator that is used as a value.
      Returns:
      Its name, without arguments to tell shared names apart.
    • getNodeName

      public static String getNodeName(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types)
      Parameters:
      node - An operator node.
      path - The path of the node.
      types - The type checking result of the expression that contains the node.
      Returns:
      The name of the node's operator, as it is printed.
    • getCallName

      public static String getCallName(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types)
      Parameters:
      node - An operator node.
      path - The path of the node.
      types - The type checking result of the expression that contains the node.
      Returns:
      The name of the node's operator, as it is printed when the node is written as a call.
    • isMethodCall

      public static boolean isMethodCall(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types)
      Calls are written as a method of their first argument, as in item.size(), when they use the scoped name, as the type of that argument tells which operator it is. Operators that take an operator first, such as map(f, l), and choices stay calls, and so do calls on an empty slot or a number, which reads as a decimal point, as in 1.max(2).
      Parameters:
      node - An operator node.
      path - The path of the node.
      types - The type checking result of the expression that contains the node.
      Returns:
      If the node is written as a method of its first argument.
    • resolve

      @Nullable public static IOperator resolve(String name, @Nullable List<IValueType<?>> argumentTypes)
      Find the operator with the given name, as written by getName(IOperator, List). Global names always match exactly, and scoped names that several operators share are chosen between by choose(List, List, boolean).
      Parameters:
      name - A global or scoped name.
      argumentTypes - The types of all arguments, null where unknown, or null for an operator used as a value.
      Returns:
      The operator, or null if the name is unknown.
    • resolvePartial

      @Nullable public static IOperator resolvePartial(String name, List<IValueType<?>> argumentTypes)
      Find the operator of a call that is still being typed, as resolve(String, List) does.
      Parameters:
      name - A global or scoped name.
      argumentTypes - The types of the arguments typed so far, null where unknown.
      Returns:
      The operator, or null if the name is unknown.
    • getMethods

      public static SortedMap<String, IOperator> getMethods(IValueType<?> receiverType)
      Parameters:
      receiverType - The type of a value.
      Returns:
      The operators that can be called as a method on values of this type, by the name to call them with, ordered by name. These are the operators whose first input takes the type, as for the methods of values in Integrated Scripting.
    • isRegistered

      public static boolean isRegistered(IOperator operator)
      Parameters:
      operator - An operator.
      Returns:
      If the operator is registered, so it can be named, in contrast to curried or combined operators.