Class OperatorNames
java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.expression.tree.OperatorNames
Names of operators in printed expressions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetCallName(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types) static IOperatorgetInfixOperator(String symbol) static IOperatorgetInfixOperator(String symbol, IValueType<?> leftType, IValueType<?> rightType) static StringgetInfixSymbol(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types) static StringgetInfixSymbol(IOperator operator) getMethods(IValueType<?> receiverType) static StringgetName(IOperator operator, List<IValueType<?>> argumentTypes) static StringgetNodeName(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types) static IOperatorgetPrefixOperator(String symbol, IValueType<?> type) static StringgetPrefixSymbol(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types) static StringgetPrefixSymbol(IOperator operator) getScopedNameOperators(String name) static IOperatorgetSymbolValue(String symbol) static StringgetValueName(IOperator operator) static booleanisMethodCall(ExpressionNode.Operator node, int[] path, ExpressionTypeChecker.Result types) Calls are written as a method of their first argument, as initem.size(), when they use the scoped name, as the type of that argument tells which operator it is.static booleanisRegistered(IOperator operator) static IOperatorresolve(String name, List<IValueType<?>> argumentTypes) Find the operator with the given name, as written bygetName(IOperator, List).static IOperatorresolvePartial(String name, List<IValueType<?>> argumentTypes) Find the operator of a call that is still being typed, asresolve(String, List)does.
-
Method Details
-
getInfixSymbol
-
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
-
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
- 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
- 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
-
getScopedNameOperators
-
getName
- 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
-
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 initem.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 asmap(f, l), and choices stay calls, and so do calls on an empty slot or a number, which reads as a decimal point, as in1.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
Find the operator with the given name, as written bygetName(IOperator, List). Global names always match exactly, and scoped names that several operators share are chosen between bychoose(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
Find the operator of a call that is still being typed, asresolve(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
- 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
- Parameters:
operator- An operator.- Returns:
- If the operator is registered, so it can be named, in contrast to curried or combined operators.
-