Skip to content

Commit 79b9c73

Browse files
committed
feat: added malloc in the example
1 parent cc6efcd commit 79b9c73

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

examples/sample.qf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
static staticstr bobby = "\nHellossssss %d"
22

33
shadowfunc printf(ptr str_ptr) si32
4+
shadowfunc malloc(un64 sz) ptr
45

56
func main() si32 {
67
var si32 test = 65_si32
78

9+
malloc(544_un64)
10+
811
printf(bobby, test)
912

1013
ret 0_si32

ir/src/conv/val.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ pub fn parse_ir_value<'a>(lctx: Option<&IRLocalContext>, ctx: &IRContext, node:
2929
return Err(PositionlessError::new("Invalid type storage! integer type indicator not found!"));
3030
}
3131

32-
return Ok(IRValueRef::from_val(IRValue::from_signed(ctx, t.unwrap(), *v as i128)?));
32+
if t.as_ref().unwrap().is_signed() {
33+
return Ok(IRValueRef::from_val(IRValue::from_signed(ctx, t.as_ref().unwrap().clone(), *v as i128)?));
34+
} else {
35+
return Ok(IRValueRef::from_val(IRValue::from_unsigned(ctx, t.as_ref().unwrap().clone(), *v as u128)?));
36+
}
3337
},
3438

3539
ASTTreeNode::StringLit(v) => {

0 commit comments

Comments
 (0)