summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/arr.toc11
-rw-r--r--std/io.toc12
2 files changed, 5 insertions, 18 deletions
diff --git a/std/arr.toc b/std/arr.toc
index 12d44f5..24fdf9f 100644
--- a/std/arr.toc
+++ b/std/arr.toc
@@ -1,13 +1,10 @@
-// array package
-pkg "arr";
-
-#export Arr ::= fn (t :: Type) Type {
+Arr ::= fn (t :: Type) Type {
struct {
data : []t;
cap : int;
}
};
-#export arr_add ::= fn(t ::=, a : &Arr(t), x : t) {
+arr_add ::= fn(t ::=, a : &Arr(t), x : t) {
if a.data.len >= a.cap {
a.cap = a.cap * 2 + 2;
new_data := new(t, a.cap);
@@ -17,7 +14,7 @@ pkg "arr";
}
a.data = new_data;
}
- a.data[a.data.len] = x;
a.data.len += 1;
+ a.data[a.data.len-1] = x;
};
-#export arr_len ::= fn(t ::=, a : Arr(t)) int { a.data.len };
+arr_len ::= fn(t ::=, a : Arr(t)) int { a.data.len };
diff --git a/std/io.toc b/std/io.toc
index e9d73d6..dab2aea 100644
--- a/std/io.toc
+++ b/std/io.toc
@@ -1,5 +1,3 @@
-pkg "io";
-
get_type_with_size ::= fn(size :: i64) Type {
if size == 1 { i8 }
elif size == 2 { i16 }
@@ -30,15 +28,7 @@ stdout_fwrite ::= fn(data: &u8, size: u64, nmemb: u64) {
c_fwrite(data, size as c_size_t, nmemb as c_size_t, #builtin("stdout"));
};
-#export puts ::= fn(x: []char) {
+puts ::= fn(x: []char) {
stdout_fwrite(&x[0] as &u8, 1, x.len as u64);
toc_putchar('\n');
};
-
-arr ::= pkg "arr";
-
-#export puts_arr ::= fn(x: arr.Arr([]char)) {
- for s := x.data {
- puts(s);
- }
-}; \ No newline at end of file