You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
806 B
37 lines
806 B
/* |
|
* Copyright (C) 2023 Riyyi |
|
* |
|
* SPDX-License-Identifier: MIT |
|
*/ |
|
|
|
#pragma once |
|
|
|
#include <list> |
|
#include <string> |
|
#include <unordered_map> |
|
|
|
#include "forward.h" |
|
|
|
namespace blaze { |
|
|
|
class Environment { |
|
public: |
|
virtual ~Environment() = default; |
|
|
|
// Factory functions instead of constructors because it can fail in the bindings/arguments case |
|
static EnvironmentPtr create(); |
|
static EnvironmentPtr create(EnvironmentPtr outer); |
|
static EnvironmentPtr create(const ValuePtr lambda, std::list<ValuePtr> arguments); |
|
|
|
bool exists(const std::string& symbol); |
|
ValuePtr set(const std::string& symbol, ValuePtr value); |
|
ValuePtr get(const std::string& symbol); |
|
|
|
protected: |
|
Environment() {} |
|
|
|
EnvironmentPtr m_outer { nullptr }; |
|
std::unordered_map<std::string, ValuePtr> m_values; |
|
}; |
|
|
|
} // namespace blaze
|
|
|