https://github.com/akkartik/mu/blob/master/038new_text.cc
1
2
3
4 :(before "End Mu Types Initialization")
5 put(Type_abbreviations, "text", new_type_tree("&:@:character"));
6
7 :(scenario new_string)
8 def main [
9 10:text <- new [abc def]
10 20:char <- index *10:text, 5
11 ]
12
13 +mem: storing 101 in location 20
14
15 :(scenario new_string_handles_unicode)
16 def main [
17 10:text <- new [a«c]
18 20:num <- length *10:text
19 21:char <- index *10:text, 1
20 ]
21 +mem: storing 3 in location 20
22
23 +mem: storing 171 in location 21
24
25 :(before "End NEW Check Special-cases")
26 if (is_literal_text(inst.ingredients.at(0))) break;
27 :(before "Convert 'new' To 'allocate'")
28 if (inst.name == "new" && !inst.ingredients.empty() && is_literal_text(inst.ingredients.at(0))) continue;
29 :(after "case NEW" following "Primitive Recipe Implementations")
30 if (is_literal_text(current_instruction().ingredients.at(0))) {
31 products.resize(1);
32 products.at(0).push_back(0);
33 products.at(0).push_back(new_mu_text(current_instruction().ingredients.at(0).name));
34 trace("mem") << "new string alloc: " << products.at(0).at(0) << end();
35 break;
36 }
37
38 :(code)
39 int generated by cgit-pink 1.4.1-2-gfad0 (git 2.36.2.497.gbbea4dcf42) at 2025-06-22 12:31:31 +0000