OmniSciDB  a5dc49c757
 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 272 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 274 of file ParserNode.h.

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

Definition at line 275 of file ParserNode.h.

References CHECK, and value_list_.

275  {
276  CHECK(v);
277  for (const auto e : *v) {
278  value_list_.emplace_back(e);
279  }
280  delete v;
281  }
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:290
#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 247 of file ParserNode.cpp.

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

250  {
251  SQLTypeInfo ti = SQLTypeInfo(kARRAY, true);
252  bool set_subtype = true;
253  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
254  for (auto& p : value_list_) {
255  auto e = p->analyze(catalog, query, allow_tlist_ref);
256  CHECK(e);
257  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
258  if (c != nullptr && c->get_is_null()) {
259  value_exprs.push_back(c);
260  continue;
261  }
262  auto subtype = e->get_type_info().get_type();
263  if (subtype == kNULLT) {
264  // NULL element
265  } else if (set_subtype) {
266  ti.set_subtype(subtype);
267  set_subtype = false;
268  }
269  value_exprs.push_back(e);
270  }
271  std::shared_ptr<Analyzer::Expr> result =
272  makeExpr<Analyzer::Constant>(ti, false, value_exprs);
273  return result;
274 }
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:471
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:290
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 282 of file ParserNode.h.

References value_list_.

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

Implements Parser::Literal.

Definition at line 276 of file ParserNode.cpp.

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

Member Data Documentation

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

Definition at line 290 of file ParserNode.h.

Referenced by ArrayLiteral(), and get_value_list().


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