#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 u32 length; bool operator==(const Variable& other) const; Variable(); // Makes Nil, length 0 Variable(Type t); // Reserved for Nil Variable(const Number& v); Variable(const String& v); Variable(const std::vector& v); Variable(const std::function)>& v, u32 l); }; class Environment { private: std::unordered_map env{}; public: void enter(const String& name, Variable p); void set(const String& name, Variable p); Variable& get(const String& name); bool exists(const String& name); }; extern Environment ENVIRONMENT; Variable Eval(const Parse::Object& obj); Variable Apply(const Parse::Command& c); void EvalScene(const Parse::Scene & s); struct Markup { u32 begin, end; std::vector>> efs; } UnpackMarkupVariable(const Variable& m); }