OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 267 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 269 of file ParserNode.h.

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

Definition at line 270 of file ParserNode.h.

References CHECK(), and value_list.

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

+ Here is the call graph for this function:

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 198 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().

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

+ 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 277 of file ParserNode.h.

References value_list.

277 { return value_list; }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:285
std::string Parser::ArrayLiteral::to_string ( ) const
overridevirtual

Implements Parser::Literal.

Definition at line 231 of file ParserNode.cpp.

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

Member Data Documentation

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

Definition at line 285 of file ParserNode.h.

Referenced by ArrayLiteral(), and get_value_list().


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