From 0292940e557d91faa84b8570619226a75b8468d3 Mon Sep 17 00:00:00 2001 From: crimsonwoods Date: Thu, 21 Mar 2013 22:55:35 +0900 Subject: fix the type of value that is returned by bit-shift expression. --- src/codegen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/codegen.c b/src/codegen.c index 7a91d597d..3141fafe1 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -580,7 +580,8 @@ lambda_body(codegen_scope *s, node *tree, int blk) } tree = tree->cdr; if (tree->car) { - int ma, oa, ra, pa, ka, kd, ba, a; + int32_t a; + int ma, oa, ra, pa, ka, kd, ba; int pos, i; node *n, *opt; @@ -595,8 +596,8 @@ lambda_body(codegen_scope *s, node *tree, int blk) ka = kd = 0; ba = tree->car->cdr->cdr->cdr->cdr ? 1 : 0; - a = ((ma & 0x1f) << 18) - | ((oa & 0x1f) << 13) + a = ((int32_t)(ma & 0x1f) << 18) + | ((int32_t)(oa & 0x1f) << 13) | ((ra & 1) << 12) | ((pa & 0x1f) << 7) | ((ka & 0x1f) << 2) -- cgit v1.2.3 From c1f6a27660432771c033775ec144d06d361e704d Mon Sep 17 00:00:00 2001 From: crimsonwoods Date: Thu, 21 Mar 2013 22:57:14 +0900 Subject: fix the type of value that is returned by bit-shift expression. --- src/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/hash.c b/src/hash.c index dc00c0db5..262c713b6 100644 --- a/src/hash.c +++ b/src/hash.c @@ -15,7 +15,7 @@ static inline khint_t mrb_hash_ht_hash_func(mrb_state *mrb, mrb_value key) { - khint_t h = mrb_type(key) << 24; + khint_t h = (khint_t)mrb_type(key) << 24; mrb_value h2; h2 = mrb_funcall(mrb, key, "hash", 0, 0); -- cgit v1.2.3 From e06648a88d4369c8ffc1a0b5ff0cffd85e269477 Mon Sep 17 00:00:00 2001 From: crimsonwoods Date: Thu, 21 Mar 2013 22:57:29 +0900 Subject: "Ax" is larger than 16-bit. --- src/vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/vm.c b/src/vm.c index 881acf4fc..906718392 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1126,7 +1126,7 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) CASE(OP_ENTER) { /* Ax arg setup according to flags (24=5:5:1:5:5:1:1) */ /* number of optional arguments times OP_JMP should follow */ - int ax = GETARG_Ax(i); + int32_t ax = GETARG_Ax(i); int m1 = (ax>>18)&0x1f; int o = (ax>>13)&0x1f; int r = (ax>>12)&0x1; -- cgit v1.2.3 From cc4e9ee5b65e5f35b7517e19dce5a5c62e0b2250 Mon Sep 17 00:00:00 2001 From: crimsonwoods Date: Thu, 21 Mar 2013 22:58:33 +0900 Subject: fix the type of value that is returned by bit-shift expression. --- src/opcode.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/opcode.h b/src/opcode.h index 7c2ec204d..6b2288d48 100644 --- a/src/opcode.h +++ b/src/opcode.h @@ -20,17 +20,17 @@ #define GETARG_C(i) ((int)((((mrb_code)(i)) >> 7) & 0x7f)) #define GETARG_Bx(i) ((int)((((mrb_code)(i)) >> 7) & 0xffff)) #define GETARG_sBx(i) ((int)(GETARG_Bx(i)-MAXARG_sBx)) -#define GETARG_Ax(i) ((int)((((mrb_code)(i)) >> 7) & 0x1ffffff)) +#define GETARG_Ax(i) ((int32_t)((((mrb_code)(i)) >> 7) & 0x1ffffff)) #define GETARG_UNPACK_b(i,n1,n2) ((int)((((mrb_code)(i)) >> (7+n2)) & (((1<> 7) & (((1< Date: Thu, 21 Mar 2013 23:07:18 +0900 Subject: fix comment. --- src/opcode.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/opcode.h b/src/opcode.h index 6b2288d48..8678ef73d 100644 --- a/src/opcode.h +++ b/src/opcode.h @@ -10,9 +10,12 @@ #define MAXARG_Bx (0xffff) #define MAXARG_sBx (MAXARG_Bx>>1) /* `sBx' is signed */ -/* instructions OP:A:B:C = 7:9:9:7 (32 bits) */ -/* OP:A:Bx = 7:9:16 */ -/* OP:Ax = 7:25 */ +/* instructions: packed 32 bit */ +/* ------------------------------- */ +/* A:B:C:OP = 9: 9: 7: 7 */ +/* A:Bx:OP = 9:16: 7 */ +/* Ax:OP = 25: 7 */ +/* A:Bz:Cz:OP = 9:14: 2: 7 */ #define GET_OPCODE(i) ((int)(((mrb_code)(i)) & 0x7f)) #define GETARG_A(i) ((int)((((mrb_code)(i)) >> 23) & 0x1ff)) -- cgit v1.2.3