PorygonLang/src/Script.hpp

54 lines
1.2 KiB
C++
Raw Normal View History

2019-05-21 10:59:15 +00:00
#ifndef PORYGONLANG_SCRIPT_HPP
#define PORYGONLANG_SCRIPT_HPP
#include <utility>
2019-05-21 10:59:15 +00:00
#include <string>
2019-05-28 15:49:03 +00:00
#include <unordered_map>
2019-06-06 17:01:54 +00:00
#include "Diagnostics/DiagnosticsHolder.hpp"
#include "Binder/BoundStatements/BoundStatement.hpp"
2019-05-23 16:50:09 +00:00
class Script;
class Evaluator;
#include "Evaluator/Evaluator.hpp"
#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;
unordered_map<uint32_t, shared_ptr<EvalValue>>* _scriptVariables;
BoundScriptStatement* _boundScript;
2019-06-07 13:23:13 +00:00
shared_ptr<ScriptType> _returnType;
2019-05-23 16:50:09 +00:00
explicit Script();
void Parse(const string& script);
2019-05-21 10:59:15 +00:00
public:
static Script* Create(const string& script);
2019-06-06 17:01:54 +00:00
DiagnosticsHolder* Diagnostics;
2019-05-21 12:15:39 +00:00
~Script();
2019-05-23 16:50:09 +00:00
2019-06-07 13:23:13 +00:00
shared_ptr<ScriptType> GetReturnType(){
return _returnType;
}
void SetReturnType(shared_ptr<ScriptType> t){
_returnType = t;
}
EvalValue* Evaluate();
2019-05-23 16:50:09 +00:00
EvalValue* GetLastValue();
2019-05-28 15:49:03 +00:00
EvalValue* GetVariable(const string& key);
bool HasVariable(const string& key);
shared_ptr<EvalValue> CallFunction(const string& key, const vector<EvalValue*>& variables);
bool HasFunction(const string& key);
2019-05-21 10:59:15 +00:00
};
#endif //PORYGONLANG_SCRIPT_HPP