Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 49 additions & 66 deletions include/interpreter/data/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ enum class ArrayMethod {

class Array {
public:
Storage::DataWrapper
callMethod(std::string method, Expr *caller,
const std::vector<std::unique_ptr<Expr>> args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper callMethod(std::string method,
Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> args,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);

private:
inline static const std::unordered_map<std::string, ArrayMethod>
Expand Down Expand Up @@ -78,114 +79,96 @@ class Array {
{"flatMap", ArrayMethod::FLAT_MAP},
{"forEach", ArrayMethod::FOR_EACH}};

Storage::DataWrapper length(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper length(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper push(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper push(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper pop(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper pop(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper shift(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper shift(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper unshift(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper unshift(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper splice(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper splice(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper reverse(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper reverse(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper sort(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper sort(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper fill(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper fill(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper concat(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
std::vector<std::shared_ptr<Storage>> storage,
std::string identifier);
Storage::DataWrapper concat(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper slice(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper slice(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper includes(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper includes(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper indexOf(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper indexOf(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper
lastIndexOf(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
lastIndexOf(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper join(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper join(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper every(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper every(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper some(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper some(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper find(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper find(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper findIndex(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper findIndex(std::string method,
Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper findLast(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper findLast(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper
findLastIndex(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
findLastIndex(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper filter(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper filter(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper map(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper map(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper reduce(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper reduce(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper flat(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper flat(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper flatMap(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper flatMap(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper forEach(std::string method, Expr *caller,
Storage::DataWrapper callerValue,
Storage::DataWrapper forEach(std::string method, Storage::DataWrapper caller,
const std::vector<std::unique_ptr<Expr>> &args,
std::vector<std::shared_ptr<Storage>> storage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

class ShortOperationExpression {
public:
ShortOperationExpression(ShortOperationLiteral *expressionNode,
std::vector<std::shared_ptr<Storage>> storage);
ShortOperationExpression(ShortOperationExpr *expressionNode,
std::vector<std::shared_ptr<Storage>> storage);
Storage::DataWrapper execute();
Storage::DataWrapper executeExpression(Storage::DataWrapper leftValue);

private:
ShortOperationLiteral *expressionNode;
ShortOperationExpr *expressionNode;
std::vector<std::shared_ptr<Storage>> storage;
};

Expand Down
4 changes: 2 additions & 2 deletions include/interpreter/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Storage {
std::map<std::string, DataWrapper> *_object;
FunctionDeclaration *_function;
CallbackFunctionExpr *_callbackFunction;
ShortOperationLiteral *_shortOperation;
ShortOperationExpr *_shortOperation;

Data();
Data(int value);
Expand All @@ -51,7 +51,7 @@ class Storage {
Data(std::map<std::string, DataWrapper> *value);
Data(FunctionDeclaration *value);
Data(CallbackFunctionExpr *value);
Data(ShortOperationLiteral *value);
Data(ShortOperationExpr *value);
~Data();
};

Expand Down
Loading