Skip to content

Commit

Permalink
refactor: removing more dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFola committed Sep 28, 2024
1 parent badb8c6 commit 388e0ac
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 99 deletions.
18 changes: 1 addition & 17 deletions include/Ark/Compiler/NameResolutionPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file NameResolutionPass.hpp
* @author Alexandre Plateau ([email protected])
* @brief
* @version 0.1
* @version 1.0
* @date 2024-07-22
*
* @copyright Copyright (c) 2024
Expand Down Expand Up @@ -83,22 +83,6 @@ namespace Ark::internal
*/
[[nodiscard]] bool isRegistered(const std::string& name) const;

/**
* @brief Returns false if we have only one scope (global), checks the scopes recursively for 'name'
*
* @param name
* @return
*/
[[nodiscard]] bool isLocalVar(const std::string& name) const;

/**
* @brief 'name' has to be defined only in the first scope to be considered global
*
* @param name
* @return
*/
[[nodiscard]] bool isGlobalVar(const std::string& name) const;

/**
* @brief Checks if 'name' is in the current scope
*
Expand Down
5 changes: 0 additions & 5 deletions include/Ark/Compiler/Pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ namespace Ark::internal
class Pass
{
public:
/**
* @brief Construct a new Pass object
*/
Pass();

/**
* @brief Construct a new Pass object
*
Expand Down
7 changes: 1 addition & 6 deletions include/Ark/Compiler/ValTableElem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file ValTableElem.hpp
* @author Alexandre Plateau ([email protected])
* @brief The basic value type handled by the compiler
* @version 0.2
* @version 1.0
* @date 2020-10-27
*
* @copyright Copyright (c) 2020-2024
Expand Down Expand Up @@ -39,11 +39,6 @@ namespace Ark::internal
std::variant<double, std::string, std::size_t> value;
ValTableElemType type;

// Numbers
explicit ValTableElem(double num) noexcept;
explicit ValTableElem(long num) noexcept;
// Strings
explicit ValTableElem(const std::string& str) noexcept;
// automatic handling (Number/String/Function)
explicit ValTableElem(const Node& node) noexcept;
// Functions
Expand Down
4 changes: 1 addition & 3 deletions include/Ark/VM/Value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Value.hpp
* @author Default value type handled by the virtual machine
* @brief
* @version 1.2
* @version 2.0
* @date 2024-04-20
*
* @copyright Copyright (c) 2020-2024
Expand Down Expand Up @@ -102,10 +102,8 @@ namespace Ark
{}

explicit Value(int value) noexcept;
explicit Value(float value) noexcept;
explicit Value(double value) noexcept;
explicit Value(const std::string& value) noexcept;
explicit Value(const char* value) noexcept;
explicit Value(internal::PageAddr_t value) noexcept;
explicit Value(ProcType value) noexcept;
explicit Value(std::vector<Value>&& value) noexcept;
Expand Down
16 changes: 1 addition & 15 deletions include/Ark/VM/Value/Closure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file Closure.hpp
* @author Alexandre Plateau ([email protected])
* @brief Subtype of the value type, handling closures
* @version 1.1
* @version 2.0
* @date 2024-04-21
*
* @copyright Copyright (c) 2020-2024
Expand Down Expand Up @@ -36,20 +36,6 @@ namespace Ark::internal
class Closure
{
public:
/**
* @brief Construct a new Closure object
*
*/
Closure() noexcept;

/**
* @brief Construct a new Closure object
*
* @param scope the scope of the function turned into a closure
* @param pa the current page address of the function turned into a closure
*/
Closure(Scope&& scope, PageAddr_t pa) noexcept;

/**
* @brief Construct a new Closure object
*
Expand Down
16 changes: 0 additions & 16 deletions src/arkreactor/Compiler/NameResolutionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ namespace Ark::internal
});
}

bool ScopeResolver::isLocalVar(const std::string& name) const
{
// only one scope, this is the global one
if (m_scopes.size() == 1)
return false;
return m_scopes.back().has(name);
}

bool ScopeResolver::isGlobalVar(const std::string& name) const
{
if (m_scopes.size() == 1)
return m_scopes[0].has(name);
// for a variable to be considered global, it has to not be shadowed in the current local scope
return !m_scopes.back().has(name) && m_scopes[0].has(name);
}

bool ScopeResolver::isInScope(const std::string& name) const
{
return m_scopes.back().has(name);
Expand Down
4 changes: 0 additions & 4 deletions src/arkreactor/Compiler/Pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

namespace Ark::internal
{
Pass::Pass() :
m_logger("", 0)
{}

Pass::Pass(std::string name, const unsigned debug_level) :
m_logger(std::move(name), debug_level)
{}
Expand Down
15 changes: 0 additions & 15 deletions src/arkreactor/Compiler/ValTableElem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@

namespace Ark::internal
{
ValTableElem::ValTableElem(double num) noexcept :
value(num),
type(ValTableElemType::Number)
{}

ValTableElem::ValTableElem(const long num) noexcept :
value(static_cast<double>(num)),
type(ValTableElemType::Number)
{}

ValTableElem::ValTableElem(const std::string& str) noexcept :
value(str),
type(ValTableElemType::String)
{}

ValTableElem::ValTableElem(const Node& node) noexcept
{
if (node.nodeType() == NodeType::Number)
Expand Down
8 changes: 0 additions & 8 deletions src/arkreactor/VM/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ namespace Ark
m_type(ValueType::Number), m_value(static_cast<double>(value))
{}

Value::Value(const float value) noexcept :
m_type(ValueType::Number), m_value(static_cast<double>(value))
{}

Value::Value(double value) noexcept :
m_type(ValueType::Number), m_value(value)
{}
Expand All @@ -34,10 +30,6 @@ namespace Ark
m_type(ValueType::String), m_value(value)
{}

Value::Value(const char* value) noexcept :
m_type(ValueType::String), m_value(value)
{}

Value::Value(internal::PageAddr_t value) noexcept :
m_type(ValueType::PageAddr), m_value(value)
{}
Expand Down
10 changes: 0 additions & 10 deletions src/arkreactor/VM/Value/Closure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@

namespace Ark::internal
{
Closure::Closure() noexcept :
m_scope(nullptr),
m_page_addr(0)
{}

Closure::Closure(Scope&& scope, const PageAddr_t pa) noexcept :
m_scope(std::make_shared<Scope>(scope)),
m_page_addr(pa)
{}

Closure::Closure(const Scope& scope, const PageAddr_t pa) noexcept :
m_scope(std::make_shared<Scope>(scope)),
m_page_addr(pa)
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/resources/LangSuite/vm-tests.ark
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
(test:case "arithmetic operations" {
(test:eq (+ 1 2) 3)
(test:eq (+ 1.5 2.5) 4.0)
(test:eq (+ "a" "b") "ab")
(test:eq (- 1 2) -1)
(test:eq (- 1.5 2) -0.5)
(test:eq (/ 1 2) 0.5)
Expand Down

0 comments on commit 388e0ac

Please sign in to comment.