Everywhere: Rename ValueList -> ValueVector
This commit is contained in:
+13
-13
@@ -30,18 +30,18 @@ ValuePtr Value::meta() const
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
Collection::Collection(const ValueList& nodes)
|
||||
Collection::Collection(const ValueVector& nodes)
|
||||
: m_nodes(nodes)
|
||||
{
|
||||
}
|
||||
|
||||
Collection::Collection(ValueListIt begin, ValueListIt end)
|
||||
: m_nodes(ValueList(begin, end))
|
||||
Collection::Collection(ValueVectorIt begin, ValueVectorIt end)
|
||||
: m_nodes(ValueVector(begin, end))
|
||||
{
|
||||
}
|
||||
|
||||
Collection::Collection(ValueListConstIt begin, ValueListConstIt end)
|
||||
: m_nodes(ValueList(begin, end))
|
||||
Collection::Collection(ValueVectorConstIt begin, ValueVectorConstIt end)
|
||||
: m_nodes(ValueVector(begin, end))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,25 +60,25 @@ void Collection::add(ValuePtr node)
|
||||
m_nodes.push_back(node);
|
||||
}
|
||||
|
||||
ValueList Collection::rest() const
|
||||
ValueVector Collection::rest() const
|
||||
{
|
||||
auto start = (m_nodes.size() > 0) ? m_nodes.begin() + 1 : m_nodes.end();
|
||||
return ValueList(start, m_nodes.end());
|
||||
return ValueVector(start, m_nodes.end());
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
List::List(const ValueList& nodes)
|
||||
List::List(const ValueVector& nodes)
|
||||
: Collection(nodes)
|
||||
{
|
||||
}
|
||||
|
||||
List::List(ValueListIt begin, ValueListIt end)
|
||||
List::List(ValueVectorIt begin, ValueVectorIt end)
|
||||
: Collection(begin, end)
|
||||
{
|
||||
}
|
||||
|
||||
List::List(ValueListConstIt begin, ValueListConstIt end)
|
||||
List::List(ValueVectorConstIt begin, ValueVectorConstIt end)
|
||||
: Collection(begin, end)
|
||||
{
|
||||
}
|
||||
@@ -90,17 +90,17 @@ List::List(const List& that, ValuePtr meta)
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
Vector::Vector(const ValueList& nodes)
|
||||
Vector::Vector(const ValueVector& nodes)
|
||||
: Collection(nodes)
|
||||
{
|
||||
}
|
||||
|
||||
Vector::Vector(ValueListIt begin, ValueListIt end)
|
||||
Vector::Vector(ValueVectorIt begin, ValueVectorIt end)
|
||||
: Collection(begin, end)
|
||||
{
|
||||
}
|
||||
|
||||
Vector::Vector(ValueListConstIt begin, ValueListConstIt end)
|
||||
Vector::Vector(ValueVectorConstIt begin, ValueVectorConstIt end)
|
||||
: Collection(begin, end)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,15 +101,15 @@ public:
|
||||
bool empty() const { return m_nodes.size() == 0; }
|
||||
|
||||
ValuePtr front() const { return m_nodes.front(); }
|
||||
ValueList rest() const;
|
||||
ValueVector rest() const;
|
||||
|
||||
const ValueList& nodes() const { return m_nodes; }
|
||||
const ValueVector& nodes() const { return m_nodes; }
|
||||
|
||||
protected:
|
||||
Collection() = default;
|
||||
Collection(const ValueList& nodes);
|
||||
Collection(ValueListIt begin, ValueListIt end);
|
||||
Collection(ValueListConstIt begin, ValueListConstIt end);
|
||||
Collection(const ValueVector& nodes);
|
||||
Collection(ValueVectorIt begin, ValueVectorIt end);
|
||||
Collection(ValueVectorConstIt begin, ValueVectorConstIt end);
|
||||
Collection(const Collection& that, ValuePtr meta);
|
||||
|
||||
template<IsValue... Ts>
|
||||
@@ -121,7 +121,7 @@ protected:
|
||||
private:
|
||||
virtual bool isCollection() const override { return true; }
|
||||
|
||||
ValueList m_nodes;
|
||||
ValueVector m_nodes;
|
||||
};
|
||||
|
||||
// -----------------------------------------
|
||||
@@ -130,9 +130,9 @@ private:
|
||||
class List final : public Collection {
|
||||
public:
|
||||
List() = default;
|
||||
List(const ValueList& nodes);
|
||||
List(ValueListIt begin, ValueListIt end);
|
||||
List(ValueListConstIt begin, ValueListConstIt end);
|
||||
List(const ValueVector& nodes);
|
||||
List(ValueVectorIt begin, ValueVectorIt end);
|
||||
List(ValueVectorConstIt begin, ValueVectorConstIt end);
|
||||
List(const List& that, ValuePtr meta);
|
||||
|
||||
template<IsValue... Ts>
|
||||
@@ -155,9 +155,9 @@ private:
|
||||
class Vector final : public Collection {
|
||||
public:
|
||||
Vector() = default;
|
||||
Vector(const ValueList& nodes);
|
||||
Vector(ValueListIt begin, ValueListIt end);
|
||||
Vector(ValueListConstIt begin, ValueListConstIt end);
|
||||
Vector(const ValueVector& nodes);
|
||||
Vector(ValueVectorIt begin, ValueVectorIt end);
|
||||
Vector(ValueVectorConstIt begin, ValueVectorConstIt end);
|
||||
Vector(const Vector& that, ValuePtr meta);
|
||||
|
||||
template<IsValue... Ts>
|
||||
@@ -324,7 +324,7 @@ private:
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
using FunctionType = std::function<ValuePtr(ValueListIt, ValueListIt)>;
|
||||
using FunctionType = std::function<ValuePtr(ValueVectorIt, ValueVectorIt)>;
|
||||
|
||||
class Function final : public Callable {
|
||||
public:
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ EnvironmentPtr Environment::create(EnvironmentPtr outer)
|
||||
return env;
|
||||
}
|
||||
|
||||
EnvironmentPtr Environment::create(const ValuePtr lambda, const ValueList& arguments)
|
||||
EnvironmentPtr Environment::create(const ValuePtr lambda, const ValueVector& arguments)
|
||||
{
|
||||
auto lambda_casted = std::static_pointer_cast<Lambda>(lambda);
|
||||
auto env = create(lambda_casted->env());
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public:
|
||||
// Factory functions instead of constructors because it can fail in the bindings/arguments case
|
||||
static EnvironmentPtr create();
|
||||
static EnvironmentPtr create(EnvironmentPtr outer);
|
||||
static EnvironmentPtr create(const ValuePtr lambda, const ValueList& arguments);
|
||||
static EnvironmentPtr create(const ValuePtr lambda, const ValueVector& arguments);
|
||||
|
||||
bool exists(const std::string& symbol);
|
||||
ValuePtr set(const std::string& symbol, ValuePtr value);
|
||||
|
||||
+11
-11
@@ -22,7 +22,7 @@ namespace blaze {
|
||||
static ValuePtr evalQuasiQuoteImpl(ValuePtr ast);
|
||||
|
||||
// (def! x 2)
|
||||
ValuePtr Eval::evalDef(const ValueList& nodes, EnvironmentPtr env)
|
||||
ValuePtr Eval::evalDef(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("def!", nodes.size(), 2);
|
||||
|
||||
@@ -44,7 +44,7 @@ ValuePtr Eval::evalDef(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (defmacro! x (fn* (x) x))
|
||||
ValuePtr Eval::evalDefMacro(const ValueList& nodes, EnvironmentPtr env)
|
||||
ValuePtr Eval::evalDefMacro(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("defmacro!", nodes.size(), 2);
|
||||
|
||||
@@ -67,7 +67,7 @@ ValuePtr Eval::evalDefMacro(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (fn* (x) x)
|
||||
ValuePtr Eval::evalFn(const ValueList& nodes, EnvironmentPtr env)
|
||||
ValuePtr Eval::evalFn(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("fn*", nodes.size(), 2);
|
||||
|
||||
@@ -88,7 +88,7 @@ ValuePtr Eval::evalFn(const ValueList& nodes, EnvironmentPtr env)
|
||||
return makePtr<Lambda>(bindings, *std::next(nodes.begin()), env);
|
||||
}
|
||||
|
||||
ValuePtr Eval::evalMacroExpand(const ValueList& nodes, EnvironmentPtr env)
|
||||
ValuePtr Eval::evalMacroExpand(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("macroexpand", nodes.size(), 1);
|
||||
|
||||
@@ -96,7 +96,7 @@ ValuePtr Eval::evalMacroExpand(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (quasiquoteexpand x)
|
||||
ValuePtr Eval::evalQuasiQuoteExpand(const ValueList& nodes)
|
||||
ValuePtr Eval::evalQuasiQuoteExpand(const ValueVector& nodes)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("quasiquoteexpand", nodes.size(), 1);
|
||||
|
||||
@@ -104,7 +104,7 @@ ValuePtr Eval::evalQuasiQuoteExpand(const ValueList& nodes)
|
||||
}
|
||||
|
||||
// (quote x)
|
||||
ValuePtr Eval::evalQuote(const ValueList& nodes)
|
||||
ValuePtr Eval::evalQuote(const ValueVector& nodes)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("quote", nodes.size(), 1);
|
||||
|
||||
@@ -112,7 +112,7 @@ ValuePtr Eval::evalQuote(const ValueList& nodes)
|
||||
}
|
||||
|
||||
// (do 1 2 3)
|
||||
void Eval::evalDo(const ValueList& nodes, EnvironmentPtr env)
|
||||
void Eval::evalDo(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_AT_LEAST("do", nodes.size(), 1, void());
|
||||
|
||||
@@ -130,7 +130,7 @@ void Eval::evalDo(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (if x true false)
|
||||
void Eval::evalIf(const ValueList& nodes, EnvironmentPtr env)
|
||||
void Eval::evalIf(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_BETWEEN("if", nodes.size(), 2, 3, void());
|
||||
|
||||
@@ -154,7 +154,7 @@ void Eval::evalIf(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (let* (x 1) x)
|
||||
void Eval::evalLet(const ValueList& nodes, EnvironmentPtr env)
|
||||
void Eval::evalLet(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("let*", nodes.size(), 2, void());
|
||||
|
||||
@@ -271,7 +271,7 @@ static ValuePtr evalQuasiQuoteImpl(ValuePtr ast)
|
||||
}
|
||||
|
||||
// (quasiquote x)
|
||||
void Eval::evalQuasiQuote(const ValueList& nodes, EnvironmentPtr env)
|
||||
void Eval::evalQuasiQuote(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_IS("quasiquote", nodes.size(), 1, void());
|
||||
|
||||
@@ -283,7 +283,7 @@ void Eval::evalQuasiQuote(const ValueList& nodes, EnvironmentPtr env)
|
||||
}
|
||||
|
||||
// (try* x (catch* y z))
|
||||
void Eval::evalTry(const ValueList& nodes, EnvironmentPtr env)
|
||||
void Eval::evalTry(const ValueVector& nodes, EnvironmentPtr env)
|
||||
{
|
||||
CHECK_ARG_COUNT_AT_LEAST("try*", nodes.size(), 1, void());
|
||||
|
||||
|
||||
+11
-11
@@ -32,17 +32,17 @@ private:
|
||||
bool isMacroCall(ValuePtr ast, EnvironmentPtr env);
|
||||
ValuePtr macroExpand(ValuePtr ast, EnvironmentPtr env);
|
||||
|
||||
ValuePtr evalDef(const ValueList& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalDefMacro(const ValueList& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalFn(const ValueList& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalMacroExpand(const ValueList& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalQuasiQuoteExpand(const ValueList& nodes);
|
||||
ValuePtr evalQuote(const ValueList& nodes);
|
||||
void evalDo(const ValueList& nodes, EnvironmentPtr env);
|
||||
void evalIf(const ValueList& nodes, EnvironmentPtr env);
|
||||
void evalLet(const ValueList& nodes, EnvironmentPtr env);
|
||||
void evalQuasiQuote(const ValueList& nodes, EnvironmentPtr env);
|
||||
void evalTry(const ValueList& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalDef(const ValueVector& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalDefMacro(const ValueVector& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalFn(const ValueVector& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalMacroExpand(const ValueVector& nodes, EnvironmentPtr env);
|
||||
ValuePtr evalQuasiQuoteExpand(const ValueVector& nodes);
|
||||
ValuePtr evalQuote(const ValueVector& nodes);
|
||||
void evalDo(const ValueVector& nodes, EnvironmentPtr env);
|
||||
void evalIf(const ValueVector& nodes, EnvironmentPtr env);
|
||||
void evalLet(const ValueVector& nodes, EnvironmentPtr env);
|
||||
void evalQuasiQuote(const ValueVector& nodes, EnvironmentPtr env);
|
||||
void evalTry(const ValueVector& nodes, EnvironmentPtr env);
|
||||
|
||||
ValuePtr apply(std::shared_ptr<List> evaluated_list);
|
||||
|
||||
|
||||
+3
-3
@@ -16,9 +16,9 @@ namespace blaze {
|
||||
|
||||
class Value;
|
||||
typedef std::shared_ptr<Value> ValuePtr;
|
||||
typedef std::vector<ValuePtr> ValueList;
|
||||
typedef ValueList::iterator ValueListIt;
|
||||
typedef ValueList::const_iterator ValueListConstIt;
|
||||
typedef std::vector<ValuePtr> ValueVector;
|
||||
typedef ValueVector::iterator ValueVectorIt;
|
||||
typedef ValueVector::const_iterator ValueVectorConstIt;
|
||||
|
||||
class Environment;
|
||||
typedef std::shared_ptr<Environment> EnvironmentPtr;
|
||||
|
||||
+7
-7
@@ -39,7 +39,7 @@
|
||||
static struct FUNCTION_STRUCT_NAME(unique) \
|
||||
FUNCTION_STRUCT_NAME(unique)( \
|
||||
symbol, \
|
||||
[](ValueListIt begin, ValueListIt end) -> ValuePtr lambda);
|
||||
[](ValueVectorIt begin, ValueVectorIt end) -> ValuePtr lambda);
|
||||
|
||||
#define ADD_FUNCTION(symbol, lambda) ADD_FUNCTION_IMPL(__LINE__, symbol, lambda);
|
||||
|
||||
@@ -391,7 +391,7 @@ ADD_FUNCTION(
|
||||
|
||||
// Remove atom and function from the argument list, add atom value
|
||||
begin += 2;
|
||||
auto arguments = ValueList(end - begin + 1);
|
||||
auto arguments = ValueVector(end - begin + 1);
|
||||
arguments[0] = atom->deref();
|
||||
std::copy(begin, end, arguments.begin() + 1);
|
||||
|
||||
@@ -420,7 +420,7 @@ ADD_FUNCTION(
|
||||
VALUE_CAST(collection, Collection, (*begin));
|
||||
const auto& collection_nodes = collection->nodes();
|
||||
|
||||
ValueList* result_nodes = new ValueList(collection_nodes.size() + 1);
|
||||
ValueVector* result_nodes = new ValueVector(collection_nodes.size() + 1);
|
||||
result_nodes->at(0) = first;
|
||||
std::copy(collection_nodes.begin(), collection_nodes.end(), result_nodes->begin() + 1);
|
||||
|
||||
@@ -437,7 +437,7 @@ ADD_FUNCTION(
|
||||
count += collection->size();
|
||||
}
|
||||
|
||||
auto result_nodes = new ValueList(count);
|
||||
auto result_nodes = new ValueVector(count);
|
||||
size_t offset = 0;
|
||||
for (auto it = begin; it != end; ++it) {
|
||||
const auto& collection_nodes = std::static_pointer_cast<Collection>(*it)->nodes();
|
||||
@@ -530,7 +530,7 @@ ADD_FUNCTION(
|
||||
|
||||
VALUE_CAST(collection, Collection, (*std::prev(end)));
|
||||
|
||||
ValueList arguments(begin + 1, end - 1);
|
||||
ValueVector arguments(begin + 1, end - 1);
|
||||
arguments.reserve(arguments.size() + collection->size());
|
||||
|
||||
// Append list nodes to the argument leftovers
|
||||
@@ -567,7 +567,7 @@ ADD_FUNCTION(
|
||||
if (is<Function>(callable.get())) {
|
||||
auto function = std::static_pointer_cast<Function>(callable)->function();
|
||||
for (const auto& node : collection_nodes) {
|
||||
auto arguments = ValueList { node };
|
||||
auto arguments = ValueVector { node };
|
||||
result->add(function(arguments.begin(), arguments.end()));
|
||||
}
|
||||
}
|
||||
@@ -910,7 +910,7 @@ ADD_FUNCTION(
|
||||
size_t collection_count = collection_nodes.size();
|
||||
size_t argument_count = SIZE();
|
||||
|
||||
ValueList* nodes = new ValueList(argument_count + collection_count);
|
||||
ValueVector* nodes = new ValueVector(argument_count + collection_count);
|
||||
|
||||
if (is<List>(collection.get())) {
|
||||
std::reverse_copy(begin, end, nodes->begin());
|
||||
|
||||
Reference in New Issue
Block a user