Class StringSubstring
- java.lang.Object
-
- it.unive.lisa.symbolic.value.operator.ternary.StringSubstring
-
- All Implemented Interfaces:
Operator
,StringOperator
,TernaryOperator
public class StringSubstring extends java.lang.Object implements StringOperator, TernaryOperator
Given three expressions, with the first one evaluating to a string value and the second and third one evaluating to integral numerical values, aTernaryExpression
using this operator computes a new string corresponding to the portion of first argument's string starting at the second argument's number position (inclusive) and ending at the third argument's number position (exclusive).
Note that:- both second and third argument's numbers must be non-negative and less than the length of the first argument's string, with the second one's less or equal than the third one's
- if the second and third argument's numbers are equal, the empty string is returned
First argument expression type:StringType
Second argument expression type:NumericType
Third argument expression type:NumericType
Computed expression type:StringType
-
-
Field Summary
Fields Modifier and Type Field Description static StringSubstring
INSTANCE
The singleton instance of this class.
-
Constructor Summary
Constructors Modifier Constructor Description protected
StringSubstring()
Builds the operator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
toString()
java.util.Set<Type>
typeInference(TypeSystem types, java.util.Set<Type> left, java.util.Set<Type> middle, java.util.Set<Type> right)
Computes the runtime types of this expression (i.e., of the result of this expression) assuming that the arguments of this expression have the given types.
-
-
-
Field Detail
-
INSTANCE
public static final StringSubstring INSTANCE
The singleton instance of this class.
-
-
Constructor Detail
-
StringSubstring
protected StringSubstring()
Builds the operator. This constructor is visible to allow subclassing: instances of this class should be unique, and the singleton can be retrieved through fieldINSTANCE
.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
typeInference
public java.util.Set<Type> typeInference(TypeSystem types, java.util.Set<Type> left, java.util.Set<Type> middle, java.util.Set<Type> right)
Description copied from interface:TernaryOperator
Computes the runtime types of this expression (i.e., of the result of this expression) assuming that the arguments of this expression have the given types.- Specified by:
typeInference
in interfaceTernaryOperator
- Parameters:
types
- the type system knowing about the types of the current programleft
- the set of types of the left-most argument of this expressionmiddle
- the set of types of the middle argument of this expressionright
- the set of types of the right-most argument of this expression- Returns:
- the runtime types of this expression
-
-