summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-04-15 18:59:14 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-04-15 18:59:14 +0330
commit52fac2c9232d39b3fe98438a47c22f985b260f58 (patch)
treefe95e62f933a28a29d92d274c8c0e1c93d60b79f /code
parent038bbfc95cf79e1be48b1926e9893e2a12a3b92a (diff)
some improvements for type system
Diffstat (limited to 'code')
-rw-r--r--code/main.felan77
1 files changed, 74 insertions, 3 deletions
diff --git a/code/main.felan b/code/main.felan
index a49972b..15dbe68 100644
--- a/code/main.felan
+++ b/code/main.felan
@@ -1,7 +1,46 @@
+ptr :: (t:type) -> type {
+ return struct {
+ address : u64;
+ t :: t;
+ };
+};
+
+array :: (t:type,length:u64)->type{
+ return struct {
+ ptr : *t;
+ length :: length;
+ };
+};
+
main :: () -> void {
- a : [10]u8 = undefined;
- a[0] = 2;
- print(123);
+ test : array(u64,@cast(8,u64)) = undefined;
+ test2 : array(u64,@cast(8,u64)) = undefined;
+ println(@typeOf(test) == @typeOf(test2));
+ test.ptr = null;
+ test.length;
+};
+
+print :: (value:[10]u8)->void{
+ println(23);
+};
+
+println :: ()->void{
+ putc '\n';
+};
+
+println :: (value:i64)->void{
+ print(value);
+ putc '\n';
+};
+
+println :: (value:u64)->void{
+ print(value);
+ putc '\n';
+};
+
+println :: (value:bool)->void{
+ print(value);
+ putc '\n';
};
print :: (value:i64)->void{
@@ -20,3 +59,35 @@ print :: (value:i64)->void{
i -= 1;
}
};
+
+print :: (value:u64)->void{
+ value := value;
+ a : [20]u8 = undefined;
+ i := 0;
+ while {
+ a[i] = '0' + @cast(value % 10,u8);
+ i += 1;
+ value /= 10;
+ value != 0;
+ } {}
+
+ while i > 0 {
+ putc a[i-1];
+ i -= 1;
+ }
+};
+
+print :: (value:bool)->void{
+ if value {
+ putc 't';
+ putc 'r';
+ putc 'u';
+ putc 'e';
+ }else{
+ putc 'f';
+ putc 'a';
+ putc 'l';
+ putc 's';
+ putc 'e';
+ }
+};