OmniSciDB  1dac507f6e
 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 283 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::ArrayLiteral::ArrayLiteral ( )
inline

Definition at line 285 of file ParserNode.h.

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

Definition at line 286 of file ParserNode.h.

References CHECK(), and value_list.

286  {
287  CHECK(v);
288  for (const auto e : *v) {
289  value_list.emplace_back(e);
290  }
291  delete v;
292  }
CHECK(cgen_state)
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:301

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

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

190  {
191  SQLTypeInfo ti = SQLTypeInfo(kARRAY, true);
192  bool set_subtype = true;
193  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
194  for (auto& p : value_list) {
195  auto e = p->analyze(catalog, query, allow_tlist_ref);
196  CHECK(e);
197  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
198  if (c != nullptr && c->get_is_null()) {
199  value_exprs.push_back(c);
200  continue;
201  }
202  auto subtype = e->get_type_info().get_type();
203  if (subtype == kNULLT) {
204  // NULL element
205  } else if (set_subtype) {
206  ti.set_subtype(subtype);
207  set_subtype = false;
208  } else {
209  if (ti.get_subtype() != subtype) {
210  throw std::runtime_error("ARRAY element literals should be of the same type.");
211  }
212  }
213  value_exprs.push_back(e);
214  }
215  std::shared_ptr<Analyzer::Expr> result =
216  makeExpr<Analyzer::Constant>(ti, false, value_exprs);
217  return result;
218 }
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:417
CHECK(cgen_state)
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:301
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:326
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:327

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

References value_list.

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

Implements Parser::Literal.

Definition at line 220 of file ParserNode.cpp.

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

Member Data Documentation

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

Definition at line 301 of file ParserNode.h.

Referenced by ArrayLiteral(), and get_value_list().


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