blob: 239a2012b50d764228135b8a6f904a2645a5ca32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
@import("basic.felan");
@import("lib/memory.felan");
print :: (value:**anytype)->void{
if comptime @type_of(value.*) == u8 {
@putc(value.*);
}else{
@putc('h');
}
};
__get_item__ :: (left:*anytype,index:i64) -> (@type_of(left.*)) {
return (left + index).*;
};
__set_item__ :: (left:*anytype,index:i64,item:@type_of(left.*)) -> (@type_of(left.*)) {
return (left + index).* = item;
};
__get_item_address__ :: (left:*anytype,index:i64,item:@type_of(left.*)) -> (@type_of(left)) {
return (left + index);
};
main :: ()->void{
arr :array(@cast(10,u64),i64) = undefined;
arr.ptr = @stack_alloc(10,i64);
i := 0;
while i < 10 {
__set_item__(arr.ptr,i,0);
i += 1;
}
print(__get_item__(arr.ptr,1));
free(@cast(arr.ptr,*void));
};
|