File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -407,7 +407,7 @@ fn add_control_ops(isa: &mut Isa) {
407407 ) ) ,
408408 Op :: from ( GenericOp :: new (
409409 Ident :: ReturnSpan ,
410- [ Field :: new ( Ident :: Values , FieldTy :: SlotSpan ) ] ,
410+ [ Field :: new ( Ident :: Values , FieldTy :: BoundedSlotSpan ) ] ,
411411 ) ) ,
412412 Op :: from ( GenericOp :: new (
413413 Ident :: Branch ,
@@ -417,14 +417,14 @@ fn add_control_ops(isa: &mut Isa) {
417417 Ident :: BranchTable ,
418418 [
419419 Field :: new ( Ident :: Index , FieldTy :: Slot ) ,
420- Field :: new ( Ident :: LenTargets , FieldTy :: U16 ) ,
420+ Field :: new ( Ident :: LenTargets , FieldTy :: U32 ) ,
421421 ] ,
422422 ) ) ,
423423 Op :: from ( GenericOp :: new (
424424 Ident :: BranchTableSpan ,
425425 [
426426 Field :: new ( Ident :: Index , FieldTy :: Slot ) ,
427- Field :: new ( Ident :: LenTargets , FieldTy :: U16 ) ,
427+ Field :: new ( Ident :: LenTargets , FieldTy :: U32 ) ,
428428 Field :: new ( Ident :: Values , FieldTy :: SlotSpan ) ,
429429 Field :: new ( Ident :: LenValues , FieldTy :: U16 ) ,
430430 ] ,
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ pub enum Error {
99 BranchOffsetOutOfBounds ,
1010 /// Encountered when trying to create a [`BlockFuel`](crate::BlockFuel) from an out of bounds integer.
1111 BlockFuelOutOfBounds ,
12+ /// Encountered when trying to create a [`Memory`] from an out of bounds integer.
13+ ///
14+ /// [`Memory`]: crate::index::Memory
15+ MemoryIndexOutOfBounds ,
1216}
1317
1418impl fmt:: Display for Error {
@@ -17,6 +21,7 @@ impl fmt::Display for Error {
1721 Self :: StackSlotOutOfBounds => "stack slot out of bounds" ,
1822 Self :: BranchOffsetOutOfBounds => "branch offset out of bounds" ,
1923 Self :: BlockFuelOutOfBounds => "block fuel out of bounds" ,
24+ Self :: MemoryIndexOutOfBounds => "memory index out of bounds" ,
2025 } ;
2126 f. write_str ( s)
2227 }
Original file line number Diff line number Diff line change @@ -62,6 +62,16 @@ macro_rules! define_index {
6262}
6363for_each_index ! ( define_index) ;
6464
65+ impl TryFrom < u32 > for Memory {
66+ type Error = Error ;
67+
68+ fn try_from ( index : u32 ) -> Result < Self , Self :: Error > {
69+ u16:: try_from ( index)
70+ . map_err ( |_| Error :: MemoryIndexOutOfBounds )
71+ . map ( Self :: from)
72+ }
73+ }
74+
6575impl TryFrom < u32 > for Slot {
6676 type Error = Error ;
6777
You can’t perform that action at this time.
0 commit comments