File tree 4 files changed +27
-7
lines changed
4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -740,7 +740,10 @@ fn generate_code_stmt(
740
740
is_last_instr,
741
741
) ;
742
742
let body_len = get_instructions_length ( & body) as i16 ;
743
- result. push ( Instruction :: ifeq ( 3 + body_len, body. len ( ) as i16 + 1 ) ) ;
743
+ result. push ( Instruction :: ifeq (
744
+ 2 + 1 + 3 + body_len,
745
+ body. len ( ) as i16 + 2 ,
746
+ ) ) ;
744
747
result. append ( & mut body) ;
745
748
result. push ( Instruction :: goto (
746
749
-3 - body_len - cond_len,
Original file line number Diff line number Diff line change @@ -438,7 +438,10 @@ impl StackMapFrame {
438
438
v
439
439
}
440
440
StackMapFrame :: CHOP ( chopped_amount, offset_delta) => {
441
- todo ! ( )
441
+ let mut v = Vec :: with_capacity ( 8 ) ;
442
+ v. push ( * chopped_amount) ;
443
+ v. extend_from_slice ( & offset_delta. to_be_bytes ( ) ) ;
444
+ v
442
445
}
443
446
StackMapFrame :: APPEND ( appended_amount, offset_delta, types) => {
444
447
let mut v = Vec :: with_capacity ( 16 ) ;
Original file line number Diff line number Diff line change @@ -217,6 +217,23 @@ fn fib_class() -> Class {
217
217
) ) ) ,
218
218
Type :: Int ,
219
219
) ,
220
+ TypedStmt (
221
+ Box :: new( LocalVarDecl ( Type :: Int , "next" . to_string( ) ) ) ,
222
+ Type :: Int ,
223
+ ) ,
224
+ TypedStmt (
225
+ Box :: new( StmtExprStmt ( TypedStmtExpr (
226
+ Box :: new( Assign (
227
+ Expr :: TypedExpr (
228
+ Box :: new( Expr :: LocalVar ( "next" . to_string( ) ) ) ,
229
+ Type :: Int ,
230
+ ) ,
231
+ TypedExpr ( Box :: new( Expr :: Integer ( 0 ) ) , Type :: Int ) ,
232
+ ) ) ,
233
+ Type :: Int ,
234
+ ) ) ) ,
235
+ Type :: Int ,
236
+ ) ,
220
237
TypedStmt (
221
238
Box :: new( While (
222
239
TypedExpr (
@@ -235,10 +252,6 @@ fn fib_class() -> Class {
235
252
) ,
236
253
Box :: new( TypedStmt (
237
254
Box :: new( Block ( vec![
238
- TypedStmt (
239
- Box :: new( LocalVarDecl ( Type :: Int , "next" . to_string( ) ) ) ,
240
- Type :: Int ,
241
- ) ,
242
255
TypedStmt (
243
256
Box :: new( StmtExprStmt ( TypedStmtExpr (
244
257
Box :: new( Assign (
Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ int iter(int n) {
14
14
int x = 0 ;
15
15
int y = 1 ;
16
16
int i = 1 ;
17
+ int next = 0 ;
17
18
while (i < n ) {
18
- int next = y + x ;
19
+ next = y + x ;
19
20
x = y ;
20
21
y = next ;
21
22
i = i + 1 ;
You can’t perform that action at this time.
0 commit comments