@@ -14,6 +14,7 @@ pub struct OutputBuiltinState {
14
14
pub base : usize ,
15
15
pub pages : Pages ,
16
16
pub attributes : Attributes ,
17
+ pub base_offset : usize ,
17
18
}
18
19
19
20
#[ derive( Debug , Clone ) ]
@@ -23,6 +24,7 @@ pub struct OutputBuiltinRunner {
23
24
pub ( crate ) attributes : Attributes ,
24
25
pub ( crate ) stop_ptr : Option < usize > ,
25
26
pub ( crate ) included : bool ,
27
+ pub base_offset : usize ,
26
28
}
27
29
28
30
impl OutputBuiltinRunner {
@@ -33,15 +35,17 @@ impl OutputBuiltinRunner {
33
35
attributes : HashMap :: default ( ) ,
34
36
stop_ptr : None ,
35
37
included,
38
+ base_offset : 0 ,
36
39
}
37
40
}
38
41
39
- pub fn new_state ( & mut self , base : usize , included : bool ) {
42
+ pub fn new_state ( & mut self , base : usize , included : bool , base_offset : usize ) {
40
43
self . base = base;
41
44
self . pages = HashMap :: default ( ) ;
42
45
self . attributes = HashMap :: default ( ) ;
43
46
self . stop_ptr = None ;
44
47
self . included = included;
48
+ self . base_offset = base_offset;
45
49
}
46
50
47
51
pub fn initialize_segments ( & mut self , segments : & mut MemorySegmentManager ) {
@@ -145,13 +149,15 @@ impl OutputBuiltinRunner {
145
149
self . base = new_state. base ;
146
150
self . pages = new_state. pages ;
147
151
self . attributes = new_state. attributes ;
152
+ self . base_offset = new_state. base_offset ;
148
153
}
149
154
150
155
pub fn get_state ( & mut self ) -> OutputBuiltinState {
151
156
OutputBuiltinState {
152
157
base : self . base ,
153
158
pages : self . pages . clone ( ) ,
154
159
attributes : self . attributes . clone ( ) ,
160
+ base_offset : self . base_offset ,
155
161
}
156
162
}
157
163
@@ -168,7 +174,7 @@ impl OutputBuiltinRunner {
168
174
self . pages . insert (
169
175
page_id,
170
176
PublicMemoryPage {
171
- start : page_start. offset ,
177
+ start : page_start. offset - self . base_offset ,
172
178
size : page_size,
173
179
} ,
174
180
) ;
0 commit comments