about summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-05-27 19:51:27 +0200
committerBaitinq <[email protected]>2025-05-27 20:38:24 +0200
commit342d5d74be0d839574d05b852a13d2145d9335e3 (patch)
tree90dfe9e96d88cc6ef03061080bfde3783bb77d41 /examples
parentFeature: Start adding structs support (diff)
downloadpry-lang-342d5d74be0d839574d05b852a13d2145d9335e3.tar.gz
pry-lang-342d5d74be0d839574d05b852a13d2145d9335e3.tar.bz2
pry-lang-342d5d74be0d839574d05b852a13d2145d9335e3.zip
Feature: Finish adding struct support :^)
Diffstat (limited to 'examples')
-rw-r--r--examples/22.src23
1 files changed, 17 insertions, 6 deletions
diff --git a/examples/22.src b/examples/22.src
index 9d73d1a..b984202 100644
--- a/examples/22.src
+++ b/examples/22.src
@@ -1,3 +1,5 @@
+extern malloc = (i64) => *void;
+
 import "!stdlib.src";
 
 /* declare new struct type */
@@ -10,13 +12,22 @@ let test = struct {
 let main = () => i64 {
 	/* instanciate new struct. instanciating fields isn't supported here */
 	let inst = test{};
+
 	inst.x = 2;
-	inst.y = "hello";
 	inst.z = true;
+	inst.y = malloc(1);
+	(*(inst.y)) = 5;
+
+	let x = 0;
 
 	println("Inst x: %d", inst.x);
-	println("Inst y: %s", inst.y);
-	println("Inst z: %d", inst.z);
+	println("Inst y: %d", *(inst.y));
+
+	if inst.z {
+		x = 1;
+	};
+
+	println("Test: %d", x);
 
 	return 0;
 };
@@ -25,9 +36,9 @@ let main = () => i64 {
 
 Expected stdout:
 
-2
-hello
-1
+Inst x: 2
+Inst y: 5
+Test: 1
 
 Expected return: 0