Clarify that Imm64 holds sign-extended values.

When representing smaller integer types, immediate values should be
sign-extended to i64.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-24 14:37:32 -07:00
parent 125b79c06a
commit 055c7a0374
2 changed files with 14 additions and 7 deletions

View File

@@ -596,8 +596,11 @@ impl<'a> Parser<'a> {
try!(self.match_identifier("stack_slot", "expected 'stack_slot'"));
// stack-slot-decl ::= StackSlot(ss) "=" "stack_slot" * Bytes {"," stack-slot-flag}
let bytes = try!(self.match_imm64("expected byte-size in stack_slot decl")).to_bits();
if bytes > u32::MAX as u64 {
let bytes: i64 = try!(self.match_imm64("expected byte-size in stack_slot decl")).into();
if bytes < 0 {
return err!(self.loc, "negative stack slot size");
}
if bytes > u32::MAX as i64 {
return err!(self.loc, "stack slot too large");
}
let data = StackSlotData::new(bytes as u32);