This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <locale>
|
||||
#include <unordered_map>
|
||||
#include <codecvt>
|
||||
#include "Script.hpp"
|
||||
#include "Parser/Lexer.hpp"
|
||||
@@ -27,13 +24,13 @@ Porygon::Script *Porygon::Script::Create(const string &script) {
|
||||
Porygon::Script::Script(const u16string& s)
|
||||
: Diagnostics(make_shared<Diagnostics::DiagnosticsHolder>(s)),
|
||||
_boundScript(nullptr),
|
||||
_scriptVariables(new map<Utilities::HashedString, shared_ptr<EvalValue>>())
|
||||
_scriptVariables(new map<Utilities::HashedString, shared_ptr<const EvalValue>>())
|
||||
{
|
||||
_evaluator = new Evaluator(this -> _scriptVariables);
|
||||
this -> Parse(s);
|
||||
}
|
||||
|
||||
EvalValue* Porygon::Script::Evaluate() {
|
||||
const EvalValue* Porygon::Script::Evaluate() {
|
||||
return _evaluator->Evaluate(_boundScript.get());
|
||||
}
|
||||
|
||||
@@ -65,7 +62,7 @@ void Porygon::Script::Parse(const u16string& script) {
|
||||
delete parseResult;
|
||||
}
|
||||
|
||||
EvalValue *Porygon::Script::GetVariable(const u16string &key) {
|
||||
const EvalValue *Porygon::Script::GetVariable(const u16string &key) {
|
||||
return _scriptVariables -> at(HashedString::CreateLookup(key)).get();
|
||||
}
|
||||
|
||||
@@ -74,7 +71,7 @@ bool Porygon::Script::HasVariable(const u16string &key) {
|
||||
return f != _scriptVariables->end();
|
||||
}
|
||||
|
||||
EvalValue *Porygon::Script::GetLastValue() {
|
||||
const EvalValue *Porygon::Script::GetLastValue() {
|
||||
return _evaluator->GetLastValue();
|
||||
}
|
||||
|
||||
@@ -83,7 +80,7 @@ bool Porygon::Script::HasFunction(const u16string &key) {
|
||||
return f != _scriptVariables->end() && f.operator->()->second->GetTypeClass() == TypeClass ::Function;
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> Porygon::Script::CallFunction(const u16string &key, const vector<EvalValue *>& variables) {
|
||||
shared_ptr<const EvalValue> Porygon::Script::CallFunction(const u16string &key, const vector<EvalValue *>& variables) {
|
||||
auto var = (GenericFunctionEvalValue*)GetVariable(key);
|
||||
return this->_evaluator->EvaluateFunction(var, variables);
|
||||
}
|
||||
@@ -101,7 +98,7 @@ Porygon::Script::Script(shared_ptr<BoundScriptStatement> boundScript,
|
||||
shared_ptr<Porygon::Diagnostics::DiagnosticsHolder> diagnostics)
|
||||
: _boundScript(std::move(boundScript)),
|
||||
Diagnostics(std::move(diagnostics)),
|
||||
_scriptVariables(new map<Utilities::HashedString, shared_ptr<EvalValue>>())
|
||||
_scriptVariables(new map<Utilities::HashedString, shared_ptr<const EvalValue>>())
|
||||
{
|
||||
_evaluator = new Evaluator(_scriptVariables);
|
||||
}
|
||||
@@ -116,7 +113,7 @@ extern "C" {
|
||||
script->Evaluate();
|
||||
}
|
||||
|
||||
EvalValue* GetLastValue(Porygon::Script* script){
|
||||
const EvalValue* GetLastValue(Porygon::Script* script){
|
||||
return script->GetLastValue();
|
||||
}
|
||||
|
||||
@@ -124,7 +121,7 @@ extern "C" {
|
||||
return script->HasVariable(key);
|
||||
}
|
||||
|
||||
EvalValue* GetVariable(Porygon::Script* script, const char16_t* key){
|
||||
const EvalValue* GetVariable(Porygon::Script* script, const char16_t* key){
|
||||
return script->GetVariable(key);
|
||||
}
|
||||
|
||||
@@ -132,7 +129,7 @@ extern "C" {
|
||||
return script->HasFunction(key);
|
||||
}
|
||||
|
||||
EvalValue* CallFunction(Porygon::Script* script, const char16_t* key, EvalValue* parameters[], int parameterCount){
|
||||
const EvalValue* CallFunction(Porygon::Script* script, const char16_t* key, EvalValue* parameters[], int parameterCount){
|
||||
std::vector<EvalValue*> v(parameters, parameters + parameterCount);
|
||||
return script->CallFunction(key, v).get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user