Переглянути джерело

made prepare configurable

master
Ludovic 'Archivist' Lagouardette 9 місяці тому
джерело
коміт
46c5e1f894
3 змінених файлів з 4 додано та 4 видалено
  1. +1
    -1
      include/UserScript.h
  2. +2
    -2
      priv_include/UserScript/interpreter.h
  3. +1
    -1
      src/interpreter.cpp

+ 1
- 1
include/UserScript.h Переглянути файл

@ -57,7 +57,7 @@ namespace scripting {
virtual std::optional<script_value> var_by_idx(int32_t idx) = 0; virtual std::optional<script_value> var_by_idx(int32_t idx) = 0;
virtual script_value resolve(const std::string& name) = 0; virtual script_value resolve(const std::string& name) = 0;
virtual std::variant<script_value, std::vector<script_error>> executeAtOnce(std::string code) = 0; virtual std::variant<script_value, std::vector<script_error>> executeAtOnce(std::string code) = 0;
virtual std::vector<script_error> prepare(std::string code) = 0;
virtual std::vector<script_error> prepare(std::string code, bool repeating = true) = 0;
virtual std::optional<script_error> stepOnce() = 0; virtual std::optional<script_error> stepOnce() = 0;
virtual ~UserScript() = default; virtual ~UserScript() = default;
}; };

+ 2
- 2
priv_include/UserScript/interpreter.h Переглянути файл

@ -167,12 +167,12 @@ namespace scripting {
return v; return v;
} }
std::vector<script_error> prepare(std::string code) final {
std::vector<script_error> prepare(std::string code, bool repeating) final {
std::vector<script_error> errors; std::vector<script_error> errors;
auto lexed = ast::lex(code, errors); auto lexed = ast::lex(code, errors);
auto parsed = ast::parse(lexed, errors); auto parsed = ast::parse(lexed, errors);
if (errors.empty()) { if (errors.empty()) {
bytecode = generate(errors, parsed, b">true);
bytecode = generate(errors, parsed, ">repeating);
} }
return errors; return errors;

+ 1
- 1
src/interpreter.cpp Переглянути файл

@ -83,7 +83,7 @@ namespace scripting {
std::unique_ptr<UserScript> prepare_interpreter(const std::string& code) { std::unique_ptr<UserScript> prepare_interpreter(const std::string& code) {
auto script = std::make_unique<ByteCodeInterpreter>(); auto script = std::make_unique<ByteCodeInterpreter>();
script->prepare(code);
script->prepare(code, false);
return script; return script;
} }

Завантаження…
Відмінити
Зберегти