upd: first version of function call
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "utils.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Evalvisitor.h"
|
||||
#include "Python3ParserBaseVisitor.h"
|
||||
#include "int2048/int2048.h"
|
||||
class InterpretException : public std::exception {
|
||||
@ -71,14 +72,6 @@ struct FunctionItem {
|
||||
const std::vector<ParaArguItemType> ¶_list)
|
||||
: code_address(code_address), para_list(para_list) {}
|
||||
};
|
||||
class FucntionContainer {
|
||||
std::unordered_map<std::string, FunctionItem> FunctionIndex;
|
||||
|
||||
public:
|
||||
void AddFunction(const std::string &name, const FunctionItem &item);
|
||||
std::any CallFunction(const std::string &name,
|
||||
const std::vector<ParaArguItemType> &args);
|
||||
};
|
||||
class VariableContainer {
|
||||
std::unordered_map<std::string, std::any> GlobalScope;
|
||||
std::stack<std::unordered_map<std::string, std::any>> StackScopes;
|
||||
@ -87,7 +80,17 @@ class VariableContainer {
|
||||
void CreateFrame();
|
||||
void DestroyFrame();
|
||||
std::any ReadVariable(const std::string &name);
|
||||
void WriteVariable(const std::string &name, const std::any &value);
|
||||
void WriteVariable(const std::string &name, const std::any &value,
|
||||
bool cover = false);
|
||||
};
|
||||
class FucntionContainer {
|
||||
std::unordered_map<std::string, FunctionItem> FunctionIndex;
|
||||
|
||||
public:
|
||||
void AddFunction(const std::string &name, const FunctionItem &item);
|
||||
std::any CallFunction(const std::string &name,
|
||||
const std::vector<ParaArguItemType> &args,
|
||||
VariableContainer &Varables);
|
||||
};
|
||||
std::any DeQuate(std::any val, VariableContainer &Variables);
|
||||
|
||||
|
Reference in New Issue
Block a user