aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/lib/io.felan2
-rw-r--r--code/lib/string.felan12
-rw-r--r--code/main.felan7
3 files changed, 14 insertions, 7 deletions
diff --git a/code/lib/io.felan b/code/lib/io.felan
index 413da8d..d470331 100644
--- a/code/lib/io.felan
+++ b/code/lib/io.felan
@@ -72,7 +72,7 @@ _print_unsigned :: (comptime t:type, value:t) -> void {
} {}
while i < NUMBERS_SIZE - 1 {
- @putc(numbers[i]);
+ print_char(numbers[i]);
i += 1;
}
return;
diff --git a/code/lib/string.felan b/code/lib/string.felan
index 4b5452f..789b0fb 100644
--- a/code/lib/string.felan
+++ b/code/lib/string.felan
@@ -67,6 +67,16 @@ _grow_if_needed :: (this:*String, count:u64) -> void {
}
};
+slice :: (this:String, begin:i64, end:i64) -> String {
+ result:String = undefined;
+
+ result.ptr = this.ptr + begin;
+ result.size = @cast(end-begin,u64);
+ result.capacity = 0u64;
+
+ return result;
+};
+
delete :: (this:String) -> void {
free(this.ptr);
};
@@ -74,7 +84,7 @@ delete :: (this:String) -> void {
print :: (this:String) -> void {
i := 0u64;
while i < this.size {
- @putc(this[i]);
+ print_char(this[i]);
i += 1u64;
}
};
diff --git a/code/main.felan b/code/main.felan
index e365c37..44f620f 100644
--- a/code/main.felan
+++ b/code/main.felan
@@ -4,12 +4,9 @@ main :: () -> void {
// print_formatted("hello");
str := string_from("Hey");
- print(str);
- print_char('\n');
- _grow_if_needed(&str,23u64);
- // append(&str,"\nHello");
+ append(&str,"\nHello");
- print(str);
+ print(slice(str,4,7));
delete(str);
};