From 0ca56ed853c3d9bc8c26d1b014d8b665363fc2d0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Sep 2016 01:01:58 -0700 Subject: 3355 --- html/058to_text.cc.html | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 html/058to_text.cc.html (limited to 'html/058to_text.cc.html') diff --git a/html/058to_text.cc.html b/html/058to_text.cc.html new file mode 100644 index 00000000..c79ad7fc --- /dev/null +++ b/html/058to_text.cc.html @@ -0,0 +1,62 @@ + + + + +Mu - 058to_text.cc + + + + + + + + + + +
+//: Primitive to convert any type to text (array of characters).
+//: Later layers will allow us to override this to do something smarter for
+//: specific types.
+
+:(before "End Mu Types Initialization")
+put(Type_abbreviations, "text", new_type_tree("address:array:character"));
+
+:(before "End Primitive Recipe Declarations")
+TO_TEXT,
+:(before "End Primitive Recipe Numbers")
+put(Recipe_ordinal, "to-text", TO_TEXT);
+:(before "End Primitive Recipe Checks")
+case TO_TEXT: {
+  if (SIZE(inst.ingredients) != 1) {
+    raise << maybe(get(Recipe, r).name) << "'to-text' requires a single ingredient, but got '" << inst.original_string << "'\n" << end();
+    break;
+  }
+  // can handle any type
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case TO_TEXT: {
+  products.resize(1);
+  products.at(0).push_back(new_mu_string(print_mu(current_instruction().ingredients.at(0), ingredients.at(0))));
+  break;
+}
+
+ + + -- cgit 1.4.1-2-gfad0