Search in sources :

Example 11 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubBrace.

public void testPSubBrace() {
    Location l = new Location(getTestName(), 0);
    PSubBrace node = new PSubBrace(l, Definition.INT_TYPE, new ENumeric(l, "1", 10));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubBrace (EVariable a) (ENumeric 1))", node.toString());
}
Also used : Location(org.elasticsearch.painless.Location)

Example 12 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubArrayLength.

public void testPSubArrayLength() {
    Location l = new Location(getTestName(), 0);
    PSubArrayLength node = new PSubArrayLength(l, "int", "a");
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubArrayLength (EVariable a))", node.toString());
    assertEquals("(PSubNullSafeField (PSubArrayLength (EVariable a)))", new PSubNullSafeField(l, node).toString());
}
Also used : Location(org.elasticsearch.painless.Location)

Example 13 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubMapShortcut.

public void testPSubMapShortcut() {
    Location l = new Location(getTestName(), 0);
    Struct s = Definition.getType(Map.class.getSimpleName()).struct;
    PSubMapShortcut node = new PSubMapShortcut(l, s, new EConstant(l, "cat"));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubMapShortcut (EVariable a) (EConstant String 'cat'))", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubMapShortcut (EVariable a) (EConstant String 'cat')))", new PSubNullSafeCallInvoke(l, node).toString());
    l = new Location(getTestName(), 1);
    s = Definition.getType(Map.class.getSimpleName()).struct;
    node = new PSubMapShortcut(l, s, new EBinary(l, Operation.ADD, new EConstant(l, 1), new EConstant(l, 4)));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubMapShortcut (EVariable a) (EBinary (EConstant Integer 1) + (EConstant Integer 4)))", node.toString());
}
Also used : Map(java.util.Map) Location(org.elasticsearch.painless.Location) Struct(org.elasticsearch.painless.Definition.Struct)

Example 14 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubShortcut.

public void testPSubShortcut() {
    Location l = new Location(getTestName(), 0);
    Struct s = Definition.getType(FeatureTest.class.getName()).struct;
    Method getter = s.methods.get(new MethodKey("getX", 0));
    Method setter = s.methods.get(new MethodKey("setX", 1));
    PSubShortcut node = new PSubShortcut(l, "x", FeatureTest.class.getName(), getter, setter);
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubShortcut (EVariable a) x)", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubShortcut (EVariable a) x))", new PSubNullSafeCallInvoke(l, node).toString());
}
Also used : FeatureTest(org.elasticsearch.painless.FeatureTest) Method(org.elasticsearch.painless.Definition.Method) Location(org.elasticsearch.painless.Location) Struct(org.elasticsearch.painless.Definition.Struct) MethodKey(org.elasticsearch.painless.Definition.MethodKey)

Example 15 with Location

use of org.elasticsearch.painless.Location in project elasticsearch by elastic.

the class NodeToStringTests method testPSubListShortcut.

public void testPSubListShortcut() {
    Location l = new Location(getTestName(), 0);
    Struct s = Definition.getType(List.class.getSimpleName()).struct;
    PSubListShortcut node = new PSubListShortcut(l, s, new EConstant(l, 1));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubListShortcut (EVariable a) (EConstant Integer 1))", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubListShortcut (EVariable a) (EConstant Integer 1)))", new PSubNullSafeCallInvoke(l, node).toString());
    l = new Location(getTestName(), 0);
    s = Definition.getType(List.class.getSimpleName()).struct;
    node = new PSubListShortcut(l, s, new EBinary(l, Operation.ADD, new EConstant(l, 1), new EConstant(l, 4)));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubListShortcut (EVariable a) (EBinary (EConstant Integer 1) + (EConstant Integer 4)))", node.toString());
}
Also used : Collections.emptyList(java.util.Collections.emptyList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) Location(org.elasticsearch.painless.Location) Struct(org.elasticsearch.painless.Definition.Struct)

Aggregations

Location (org.elasticsearch.painless.Location)18 Struct (org.elasticsearch.painless.Definition.Struct)4 Token (org.antlr.v4.runtime.Token)2 Method (org.elasticsearch.painless.Definition.Method)2 MethodKey (org.elasticsearch.painless.Definition.MethodKey)2 Variable (org.elasticsearch.painless.Locals.Variable)2 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Map (java.util.Map)1 CharStream (org.antlr.v4.runtime.CharStream)1 InputMismatchException (org.antlr.v4.runtime.InputMismatchException)1 NoViableAltException (org.antlr.v4.runtime.NoViableAltException)1 Cast (org.elasticsearch.painless.Definition.Cast)1 Field (org.elasticsearch.painless.Definition.Field)1 RuntimeClass (org.elasticsearch.painless.Definition.RuntimeClass)1 FeatureTest (org.elasticsearch.painless.FeatureTest)1 EFunctionRef (org.elasticsearch.painless.node.EFunctionRef)1 ENewArray (org.elasticsearch.painless.node.ENewArray)1 EString (org.elasticsearch.painless.node.EString)1