-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: builtin functions imported by default
- Loading branch information
1 parent
6fad360
commit fc15b3f
Showing
4 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import std:builtin | ||
|
||
func main() u32 { | ||
let u32[] a = [1, 2, 3] | ||
let u32 b = builtin:len(a) | ||
let u32[] a = [1, 2, 3, 2] | ||
let u32 b = len(a) | ||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#[repr(C)] | ||
pub struct Array { | ||
pub len: u64, | ||
pub data: *const u32, | ||
pub data: *const u32, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn __std__builtin__len(arr: Array) -> u64 { | ||
let len = unsafe { &*(arr.len as *const u64) }; | ||
return *len; | ||
pub extern "C" fn __builtin__len(arr: *const Array) -> u64 { | ||
let deref_arr = unsafe { &*(arr) }; | ||
return deref_arr.len; | ||
} |