2019-05-21 10:59:15 +00:00
|
|
|
#ifndef PORYGONLANG_SCRIPT_HPP
|
|
|
|
#define PORYGONLANG_SCRIPT_HPP
|
|
|
|
|
2019-06-05 15:46:46 +00:00
|
|
|
#include <utility>
|
2019-05-21 10:59:15 +00:00
|
|
|
#include <string>
|
2019-05-28 15:49:03 +00:00
|
|
|
#include <unordered_map>
|
2019-05-21 11:56:08 +00:00
|
|
|
#include "Diagnostics/Diagnostics.hpp"
|
2019-05-21 18:59:26 +00:00
|
|
|
#include "Binder/BoundStatements/BoundStatement.hpp"
|
2019-05-23 16:50:09 +00:00
|
|
|
class Script;
|
|
|
|
class Evaluator;
|
|
|
|
#include "Evaluator/Evaluator.hpp"
|
2019-05-24 17:14:30 +00:00
|
|
|
#include "Evaluator/EvalValues/EvalValue.hpp"
|
2019-05-28 15:49:03 +00:00
|
|
|
#include "Utilities/HashedString.hpp"
|
2019-05-21 10:59:15 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class Script {
|
2019-05-23 16:50:09 +00:00
|
|
|
friend class Evaluator;
|
|
|
|
|
|
|
|
Evaluator* _evaluator;
|
2019-06-01 19:38:39 +00:00
|
|
|
unordered_map<int, shared_ptr<EvalValue>>* _scriptVariables;
|
2019-06-05 15:46:46 +00:00
|
|
|
BoundScriptStatement* _boundScript;
|
2019-05-23 16:50:09 +00:00
|
|
|
|
|
|
|
explicit Script();
|
2019-05-21 10:59:15 +00:00
|
|
|
void Parse(string script);
|
|
|
|
public:
|
2019-05-28 15:49:03 +00:00
|
|
|
static Script* Create(string script);
|
2019-05-21 12:15:39 +00:00
|
|
|
Diagnostics* Diagnostics;
|
|
|
|
|
|
|
|
~Script();
|
2019-05-23 16:50:09 +00:00
|
|
|
|
|
|
|
void Evaluate();
|
|
|
|
|
2019-06-05 15:46:46 +00:00
|
|
|
EvalValue* GetLastValue();
|
2019-05-28 15:49:03 +00:00
|
|
|
|
2019-05-29 13:10:16 +00:00
|
|
|
EvalValue* GetVariable(const string& key);
|
|
|
|
bool HasVariable(const string& key);
|
2019-06-05 15:46:46 +00:00
|
|
|
|
2019-06-05 16:44:23 +00:00
|
|
|
EvalValue* CallFunction(const string& key, vector<EvalValue*> variables);
|
|
|
|
bool HasFunction(const string& key);
|
|
|
|
|
2019-06-05 15:46:46 +00:00
|
|
|
|
2019-05-21 10:59:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //PORYGONLANG_SCRIPT_HPP
|