Skip to content

Commit eedb347

Browse files
committed
chore: cleaning up dead code and old todos
1 parent 805f6a8 commit eedb347

File tree

12 files changed

+31
-45
lines changed

12 files changed

+31
-45
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ jobs:
176176
compiler_version: 16
177177
sanitizers: On
178178
coverage: On
179-
with_deps: false
179+
with_deps: true
180180

181181
- name: Run tests
182182
run: |

include/Ark/Compiler/BytecodeReader.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* @file BytecodeReader.hpp
33
* @author Alexandre Plateau (lexplt.dev@gmail.com)
44
* @brief A bytecode disassembler for ArkScript
5-
* @version 0.5
5+
* @version 1.0
66
* @date 2020-10-27
77
*
8-
* @copyright Copyright (c) 2020-2024
8+
* @copyright Copyright (c) 2020-2025
99
*
1010
*/
1111

@@ -96,13 +96,6 @@ namespace Ark
9696
*/
9797
[[nodiscard]] bool checkMagic() const;
9898

99-
/**
100-
* @brief Return the bytecode object constructed
101-
*
102-
* @return const bytecode_t&
103-
*/
104-
[[nodiscard]] const bytecode_t& bytecode() noexcept;
105-
10699
/**
107100
*
108101
* @return Version compiler version used to create the given bytecode file

include/Ark/Files.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ namespace Ark::Utils
7777
ifs.close();
7878

7979
auto bytecode = std::vector<uint8_t>(static_cast<std::size_t>(pos));
80-
// TODO would it be faster to memcpy?
8180
for (std::size_t i = 0; i < static_cast<std::size_t>(pos); ++i)
8281
bytecode[i] = static_cast<uint8_t>(temp[i]);
8382
return bytecode;

src/arkreactor/Builtins/List.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ namespace Ark::internal::Builtins::List
5151
{ { types::Contract { { types::Typedef("list", ValueType::List), types::Typedef("value", ValueType::Any) } } } },
5252
n);
5353

54-
std::vector<Value>& l = n[0].list();
55-
for (auto it = l.begin(), it_end = l.end(); it != it_end; ++it)
56-
{
57-
if (*it == n[1]) // FIXME cast
58-
return Value(static_cast<int>(std::distance<Value::Iterator>(l.begin(), it)));
59-
}
60-
54+
if (const auto it = std::ranges::find(n[0].list(), n[1]); it != n[0].list().end())
55+
return Value(static_cast<int>(std::distance<Value::Iterator>(n[0].list().begin(), it)));
6156
return Value(-1);
6257
}
6358

src/arkreactor/Builtins/Mathematics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ namespace Ark::internal::Builtins::Mathematics
4343
{
4444
if (!types::check(n, ValueType::Number))
4545
types::generateError(
46-
"math:log",
46+
"math:ln",
4747
{ { types::Contract { { types::Typedef("value", ValueType::Number) } } } },
4848
n);
4949

5050
if (n[0].number() <= 0.0)
51-
throw std::runtime_error(fmt::format("math:log: value {} must be greater than 0", n[0].number()));
51+
throw std::runtime_error(fmt::format("math:ln: value {} must be greater than 0", n[0].number()));
5252

5353
return Value(std::log(n[0].number()));
5454
}
@@ -128,7 +128,7 @@ namespace Ark::internal::Builtins::Mathematics
128128
{
129129
if (!types::check(n, ValueType::Any))
130130
types::generateError(
131-
"math:exp",
131+
"math:NaN?",
132132
{ { types::Contract { { types::Typedef("value", ValueType::Any) } } } },
133133
n);
134134

src/arkreactor/Compiler/AST/Parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ namespace Ark::internal
353353
Node symbols(NodeType::List);
354354
setNodePosAndFilename(symbols);
355355
// then parse the symbols to import, if any
356-
if (space()) // FIXME: potential regression introduced here
356+
if (space())
357357
{
358358
comment.clear();
359359
newlineOrComment(&comment);

src/arkreactor/Compiler/BytecodeReader.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ namespace Ark
4747
m_bytecode[3] == bytecode::Magic[3];
4848
}
4949

50-
const bytecode_t& BytecodeReader::bytecode() noexcept
51-
{
52-
return m_bytecode;
53-
}
54-
5550
Version BytecodeReader::version() const
5651
{
5752
if (!checkMagic() || m_bytecode.size() < bytecode::Magic.size() + bytecode::Version.size())

src/arkreactor/Compiler/Macros/Processor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace Ark::internal
7979
{
8080
if (node.nodeType() == NodeType::List && node.constList().size() == 3 && node.constList()[0].nodeType() == NodeType::Keyword)
8181
{
82-
Keyword kw = node.constList()[0].keyword();
82+
const Keyword kw = node.constList()[0].keyword();
8383
// checking for function definition, which can occur only inside an assignment node
8484
if (kw != Keyword::Let && kw != Keyword::Mut && kw != Keyword::Set)
8585
return;
@@ -99,7 +99,7 @@ namespace Ark::internal
9999
}
100100
}
101101

102-
void MacroProcessor::processNode(Node& node, unsigned depth, bool is_processing_namespace)
102+
void MacroProcessor::processNode(Node& node, unsigned depth, const bool is_processing_namespace)
103103
{
104104
if (depth >= MaxMacroProcessingDepth)
105105
throwMacroProcessingError(
@@ -666,7 +666,7 @@ namespace Ark::internal
666666
node.constList()[0].keyword() == Keyword::Begin;
667667
}
668668

669-
void MacroProcessor::removeBegin(Node& node, std::size_t i)
669+
void MacroProcessor::removeBegin(Node& node, const std::size_t i)
670670
{
671671
if (node.isListLike() && node.list()[i].nodeType() == NodeType::List && !node.list()[i].list().empty())
672672
{

src/arkreactor/Exceptions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ namespace Ark::Diagnostics
194194
if (e.filename != ARK_NO_NAME_FILE)
195195
file_content = Utils::readFile(e.filename);
196196

197-
// TODO enhance the error messages
198197
helper(
199198
os,
200199
e.what(),

src/arkreactor/VM/VM.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,21 +1637,13 @@ namespace Ark
16371637
fmt::styled(m_state.m_symbols[old_scope.atPos(i).first], fmt::fg(fmt::color::cyan)),
16381638
old_scope.atPos(i).second.toString(*this));
16391639
}
1640-
1641-
while (context.fc != 1)
1642-
{
1643-
Value* tmp = pop(context);
1644-
if (tmp->valueType() == ValueType::InstPtr)
1645-
--context.fc;
1646-
*tmp = m_no_value;
1647-
}
1648-
// pop the PP as well
1649-
pop(context);
16501640
}
16511641

1652-
std::cerr << "At IP: " << (saved_ip / 4) // dividing by 4 because the instructions are actually on 4 bytes
1653-
<< ", PP: " << saved_pp
1654-
<< ", SP: " << saved_sp
1655-
<< "\n";
1642+
fmt::println(
1643+
"At IP: {}, PP: {}, SP: {}",
1644+
// dividing by 4 because the instructions are actually on 4 bytes
1645+
fmt::styled(saved_ip / 4, fmt::fg(fmt::color::cyan)),
1646+
fmt::styled(saved_pp, fmt::fg(fmt::color::green)),
1647+
fmt::styled(saved_sp, fmt::fg(fmt::color::yellow)));
16561648
}
16571649
}

0 commit comments

Comments
 (0)