Unified · Split
| @@ -22,6 +22,7 @@ init(args: list of string) · 21 unmodified lines | |||
| 22 | args = tl args; | 22 | args = tl args; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | test_poly(); | ||
| 25 | test_function_refs(); | 26 | test_function_refs(); |
| 26 | test_alt(); | 27 | test_alt(); |
| 27 | test_channel(); | 28 | test_channel(); |
| @@ -39,6 +40,44 @@ init(args: list of string) · 11 unmodified lines | |||
| 39 | test_for_loop_function_call(); | 40 | test_for_loop_function_call(); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 43 | reverse[T](l: list of T): list of T | ||
| 44 | { | ||
| 45 | rl: list of T; | ||
| 46 | for(; l != nil; l = tl l) | ||
| 47 | rl = hd l :: rl; | ||
| 48 | return rl; | ||
| 49 | } | ||
| 50 | |||
| 51 | equal[T](l, r: list of T): int | ||
| 52 | { | ||
| 53 | l_v, r_v : T; | ||
| 54 | l_v = hd l; | ||
| 55 | r_v = hd r; | ||
| 56 | l = tl l; | ||
| 57 | r = tl r; | ||
| 58 | |||
| 59 | while (l_v == r_v) | ||
| 60 | { | ||
| 61 | l_v = hd l; | ||
| 62 | r_v = hd r; | ||
| 63 | l = tl l; | ||
| 64 | r = tl r; | ||
| 65 | |||
| 66 | if (l == nil || r == nil) | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | |||
| 70 | return l == r; | ||
| 71 | } | ||
| 72 | |||
| 73 | test_poly() | ||
| 74 | { | ||
| 75 | sys->print("test_poly()\n"); | ||
| 76 | l1 := list of {"a", "b", "c"}; | ||
| 77 | l2 := reverse(l1); | ||
| 78 | if (!equal(l1, reverse(l2)) != 0) raise TEST_FAILED(); | ||
| 79 | } | ||
| 80 | |||
| 42 | str_cmp(s1: string, s2: string): int | 81 | str_cmp(s1: string, s2: string): int |
| 43 | { | 82 | { |
| 44 | if (s1 < s2) | 83 | if (s1 < s2) |
| @@ -599,10 +599,7 @@ namespace · 598 unmodified lines | |||
| 599 | case type_class_t::integer: return "int"; | 599 | case type_class_t::integer: return "int"; |
| 600 | case type_class_t::real: return "real"; | 600 | case type_class_t::real: return "real"; |
| 601 | case type_class_t::string: return "string"; | 601 | case type_class_t::string: return "string"; |
| 602 | 602 | case type_class_t::poly: return "*"; | |
| 603 | case type_class_t::poly: | ||
| 604 | assert(false && "Not fully implemented"); | ||
| 605 | return "poly<T>"; | ||
| 606 | 603 | ||
| 607 | case type_class_t::array: | 604 | case type_class_t::array: |
| 608 | return "array of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt); | 605 | return "array of " + to_string(tt.resolve_table_index<type_t>(t.value_index_1), tt); |
| @@ -1094,7 +1094,7 @@ namespace · 1093 unmodified lines | |||
| 1094 | EXEC_DECL(newcl) { _newc_(r, vm, intrinsic_type_desc::type<big_t>(), _mov_<big_t>); } | 1094 | EXEC_DECL(newcl) { _newc_(r, vm, intrinsic_type_desc::type<big_t>(), _mov_<big_t>); } |
| 1095 | EXEC_DECL(newcp) { _newc_(r, vm, intrinsic_type_desc::type<pointer_t>(), _mov_<vm_alloc_t>); } | 1095 | EXEC_DECL(newcp) { _newc_(r, vm, intrinsic_type_desc::type<pointer_t>(), _mov_<vm_alloc_t>); } |
| 1096 | 1096 | ||
| 1097 | EXEC_DECL(newcm) | 1097 | EXEC_DECL(newcm) |
| 1098 | { | 1098 | { |
| 1099 | auto memory_size = vt_ref<word_t>(r.src); | 1099 | auto memory_size = vt_ref<word_t>(r.src); |
| 1100 | auto channel_data_type = type_descriptor_t::create(memory_size); | 1100 | auto channel_data_type = type_descriptor_t::create(memory_size); |