13#include <alib/optional>
32 std::shared_ptr < abstraction::Value > m_result;
36 std::shared_ptr < abstraction::Value > getVariableInt (
const std::string & name )
const;
38 void setVariableInt ( std::string name, std::shared_ptr < abstraction::Value > value ) {
39 m_variables [ std::move ( name ) ] = std::move ( value );
48 std::string
getBinding (
const std::string & name )
const;
51 std::set < std::string >
res;
53 for (
const std::pair < const std::string, std::string > & kv : m_bindings ) {
54 res.insert ( kv.first );
60 void setBinding ( std::string name, std::string value ) {
61 m_bindings [ std::move ( name ) ] = std::move ( value );
65 return m_bindings.
erase ( name ) != 0;
68 std::shared_ptr < abstraction::Value >
getVariable (
const std::string & name )
const {
69 return getVariableInt ( name );
74 return abstraction::retrieveValue < const T & > ( getVariableInt ( name ) );
78 std::set < std::string >
res;
80 for (
const std::pair <
const std::string, std::shared_ptr < abstraction::Value > > & kv : m_variables ) {
81 res.insert ( kv.first );
87 void setVariable ( std::string name, std::shared_ptr < abstraction::Value > value ) {
88 setVariableInt ( std::move ( name ), std::move ( value ) );
93 auto variable = std::make_shared < abstraction::ValueHolder < T > > ( std::move ( value ), false );
94 setVariableInt ( std::move ( name ), variable );
98 return m_variables.
erase ( name ) != 0u;
101 void setResult ( std::shared_ptr < abstraction::Value > value ) {
102 m_result = std::move ( value );
105 std::shared_ptr < abstraction::Value >
getResult ( )
const {
Definition: TemporariesHolder.h:13
Definition: CharSequence.h:16
Definition: Environment.h:29
std::set< std::string > getVariableNames() const
Definition: Environment.h:77
void setVariable(std::string name, std::shared_ptr< abstraction::Value > value)
Definition: Environment.h:87
bool clearVariable(const std::string &name)
Definition: Environment.h:97
void setVariable(std::string name, T value)
Definition: Environment.h:92
std::shared_ptr< abstraction::Value > getResult() const
Definition: Environment.h:105
Environment(ext::optional_ref< Environment > upper)
Definition: Environment.h:45
std::set< std::string > getBindingNames() const
Definition: Environment.h:50
std::string getBinding(const std::string &name) const
Definition: Environment.cpp:33
std::shared_ptr< abstraction::Value > getVariable(const std::string &name) const
Definition: Environment.h:68
void setBinding(std::string name, std::string value)
Definition: Environment.h:60
cli::CommandResult execute_line(cli::CharSequence charSequence)
Definition: Environment.cpp:58
void setResult(std::shared_ptr< abstraction::Value > value)
Definition: Environment.h:101
const T & getVariable(const std::string &name) const
Definition: Environment.h:73
bool clearBinding(const std::string &name)
Definition: Environment.h:64
Environment & getGlobalScope()
Definition: Environment.cpp:74
cli::CommandResult execute(const std::shared_ptr< cli::LineInterface > &lineInterface)
Definition: Environment.cpp:49
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
size_t erase(const K &key)
Erase by key of arbitrary type.
Definition: map.hpp:340
Definition: optional_ref.hpp:33
return res
Definition: MinimizeByPartitioning.h:145
CommandResult
Definition: CommandResult.h:10