From 21ac6662c43b87ed678c9cb6d7c911cc1a9f76cb Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Sun, 9 Oct 2022 14:17:48 +0200 Subject: [PATCH] Dynamic typing example --- examples/dynamic_typing.core | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/dynamic_typing.core diff --git a/examples/dynamic_typing.core b/examples/dynamic_typing.core new file mode 100644 index 0000000..6152040 --- /dev/null +++ b/examples/dynamic_typing.core @@ -0,0 +1,16 @@ + +storage: [32]S64 +len : S64 + +"+" :: (a: Any, b: Any): Any + result: Any = storage[len++] + if a.type == S64 && b.type == S64 + *(result.data->*S64) = *(a.data->*S64) + *(b.data->*S64) + return result + +main :: (): int + a: Any = 10 + b: Any = 20 + c := a + b + Assert(c.type == S64 && *(c.data->*S64) == 30) + return 0 \ No newline at end of file