Browse Source

Main: Fix *ARGV* with 0 arguments

master
Riyyi 7 months ago
parent
commit
733d84c124
  1. 8
      src/step6_file.cpp
  2. 8
      src/step7_quote.cpp
  3. 8
      src/step8_macros.cpp
  4. 8
      src/step9_try.cpp
  5. 23
      src/stepA_mal.cpp

8
src/step6_file.cpp

@ -94,11 +94,9 @@ static auto installLambdas(EnvironmentPtr env) -> void
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void
{
size_t count = arguments.size();
auto nodes = ValueVector(count - 1);
if (count > 1) {
for (size_t i = 1; i < count; ++i) {
nodes.at(i) = makePtr<String>(arguments[i]);
}
auto nodes = ValueVector();
for (size_t i = 1; i < count; ++i) {
nodes.push_back(makePtr<String>(arguments[i]));
}
env->set("*ARGV*", makePtr<List>(nodes));
}

8
src/step7_quote.cpp

@ -94,11 +94,9 @@ static auto installLambdas(EnvironmentPtr env) -> void
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void
{
size_t count = arguments.size();
auto nodes = ValueVector(count - 1);
if (count > 1) {
for (size_t i = 1; i < count; ++i) {
nodes.at(i) = makePtr<String>(arguments[i]);
}
auto nodes = ValueVector();
for (size_t i = 1; i < count; ++i) {
nodes.push_back(makePtr<String>(arguments[i]));
}
env->set("*ARGV*", makePtr<List>(nodes));
}

8
src/step8_macros.cpp

@ -101,11 +101,9 @@ static auto installLambdas(EnvironmentPtr env) -> void
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void
{
size_t count = arguments.size();
auto nodes = ValueVector(count - 1);
if (count > 1) {
for (size_t i = 1; i < count; ++i) {
nodes.at(i) = makePtr<String>(arguments[i]);
}
auto nodes = ValueVector();
for (size_t i = 1; i < count; ++i) {
nodes.push_back(makePtr<String>(arguments[i]));
}
env->set("*ARGV*", makePtr<List>(nodes));
}

8
src/step9_try.cpp

@ -101,11 +101,9 @@ static auto installLambdas(EnvironmentPtr env) -> void
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void
{
size_t count = arguments.size();
auto nodes = ValueVector(count - 1);
if (count > 1) {
for (size_t i = 1; i < count; ++i) {
nodes.at(i) = makePtr<String>(arguments[i]);
}
auto nodes = ValueVector();
for (size_t i = 1; i < count; ++i) {
nodes.push_back(makePtr<String>(arguments[i]));
}
env->set("*ARGV*", makePtr<List>(nodes));
}

23
src/stepA_mal.cpp

@ -113,11 +113,9 @@ static auto installLambdas(EnvironmentPtr env) -> void
static auto makeArgv(EnvironmentPtr env, std::vector<std::string> arguments) -> void
{
size_t count = arguments.size();
auto nodes = ValueVector(count - 1);
if (count > 1) {
for (size_t i = 1; i < count; ++i) {
nodes.at(i) = makePtr<String>(arguments[i]);
}
auto nodes = ValueVector();
for (size_t i = 1; i < count; ++i) {
nodes.push_back(makePtr<String>(arguments[i]));
}
env->set("*ARGV*", makePtr<List>(nodes));
}
@ -178,3 +176,18 @@ auto main(int argc, char* argv[]) -> int
return 0;
}
// TODO: List of things below
// v Pass stepA tests (implement leftover functions)
// v Make Macro into a subclass of Lambda (?) to simplify some logic
// v Convert std::list -> std::vector, test speed before/after
// v Better way of running mal tests
// - Make Collections/HashMaps const, construct a new one with the added items
// - Basic performance testing macros, enabled in debug builds
// Iterations to beat:
// Debug: ~5k
// Release: ~30k
// New:
// Debug: ~6k
// Release: ~37k

Loading…
Cancel
Save