|
|
@ -58,6 +58,7 @@ public: |
|
|
|
virtual bool isCallable() const { return false; } |
|
|
|
virtual bool isCallable() const { return false; } |
|
|
|
virtual bool isFunction() const { return false; } |
|
|
|
virtual bool isFunction() const { return false; } |
|
|
|
virtual bool isLambda() const { return false; } |
|
|
|
virtual bool isLambda() const { return false; } |
|
|
|
|
|
|
|
virtual bool isMacro() const { return false; } |
|
|
|
virtual bool isAtom() const { return false; } |
|
|
|
virtual bool isAtom() const { return false; } |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
@ -343,17 +344,16 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
class Lambda final : public Callable { |
|
|
|
class Lambda : public Callable { |
|
|
|
public: |
|
|
|
public: |
|
|
|
Lambda(const std::vector<std::string>& bindings, ValuePtr body, EnvironmentPtr env); |
|
|
|
Lambda(const std::vector<std::string>& bindings, ValuePtr body, EnvironmentPtr env); |
|
|
|
Lambda(std::shared_ptr<Lambda> that, bool is_macro); |
|
|
|
Lambda(const Lambda& that); |
|
|
|
Lambda(const Lambda& that, ValuePtr meta); |
|
|
|
Lambda(const Lambda& that, ValuePtr meta); |
|
|
|
virtual ~Lambda() = default; |
|
|
|
virtual ~Lambda() = default; |
|
|
|
|
|
|
|
|
|
|
|
const std::vector<std::string>& bindings() const { return m_bindings; } |
|
|
|
const std::vector<std::string>& bindings() const { return m_bindings; } |
|
|
|
ValuePtr body() const { return m_body; } |
|
|
|
ValuePtr body() const { return m_body; } |
|
|
|
EnvironmentPtr env() const { return m_env; } |
|
|
|
EnvironmentPtr env() const { return m_env; } |
|
|
|
bool isMacro() const { return m_is_macro; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WITH_META(Lambda); |
|
|
|
WITH_META(Lambda); |
|
|
|
|
|
|
|
|
|
|
@ -363,7 +363,19 @@ private: |
|
|
|
const std::vector<std::string> m_bindings; |
|
|
|
const std::vector<std::string> m_bindings; |
|
|
|
const ValuePtr m_body; |
|
|
|
const ValuePtr m_body; |
|
|
|
const EnvironmentPtr m_env; |
|
|
|
const EnvironmentPtr m_env; |
|
|
|
const bool m_is_macro { false }; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Macro final : public Lambda { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
Macro(const Lambda& that); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WITH_NO_META(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
virtual bool isLambda() const override { return false; } |
|
|
|
|
|
|
|
virtual bool isMacro() const override { return true; } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
@ -424,6 +436,9 @@ inline bool Value::fastIs<Function>() const { return isFunction(); } |
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool Value::fastIs<Lambda>() const { return isLambda(); } |
|
|
|
inline bool Value::fastIs<Lambda>() const { return isLambda(); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
inline bool Value::fastIs<Macro>() const { return isMacro(); } |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool Value::fastIs<Atom>() const { return isAtom(); } |
|
|
|
inline bool Value::fastIs<Atom>() const { return isAtom(); } |
|
|
|
// clang-format on
|
|
|
|
// clang-format on
|
|
|
|