@effekt-lang/effekt 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,29 +8,6 @@ declare void @c_io_println_Int(%Int)
8
8
  declare void @c_io_println_Double(%Double)
9
9
  declare void @c_io_println_String(%Pos)
10
10
 
11
- declare %Pos @c_buffer_construct(i64, ptr)
12
- declare %Pos @c_buffer_concatenate(%Pos, %Pos)
13
- declare ptr @c_buffer_as_null_terminated_string(%Pos)
14
- declare %Pos @c_buffer_construct_from_null_terminated_string(ptr)
15
- declare ptr @c_buffer_construct_uninitialized(i64)
16
- declare ptr @c_buffer_bytes(ptr)
17
- declare void @c_buffer_copy(%Pos, %Pos, i64, i64, i64)
18
- declare %Pos @c_buffer_clone(%Pos)
19
-
20
- declare %Pos @c_buffer_eq(%Pos, %Pos)
21
- declare %Pos @c_buffer_substring(%Pos, i64, i64)
22
- declare i64 @c_buffer_length(%Pos)
23
- declare i64 @c_buffer_toInt(%Pos)
24
- declare %Pos @c_buffer_show_Int(i64)
25
- declare %Pos @c_buffer_show_Char(i32)
26
- declare %Pos @c_buffer_show_Byte(i8)
27
- declare %Pos @c_buffer_show_Double(double)
28
- declare %Int @c_buffer_index(%Pos, i64)
29
- declare void @c_buffer_set(%Pos, i64, i8)
30
- declare %Int @c_buffer_character_at(%Pos, i64)
31
-
32
- declare %Pos @c_buffer_slice(%Pos, i64, i64)
33
-
34
11
  declare void @hole()
35
12
 
36
13
  declare %Pos @c_ref_fresh(%Pos)
@@ -41,3 +18,26 @@ declare %Pos @c_array_new(%Int)
41
18
  declare %Int @c_array_size(%Pos)
42
19
  declare %Pos @c_array_get(%Pos, %Int)
43
20
  declare %Pos @c_array_set(%Pos, %Int, %Pos)
21
+
22
+ declare %Pos @c_bytearray_new(%Int)
23
+ declare %Int @c_bytearray_size(%Pos)
24
+ declare %Byte @c_bytearray_get(%Pos, %Int)
25
+ declare %Pos @c_bytearray_set(%Pos, %Int, %Byte)
26
+
27
+ declare ptr @c_bytearray_data(%Pos)
28
+ declare %Pos @c_bytearray_construct(i64, ptr)
29
+
30
+ declare %Pos @c_bytearray_from_nullterminated_string(ptr)
31
+ declare ptr @c_bytearray_into_nullterminated_string(%Pos)
32
+
33
+ declare %Pos @c_bytearray_show_Int(i64)
34
+ declare %Pos @c_bytearray_show_Char(i32)
35
+ declare %Pos @c_bytearray_show_Byte(i8)
36
+ declare %Pos @c_bytearray_show_Double(double)
37
+
38
+ declare %Pos @c_bytearray_concatenate(%Pos, %Pos)
39
+ declare %Pos @c_bytearray_equal(%Pos, %Pos)
40
+
41
+ declare %Pos @c_bytearray_substring(%Pos, i64, i64)
42
+ declare %Int @c_bytearray_character_at(%Pos, i64)
43
+
@@ -20,8 +20,8 @@ void c_io_println_Double(const Double x) {
20
20
  }
21
21
 
22
22
  void c_io_println_String(String text) {
23
- for (uint64_t j = 0; j < c_buffer_length(text); ++j)
24
- putchar(c_buffer_bytes(text)[j]);
23
+ for (int64_t j = 0; j < c_bytearray_size(text); ++j)
24
+ putchar(c_bytearray_data(text)[j]);
25
25
  erasePositive(text);
26
26
  putchar('\n');
27
27
  }
@@ -34,7 +34,7 @@ void c_io_println_String(String text) {
34
34
  // Share memory between Effekt-buffers and libuv buffers
35
35
  // -----------------------------------------------------
36
36
  // A libuv buffer is a {ptr, i64} where i64 is the capacity
37
- // while our buffer (from buffer.c, which is ref-counted) is a %Pos with a
37
+ // while our buffer (from bytearray.c, which is ref-counted) is a %Pos with a
38
38
  // pointer and a length. The data ptr is shared between the two such that
39
39
  // libuv (and underlying mechanisms) can directly write into our buffer without
40
40
  // copying. Since our buffer is ref-counted, this has the advantage that we
@@ -96,10 +96,10 @@ int modeFlags(struct Pos mode) {
96
96
  }
97
97
  }
98
98
 
99
- void c_fs_open(struct Pos path, struct Pos mode, Stack stack) {
99
+ void c_fs_open(String path, struct Pos mode, Stack stack) {
100
100
 
101
101
  // Convert the Effekt String to a 0-terminated string
102
- char* path_str = c_buffer_as_null_terminated_string(path);
102
+ char* path_str = c_bytearray_into_nullterminated_string(path);
103
103
  erasePositive((struct Pos) path);
104
104
 
105
105
  // Convert the Effekt String representing the opening mode to libuv flags
@@ -123,17 +123,16 @@ void c_fs_open(struct Pos path, struct Pos mode, Stack stack) {
123
123
  return;
124
124
  }
125
125
 
126
- void c_fs_read(Int fd, struct Pos buffer, Int offset, Stack stack) {
126
+ void c_fs_read(Int file, struct Pos buffer, Int offset, Int size, Int position, Stack stack) {
127
127
 
128
- char* bytes = (char*)c_buffer_bytes(buffer); // libuv expects signed integers
129
- uv_buf_t buf = uv_buf_init(bytes, c_buffer_length(buffer));
128
+ uv_buf_t buf = uv_buf_init((char*)(c_bytearray_data(buffer) + offset), size);
130
129
  // erasePositive(buffer);
131
130
  // TODO we should erase the buffer but abort if this was the last reference
132
131
 
133
132
  uv_fs_t* request = malloc(sizeof(uv_fs_t));
134
133
  request->data = stack;
135
134
 
136
- int result = uv_fs_read(uv_default_loop(), request, fd, &buf, 1, offset, c_resume_int_fs);
135
+ int result = uv_fs_read(uv_default_loop(), request, file, &buf, 1, position, c_resume_int_fs);
137
136
 
138
137
  if (result < 0) {
139
138
  uv_fs_req_cleanup(request);
@@ -142,17 +141,16 @@ void c_fs_read(Int fd, struct Pos buffer, Int offset, Stack stack) {
142
141
  }
143
142
  }
144
143
 
145
- void c_fs_write(Int fd, struct Pos buffer, Int offset, Stack stack) {
144
+ void c_fs_write(Int file, struct Pos buffer, Int offset, Int size, Int position, Stack stack) {
146
145
 
147
- char* bytes = (char*)c_buffer_bytes(buffer); // libuv expects signed integers
148
- uv_buf_t buf = uv_buf_init(bytes, c_buffer_length(buffer));
146
+ uv_buf_t buf = uv_buf_init((char*)(c_bytearray_data(buffer) + offset), size);
149
147
  // erasePositive(buffer);
150
148
  // TODO we should erase the buffer but abort if this was the last reference
151
149
 
152
150
  uv_fs_t* request = malloc(sizeof(uv_fs_t));
153
151
  request->data = stack;
154
152
 
155
- int result = uv_fs_write(uv_default_loop(), request, fd, &buf, 1, offset, c_resume_int_fs);
153
+ int result = uv_fs_write(uv_default_loop(), request, file, &buf, 1, position, c_resume_int_fs);
156
154
 
157
155
  if (result < 0) {
158
156
  uv_fs_req_cleanup(request);
@@ -161,12 +159,12 @@ void c_fs_write(Int fd, struct Pos buffer, Int offset, Stack stack) {
161
159
  }
162
160
  }
163
161
 
164
- void c_fs_close(Int fd, Stack stack) {
162
+ void c_fs_close(Int file, Stack stack) {
165
163
 
166
164
  uv_fs_t* request = malloc(sizeof(uv_fs_t));
167
165
  request->data = stack;
168
166
 
169
- int result = uv_fs_close(uv_default_loop(), request, fd, c_resume_int_fs);
167
+ int result = uv_fs_close(uv_default_loop(), request, file, c_resume_int_fs);
170
168
 
171
169
  if (result < 0) {
172
170
  uv_fs_req_cleanup(request);
@@ -11,7 +11,7 @@
11
11
 
12
12
  #include "sanity.c"
13
13
  #include "types.c"
14
- #include "buffer.c"
14
+ #include "bytearray.c"
15
15
  #include "io.c"
16
16
  #include "hole.c"
17
17
  #include "ref.c"
@@ -25,9 +25,9 @@ char** program_argv;
25
25
 
26
26
  struct Pos c_get_arg(uint64_t idx) {
27
27
  if(idx < (uint64_t)program_argc) {
28
- return c_buffer_construct_from_null_terminated_string(program_argv[idx]);
28
+ return c_bytearray_from_nullterminated_string(program_argv[idx]);
29
29
  } else {
30
- return c_buffer_construct_zeroed(1);
30
+ return c_bytearray_new(0);
31
31
  }
32
32
  }
33
33
  uint64_t c_get_argc() {