diff options
author | Ludovic Courtès <ludo@gnu.org> | 2009-02-18 00:54:05 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2009-02-18 00:54:05 +0100 |
commit | b912a1cd6b5d22e1fd3eadca10858d8d0dd9c027 (patch) | |
tree | cbd35bdcee9c0d3da264ceaa3ffba2917cbddb53 /libguile/vm-i-loader.c | |
parent | 4e29767187774d44a899a82c3d2a7d509ed9e5b9 (diff) | |
download | guile-b912a1cd6b5d22e1fd3eadca10858d8d0dd9c027.tar.gz |
Add `load-unsigned-integer' instruction.
* libguile/vm-i-loader.c (load_unsigned_integer): New loader.
* module/language/assembly.scm (byte-length): Handle
`load-unsigned-integer'.
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Likewise.
* module/language/glil/compile-assembly.scm (dump-object): Emit a
`load-unsigned-integer' instruction for positive integers. This fixes
loading of integers greater than 2^31 - 1.
* testsuite/Makefile.am (vm_test_files): Add `t-literal-integers.scm'.
* doc/ref/vm.texi (Loading Instructions): Add `load-unsigned-integer'.
Diffstat (limited to 'libguile/vm-i-loader.c')
-rw-r--r-- | libguile/vm-i-loader.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libguile/vm-i-loader.c b/libguile/vm-i-loader.c index 66b07b1f5..bba4f4b9c 100644 --- a/libguile/vm-i-loader.c +++ b/libguile/vm-i-loader.c @@ -18,12 +18,30 @@ /* This file is included in vm_engine.c */ +VM_DEFINE_LOADER (59, load_unsigned_integer, "load-unsigned-integer") +{ + size_t len; + + FETCH_LENGTH (len); + if (SCM_LIKELY (len <= 4)) + { + unsigned int val = 0; + while (len-- > 0) + val = (val << 8U) + FETCH (); + SYNC_REGISTER (); + PUSH (scm_from_uint (val)); + NEXT; + } + else + SCM_MISC_ERROR ("load-unsigned-integer: not implemented yet", SCM_EOL); +} + VM_DEFINE_LOADER (60, load_integer, "load-integer") { size_t len; FETCH_LENGTH (len); - if (len <= 4) + if (SCM_LIKELY (len <= 4)) { int val = 0; while (len-- > 0) |