1313import com .adacore .lkql_jit .nodes .arguments .NamedArg ;
1414import com .adacore .lkql_jit .nodes .expressions .Expr ;
1515import com .adacore .lkql_jit .runtime .values .LKQLSelector ;
16- import com .adacore .lkql_jit .runtime .values .interfaces .Iterator ;
17- import com .adacore .lkql_jit .runtime .values .lists .LKQLList ;
1816import com .adacore .lkql_jit .runtime .values .lists .LKQLSelectorList ;
1917import com .adacore .lkql_jit .utils .Constants ;
2018import com .adacore .lkql_jit .utils .LKQLTypesHelper ;
21- import com .adacore .lkql_jit .utils .functions .FrameUtils ;
2219import com .oracle .truffle .api .frame .VirtualFrame ;
2320import com .oracle .truffle .api .nodes .UnexpectedResultException ;
2421import com .oracle .truffle .api .source .SourceSection ;
25- import java .util .ArrayList ;
26- import java .util .List ;
2722
2823/**
2924 * This node represents the call of a selector in the LKQL language.
@@ -37,9 +32,6 @@ public final class SelectorCall extends LKQLNode {
3732 /** The quantifier for the selector call. */
3833 private final Quantifier quantifier ;
3934
40- /** The slot to put the binding value in, might be -1 if there is no binding. */
41- private final int bindingSlot ;
42-
4335 // ----- Children -----
4436
4537 /** The selector to call. */
@@ -59,20 +51,17 @@ public final class SelectorCall extends LKQLNode {
5951 *
6052 * @param location The location of the node in the source.
6153 * @param quantifier The quantifier for the selector.
62- * @param bindingSlot The slot of the binding.
6354 * @param selectorExpr The selector expression.
6455 * @param args The arguments for the call.
6556 */
6657 public SelectorCall (
6758 SourceSection location ,
6859 Quantifier quantifier ,
69- int bindingSlot ,
7060 Expr selectorExpr ,
7161 ArgList args
7262 ) {
7363 super (location );
7464 this .quantifier = quantifier ;
75- this .bindingSlot = bindingSlot ;
7665 this .selectorExpr = selectorExpr ;
7766 this .args = args ;
7867 }
@@ -109,11 +98,6 @@ public boolean executeVerification(VirtualFrame frame, Object node, Pattern patt
10998 isValid = this .isAny (frame , selectorListValue , pattern );
11099 }
111100
112- // Do the bindings
113- if (this .bindingSlot > -1 ) {
114- this .doBinding (frame , selectorListValue , pattern );
115- }
116-
117101 // Return the result
118102 return isValid ;
119103 }
@@ -233,61 +217,6 @@ private boolean isAny(VirtualFrame frame, LKQLSelectorList selectorListValue, Pa
233217 return false ;
234218 }
235219
236- /**
237- * Get the list value filtered with the given pattern.
238- *
239- * @param frame The frame to execute in.
240- * @param selectorListValue The selector list value to filter.
241- * @param pattern The pattern for the filtering.
242- * @return The list value
243- */
244- private LKQLList getFilteredList (
245- VirtualFrame frame ,
246- LKQLSelectorList selectorListValue ,
247- Pattern pattern
248- ) {
249- // Prepare the result
250- List <Object > resList = new ArrayList <>();
251-
252- // Iterate on nodes
253- Iterator iterator = selectorListValue .iterator ();
254- while (iterator .hasNext ()) {
255- Object value = iterator .next ();
256- if (pattern .executeValue (frame , value )) {
257- resList .add (value );
258- }
259- }
260-
261- // Return the result
262- return new LKQLList (resList .toArray (new Object [0 ]));
263- }
264-
265- /**
266- * Do the binding process.
267- *
268- * @param frame The frame to execute in.
269- * @param selectorListValue The selector list to bind.
270- * @param pattern The pattern to filter the list.
271- */
272- private void doBinding (
273- VirtualFrame frame ,
274- LKQLSelectorList selectorListValue ,
275- Pattern pattern
276- ) {
277- LKQLList listValue = this .getFilteredList (frame , selectorListValue , pattern );
278- this .doBinding (frame , listValue );
279- }
280-
281- /**
282- * Do the binding with the already computed list.
283- *
284- * @param frame The frame to execute in.
285- * @param listValue The list bind.
286- */
287- private void doBinding (VirtualFrame frame , LKQLList listValue ) {
288- FrameUtils .writeLocal (frame , this .bindingSlot , listValue );
289- }
290-
291220 // ----- Override methods -----
292221
293222 /**
@@ -297,8 +226,8 @@ private void doBinding(VirtualFrame frame, LKQLList listValue) {
297226 public String toString (int indentLevel ) {
298227 return this .nodeRepresentation (
299228 indentLevel ,
300- new String [] { "quantifier" , "slot" },
301- new Object [] { this .quantifier , this . bindingSlot }
229+ new String [] { "quantifier" },
230+ new Object [] { this .quantifier }
302231 );
303232 }
304233
0 commit comments