2019-06-17 16:35:12 +00:00
|
|
|
#include <utility>
|
|
|
|
|
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-06-23 13:58:14 +00:00
|
|
|
#include <map>
|
2019-06-06 17:01:54 +00:00
|
|
|
#include "Diagnostics/DiagnosticsHolder.hpp"
|
2019-05-21 18:59:26 +00:00
|
|
|
#include "Binder/BoundStatements/BoundStatement.hpp"
|
2019-05-23 16:50:09 +00:00
|
|
|
#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;
|
2019-06-17 16:35:12 +00:00
|
|
|
using namespace Porygon::Evaluation;
|
2019-05-21 10:59:15 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
namespace Porygon{
|
|
|
|
class Script {
|
|
|
|
Evaluator* _evaluator;
|
2019-06-23 13:58:14 +00:00
|
|
|
map<Utilities::HashedString, shared_ptr<EvalValue>>* _scriptVariables;
|
2019-06-17 16:35:12 +00:00
|
|
|
Binder::BoundScriptStatement* _boundScript;
|
|
|
|
shared_ptr<ScriptType> _returnType;
|
2019-05-23 16:50:09 +00:00
|
|
|
|
2019-06-18 15:14:18 +00:00
|
|
|
explicit Script(const u16string&);
|
2019-06-17 16:35:12 +00:00
|
|
|
void Parse(const u16string& script);
|
|
|
|
public:
|
|
|
|
static Script* Create(const u16string& script);
|
|
|
|
static Script* Create(const string& script);
|
2019-06-18 14:39:36 +00:00
|
|
|
Diagnostics::DiagnosticsHolder* Diagnostics;
|
2019-05-23 16:50:09 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
~Script();
|
2019-05-21 12:15:39 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
shared_ptr<ScriptType> GetReturnType(){
|
|
|
|
return _returnType;
|
|
|
|
}
|
2019-05-23 16:50:09 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
void SetReturnType(shared_ptr<ScriptType> t){
|
|
|
|
_returnType = std::move(t);
|
|
|
|
}
|
2019-06-07 13:23:13 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
EvalValue* Evaluate();
|
2019-06-12 16:45:47 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
EvalValue* GetLastValue();
|
2019-05-23 16:50:09 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
EvalValue* GetVariable(const u16string& key);
|
|
|
|
bool HasVariable(const u16string& key);
|
2019-05-28 15:49:03 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
shared_ptr<EvalValue> CallFunction(const u16string& key, const vector<EvalValue*>& variables);
|
|
|
|
bool HasFunction(const u16string& key);
|
|
|
|
};
|
2019-06-05 15:46:46 +00:00
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
}
|
2019-05-21 10:59:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif //PORYGONLANG_SCRIPT_HPP
|