File tree Expand file tree Collapse file tree 5 files changed +137
-0
lines changed Expand file tree Collapse file tree 5 files changed +137
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ typedef as_ptr blob_iter_t; // the data structure used to iterate a text value
17
17
export blob_iter_t blob_iter (blob_t s ) {
18
18
as_ptr i = alloc_words (TUPLE_HEADER_SIZE + 2 );
19
19
TAG (i ) = TAG_ARRAY ;
20
+ TUPLE_LEN (i ) = 2 ;
20
21
BLOB_ITER_BLOB (i ) = s ;
21
22
BLOB_ITER_POS (i ) = 0 ;
22
23
return i ;
Original file line number Diff line number Diff line change @@ -297,6 +297,7 @@ static blob_t find_leaf(text_t s, text_iter_cont_t *todo) {
297
297
while (TAG (s ) == TAG_CONCAT ) {
298
298
as_ptr c = alloc_words (TUPLE_HEADER_SIZE + 2 );
299
299
TAG (c ) = TAG_ARRAY ;
300
+ TUPLE_LEN (c ) = 2 ;
300
301
TEXT_CONT_TEXT (c ) = CONCAT_ARG2 (s );
301
302
TEXT_CONT_NEXT (c ) = * todo ;
302
303
* todo = c ;
@@ -308,6 +309,7 @@ static blob_t find_leaf(text_t s, text_iter_cont_t *todo) {
308
309
export text_iter_t text_iter (text_t s ) {
309
310
as_ptr i = alloc_words (TUPLE_HEADER_SIZE + 3 );
310
311
TAG (i ) = TAG_ARRAY ;
312
+ TUPLE_LEN (i ) = 3 ;
311
313
TEXT_ITER_POS (i ) = 0 ;
312
314
TEXT_ITER_TODO (i ) = 0 ;
313
315
TEXT_ITER_BLOB (i ) = find_leaf (s , & TEXT_ITER_TODO (i ));
Original file line number Diff line number Diff line change
1
+ import Prim "mo:prim" ;
2
+ // check blob and text iterator objects survive gc correctly
3
+ actor {
4
+ public shared func testBytes() : async () {
5
+ let blob = " \0 0 \0 1 \0 2 \0 3" : Blob ;
6
+ for (b in blob. bytes()) {
7
+ await async {};
8
+ Prim . debugPrint(debug_show b);
9
+ };
10
+ };
11
+
12
+ public shared func testChars() : async () {
13
+ let text = "abcd" # "efgh" # "hijklmnopqrstuvwxyz" ;
14
+ for (c in text. chars()) {
15
+ await async {};
16
+ Prim . debugPrint(debug_show c);
17
+ };
18
+ };
19
+
20
+ public shared func testArray() : async () {
21
+ let is = ["0" ,"1" ,"2" ];
22
+ for (i in is. vals()) {
23
+ await async {};
24
+ Prim . debugPrint(debug_show i);
25
+ };
26
+ };
27
+
28
+
29
+ public shared func testArrayMut() : async () {
30
+ let is = [var "0" ,"1" ,"2" ];
31
+ for (i in is. vals()) {
32
+ await async {};
33
+ Prim . debugPrint(debug_show i);
34
+ };
35
+ };
36
+ }
37
+
38
+ // CALL ingress testBytes "DIDL\x00\x00"
39
+ // CALL ingress testChars "DIDL\x00\x00"
40
+ // CALL ingress testArray "DIDL\x00\x00"
41
+ // CALL ingress testArrayMut "DIDL\x00\x00"
42
+
Original file line number Diff line number Diff line change
1
+ ingress Completed: Reply: 0x4449444c016c01b3c4b1f2046801000112010000000000000000000000000000000001
2
+ ingress Completed: Reply: 0x4449444c0000
3
+ debug.print: 0x0
4
+ debug.print: 0x1
5
+ debug.print: 0x2
6
+ debug.print: 0x3
7
+ ingress Completed: Reply: 0x4449444c0000
8
+ debug.print: 'a'
9
+ debug.print: 'b'
10
+ debug.print: 'c'
11
+ debug.print: 'd'
12
+ debug.print: 'e'
13
+ debug.print: 'f'
14
+ debug.print: 'g'
15
+ debug.print: 'h'
16
+ debug.print: 'h'
17
+ debug.print: 'i'
18
+ debug.print: 'j'
19
+ debug.print: 'k'
20
+ debug.print: 'l'
21
+ debug.print: 'm'
22
+ debug.print: 'n'
23
+ debug.print: 'o'
24
+ debug.print: 'p'
25
+ debug.print: 'q'
26
+ debug.print: 'r'
27
+ debug.print: 's'
28
+ debug.print: 't'
29
+ debug.print: 'u'
30
+ debug.print: 'v'
31
+ debug.print: 'w'
32
+ debug.print: 'x'
33
+ debug.print: 'y'
34
+ debug.print: 'z'
35
+ ingress Completed: Reply: 0x4449444c0000
36
+ debug.print: "0"
37
+ debug.print: "1"
38
+ debug.print: "2"
39
+ ingress Completed: Reply: 0x4449444c0000
40
+ debug.print: "0"
41
+ debug.print: "1"
42
+ debug.print: "2"
43
+ ingress Completed: Reply: 0x4449444c0000
Original file line number Diff line number Diff line change
1
+ → update create_canister()
2
+ ← completed: (record {1313628723 = service "cvccv-qqaaq-aaaaa-aaaaa-c"})
3
+ → update install_code(record {4849238 = blob ""; 265441191 = blob "\00asm\01\00\0…
4
+ ← completed: ()
5
+ → update testBytes()
6
+ debug.print: 0x0
7
+ debug.print: 0x1
8
+ debug.print: 0x2
9
+ debug.print: 0x3
10
+ ← completed: ()
11
+ → update testChars()
12
+ debug.print: 'a'
13
+ debug.print: 'b'
14
+ debug.print: 'c'
15
+ debug.print: 'd'
16
+ debug.print: 'e'
17
+ debug.print: 'f'
18
+ debug.print: 'g'
19
+ debug.print: 'h'
20
+ debug.print: 'h'
21
+ debug.print: 'i'
22
+ debug.print: 'j'
23
+ debug.print: 'k'
24
+ debug.print: 'l'
25
+ debug.print: 'm'
26
+ debug.print: 'n'
27
+ debug.print: 'o'
28
+ debug.print: 'p'
29
+ debug.print: 'q'
30
+ debug.print: 'r'
31
+ debug.print: 's'
32
+ debug.print: 't'
33
+ debug.print: 'u'
34
+ debug.print: 'v'
35
+ debug.print: 'w'
36
+ debug.print: 'x'
37
+ debug.print: 'y'
38
+ debug.print: 'z'
39
+ ← completed: ()
40
+ → update testArray()
41
+ debug.print: "0"
42
+ debug.print: "1"
43
+ debug.print: "2"
44
+ ← completed: ()
45
+ → update testArrayMut()
46
+ debug.print: "0"
47
+ debug.print: "1"
48
+ debug.print: "2"
49
+ ← completed: ()
You can’t perform that action at this time.
0 commit comments