diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-15 14:08:17 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-15 14:08:17 +0900 |
| commit | b7d75591f36575fc0a6e56378b4fa891981d803e (patch) | |
| tree | 694995d453126d2f09f0f4a5fecc7586245c254e /mrbgems/mruby-compiler/core/codegen.c | |
| parent | b8863c69dccce97f6fae178552afc61ba0b07f0c (diff) | |
| download | mruby-b7d75591f36575fc0a6e56378b4fa891981d803e.tar.gz mruby-b7d75591f36575fc0a6e56378b4fa891981d803e.zip | |
codegen.c: `gen_jmpdst` always needs to generate relative address.
Diffstat (limited to 'mrbgems/mruby-compiler/core/codegen.c')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 5b779b63d..bd3f34ddd 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -398,17 +398,15 @@ gen_jmpdst(codegen_scope *s, uint32_t pc) { if (pc == JMPLINK_START) { - gen_S(s, 0); + pc = 0; } - else { - uint32_t pos2 = s->pc+2; - int32_t off = pc - pos2; + uint32_t pos2 = s->pc+2; + int32_t off = pc - pos2; - if (off > INT16_MAX || INT16_MIN > off) { - codegen_error(s, "too big jump offset"); - } - gen_S(s, (uint16_t)off); + if (off > INT16_MAX || INT16_MIN > off) { + codegen_error(s, "too big jump offset"); } + gen_S(s, (uint16_t)off); } static uint32_t |
