Thorin 1.9.0
The Higher ORder INtermediate representation
Loading...
Searching...
No Matches
scopes.h
Go to the documentation of this file.
1#pragma once
2
3#include <deque>
4
5#include "thorin/util/dbg.h"
6
7namespace thorin {
8
9class Def;
10class Ptrn;
11
12class Scopes {
13public:
14 using Scope = fe::SymMap<std::pair<Loc, const Def*>>;
15
16 Scopes() { push(); /* root scope */ }
17
18 void push() { scopes_.emplace_back(); }
19 void pop();
20 Scope* curr() { return &scopes_.back(); }
21 const Def* query(Dbg) const;
22 const Def* find(Dbg) const; ///< Same as Scopes::query but potentially raises an error.
23 void bind(Scope*, Dbg, const Def*, bool rebind = false);
24 void bind(Dbg dbg, const Def* def, bool rebind = false) { bind(&scopes_.back(), dbg, def, rebind); }
25 void swap(Scope& other) { std::swap(scopes_.back(), other); }
26
27private:
28 std::deque<Scope> scopes_;
29};
30
31} // namespace thorin
Base class for all Defs.
Definition def.h:222
A Scope represents a region of Defs that are live from the view of an entry's Var.
Definition scope.h:22
const Def * query(Dbg) const
Definition scopes.cpp:12
void pop()
Definition scopes.cpp:7
void bind(Scope *, Dbg, const Def *, bool rebind=false)
Definition scopes.cpp:27
void swap(Scope &other)
Definition scopes.h:25
void push()
Definition scopes.h:18
fe::SymMap< std::pair< Loc, const Def * > > Scope
Definition scopes.h:14
Scope * curr()
Definition scopes.h:20
const Def * find(Dbg) const
Same as Scopes::query but potentially raises an error.
Definition scopes.cpp:21
void bind(Dbg dbg, const Def *def, bool rebind=false)
Definition scopes.h:24
Definition cfg.h:11