OmniSciDB  f632821e96
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 267 of file ParserNode.h.

Constructor & Destructor Documentation

◆ ArrayLiteral() [1/2]

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 269 of file ParserNode.h.

269 {}

◆ ArrayLiteral() [2/2]

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

Definition at line 270 of file ParserNode.h.

References CHECK.

270  {
271  CHECK(v);
272  for (const auto e : *v) {
273  value_list.emplace_back(e);
274  }
275  delete v;
276  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:285
#define CHECK(condition)
Definition: Logger.h:197

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

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

199  {
200  SQLTypeInfo ti = SQLTypeInfo(kARRAY, true);
201  bool set_subtype = true;
202  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
203  for (auto& p : value_list) {
204  auto e = p->analyze(catalog, query, allow_tlist_ref);
205  CHECK(e);
206  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
207  if (c != nullptr && c->get_is_null()) {
208  value_exprs.push_back(c);
209  continue;
210  }
211  auto subtype = e->get_type_info().get_type();
212  if (subtype == kNULLT) {
213  // NULL element
214  } else if (set_subtype) {
215  ti.set_subtype(subtype);
216  set_subtype = false;
217  } else {
218  if (ti.get_subtype() != subtype) {
219  throw std::runtime_error("ARRAY element literals should be of the same type.");
220  }
221  }
222  value_exprs.push_back(e);
223  }
224  std::shared_ptr<Analyzer::Expr> result =
225  makeExpr<Analyzer::Constant>(ti, false, value_exprs);
226  return result;
227 }
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:350
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:285
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:260
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
#define CHECK(condition)
Definition: Logger.h:197
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:259
+ 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 277 of file ParserNode.h.

References to_string().

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

◆ to_string()

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

Implements Parser::Literal.

Definition at line 229 of file ParserNode.cpp.

229  {
230  std::string str = "{";
231  bool notfirst = false;
232  for (auto& p : value_list) {
233  if (notfirst) {
234  str += ", ";
235  } else {
236  notfirst = true;
237  }
238  str += p->to_string();
239  }
240  str += "}";
241  return str;
242 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:285

Member Data Documentation

◆ value_list

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

Definition at line 285 of file ParserNode.h.


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