Browse Source

made prepare configurable

master
Ludovic 'Archivist' Lagouardette 1 year ago
parent
commit
46c5e1f894
3 changed files with 4 additions and 4 deletions
  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 View File

@ -57,7 +57,7 @@ namespace scripting {
virtual std::optional<script_value> var_by_idx(int32_t idx) = 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::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 ~UserScript() = default;
};

+ 2
- 2
priv_include/UserScript/interpreter.h View File

@ -167,12 +167,12 @@ namespace scripting {
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;
auto lexed = ast::lex(code, errors);
auto parsed = ast::parse(lexed, errors);
if (errors.empty()) {
bytecode = generate(errors, parsed, b">true);
bytecode = generate(errors, parsed, ">repeating);
}
return errors;

+ 1
- 1
src/interpreter.cpp View File

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

Loading…
Cancel
Save