-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathScope.h
39 lines (28 loc) · 926 Bytes
/
Scope.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef __SCOPE_H__
#define __SCOPE_H__
#include <vector>
#include <string>
#include <map>
#include "Type.h"
#include "Variable.h"
class Scope
{
Scope* m_root;
Scope* m_parent;
std::vector< Ref<Variable> > m_vars;
std::map< std::string, Ref<Variable> > m_currentScopeVars;
public:
Scope(Scope* parent, bool newContext);
Scope* Duplicate(DuplicateContext& dup);
Scope* GetParent() const { return m_parent; }
Scope* GetRoot() const { return m_root; }
const std::vector< Ref<Variable> >& GetVariables() { return m_vars; }
bool IsVariableDefined(const std::string& name) const;
bool IsVariableDefinedInCurrentScope(const std::string& name) const;
Variable* GetVariable(const std::string& name) const;
Variable* DefineVariable(VariableClass cls, Type* type, const std::string& name);
void DefineVariable(Variable* var);
void Serialize(OutputBlock* output);
bool Deserialize(InputBlock* input);
};
#endif