Support for retrieving bound tree string from script objecsts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -115,6 +115,15 @@ Porygon::Script::Script(shared_ptr<BoundScriptStatement> boundScript,
|
||||
_evaluator = new Evaluator(_scriptVariables, this -> GetScriptOptions());
|
||||
}
|
||||
|
||||
std::string Porygon::Script::GetTreeString() {
|
||||
if (_treeString.empty()){
|
||||
std::stringstream stream;
|
||||
_boundScript->GetTreeString(stream, 0);
|
||||
_treeString = stream.str();
|
||||
}
|
||||
return _treeString;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
Porygon::Script* CreateScript(char16_t * s, Porygon::ScriptOptions* options){
|
||||
return Porygon::Script::Create(s, options);
|
||||
@@ -160,4 +169,16 @@ extern "C" {
|
||||
const char * GetResultError(Porygon::EvaluateResult * result){
|
||||
return result->GetError();
|
||||
}
|
||||
|
||||
const size_t GetTreeStringLength(Porygon::Script* script){
|
||||
return script->GetTreeString().size();
|
||||
}
|
||||
|
||||
void GetTreeString(Porygon::Script* script, char* buffer){
|
||||
auto s = script->GetTreeString();
|
||||
for (size_t i = 0; i < s.size(); i++){
|
||||
buffer[i] = s[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace Porygon{
|
||||
shared_ptr<Binder::BoundScriptStatement> _boundScript;
|
||||
shared_ptr<const ScriptType> _returnType = nullptr;
|
||||
ScriptOptions* _scriptOptions;
|
||||
std::string _treeString;
|
||||
|
||||
explicit Script(const u16string&, ScriptOptions*);
|
||||
Script(shared_ptr<BoundScriptStatement> boundScript, shared_ptr<Diagnostics::DiagnosticsHolder> diagnostics);
|
||||
@@ -65,6 +66,8 @@ namespace Porygon{
|
||||
const map<Utilities::HashedString, EvalValuePointer>* GetScriptVariables(){
|
||||
return _scriptVariables;
|
||||
}
|
||||
|
||||
std::string GetTreeString();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user