lang_2023/include/contexts.hpp

41 lines
1,010 B
C++
Raw Normal View History

2023-03-26 15:20:53 +03:00
#pragma once
#include <string>
#include <vector>
#include <unordered_map>
// for clangd
#include "symbols_info.hpp"
namespace info {
class ContextManager {
public:
void CallFunction(const std::vector<VariableInfo>&);
void EnterContext();
void ExitContext();
void DefineVariable(const VariableInfo& variable);
void ChangeVariableValue(const std::string& name, const Value& new_value);
const Value& GetVariableValue(const std::string& name);
private:
class Context {
public:
Context(bool hide_previous = false) : hide_previous_(hide_previous) {}
void DefineVariable(const VariableInfo& variable);
void ChangeVaraibleValue(const std::string& name, const Value& neew_value);
const Value& GetVariableValue(const std::string& name);
bool IsFirst() { return hide_previous_; }
private:
bool hide_previous_;
std::unordered_map<std::string, VariableInfo> variables_;
};
2023-04-17 11:14:33 +03:00
// Context global_context_; // ??
2023-03-26 15:20:53 +03:00
std::vector<Context> contexts_;
};
} // namespace info