diff --git a/asteria/compiler/expression_unit.cpp b/asteria/compiler/expression_unit.cpp index 74815dd5b..8443956b8 100644 --- a/asteria/compiler/expression_unit.cpp +++ b/asteria/compiler/expression_unit.cpp @@ -56,7 +56,7 @@ generate_code(cow_vector& code, const Compiler_Options& opts, // If a named reference is found, it will not be replaced or hidden by a // later-declared one. const Reference* qref; - Abstract_Context* qctx = &ctx; + const Abstract_Context* qctx = &ctx; uint32_t depth = 0; for(;;) { diff --git a/asteria/runtime/abstract_context.hpp b/asteria/runtime/abstract_context.hpp index 365a6ff17..cd2ed8089 100644 --- a/asteria/runtime/abstract_context.hpp +++ b/asteria/runtime/abstract_context.hpp @@ -32,7 +32,7 @@ class Abstract_Context do_is_analytic() const noexcept = 0; virtual - Abstract_Context* + const Abstract_Context* do_get_parent_opt() const noexcept = 0; // This function is called when a name is not found in `m_named_refs`. @@ -57,7 +57,7 @@ class Abstract_Context is_analytic() const noexcept { return this->do_is_analytic(); } - Abstract_Context* + const Abstract_Context* get_parent_opt() const noexcept { return this->do_get_parent_opt(); } diff --git a/asteria/runtime/air_node.cpp b/asteria/runtime/air_node.cpp index 75f89a029..2ad1871fe 100644 --- a/asteria/runtime/air_node.cpp +++ b/asteria/runtime/air_node.cpp @@ -1009,7 +1009,7 @@ struct Traits_push_local_reference execute(Executive_Context& ctx, AVMC_Queue::Uparam up, phsh_stringR name) { // Get the context. - Executive_Context* qctx = &ctx; + const Executive_Context* qctx = &ctx; for(uint32_t k = 0; k != up.u32; ++k) qctx = qctx->get_parent_opt(); @@ -4888,7 +4888,7 @@ rebind_opt(Abstract_Context& ctx) const const auto& altr = this->m_stor.as(); // Get the context. - Abstract_Context* qctx = &ctx; + const Abstract_Context* qctx = &ctx; for(uint32_t k = 0; k != altr.depth; ++k) qctx = qctx->get_parent_opt(); diff --git a/asteria/runtime/analytic_context.hpp b/asteria/runtime/analytic_context.hpp index a48586f58..9235bbf70 100644 --- a/asteria/runtime/analytic_context.hpp +++ b/asteria/runtime/analytic_context.hpp @@ -13,7 +13,7 @@ class Analytic_Context public Abstract_Context { private: - Abstract_Context* m_parent_opt; + const Abstract_Context* m_parent_opt; public: // A plain context must have a parent context. @@ -37,7 +37,7 @@ class Analytic_Context do_is_analytic() const noexcept final { return true; } - Abstract_Context* + const Abstract_Context* do_get_parent_opt() const noexcept override { return this->m_parent_opt; } @@ -48,7 +48,7 @@ class Analytic_Context public: ASTERIA_NONCOPYABLE_DESTRUCTOR(Analytic_Context); - Abstract_Context* + const Abstract_Context* get_parent_opt() const noexcept { return this->m_parent_opt; } }; diff --git a/asteria/runtime/executive_context.hpp b/asteria/runtime/executive_context.hpp index f2a4c4a55..151705085 100644 --- a/asteria/runtime/executive_context.hpp +++ b/asteria/runtime/executive_context.hpp @@ -14,7 +14,7 @@ class Executive_Context public Abstract_Context { private: - Executive_Context* m_parent_opt; + const Executive_Context* m_parent_opt; // Store some references to the enclosing function, // so they are not passed here and there upon each native call. @@ -64,7 +64,7 @@ class Executive_Context do_is_analytic() const noexcept final { return false; } - Abstract_Context* + const Abstract_Context* do_get_parent_opt() const noexcept override { return this->m_parent_opt; } @@ -80,7 +80,7 @@ class Executive_Context public: ASTERIA_NONCOPYABLE_DESTRUCTOR(Executive_Context); - Executive_Context* + const Executive_Context* get_parent_opt() const noexcept { return this->m_parent_opt; } diff --git a/asteria/runtime/global_context.hpp b/asteria/runtime/global_context.hpp index 8c2678b7c..942cb273d 100644 --- a/asteria/runtime/global_context.hpp +++ b/asteria/runtime/global_context.hpp @@ -32,7 +32,7 @@ class Global_Context do_is_analytic() const noexcept final { return false; } - Abstract_Context* + const Abstract_Context* do_get_parent_opt() const noexcept final { return nullptr; }