← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/array-navigation into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/array-navigation into lp:zorba.

Commit message:
New array unboxing/navigation ($a[])[1]

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/array-navigation/+merge/168069

New array unboxing/navigation ($a[])[1]
-- 
https://code.launchpad.net/~zorba-coders/zorba/array-navigation/+merge/168069
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/compiler/parser/parser.y'
--- src/compiler/parser/parser.y	2013-05-15 10:00:58 +0000
+++ src/compiler/parser/parser.y	2013-06-07 14:11:57 +0000
@@ -4454,6 +4454,10 @@
      {
        $$ = new DynamicFunctionInvocation(LOC(@$), $1, dynamic_cast<ArgList*>($3), false);
      }
+  | FilterExpr LBRACK RBRACK
+    {
+      $$ = new JSONArrayUnboxing(LOC(@$), $1);
+    }
 #ifdef JSONIQ_PARSER     
   |  FilterExpr DOT QNAME
      {
@@ -4482,27 +4486,28 @@
 
 // [81]
 PredicateList :
-        Predicate
-        {
-            PredicateList *pl = new PredicateList( LOC(@$) );
-            pl->push_back( dynamic_cast<exprnode*>($1) );
-            $$ = pl;
-        }
-    |   PredicateList Predicate
-        {
-            if ( PredicateList *pl = dynamic_cast<PredicateList*>($1) )
-                pl->push_back( dynamic_cast<exprnode*>($2) );
-            $$ = $1;
-        }
-    ;
+    Predicate
+    {
+      PredicateList* pl = new PredicateList( LOC(@$) );
+      pl->push_back(dynamic_cast<exprnode*>($1));
+      $$ = pl;
+    }
+  | PredicateList Predicate
+    {
+      if (PredicateList* pl = dynamic_cast<PredicateList*>($1))
+        pl->push_back(dynamic_cast<exprnode*>($2));
+
+      $$ = $1;
+    }
+;
 
 // [82]
 Predicate :
-        LBRACK Expr RBRACK
-        {
-            $$ = $2;
-        }
-    ;
+    LBRACK Expr RBRACK
+    {
+      $$ = $2;
+    }
+;
 
 // [83]
 PrimaryExpr :

=== modified file 'src/compiler/parsetree/parsenode_print_xml_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xml_visitor.cpp	2013-05-08 20:14:47 +0000
+++ src/compiler/parsetree/parsenode_print_xml_visitor.cpp	2013-06-07 14:11:57 +0000
@@ -1066,6 +1066,8 @@
 ////////// JSON ///////////////////////////////////////////////////////////////
 BEGIN_END_TAG(JSONObjectLookup)
 
+BEGIN_END_TAG(JSONArrayUnboxing)
+
 BEGIN_END_TAG(JSONArrayConstructor)
 
 BEGIN_END_TAG(JSONObjectConstructor)

=== modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp	2013-04-16 21:12:12 +0000
+++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp	2013-06-07 14:11:57 +0000
@@ -1534,6 +1534,7 @@
 XQDOC_NO_BEGIN_END_TAG (WindowVars)
 
 XQDOC_NO_BEGIN_END_TAG (JSONObjectLookup)
+XQDOC_NO_BEGIN_END_TAG (JSONArrayUnboxing)
 XQDOC_NO_BEGIN_END_TAG (JSONArrayConstructor)
 XQDOC_NO_BEGIN_END_TAG (JSONObjectConstructor)
 XQDOC_NO_BEGIN_END_TAG (JSONDirectObjectConstructor)

=== modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2013-03-22 00:38:18 +0000
+++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2013-06-07 14:11:57 +0000
@@ -2055,6 +2055,8 @@
   /* JSON-related */
   DEFAULT_VISIT (JSONObjectLookup);
 
+  DEFAULT_VISIT (JSONArrayUnboxing);
+
   DEFAULT_VISIT (JSONArrayConstructor);
 
   DEFAULT_VISIT (JSONObjectConstructor);

=== modified file 'src/compiler/parsetree/parsenode_visitor.h'
--- src/compiler/parsetree/parsenode_visitor.h	2013-03-22 00:38:18 +0000
+++ src/compiler/parsetree/parsenode_visitor.h	2013-06-07 14:11:57 +0000
@@ -283,6 +283,7 @@
 
 /* JSON */
   DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( JSONObjectLookup );
+  DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( JSONArrayUnboxing );
   DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( JSONArrayConstructor );
   DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( JSONObjectConstructor );
   DECL_PARSENODE_VISITOR_VISIT_MEM_FNS( JSONDirectObjectConstructor );

=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp	2013-05-11 12:22:50 +0000
+++ src/compiler/parsetree/parsenodes.cpp	2013-06-07 14:11:57 +0000
@@ -5921,15 +5921,21 @@
 }
 
 ////////// JSON ///////////////////////////////////////////////////////////////
+
+
+/*******************************************************************************
+
+********************************************************************************/
 JSONObjectLookup::JSONObjectLookup(
     const QueryLoc& loc,
     const QueryLoc& a_dot_loc,
     const exprnode* aObjectExpr,
     const exprnode* aSelectorExpr)
-  : exprnode(loc),
-    dot_loc(a_dot_loc),
-    theObjectExpr(aObjectExpr),
-    theSelectorExpr(aSelectorExpr)
+  :
+  exprnode(loc),
+  dot_loc(a_dot_loc),
+  theObjectExpr(aObjectExpr),
+  theSelectorExpr(aSelectorExpr)
 {
 }
 
@@ -5950,6 +5956,36 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
+JSONArrayUnboxing::JSONArrayUnboxing(
+    const QueryLoc& loc,
+    const exprnode* arrayExpr)
+  :
+  exprnode(loc),
+  theArrayExpr(arrayExpr)
+{
+}
+
+
+JSONArrayUnboxing::~JSONArrayUnboxing()
+{
+  delete theArrayExpr;
+}
+
+
+void JSONArrayUnboxing::accept(parsenode_visitor& v) const
+{
+  BEGIN_VISITOR();
+  ACCEPT(theArrayExpr);
+  END_VISITOR();
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
 JSONArrayConstructor::JSONArrayConstructor(
     const QueryLoc& loc,
     const exprnode* expr)
@@ -5974,6 +6010,9 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 JSONObjectConstructor::JSONObjectConstructor(
     const QueryLoc& loc,
     const exprnode* expr,
@@ -6000,9 +6039,13 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 JSONDirectObjectConstructor::JSONDirectObjectConstructor(const QueryLoc& loc)
-  : exprnode(loc),
-    thePairs(0)
+  :
+  exprnode(loc),
+  thePairs(0)
 {
 }
 
@@ -6081,6 +6124,9 @@
 }
 
 
+/*******************************************************************************
+
+********************************************************************************/
 JSON_Test::JSON_Test(
     const QueryLoc& loc,
     store::StoreConsts::JSONItemKind k)

=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h	2013-05-15 23:22:01 +0000
+++ src/compiler/parsetree/parsenodes.h	2013-06-07 14:11:57 +0000
@@ -6781,6 +6781,22 @@
 };
 
 
+class JSONArrayUnboxing : public exprnode
+{
+protected:
+  const exprnode* theArrayExpr;
+  
+public:
+  JSONArrayUnboxing(const QueryLoc&, const exprnode* arrayExpr);
+
+  ~JSONArrayUnboxing();
+
+  const exprnode* get_array_expr() const { return theArrayExpr; }
+
+  void accept(parsenode_visitor&) const;
+};
+
+
 class JSONArrayConstructor : public exprnode
 {
 private:

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2013-06-05 07:26:13 +0000
+++ src/compiler/translator/translator.cpp	2013-06-07 14:11:57 +0000
@@ -8796,7 +8796,8 @@
 
 
 /*******************************************************************************
-  ComparisonExpr ::= RangeExpr ((ValueComp | GeneralComp | NodeComp) RangeExpr)?
+  ComparisonExpr ::= StringConcatExpr
+                     ((ValueComp | GeneralComp | NodeComp) StringConcatExpr)?
 
   Note: For the full-text extension, the rule for ComparisonExpr is:
 
@@ -8953,6 +8954,55 @@
 
 
 /*******************************************************************************
+   StringConcatExpr ::= RangeExpr ( "||" RangeExpr )*
+*******************************************************************************/
+void* begin_visit(const StringConcatExpr& v)
+{
+  TRACE_VISIT();
+  return no_state;
+}
+
+void end_visit(const StringConcatExpr& v, void* /* visit_state */)
+{
+  TRACE_VISIT_OUT();
+  std::vector<expr*> concat_args;
+  expr* right = pop_nodestack();
+  expr* left  = pop_nodestack();
+  concat_args.push_back(left);
+
+  //If the right leaf is the concat expr,
+  //we add directly its leafs to the new concat expr.
+  bool rightLeafIsConcatExpr = false;
+  if(right->get_expr_kind() == fo_expr_kind)
+  {
+    fo_expr* lFoExpr = dynamic_cast<fo_expr*>(right);
+    if(lFoExpr->get_func() == BUILTIN_FUNC(FN_CONCAT_N))
+    {
+      rightLeafIsConcatExpr = true;
+      csize i = 0;
+      for(i = 0; i < lFoExpr->num_args(); ++i)
+      {
+        concat_args.push_back(lFoExpr->get_arg(i));
+      }
+    }
+  }
+
+  if(!rightLeafIsConcatExpr)
+  {
+    concat_args.push_back(right);
+  }
+
+  expr* concat =
+  theExprManager->create_fo_expr(theRootSctx,
+                                 theUDF,
+                                 loc,
+                                 BUILTIN_FUNC(FN_CONCAT_N),
+                                 concat_args);
+  push_nodestack(concat);
+}
+
+
+/*******************************************************************************
   RangeExpr ::= AdditiveExpr ( "to" AdditiveExpr )?
 ********************************************************************************/
 void* begin_visit(const RangeExpr& v)
@@ -9621,7 +9671,7 @@
 
   RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)*
 
-  StepExpr ::= PostfixExpr | AxisStep
+  StepExpr ::= FilterExpr | AxisStep
 
   AxisStep ::= (ReverseStep | ForwardStep) PredicateList
 
@@ -9653,7 +9703,8 @@
 
   Wildcard ::= "*" | (NCName ":" "*") | ("*" ":" NCName)
 
-  PostfixExpr ::= PrimaryExpr (Predicate | ArgumentList)*
+  FilterExpr ::= PrimaryExpr 
+                 (Predicate | ArgumentList | ObjectLookupExpr | ArrayUnboxing)*
 
   PredicateList ::= Predicate*
 
@@ -10211,7 +10262,7 @@
 
 
 /*******************************************************************************
-  StepExpr ::= PostfixExpr | AxisStep
+  StepExpr ::= FilterExpr | AxisStep
 ********************************************************************************/
 
 
@@ -10662,7 +10713,8 @@
 
 
 /*******************************************************************************
-  PostfixExpr ::= PrimaryExpr (Predicate | ArgumentList)*
+  FilterExpr ::= PrimaryExpr
+                 (Predicate | ArgumentList | ObjectLookupExpr | ArrayUnboxing)*
 ********************************************************************************/
 void* begin_visit(const FilterExpr& v)
 {
@@ -10677,8 +10729,7 @@
   // This method is called from FilterExpr::accept() after the primary expr is
   // translated, but before the associated predicate list, if any, is translated.
 
-  // Nothing to do if this is a standalone filter expr (i.e., it does not appear
-  // as a step of a path expr).
+  // Nothing to do if this  does not appear/ as a step of a path expr.
   if (!v.isPathStep())
     return;
 
@@ -10747,7 +10798,6 @@
   // for each predicate in the list, before calling accept() on the predicate
   // expression itself.
 
-
   // get the predicate input seq
   expr* inputSeqExpr = pop_nodestack();
 
@@ -10772,11 +10822,11 @@
   expr* predExpr = pop_nodestack();
 
   expr* f = pop_nodestack();
-  flwor_expr* flworExpr = dynamic_cast<flwor_expr*>(f);
-  ZORBA_ASSERT(flworExpr != NULL && flworExpr->num_clauses() == 3);
+  ZORBA_ASSERT(f->get_expr_kind() == flwor_expr_kind);
+  flwor_expr* flworExpr = static_cast<flwor_expr*>(f);
+  ZORBA_ASSERT(flworExpr->num_clauses() == 3);
 
   const QueryLoc& loc = predExpr->get_loc();
-
   xqtref_t predType = predExpr->get_return_type();
 
   if (TypeOps::is_subtype(tm, *predType, *rtm.INTEGER_TYPE_QUESTION, loc))
@@ -10806,13 +10856,30 @@
       {
         expr* sourceExpr = sourceClause->get_expr();
 
-        fo_expr* pointExpr = theExprManager->
-        create_fo_expr(sourceExpr->get_sctx(),
-                       theUDF,
-                       sourceExpr->get_loc(),
-                       BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
-                       sourceExpr,
+        if (sourceExpr->get_function_kind() == FunctionConsts::FN_JSONIQ_MEMBERS_1)
+        {
+          expr* arrayExpr = static_cast<fo_expr*>(sourceExpr)->get_arg(0);
+
+          if (arrayExpr->get_return_type()->max_card() <= 1)
+          {
+            fo_expr* pointExpr = 
+            CREATE(fo)(sourceExpr->get_sctx(), theUDF, sourceExpr->get_loc(),
+                       BUILTIN_FUNC(FN_JSONIQ_MEMBER_2),
+                       arrayExpr,
                        predExpr);
+            
+            push_nodestack(pointExpr);
+            pop_scope();
+
+            return;
+          }
+        }
+
+        fo_expr* pointExpr = 
+        CREATE(fo)(sourceExpr->get_sctx(), theUDF, sourceExpr->get_loc(),
+                   BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
+                   sourceExpr,
+                   predExpr);
 
         push_nodestack(pointExpr);
       }
@@ -10820,13 +10887,11 @@
       {
         expr* sourceExpr = sourceClause->get_var();
 
-        fo_expr* pointExpr = theExprManager->
-        create_fo_expr(sourceExpr->get_sctx(),
-                       theUDF,
-                       sourceExpr->get_loc(),
-                       BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
-                       sourceExpr,
-                       predExpr);
+        fo_expr* pointExpr = 
+        CREATE(fo)(sourceExpr->get_sctx(), theUDF, sourceExpr->get_loc(),
+                   BUILTIN_FUNC(OP_ZORBA_SEQUENCE_POINT_ACCESS_2),
+                   sourceExpr,
+                   predExpr);
 
         flworExpr->set_return_expr(pointExpr);
 
@@ -10841,14 +10906,11 @@
 
       flworExpr->add_clause(lcPred);
 
-      // return if ($$dot eq $$predVar) then $$dot else ()
-      fo_expr* eqExpr = theExprManager->
-      create_fo_expr(theRootSctx,
-                     theUDF,
-                     loc,
-                     BUILTIN_FUNC(OP_VALUE_EQUAL_2),
-                     lookup_ctx_var(getDotPosVarName(), loc),
-                     predvar);
+      // return if ($$pos eq $$predVar) then $$dot else ()
+      fo_expr* eqExpr = CREATE(fo)(theRootSctx, theUDF, loc,
+                                   BUILTIN_FUNC(OP_VALUE_EQUAL_2),
+                                   lookup_ctx_var(getDotPosVarName(), loc),
+                                   predvar);
 
       normalize_fo(eqExpr);
 
@@ -10929,6 +10991,94 @@
 }
 
 
+/*******************************************************************************
+  FilterExpr ::= PrimaryExpr
+                 (Predicate | ArgumentList | ObjectLooukExpr | ArrayUnboxing)*
+
+  ArrayUnboxing := "[" "]"
+
+  Note: the emoty list is returned if ExprSingle returns 
+********************************************************************************/
+void* begin_visit(const JSONArrayUnboxing& v)
+{
+  TRACE_VISIT();
+
+  return no_state;
+}
+
+
+void end_visit(const JSONArrayUnboxing& v, void* /*visit_state*/)
+{
+  TRACE_VISIT_OUT();
+
+  std::vector<expr*> args(1);
+  args[0] = pop_nodestack();
+
+  args[0] = CREATE(treat)(theRootSctx, theUDF, loc,
+                          args[0],
+                          theRTM.ITEM_TYPE_QUESTION,
+                          TREAT_TYPE_MATCH,
+                          false);
+
+  expr* e = generate_fn_body(BUILTIN_FUNC(FN_JSONIQ_MEMBERS_1), args, loc);
+
+  push_nodestack(e);
+}
+
+
+/*******************************************************************************
+  FilterExpr ::= PrimaryExpr
+                 (Predicate | ArgumentList | ObjectLooukExpr | ArrayUnboxing)*
+
+  ObjectLooukExpr ::= "." (NCName | ParenthesizedExpr | VarRef | StringLiteral)
+********************************************************************************/
+void* begin_visit(const JSONObjectLookup& v)
+{
+  TRACE_VISIT();
+  if (theSctx->is_feature_set(feature::common_language))
+  {
+    theCCB->theXQueryDiagnostics->add_warning(
+    NEW_XQUERY_WARNING(zwarn::ZWST0009_COMMON_LANGUAGE_WARNING,
+                       WARN_PARAMS(ZED(ZWST0009_JSON_OBJECT_LOOKUP)),
+                       WARN_LOC(v.get_dot_loc())));
+  }
+  return no_state;
+}
+
+
+void end_visit(const JSONObjectLookup& v, void* /*visit_state*/)
+{
+  TRACE_VISIT_OUT();
+
+  expr* selectExpr = pop_nodestack();
+  expr* objectExpr = pop_nodestack();
+
+  assert(selectExpr && objectExpr);
+
+  flwor_expr* flworExpr = wrap_expr_in_flwor(objectExpr, false);
+
+  for_clause* fc = reinterpret_cast<for_clause*>(flworExpr->get_clause(0));
+
+  expr* flworVarExpr = CREATE(wrapper)(theRootSctx, theUDF, loc, fc->get_var());
+
+  expr* accessorExpr;
+
+  std::vector<expr*> args(2);
+  args[0] = flworVarExpr;
+  args[1] = selectExpr;
+
+  accessorExpr = generate_fn_body(BUILTIN_FUNC(FN_JSONIQ_VALUE_2), args, loc);
+
+  assert(accessorExpr->get_expr_kind() == fo_expr_kind);
+
+  flworExpr->set_return_expr(accessorExpr);
+
+  pop_scope();
+
+  push_nodestack(flworExpr);
+}
+
+
 /////////////////////////////////////////////////////////////////////////////////
 //                                                                             //
 //  Primary                                                                    //
@@ -10939,13 +11089,13 @@
 /*******************************************************************************
   PrimaryExpr ::= Literal |
                   VarRef |
+                  ContextItemExpr |
                   ParenthesizedExpr |
-                  ContextItemExpr |
-                  FunctionCall |
                   OrderedExpr |
                   UnorderedExpr |
+                  FunctionCall |
+                  FunctionItemExpr
                   Constructor |
-                  FunctionItemExpr
 ********************************************************************************/
 
 
@@ -11039,6 +11189,7 @@
 
 
 /*******************************************************************************
+
 ********************************************************************************/
 void* begin_visit(const BooleanLiteral& v)
 {
@@ -11078,55 +11229,6 @@
 
 
 /*******************************************************************************
-   StringConcatExpr ::= RangeExpr ( "||" RangeExpr )*
-*******************************************************************************/
-void* begin_visit(const StringConcatExpr& v)
-{
-  TRACE_VISIT();
-  return no_state;
-}
-
-void end_visit(const StringConcatExpr& v, void* /* visit_state */)
-{
-  TRACE_VISIT_OUT();
-  std::vector<expr*> concat_args;
-  expr* right = pop_nodestack();
-  expr* left  = pop_nodestack();
-  concat_args.push_back(left);
-
-  //If the right leaf is the concat expr,
-  //we add directly its leafs to the new concat expr.
-  bool rightLeafIsConcatExpr = false;
-  if(right->get_expr_kind() == fo_expr_kind)
-  {
-    fo_expr* lFoExpr = dynamic_cast<fo_expr*>(right);
-    if(lFoExpr->get_func() == BUILTIN_FUNC(FN_CONCAT_N))
-    {
-      rightLeafIsConcatExpr = true;
-      csize i = 0;
-      for(i = 0; i < lFoExpr->num_args(); ++i)
-      {
-        concat_args.push_back(lFoExpr->get_arg(i));
-      }
-    }
-  }
-
-  if(!rightLeafIsConcatExpr)
-  {
-    concat_args.push_back(right);
-  }
-
-  expr* concat =
-  theExprManager->create_fo_expr(theRootSctx,
-                                 theUDF,
-                                 loc,
-                                 BUILTIN_FUNC(FN_CONCAT_N),
-                                 concat_args);
-  push_nodestack(concat);
-}
-
-
-/*******************************************************************************
   VarRef ::= "$" VarName
   VarName ::= QName
 ********************************************************************************/
@@ -11387,10 +11489,9 @@
 {
   TRACE_VISIT_OUT();
 
-  push_nodestack(theExprManager->create_order_expr(theRootSctx, theUDF,
-                                loc,
-                                doc_unordered,
-                                pop_nodestack()));
+  push_nodestack(CREATE(order)(theRootSctx, theUDF, loc,
+                               doc_unordered,
+                               pop_nodestack()));
 }
 
 
@@ -12290,14 +12391,15 @@
 
 
 /*******************************************************************************
-  PostfixExpr ::= PrimaryExpr (Predicate | ArgumentList)*
+  FilterExpr ::= PrimaryExpr
+                 (Predicate | ArgumentList | ObjectLookupExpr | ArrayUnboxing)*
 
   ArgumentList ::= "(" (Argument ("," Argument)*)? ")"
 
   Argument ::= ExprSingle
 
   As shown above, there is no grammar rule for DynamicFunctionInvocation. A
-  PostfinExpr becomes a dynamic function invocation if the PrimaryExpr is
+  FilterExpr becomes a dynamic function invocation if the PrimaryExpr is
   followed by an ArgumentList, in which case, the PrimaryExpr is supposed to
   return a function item.
 ********************************************************************************/
@@ -12951,57 +13053,6 @@
 
 
 /*******************************************************************************
-   FilterExpr ::= FilterExpr
-   (. (NCName | ParenthesizedExpr | VarRef | StringLiteral)
-********************************************************************************/
-void* begin_visit(const JSONObjectLookup& v)
-{
-  TRACE_VISIT();
-  if (theSctx->is_feature_set(feature::common_language))
-  {
-    theCCB->theXQueryDiagnostics->add_warning(
-        NEW_XQUERY_WARNING(zwarn::ZWST0009_COMMON_LANGUAGE_WARNING,
-                           WARN_PARAMS(ZED(ZWST0009_JSON_OBJECT_LOOKUP)),
-                           WARN_LOC(v.get_dot_loc())));
-  }
-  return no_state;
-}
-
-
-void end_visit(const JSONObjectLookup& v, void* /*visit_state*/)
-{
-  TRACE_VISIT_OUT();
-
-  expr* selectExpr = pop_nodestack();
-  expr* objectExpr = pop_nodestack();
-
-  assert(selectExpr && objectExpr);
-
-  flwor_expr* flworExpr = wrap_expr_in_flwor(objectExpr, false);
-
-  for_clause* fc = reinterpret_cast<for_clause*>(flworExpr->get_clause(0));
-
-  expr* flworVarExpr = CREATE(wrapper)(theRootSctx, theUDF, loc, fc->get_var());
-
-  expr* accessorExpr;
-
-  std::vector<expr*> args(2);
-  args[0] = flworVarExpr;
-  args[1] = selectExpr;
-
-  accessorExpr = generate_fn_body(BUILTIN_FUNC(FN_JSONIQ_VALUE_2), args, loc);
-
-  assert(accessorExpr->get_expr_kind() == fo_expr_kind);
-
-  flworExpr->set_return_expr(accessorExpr);
-
-  pop_scope();
-
-  push_nodestack(flworExpr);
-}
-
-
-/*******************************************************************************
   JSONConstructor ::= ArrayConstructor |
                       SimpleObjectUnion |
                       AccumulatorObjectUnion |


Follow ups