OmniSciDB  04ee39c94c
Parser::ArrayLiteral Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::ArrayLiteral:
+ Collaboration diagram for Parser::ArrayLiteral:

Public Member Functions

 ArrayLiteral ()
 
 ArrayLiteral (std::list< Expr *> *v)
 
const std::list< std::unique_ptr< Expr > > & get_value_list () const
 
std::shared_ptr< Analyzer::Expranalyze (const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
 
std::string to_string () const override
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::list< std::unique_ptr< Expr > > value_list
 

Additional Inherited Members

- Public Types inherited from Parser::Expr
enum  TlistRefType { TLIST_NONE, TLIST_REF, TLIST_COPY }
 

Detailed Description

Definition at line 272 of file ParserNode.h.

Constructor & Destructor Documentation

◆ ArrayLiteral() [1/2]

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 274 of file ParserNode.h.

274 {}

◆ ArrayLiteral() [2/2]

Parser::ArrayLiteral::ArrayLiteral ( std::list< Expr *> *  v)
inline

Definition at line 275 of file ParserNode.h.

References CHECK, and v().

275  {
276  CHECK(v);
277  for (const auto e : *v) {
278  value_list.emplace_back(e);
279  }
280  delete v;
281  }
T v(const TargetValue &r)
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:290
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

Member Function Documentation

◆ analyze()

std::shared_ptr< Analyzer::Expr > Parser::ArrayLiteral::analyze ( const Catalog_Namespace::Catalog catalog,
Analyzer::Query query,
TlistRefType  allow_tlist_ref = TLIST_NONE 
) const
overridevirtual

Implements Parser::Literal.

Definition at line 183 of file ParserNode.cpp.

References anonymous_namespace{ExecuteTest.cpp}::c(), CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_subtype(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), Analyzer::Expr::get_type_info(), kARRAY, kNULLT, run-benchmark-import::result, and SQLTypeInfoCore< TYPE_FACET_PACK >::set_subtype().

186  {
187  SQLTypeInfo ti = SQLTypeInfo(kARRAY, true);
188  bool set_subtype = true;
189  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
190  for (auto& p : value_list) {
191  auto e = p->analyze(catalog, query, allow_tlist_ref);
192  CHECK(e);
193  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
194  if (c != nullptr && c->get_is_null()) {
195  value_exprs.push_back(c);
196  continue;
197  }
198  auto subtype = e->get_type_info().get_type();
199  if (subtype == kNULLT) {
200  // NULL element
201  } else if (set_subtype) {
202  ti.set_subtype(subtype);
203  set_subtype = false;
204  } else {
205  if (ti.get_subtype() != subtype) {
206  throw std::runtime_error("ARRAY element literals should be of the same type.");
207  }
208  }
209  value_exprs.push_back(e);
210  }
211  std::shared_ptr<Analyzer::Expr> result =
212  makeExpr<Analyzer::Constant>(ti, false, value_exprs);
213  return result;
214 }
void c(const std::string &query_string, const ExecutorDeviceType device_type)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:414
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:290
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:324
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ get_value_list()

const std::list<std::unique_ptr<Expr> >& Parser::ArrayLiteral::get_value_list ( ) const
inline

Definition at line 282 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query, and to_string().

282 { return value_list; }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:290
+ Here is the call graph for this function:

◆ to_string()

std::string Parser::ArrayLiteral::to_string ( ) const
overridevirtual

Implements Parser::Literal.

Definition at line 216 of file ParserNode.cpp.

216  {
217  std::string str = "{";
218  bool notfirst = false;
219  for (auto& p : value_list) {
220  if (notfirst) {
221  str += ", ";
222  } else {
223  notfirst = true;
224  }
225  str += p->to_string();
226  }
227  str += "}";
228  return str;
229 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:290

Member Data Documentation

◆ value_list

std::list<std::unique_ptr<Expr> > Parser::ArrayLiteral::value_list
private

Definition at line 290 of file ParserNode.h.


The documentation for this class was generated from the following files: