OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 271 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 273 of file ParserNode.h.

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

Definition at line 274 of file ParserNode.h.

References CHECK, and value_list_.

274  {
275  CHECK(v);
276  for (const auto e : *v) {
277  value_list_.emplace_back(e);
278  }
279  delete v;
280  }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:289
#define CHECK(condition)
Definition: Logger.h:291

Member Function Documentation

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 243 of file ParserNode.cpp.

References CHECK, SQLTypeInfo::get_type(), Analyzer::Expr::get_type_info(), kARRAY, kNULLT, run_benchmark_import::result, and SQLTypeInfo::set_subtype().

246  {
247  SQLTypeInfo ti = SQLTypeInfo(kARRAY, true);
248  bool set_subtype = true;
249  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
250  for (auto& p : value_list_) {
251  auto e = p->analyze(catalog, query, allow_tlist_ref);
252  CHECK(e);
253  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
254  if (c != nullptr && c->get_is_null()) {
255  value_exprs.push_back(c);
256  continue;
257  }
258  auto subtype = e->get_type_info().get_type();
259  if (subtype == kNULLT) {
260  // NULL element
261  } else if (set_subtype) {
262  ti.set_subtype(subtype);
263  set_subtype = false;
264  }
265  value_exprs.push_back(e);
266  }
267  std::shared_ptr<Analyzer::Expr> result =
268  makeExpr<Analyzer::Constant>(ti, false, value_exprs);
269  return result;
270 }
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:494
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:289
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

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

Definition at line 281 of file ParserNode.h.

References value_list_.

281 { return value_list_; }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:289
std::string Parser::ArrayLiteral::to_string ( ) const
overridevirtual

Implements Parser::Literal.

Definition at line 272 of file ParserNode.cpp.

272  {
273  std::string str = "{";
274  bool notfirst = false;
275  for (auto& p : value_list_) {
276  if (notfirst) {
277  str += ", ";
278  } else {
279  notfirst = true;
280  }
281  str += p->to_string();
282  }
283  str += "}";
284  return str;
285 }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:289

Member Data Documentation

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

Definition at line 289 of file ParserNode.h.

Referenced by ArrayLiteral(), and get_value_list().


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