Skip to content

Commit 4f70b58

Browse files
Ivan Chinenovbnjbvr
authored andcommitted
Update for latest cranelift
1 parent aee927d commit 4f70b58

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Toy language implemented using cranelift-jit"
88
edition = "2018"
99

1010
[dependencies]
11-
cranelift = "0.69.0"
12-
cranelift-module = "0.69.0"
13-
cranelift-jit = "0.69.0"
1411
peg = "0.6"
12+
cranelift = "0.78.0"
13+
cranelift-module = "0.78.0"
14+
cranelift-jit = "0.78.0"

‎src/jit.rs‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl JIT {
4242
pub fn compile(&mut self, input: &str) -> Result<*const u8, String> {
4343
// First, parse the string, producing AST nodes.
4444
let (name, params, the_return, stmts) =
45-
parser::function(&input).map_err(|e| e.to_string())?;
45+
parser::function(input).map_err(|e| e.to_string())?;
4646

4747
// Then, translate the AST nodes into Cranelift IR.
4848
self.translate(params, the_return, stmts)?;
@@ -64,7 +64,12 @@ impl JIT {
6464
// defined. For this toy demo for now, we'll just finalize the
6565
// function below.
6666
self.module
67-
.define_function(id, &mut self.ctx, &mut codegen::binemit::NullTrapSink {})
67+
.define_function(
68+
id,
69+
&mut self.ctx,
70+
&mut codegen::binemit::NullTrapSink {},
71+
&mut codegen::binemit::NullStackMapSink {},
72+
)
6873
.map_err(|e| e.to_string())?;
6974

7075
// Now that compilation is finished, we can clear out the context state.
@@ -427,15 +432,15 @@ fn declare_variables_in_stmt(
427432
}
428433
Expr::IfElse(ref _condition, ref then_body, ref else_body) => {
429434
for stmt in then_body {
430-
declare_variables_in_stmt(int, builder, variables, index, &stmt);
435+
declare_variables_in_stmt(int, builder, variables, index, stmt);
431436
}
432437
for stmt in else_body {
433-
declare_variables_in_stmt(int, builder, variables, index, &stmt);
438+
declare_variables_in_stmt(int, builder, variables, index, stmt);
434439
}
435440
}
436441
Expr::WhileLoop(ref _condition, ref loop_body) => {
437442
for stmt in loop_body {
438-
declare_variables_in_stmt(int, builder, variables, index, &stmt);
443+
declare_variables_in_stmt(int, builder, variables, index, stmt);
439444
}
440445
}
441446
_ => (),

0 commit comments

Comments
 (0)