60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#include <utility>
|
|
|
|
#ifndef PORYGONLANG_SCRIPT_HPP
|
|
#define PORYGONLANG_SCRIPT_HPP
|
|
|
|
#include <utility>
|
|
#include <string>
|
|
#include <map>
|
|
#include "Diagnostics/DiagnosticsHolder.hpp"
|
|
#include "Binder/BoundStatements/BoundStatement.hpp"
|
|
#include "Evaluator/Evaluator.hpp"
|
|
#include "Evaluator/EvalValues/EvalValue.hpp"
|
|
#include "Utilities/HashedString.hpp"
|
|
|
|
using namespace std;
|
|
using namespace Porygon::Evaluation;
|
|
|
|
namespace Porygon{
|
|
class Script {
|
|
Evaluator* _evaluator;
|
|
map<Utilities::HashedString, shared_ptr<EvalValue>>* _scriptVariables;
|
|
shared_ptr<Binder::BoundScriptStatement> _boundScript;
|
|
shared_ptr<ScriptType> _returnType;
|
|
|
|
explicit Script(const u16string&);
|
|
Script(shared_ptr<Binder::BoundScriptStatement> boundScript, shared_ptr<Diagnostics::DiagnosticsHolder> diagnostics);
|
|
void Parse(const u16string& script);
|
|
public:
|
|
shared_ptr<Diagnostics::DiagnosticsHolder> Diagnostics;
|
|
|
|
static Script* Create(const u16string& script);
|
|
static Script* Create(const string& script);
|
|
static Script* Clone(const Script* script);
|
|
|
|
~Script();
|
|
|
|
shared_ptr<ScriptType> GetReturnType(){
|
|
return _returnType;
|
|
}
|
|
|
|
void SetReturnType(shared_ptr<ScriptType> t){
|
|
_returnType = std::move(t);
|
|
}
|
|
|
|
EvalValue* Evaluate();
|
|
|
|
EvalValue* GetLastValue();
|
|
|
|
EvalValue* GetVariable(const u16string& key);
|
|
bool HasVariable(const u16string& key);
|
|
|
|
shared_ptr<EvalValue> CallFunction(const u16string& key, const vector<EvalValue*>& variables);
|
|
bool HasFunction(const u16string& key);
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif //PORYGONLANG_SCRIPT_HPP
|