2019-10-01 11:05:21 -07:00
|
|
|
#pragma once
|
2019-10-01 14:34:38 -07:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-10-01 11:05:21 -07:00
|
|
|
|
2019-10-01 14:34:38 -07:00
|
|
|
struct env {
|
|
|
|
virtual ~env() = default;
|
2019-10-01 11:05:21 -07:00
|
|
|
|
2019-10-01 14:34:38 -07:00
|
|
|
virtual int get_offset(const std::string& name) const = 0;
|
2019-10-01 23:23:52 -07:00
|
|
|
virtual bool has_variable(const std::string& name) const = 0;
|
2019-10-01 14:34:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
using env_ptr = std::shared_ptr<env>;
|
|
|
|
|
|
|
|
struct env_var {
|
|
|
|
std::string name;
|
|
|
|
env_ptr parent;
|
|
|
|
|
|
|
|
env_var(std::string& n, env_ptr p)
|
|
|
|
: name(std::move(n)), parent(std::move(p)) {}
|
|
|
|
|
2019-10-01 23:23:52 -07:00
|
|
|
int get_offset(const std::string& name) const;
|
|
|
|
bool has_variable(const std::string& name) const;
|
2019-10-01 14:34:38 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct env_offset {
|
|
|
|
int offset;
|
|
|
|
env_ptr parent;
|
|
|
|
|
|
|
|
env_offset(int o, env_ptr p)
|
|
|
|
: offset(o), parent(std::move(p)) {}
|
2019-10-01 11:05:21 -07:00
|
|
|
|
2019-10-01 23:23:52 -07:00
|
|
|
int get_offset(const std::string& name) const;
|
|
|
|
bool has_variable(const std::string& name) const;
|
2019-10-01 11:05:21 -07:00
|
|
|
};
|