mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-23 00:18:24 +00:00
fixes
This commit is contained in:
parent
bab8eec51f
commit
84e6cc630e
14
simple.ed
14
simple.ed
|
@ -7,12 +7,18 @@ fn test(x: Hello) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn works(x: i32) -> i32 {
|
fn works(x: i64) -> i64 {
|
||||||
return x * 4;
|
let z: i64 = 0;
|
||||||
|
if x == 2 {
|
||||||
|
z = x * 2;
|
||||||
|
} else {
|
||||||
|
z = x * 3;
|
||||||
|
}
|
||||||
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> i32 {
|
fn main() -> i64 {
|
||||||
let y = 2;
|
let y: i64 = 2;
|
||||||
let z = y;
|
let z = y;
|
||||||
return works(z);
|
return works(z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
self.functions.get(function).unwrap().clone().1
|
self.functions.get(function).unwrap().clone().1
|
||||||
}
|
}
|
||||||
Expression::BinaryOp(lhs, op, rhs) => match op {
|
Expression::BinaryOp(lhs, op, rhs) => match op {
|
||||||
OpCode::Eq | OpCode::Ne => Some(TypeExp::Boolean),
|
//OpCode::Eq | OpCode::Ne => Some(TypeExp::Boolean),
|
||||||
_ => self
|
_ => self
|
||||||
.find_expr_type(lhs, variables)
|
.find_expr_type(lhs, variables)
|
||||||
.or_else(|| self.find_expr_type(rhs, variables)),
|
.or_else(|| self.find_expr_type(rhs, variables)),
|
||||||
|
@ -386,8 +386,9 @@ impl<'ctx> CodeGen<'ctx> {
|
||||||
body,
|
body,
|
||||||
else_body,
|
else_body,
|
||||||
} => {
|
} => {
|
||||||
|
let type_hint = self.find_expr_type(condition, variables);
|
||||||
let (condition, _cond_type) = self
|
let (condition, _cond_type) = self
|
||||||
.compile_expression(condition, variables, types, Some(TypeExp::Boolean))?
|
.compile_expression(condition, variables, types, type_hint)?
|
||||||
.expect("should produce a value");
|
.expect("should produce a value");
|
||||||
|
|
||||||
let mut if_block = self.context.append_basic_block(function_value, "if");
|
let mut if_block = self.context.append_basic_block(function_value, "if");
|
||||||
|
|
Loading…
Reference in a new issue