summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-09-02 00:13:08 -0700
committerAndy Wingo <wingo@pobox.com>2008-09-02 10:30:39 -0700
commit7950b4cffb638cb34ecb79b0696d409d3034f467 (patch)
tree17d501b98f901e478fa5ceebd079782d37525cda
parent124c52d8bbfbc20a1184493182e090167685664e (diff)
downloadguile-7950b4cffb638cb34ecb79b0696d409d3034f467.tar.gz
fix a bug loading functions with 8 or more arguments
* libguile/vm-i-loader.c: A combination of superstition and a bugfix: make sure that we treat bits as being of a type as wide as we think it is, and, more importantly, allow for programs with 8 <= nargs < 16.
-rw-r--r--libguile/vm-i-loader.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libguile/vm-i-loader.c b/libguile/vm-i-loader.c
index db0ee9b57..3b232cbc3 100644
--- a/libguile/vm-i-loader.c
+++ b/libguile/vm-i-loader.c
@@ -144,19 +144,21 @@ VM_DEFINE_LOADER (load_program, "load-program")
int i = SCM_I_INUM (x);
if (-128 <= i && i <= 127)
{
+ scm_t_uint8 c = (scm_t_uint8)i;
/* 8-bit representation */
- p->nargs = (i >> 6) & 0x03; /* 7-6 bits */
- p->nrest = (i >> 5) & 0x01; /* 5 bit */
- p->nlocs = (i >> 2) & 0x07; /* 4-2 bits */
- p->nexts = i & 0x03; /* 1-0 bits */
+ p->nargs = (c >> 6) & 0x03; /* 7-6 bits */
+ p->nrest = (c >> 5) & 0x01; /* 5 bit */
+ p->nlocs = (c >> 2) & 0x07; /* 4-2 bits */
+ p->nexts = c & 0x03; /* 1-0 bits */
}
else
{
+ scm_t_uint16 s = (scm_t_uint16)i;
/* 16-bit representation */
- p->nargs = (i >> 12) & 0x07; /* 15-12 bits */
- p->nrest = (i >> 11) & 0x01; /* 11 bit */
- p->nlocs = (i >> 4) & 0x7f; /* 10-04 bits */
- p->nexts = i & 0x0f; /* 03-00 bits */
+ p->nargs = (s >> 12) & 0x0f; /* 15-12 bits */
+ p->nrest = (s >> 11) & 0x01; /* 11 bit */
+ p->nlocs = (s >> 4) & 0x7f; /* 10-04 bits */
+ p->nexts = s & 0x0f; /* 03-00 bits */
}
}
else