#pragma once #include #include #include #include "Parser.h" #include "Common.h" namespace NVL::Environment { enum class Type { Procedure, Number, String, Array, Nil }; struct Variable { Type type; std::variant, std::function)>> value; // Most things will have length 1 (including string); this is mostly for function arity and array length int length; bool operator==(const Variable& other) const; Variable(); Variable(Type t); Variable(const Number& v); Variable(const std::string& v); Variable(const std::vector& v); Variable(const std::function)>& v, int l); }; class Environment { private: std::unordered_map env{}; public: void enter(const std::string& name, Variable p); void set(const std::string& name, Variable p); Variable& get(const std::string& name); bool exists(const std::string& name); }; extern Environment ENVIRONMENT; Variable Eval(const Parse::Object& obj); Variable Apply(const Parse::Command& c); void EvalScene(const Parse::Scene & s); }