Spicy
expression.h
1 // Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <string>
6 #include <utility>
7 
8 #include <hilti/ast/forward.h>
9 #include <hilti/ast/node.h>
10 #include <hilti/ast/type.h>
11 
12 namespace hilti {
13 
15 class Expression : public Node {
16 public:
18  auto isConstant() const { return type()->isConstant(); }
19 
21  auto isResolved(node::CycleDetector* cd = nullptr) const { return type()->type()->isResolved(cd); }
22 
24  virtual QualifiedType* type() const = 0;
25 
26 protected:
27  Expression(ASTContext* ctx, node::Tags node_tags, Nodes children, Meta meta)
28  : Node::Node(ctx, node_tags, std::move(children), std::move(meta)) {}
29 
30  std::string _dump() const override;
31 
32  HILTI_NODE_0(Expression, override);
33 };
34 
35 namespace expression {
36 
38 inline bool areResolved(const node::Range<Expression>& exprs) {
39  for ( const auto& e : exprs ) {
40  if ( ! e->isResolved() )
41  return false;
42  }
43 
44  return true;
45 }
46 
47 } // namespace expression
48 
49 } // namespace hilti
Definition: ast-context.h:121
Definition: expression.h:15
auto isResolved(node::CycleDetector *cd=nullptr) const
Definition: expression.h:21
std::string _dump() const override
Definition: expression.cc:13
virtual QualifiedType * type() const =0
auto isConstant() const
Definition: expression.h:18
Definition: meta.h:30
Definition: node.h:240
const auto & children() const
Definition: node.h:364
const auto & meta() const
Definition: node.h:306
Definition: forward.h:758
Definition: type.h:362
UnqualifiedType * type(bool follow=true) const
Definition: type.h:369
bool isConstant() const
Definition: type.h:372
virtual bool isResolved(node::CycleDetector *cd=nullptr) const
Definition: type.h:296
Definition: node.h:1122
Definition: node-range.h:92