Spicy
visitors.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <iostream>
6 #include <memory>
7 #include <set>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 #include <hilti/ast/ctor.h>
13 #include <hilti/ast/expression.h>
14 #include <hilti/ast/function.h>
15 #include <hilti/ast/node.h>
16 #include <hilti/ast/operator.h>
17 #include <hilti/base/logger.h>
18 #include <hilti/compiler/context.h>
19 
20 namespace hilti {
21 
22 class Unit;
23 
24 namespace printer {
25 class Stream;
26 } // namespace printer
27 
28 namespace detail {
29 
31 std::set<context::CacheIndex> importModules(const Node& root, Unit* unit);
32 
37 void printAST(const Node& root, std::ostream& out, bool compact = false);
38 
43 void printAST(const Node& root, printer::Stream& stream); // NOLINT
44 
46 std::string renderOperatorPrototype(const expression::UnresolvedOperator& o);
47 
49 std::string renderOperatorPrototype(const expression::ResolvedOperator& o);
50 
52 std::string renderOperatorInstance(const expression::UnresolvedOperator& o);
53 
55 std::string renderOperatorInstance(const expression::ResolvedOperator& o);
56 
58 void renderNode(const Node& n, std::ostream& out, bool include_scopes = false);
59 void renderNode(const Node& n, logging::DebugStream stream, bool include_scopes = false);
60 
61 namespace ast {
63 void buildScopes(const std::shared_ptr<hilti::Context>& ctx, Node* root, Unit* unit);
65 bool normalize(Node* root, Unit* unit);
67 bool coerce(Node* root, Unit* unit);
69 bool resolve(const std::shared_ptr<hilti::Context>& ctx, Node* root, Unit* unit);
71 void validate_pre(Node* root);
73 void validate_post(Node* root);
74 } // namespace ast
75 } // namespace detail
76 } // namespace hilti