From 5497090aa1e708c22cd240913a53dda32bb067aa Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 13 May 2015 10:03:26 -0700 Subject: 1363 - rename 'integer' to 'number' ..now that we support non-integers. --- 010vm.cc | 10 +- 011load.cc | 58 +++++----- 014types.cc | 8 +- 020run.cc | 12 +-- 021arithmetic.cc | 53 ++++----- 023jump.cc | 10 +- 024compare.cc | 92 ++++++++-------- 030container.cc | 82 +++++++------- 031address.cc | 34 +++--- 032array.cc | 68 ++++++------ 033length.cc | 10 +- 034exclusive_container.cc | 32 +++--- 035call.cc | 12 +-- 036call_ingredient.cc | 14 +-- 037call_reply.cc | 24 ++--- 038scheduler.cc | 47 ++++---- 039wait.cc | 18 ++-- 040brace.cc | 88 +++++++-------- 041name.cc | 38 +++---- 042new.cc | 28 ++--- 043space.cc | 34 +++--- 044space_surround.cc | 8 +- 045closure_name.cc | 14 +-- 046tangle.cc | 58 +++++----- 047jump_label.cc | 20 ++-- 050scenario.cc | 30 +++--- 051scenario_test.mu | 12 +-- 060string.mu | 190 ++++++++++++++++---------------- 061channel.mu | 154 +++++++++++++------------- 062array.mu | 14 +-- 071print.mu | 162 ++++++++++++++-------------- 074keyboard.mu | 16 +-- Readme.md | 40 +++---- channel.mu | 22 ++-- chessboard.mu | 270 +++++++++++++++++++++++----------------------- counters.mu | 14 +-- display.mu | 2 +- factorial.mu | 18 ++-- screen.mu | 2 +- tangle.mu | 16 +-- x.mu | 6 +- 41 files changed, 922 insertions(+), 918 deletions(-) diff --git a/010vm.cc b/010vm.cc index 95b1f3ad..9b1641bd 100644 --- a/010vm.cc +++ b/010vm.cc @@ -64,7 +64,7 @@ Memory.clear(); :(after "Types") // Mu types encode how the numbers stored in different parts of memory are // interpreted. A location tagged as a 'character' type will interpret the -// number 97 as the letter 'a', while a different location of type 'integer' +// number 97 as the letter 'a', while a different location of type 'number' // would not. // // Unlike most computers today, mu stores types in a single big table, shared @@ -81,9 +81,9 @@ void setup_types() { Type_number["literal"] = 0; Next_type_number = 1; // Mu Types Initialization - type_number integer = Type_number["integer"] = Next_type_number++; - Type_number["location"] = Type_number["integer"]; // wildcard type: either a pointer or a scalar - Type[integer].name = "integer"; + type_number number = Type_number["number"] = Next_type_number++; + Type_number["location"] = Type_number["number"]; // wildcard type: either a pointer or a scalar + Type[number].name = "number"; type_number address = Type_number["address"] = Next_type_number++; Type[address].name = "address"; type_number boolean = Type_number["boolean"] = Next_type_number++; @@ -91,7 +91,7 @@ void setup_types() { type_number character = Type_number["character"] = Next_type_number++; Type[character].name = "character"; // Array types are a special modifier to any other type. For example, - // array:integer or array:address:boolean. + // array:number or array:address:boolean. type_number array = Type_number["array"] = Next_type_number++; Type[array].name = "array"; // End Mu Types Initialization diff --git a/011load.cc b/011load.cc index e7ff0142..3a23d026 100644 --- a/011load.cc +++ b/011load.cc @@ -3,11 +3,11 @@ :(scenarios load) :(scenario first_recipe) recipe main [ - 1:integer <- copy 23:literal + 1:number <- copy 23:literal ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(code) vector load(string form) { @@ -215,51 +215,51 @@ recently_added_recipes.clear(); recipe f1 [ ] # this comment will go through to 'load' recipe main [ - 1:integer <- copy 23:literal + 1:number <- copy 23:literal ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(scenario parse_comment_amongst_instruction) recipe main [ # comment - 1:integer <- copy 23:literal + 1:number <- copy 23:literal ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(scenario parse_comment_amongst_instruction2) recipe main [ # comment - 1:integer <- copy 23:literal + 1:number <- copy 23:literal # comment ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(scenario parse_comment_amongst_instruction3) recipe main [ - 1:integer <- copy 23:literal + 1:number <- copy 23:literal # comment - 2:integer <- copy 23:literal + 2:number <- copy 23:literal ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]} ++parse: product: {name: "2", value: 0, type: 1, properties: ["2": "number"]} :(scenario parse_comment_after_instruction) recipe main [ - 1:integer <- copy 23:literal # comment + 1:number <- copy 23:literal # comment ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(scenario parse_label) recipe main [ @@ -275,43 +275,43 @@ recipe main [ :(scenario parse_multiple_properties) recipe main [ - 1:integer <- copy 23:literal/foo:bar:baz + 1:number <- copy 23:literal/foo:bar:baz ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal", "foo": "bar":"baz"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} :(scenario parse_multiple_products) recipe main [ - 1:integer, 2:integer <- copy 23:literal + 1:number, 2:number <- copy 23:literal ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} -+parse: product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} ++parse: product: {name: "2", value: 0, type: 1, properties: ["2": "number"]} :(scenario parse_multiple_ingredients) recipe main [ - 1:integer, 2:integer <- copy 23:literal, 4:integer + 1:number, 2:number <- copy 23:literal, 4:number ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: ingredient: {name: "4", value: 0, type: 1, properties: ["4": "integer"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} -+parse: product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]} ++parse: ingredient: {name: "4", value: 0, type: 1, properties: ["4": "number"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} ++parse: product: {name: "2", value: 0, type: 1, properties: ["2": "number"]} :(scenario parse_multiple_types) recipe main [ - 1:integer, 2:address:integer <- copy 23:literal, 4:integer + 1:number, 2:address:number <- copy 23:literal, 4:number ] +parse: instruction: copy +parse: ingredient: {name: "23", value: 0, type: 0, properties: ["23": "literal"]} -+parse: ingredient: {name: "4", value: 0, type: 1, properties: ["4": "integer"]} -+parse: product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]} -+parse: product: {name: "2", value: 0, type: 2-1, properties: ["2": "address":"integer"]} ++parse: ingredient: {name: "4", value: 0, type: 1, properties: ["4": "number"]} ++parse: product: {name: "1", value: 0, type: 1, properties: ["1": "number"]} ++parse: product: {name: "2", value: 0, type: 2-1, properties: ["2": "address":"number"]} :(scenario parse_properties) recipe main [ - 1:integer:address/deref <- copy 23:literal + 1:number:address/deref <- copy 23:literal ] -+parse: product: {name: "1", value: 0, type: 1-2, properties: ["1": "integer":"address", "deref": ]} ++parse: product: {name: "1", value: 0, type: 1-2, properties: ["1": "number":"address", "deref": ]} diff --git a/014types.cc b/014types.cc index ca089a64..8ff3f722 100644 --- a/014types.cc +++ b/014types.cc @@ -3,8 +3,8 @@ :(scenarios load) :(scenario container) container foo [ - x:integer - y:integer + x:number + y:number ] +parse: reading container foo +parse: element name: x @@ -60,8 +60,8 @@ void insert_container(const string& command, kind_of_type kind, istream& in) { :(scenario exclusive_container) exclusive-container foo [ - x:integer - y:integer + x:number + y:number ] +parse: reading exclusive-container foo +parse: element name: x diff --git a/020run.cc b/020run.cc index 1b7c2edc..288ed708 100644 --- a/020run.cc +++ b/020run.cc @@ -11,7 +11,7 @@ :(scenario copy_literal) recipe main [ - 1:integer <- copy 23:literal + 1:number <- copy 23:literal ] +run: instruction main/0 +run: ingredient 0 is 23 @@ -19,8 +19,8 @@ recipe main [ :(scenario copy) recipe main [ - 1:integer <- copy 23:literal - 2:integer <- copy 1:integer + 1:number <- copy 23:literal + 2:number <- copy 1:number ] +run: instruction main/1 +run: ingredient 0 is 1 @@ -29,7 +29,7 @@ recipe main [ :(scenario copy_multiple) recipe main [ - 1:integer, 2:integer <- copy 23:literal, 24:literal + 1:number, 2:number <- copy 23:literal, 24:literal ] +run: ingredient 0 is 23 +run: ingredient 1 is 24 @@ -226,8 +226,8 @@ bool isa_literal(const reagent& r) { :(scenario run_label) recipe main [ +foo - 1:integer <- copy 23:literal - 2:integer <- copy 1:integer + 1:number <- copy 23:literal + 2:number <- copy 1:number ] +run: instruction main/1 +run: instruction main/2 diff --git a/021arithmetic.cc b/021arithmetic.cc index 0dedd02d..2bb330a4 100644 --- a/021arithmetic.cc +++ b/021arithmetic.cc @@ -18,7 +18,7 @@ case ADD: { :(scenario add_literal) recipe main [ - 1:integer <- add 23:literal, 34:literal + 1:number <- add 23:literal, 34:literal ] +run: instruction main/0 +run: ingredient 0 is 23 @@ -28,9 +28,9 @@ recipe main [ :(scenario add) recipe main [ - 1:integer <- copy 23:literal - 2:integer <- copy 34:literal - 3:integer <- add 1:integer, 2:integer + 1:number <- copy 23:literal + 2:number <- copy 34:literal + 3:number <- add 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -42,7 +42,7 @@ recipe main [ :(scenario add_multiple) recipe main [ - 1:integer <- add 3:literal, 4:literal, 5:literal + 1:number <- add 3:literal, 4:literal, 5:literal ] +mem: storing 12 in location 1 @@ -65,7 +65,7 @@ case SUBTRACT: { :(scenario subtract_literal) recipe main [ - 1:integer <- subtract 5:literal, 2:literal + 1:number <- subtract 5:literal, 2:literal ] +run: instruction main/0 +run: ingredient 0 is 5 @@ -75,9 +75,9 @@ recipe main [ :(scenario subtract) recipe main [ - 1:integer <- copy 23:literal - 2:integer <- copy 34:literal - 3:integer <- subtract 1:integer, 2:integer + 1:number <- copy 23:literal + 2:number <- copy 34:literal + 3:number <- subtract 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -89,7 +89,7 @@ recipe main [ :(scenario subtract_multiple) recipe main [ - 1:integer <- subtract 6:literal, 3:literal, 2:literal + 1:number <- subtract 6:literal, 3:literal, 2:literal ] +mem: storing 1 in location 1 @@ -111,7 +111,7 @@ case MULTIPLY: { :(scenario multiply_literal) recipe main [ - 1:integer <- multiply 2:literal, 3:literal + 1:number <- multiply 2:literal, 3:literal ] +run: instruction main/0 +run: ingredient 0 is 2 @@ -121,9 +121,9 @@ recipe main [ :(scenario multiply) recipe main [ - 1:integer <- copy 4:literal - 2:integer <- copy 6:literal - 3:integer <- multiply 1:integer, 2:integer + 1:number <- copy 4:literal + 2:number <- copy 6:literal + 3:number <- multiply 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -135,7 +135,7 @@ recipe main [ :(scenario multiply_multiple) recipe main [ - 1:integer <- multiply 2:literal, 3:literal, 4:literal + 1:number <- multiply 2:literal, 3:literal, 4:literal ] +mem: storing 24 in location 1 @@ -158,7 +158,7 @@ case DIVIDE: { :(scenario divide_literal) recipe main [ - 1:integer <- divide 8:literal, 2:literal + 1:number <- divide 8:literal, 2:literal ] +run: instruction main/0 +run: ingredient 0 is 8 @@ -168,9 +168,9 @@ recipe main [ :(scenario divide) recipe main [ - 1:integer <- copy 27:literal - 2:integer <- copy 3:literal - 3:integer <- divide 1:integer, 2:integer + 1:number <- copy 27:literal + 2:number <- copy 3:literal + 3:number <- divide 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -182,10 +182,12 @@ recipe main [ :(scenario divide_multiple) recipe main [ - 1:integer <- divide 12:literal, 3:literal, 2:literal + 1:number <- divide 12:literal, 3:literal, 2:literal ] +mem: storing 2 in location 1 +//: Integer division + :(before "End Primitive Recipe Declarations") DIVIDE_WITH_REMAINDER, :(before "End Primitive Recipe Numbers") @@ -195,6 +197,7 @@ case DIVIDE_WITH_REMAINDER: { long long int quotient = ingredients.at(0).at(0) / ingredients.at(1).at(0); long long int remainder = static_cast(ingredients.at(0).at(0)) % static_cast(ingredients.at(1).at(0)); products.resize(2); + // very large integers will lose precision products.at(0).push_back(quotient); products.at(1).push_back(remainder); break; @@ -202,7 +205,7 @@ case DIVIDE_WITH_REMAINDER: { :(scenario divide_with_remainder_literal) recipe main [ - 1:integer, 2:integer <- divide-with-remainder 9:literal, 2:literal + 1:number, 2:number <- divide-with-remainder 9:literal, 2:literal ] +run: instruction main/0 +run: ingredient 0 is 9 @@ -214,9 +217,9 @@ recipe main [ :(scenario divide_with_remainder) recipe main [ - 1:integer <- copy 27:literal - 2:integer <- copy 11:literal - 3:integer, 4:integer <- divide-with-remainder 1:integer, 2:integer + 1:number <- copy 27:literal + 2:number <- copy 11:literal + 3:number, 4:number <- divide-with-remainder 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -231,6 +234,6 @@ recipe main [ :(scenario divide_with_decimal_point) recipe main [ # todo: literal floats? - 1:integer <- divide 5:literal, 2:literal + 1:number <- divide 5:literal, 2:literal ] +mem: storing 2.5 in location 1 diff --git a/023jump.cc b/023jump.cc index 0ce916e0..acf2f95d 100644 --- a/023jump.cc +++ b/023jump.cc @@ -17,7 +17,7 @@ case JUMP: { :(scenario jump_can_skip_instructions) recipe main [ jump 1:offset - 1:integer <- copy 1:literal + 1:number <- copy 1:literal ] +run: instruction main/0 +run: ingredient 0 is 1 @@ -57,7 +57,7 @@ case JUMP_IF: { :(scenario jump_if) recipe main [ jump-if 999:literal, 1:offset - 1:integer <- copy 1:literal + 1:number <- copy 1:literal ] +run: instruction main/0 +run: ingredient 1 is 1 @@ -68,7 +68,7 @@ recipe main [ :(scenario jump_if_fallthrough) recipe main [ jump-if 0:literal, 1:offset - 123:integer <- copy 1:literal + 123:number <- copy 1:literal ] +run: instruction main/0 +run: jump-if fell through @@ -97,7 +97,7 @@ case JUMP_UNLESS: { :(scenario jump_unless) recipe main [ jump-unless 0:literal, 1:offset - 1:integer <- copy 1:literal + 1:number <- copy 1:literal ] +run: instruction main/0 +run: ingredient 1 is 1 @@ -108,7 +108,7 @@ recipe main [ :(scenario jump_unless_fallthrough) recipe main [ jump-unless 999:literal, 1:offset - 123:integer <- copy 1:literal + 123:number <- copy 1:literal ] +run: instruction main/0 +run: ingredient 0 is 999 diff --git a/024compare.cc b/024compare.cc index af370834..13732980 100644 --- a/024compare.cc +++ b/024compare.cc @@ -21,9 +21,9 @@ case EQUAL: { :(scenario equal) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 33:literal - 3:integer <- equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 33:literal + 3:number <- equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -35,9 +35,9 @@ recipe main [ :(scenario equal2) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 34:literal - 3:integer <- equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 34:literal + 3:number <- equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -49,13 +49,13 @@ recipe main [ :(scenario equal_multiple) recipe main [ - 1:integer <- equal 34:literal, 34:literal, 34:literal + 1:number <- equal 34:literal, 34:literal, 34:literal ] +mem: storing 1 in location 1 :(scenario equal_multiple2) recipe main [ - 1:integer <- equal 34:literal, 34:literal, 35:literal + 1:number <- equal 34:literal, 34:literal, 35:literal ] +mem: storing 0 in location 1 @@ -81,9 +81,9 @@ case GREATER_THAN: { :(scenario greater_than) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 33:literal - 3:integer <- greater-than 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 33:literal + 3:boolean <- greater-than 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -95,9 +95,9 @@ recipe main [ :(scenario greater_than2) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 34:literal - 3:integer <- greater-than 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 34:literal + 3:boolean <- greater-than 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -109,13 +109,13 @@ recipe main [ :(scenario greater_than_multiple) recipe main [ - 1:integer <- greater-than 36:literal, 35:literal, 34:literal + 1:boolean <- greater-than 36:literal, 35:literal, 34:literal ] +mem: storing 1 in location 1 :(scenario greater_than_multiple2) recipe main [ - 1:integer <- greater-than 36:literal, 35:literal, 35:literal + 1:boolean <- greater-than 36:literal, 35:literal, 35:literal ] +mem: storing 0 in location 1 @@ -141,9 +141,9 @@ case LESSER_THAN: { :(scenario lesser_than) recipe main [ - 1:integer <- copy 32:literal - 2:integer <- copy 33:literal - 3:integer <- lesser-than 1:integer, 2:integer + 1:number <- copy 32:literal + 2:number <- copy 33:literal + 3:boolean <- lesser-than 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -155,9 +155,9 @@ recipe main [ :(scenario lesser_than2) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 33:literal - 3:integer <- lesser-than 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 33:literal + 3:boolean <- lesser-than 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -169,13 +169,13 @@ recipe main [ :(scenario lesser_than_multiple) recipe main [ - 1:integer <- lesser-than 34:literal, 35:literal, 36:literal + 1:boolean <- lesser-than 34:literal, 35:literal, 36:literal ] +mem: storing 1 in location 1 :(scenario lesser_than_multiple2) recipe main [ - 1:integer <- lesser-than 34:literal, 35:literal, 35:literal + 1:boolean <- lesser-than 34:literal, 35:literal, 35:literal ] +mem: storing 0 in location 1 @@ -201,9 +201,9 @@ case GREATER_OR_EQUAL: { :(scenario greater_or_equal) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 33:literal - 3:integer <- greater-or-equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 33:literal + 3:boolean <- greater-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -215,9 +215,9 @@ recipe main [ :(scenario greater_or_equal2) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 34:literal - 3:integer <- greater-or-equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 34:literal + 3:boolean <- greater-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -229,9 +229,9 @@ recipe main [ :(scenario greater_or_equal3) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 35:literal - 3:integer <- greater-or-equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 35:literal + 3:boolean <- greater-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -243,13 +243,13 @@ recipe main [ :(scenario greater_or_equal_multiple) recipe main [ - 1:integer <- greater-or-equal 36:literal, 35:literal, 35:literal + 1:boolean <- greater-or-equal 36:literal, 35:literal, 35:literal ] +mem: storing 1 in location 1 :(scenario greater_or_equal_multiple2) recipe main [ - 1:integer <- greater-or-equal 36:literal, 35:literal, 36:literal + 1:boolean <- greater-or-equal 36:literal, 35:literal, 36:literal ] +mem: storing 0 in location 1 @@ -275,9 +275,9 @@ case LESSER_OR_EQUAL: { :(scenario lesser_or_equal) recipe main [ - 1:integer <- copy 32:literal - 2:integer <- copy 33:literal - 3:integer <- lesser-or-equal 1:integer, 2:integer + 1:number <- copy 32:literal + 2:number <- copy 33:literal + 3:boolean <- lesser-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -289,9 +289,9 @@ recipe main [ :(scenario lesser_or_equal2) recipe main [ - 1:integer <- copy 33:literal - 2:integer <- copy 33:literal - 3:integer <- lesser-or-equal 1:integer, 2:integer + 1:number <- copy 33:literal + 2:number <- copy 33:literal + 3:boolean <- lesser-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -303,9 +303,9 @@ recipe main [ :(scenario lesser_or_equal3) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 33:literal - 3:integer <- lesser-or-equal 1:integer, 2:integer + 1:number <- copy 34:literal + 2:number <- copy 33:literal + 3:boolean <- lesser-or-equal 1:number, 2:number ] +run: instruction main/2 +run: ingredient 0 is 1 @@ -317,12 +317,12 @@ recipe main [ :(scenario lesser_or_equal_multiple) recipe main [ - 1:integer <- lesser-or-equal 34:literal, 35:literal, 35:literal + 1:boolean <- lesser-or-equal 34:literal, 35:literal, 35:literal ] +mem: storing 1 in location 1 :(scenario lesser_or_equal_multiple2) recipe main [ - 1:integer <- lesser-or-equal 34:literal, 35:literal, 34:literal + 1:boolean <- lesser-or-equal 34:literal, 35:literal, 34:literal ] +mem: storing 0 in location 1 diff --git a/030container.cc b/030container.cc index edde3395..5c27de16 100644 --- a/030container.cc +++ b/030container.cc @@ -1,23 +1,23 @@ //: Containers contain a fixed number of elements of different types. :(before "End Mu Types Initialization") -//: We'll use this container as a running example, with two integer elements. +//: We'll use this container as a running example, with two number elements. type_number point = Type_number["point"] = Next_type_number++; Type[point].size = 2; Type[point].kind = container; Type[point].name = "point"; vector i; -i.push_back(integer); +i.push_back(number); Type[point].elements.push_back(i); Type[point].elements.push_back(i); //: Containers can be copied around with a single instruction just like -//: integers, no matter how large they are. +//: numbers, no matter how large they are. :(scenario copy_multiple_locations) recipe main [ - 1:integer <- copy 34:literal - 2:integer <- copy 35:literal + 1:number <- copy 34:literal + 2:number <- copy 35:literal 3:point <- copy 1:point ] +run: ingredient 0 is 1 @@ -29,50 +29,50 @@ recipe main [ :(before "End Mu Types Initialization") // A more complex container, containing another container as one of its // elements. -type_number point_integer = Type_number["point-integer"] = Next_type_number++; -Type[point_integer].size = 2; -Type[point_integer].kind = container; -Type[point_integer].name = "point-integer"; +type_number point_number = Type_number["point-number"] = Next_type_number++; +Type[point_number].size = 2; +Type[point_number].kind = container; +Type[point_number].name = "point-number"; vector p2; p2.push_back(point); -Type[point_integer].elements.push_back(p2); +Type[point_number].elements.push_back(p2); vector i2; -i2.push_back(integer); -Type[point_integer].elements.push_back(i2); +i2.push_back(number); +Type[point_number].elements.push_back(i2); :(scenario copy_handles_nested_container_elements) recipe main [ - 12:integer <- copy 34:literal - 13:integer <- copy 35:literal - 14:integer <- copy 36:literal - 15:point-integer <- copy 12:point-integer + 12:number <- copy 34:literal + 13:number <- copy 35:literal + 14:number <- copy 36:literal + 15:point-number <- copy 12:point-number ] +mem: storing 36 in location 17 //: Containers can be checked for equality with a single instruction just like -//: integers, no matter how large they are. +//: numbers, no matter how large they are. :(scenario compare_multiple_locations) recipe main [ - 1:integer <- copy 34:literal # first - 2:integer <- copy 35:literal - 3:integer <- copy 36:literal - 4:integer <- copy 34:literal # second - 5:integer <- copy 35:literal - 6:integer <- copy 36:literal - 7:boolean <- equal 1:point-integer, 4:point-integer + 1:number <- copy 34:literal # first + 2:number <- copy 35:literal + 3:number <- copy 36:literal + 4:number <- copy 34:literal # second + 5:number <- copy 35:literal + 6:number <- copy 36:literal + 7:boolean <- equal 1:point-number, 4:point-number ] +mem: storing 1 in location 7 :(scenario compare_multiple_locations2) recipe main [ - 1:integer <- copy 34:literal # first - 2:integer <- copy 35:literal - 3:integer <- copy 36:literal - 4:integer <- copy 34:literal # second - 5:integer <- copy 35:literal - 6:integer <- copy 37:literal # different - 7:boolean <- equal 1:point-integer, 4:point-integer + 1:number <- copy 34:literal # first + 2:number <- copy 35:literal + 3:number <- copy 36:literal + 4:number <- copy 34:literal # second + 5:number <- copy 35:literal + 6:number <- copy 37:literal # different + 7:boolean <- equal 1:point-number, 4:point-number ] +mem: storing 0 in location 7 @@ -90,9 +90,9 @@ if (t.kind == container) { //:: To access elements of a container, use 'get' :(scenario get) recipe main [ - 12:integer <- copy 34:literal - 13:integer <- copy 35:literal - 15:integer <- get 12:point, 1:offset + 12:number <- copy 34:literal + 13:number <- copy 35:literal + 15:number <- get 12:point, 1:offset ] +run: instruction main/2 +run: ingredient 0 is 12 @@ -139,10 +139,10 @@ Type_number["offset"] = 0; :(scenario get_handles_nested_container_elements) recipe main [ - 12:integer <- copy 34:literal - 13:integer <- copy 35:literal - 14:integer <- copy 36:literal - 15:integer <- get 12:point-integer, 1:offset + 12:number <- copy 34:literal + 13:number <- copy 35:literal + 14:number <- copy 36:literal + 15:number <- get 12:point-number, 1:offset ] +run: instruction main/2 +run: ingredient 0 is 12 @@ -157,9 +157,9 @@ recipe main [ :(scenario get_address) recipe main [ - 12:integer <- copy 34:literal - 13:integer <- copy 35:literal - 15:address:integer <- get-address 12:point, 1:offset + 12:number <- copy 34:literal + 13:number <- copy 35:literal + 15:address:number <- get-address 12:point, 1:offset ] +run: instruction main/2 +run: ingredient 0 is 12 diff --git a/031address.cc b/031address.cc index 9eeb0f49..0ea74aa1 100644 --- a/031address.cc +++ b/031address.cc @@ -3,10 +3,10 @@ :(scenario copy_indirect) recipe main [ - 1:address:integer <- copy 2:literal - 2:integer <- copy 34:literal + 1:address:number <- copy 2:literal + 2:number <- copy 34:literal # This loads location 1 as an address and looks up *that* location. - 3:integer <- copy 1:address:integer/deref + 3:number <- copy 1:address:number/deref ] +run: instruction main/2 +mem: location 1 is 2 @@ -20,8 +20,8 @@ x = canonize(x); //: 'deref' property :(scenario store_indirect) recipe main [ - 1:address:integer <- copy 2:literal - 1:address:integer/deref <- copy 34:literal + 1:address:number <- copy 2:literal + 1:address:number/deref <- copy 34:literal ] +run: instruction main/1 +mem: location 1 is 2 @@ -71,10 +71,10 @@ reagent deref(reagent x) { //:: 'get' can read from container address :(scenario get_indirect) recipe main [ - 1:integer <- copy 2:literal - 2:integer <- copy 34:literal - 3:integer <- copy 35:literal - 4:integer <- get 1:address:point/deref, 0:offset + 1:number <- copy 2:literal + 2:number <- copy 34:literal + 3:number <- copy 35:literal + 4:number <- get 1:address:point/deref, 0:offset ] +run: instruction main/3 +run: address to copy is 2 @@ -83,10 +83,10 @@ recipe main [ :(scenario include_nonderef_properties) recipe main [ - 1:integer <- copy 2:literal - 2:integer <- copy 34:literal - 3:integer <- copy 35:literal - 4:integer <- get 1:address:point/deref/foo, 0:offset + 1:number <- copy 2:literal + 2:number <- copy 34:literal + 3:number <- copy 35:literal + 4:number <- get 1:address:point/deref/foo, 0:offset ] +run: instruction main/3 +run: address to copy is 2 @@ -99,10 +99,10 @@ base = canonize(base); :(scenario get_address_indirect) # 'get' can read from container address recipe main [ - 1:integer <- copy 2:literal - 2:integer <- copy 34:literal - 3:integer <- copy 35:literal - 4:integer <- get-address 1:address:point/deref, 0:offset + 1:number <- copy 2:literal + 2:number <- copy 34:literal + 3:number <- copy 35:literal + 4:number <- get-address 1:address:point/deref, 0:offset ] +run: instruction main/3 +run: address to copy is 2 diff --git a/032array.cc b/032array.cc index 04234d3a..fd7f9baf 100644 --- a/032array.cc +++ b/032array.cc @@ -6,14 +6,14 @@ //: Create containers containing addresses to arrays instead. :(scenario copy_array) -# Arrays can be copied around with a single instruction just like integers, +# Arrays can be copied around with a single instruction just like numbers, # no matter how large they are. recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:array:integer <- copy 1:array:integer + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:array:number <- copy 1:array:number ] +run: instruction main/4 +run: ingredient 0 is 1 @@ -28,12 +28,12 @@ recipe main [ :(scenario copy_array_indirect) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:address:array:integer <- copy 1:literal - 6:array:integer <- copy 5:address:array:integer/deref + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:address:array:number <- copy 1:literal + 6:array:number <- copy 5:address:array:number/deref ] +run: instruction main/5 +run: ingredient 0 is 5 @@ -60,11 +60,11 @@ if (x.types.at(0) != Type_number["array"] && size_of(x) != data.size()) :(scenario index) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:integer <- index 1:array:integer, 0:literal + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:number <- index 1:array:number, 0:literal ] +run: instruction main/4 +run: address to copy is 2 @@ -75,12 +75,12 @@ recipe main [ :(scenario index_direct_offset) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:integer <- copy 0:literal - 6:integer <- index 1:array:integer, 5:integer + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:number <- copy 0:literal + 6:number <- index 1:array:number, 5:number ] +run: instruction main/5 +run: address to copy is 2 @@ -123,11 +123,11 @@ vector array_element(const vector& types) { :(scenario index_address) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:integer <- index-address 1:array:integer, 0:literal + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:number <- index-address 1:array:number, 0:literal ] +run: instruction main/4 +mem: storing 2 in location 5 @@ -136,12 +136,12 @@ recipe main [ :(scenario index_indirect) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:address:array:integer <- copy 1:literal - 6:integer <- index 5:address:array:integer/deref, 1:literal + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:address:array:number <- copy 1:literal + 6:number <- index 5:address:array:number/deref, 1:literal ] +run: instruction main/5 +mem: storing 15 in location 6 diff --git a/033length.cc b/033length.cc index 2268611a..e81bc061 100644 --- a/033length.cc +++ b/033length.cc @@ -2,11 +2,11 @@ :(scenario array_length) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 14:literal - 3:integer <- copy 15:literal - 4:integer <- copy 16:literal - 5:integer <- length 1:array:integer + 1:number <- copy 3:literal # length + 2:number <- copy 14:literal + 3:number <- copy 15:literal + 4:number <- copy 16:literal + 5:number <- length 1:array:number ] +run: instruction main/4 +mem: storing 3 in location 5 diff --git a/034exclusive_container.cc b/034exclusive_container.cc index b2855f79..97150af4 100644 --- a/034exclusive_container.cc +++ b/034exclusive_container.cc @@ -5,15 +5,15 @@ //: currently stored in them. :(before "End Mu Types Initialization") -//: We'll use this container as a running example, with two integer elements. +//: We'll use this container as a running example, with two number elements. { -type_number tmp = Type_number["integer-or-point"] = Next_type_number++; +type_number tmp = Type_number["number-or-point"] = Next_type_number++; Type[tmp].size = 2; Type[tmp].kind = exclusive_container; -Type[tmp].name = "integer-or-point"; +Type[tmp].name = "number-or-point"; //? cout << tmp << ": " << Type[tmp].elements.size() << '\n'; //? 1 vector t1; -t1.push_back(integer); +t1.push_back(number); Type[tmp].elements.push_back(t1); //? cout << Type[tmp].elements.size() << '\n'; //? 1 vector t2; @@ -28,10 +28,10 @@ Type[tmp].element_names.push_back("p"); :(scenario copy_exclusive_container) # Copying exclusive containers copies all their contents and an extra location for the tag. recipe main [ - 1:integer <- copy 1:literal # 'point' variant - 2:integer <- copy 34:literal - 3:integer <- copy 35:literal - 4:integer-or-point <- copy 1:integer-or-point + 1:number <- copy 1:literal # 'point' variant + 2:number <- copy 34:literal + 3:number <- copy 35:literal + 4:number-or-point <- copy 1:number-or-point ] +mem: storing 1 in location 4 +mem: storing 34 in location 5 @@ -66,19 +66,19 @@ Type_number["variant"] = 0; :(scenario maybe_convert) recipe main [ - 12:integer <- copy 1:literal - 13:integer <- copy 35:literal - 14:integer <- copy 36:literal - 20:address:point <- maybe-convert 12:integer-or-point, 1:variant + 12:number <- copy 1:literal + 13:number <- copy 35:literal + 14:number <- copy 36:literal + 20:address:point <- maybe-convert 12:number-or-point, 1:variant ] +mem: storing 13 in location 20 :(scenario maybe_convert_fail) recipe main [ - 12:integer <- copy 1:literal - 13:integer <- copy 35:literal - 14:integer <- copy 36:literal - 20:address:point <- maybe-convert 12:integer-or-point, 0:variant + 12:number <- copy 1:literal + 13:number <- copy 35:literal + 14:number <- copy 36:literal + 20:address:point <- maybe-convert 12:number-or-point, 0:variant ] +mem: storing 0 in location 20 diff --git a/035call.cc b/035call.cc index 57c1513d..8682944d 100644 --- a/035call.cc +++ b/035call.cc @@ -5,20 +5,20 @@ recipe main [ f ] recipe f [ - 3:integer <- add 2:literal, 2:literal + 3:number <- add 2:literal, 2:literal ] +mem: storing 4 in location 3 :(scenario return_on_fallthrough) recipe main [ f - 1:integer <- copy 34:literal - 2:integer <- copy 34:literal - 3:integer <- copy 34:literal + 1:number <- copy 34:literal + 2:number <- copy 34:literal + 3:number <- copy 34:literal ] recipe f [ - 4:integer <- copy 34:literal - 5:integer <- copy 34:literal + 4:number <- copy 34:literal + 5:number <- copy 34:literal ] +run: instruction main/0 +run: instruction f/0 diff --git a/036call_ingredient.cc b/036call_ingredient.cc index fe3ef1ed..b07c2d3b 100644 --- a/036call_ingredient.cc +++ b/036call_ingredient.cc @@ -6,8 +6,8 @@ recipe main [ f 2:literal ] recipe f [ - 12:integer <- next-ingredient - 13:integer <- add 1:literal, 12:integer + 12:number <- next-ingredient + 13:number <- add 1:literal, 12:number ] +run: instruction f/1 +mem: location 12 is 2 @@ -18,7 +18,7 @@ recipe main [ f ] recipe f [ - _, 12:integer <- next-ingredient + _, 12:number <- next-ingredient ] +mem: storing 0 in location 12 @@ -61,10 +61,10 @@ recipe main [ f 2:literal ] recipe f [ - 12:integer <- next-ingredient # consume ingredient + 12:number <- next-ingredient # consume ingredient _, 1:boolean <- next-ingredient # will not find any ingredients rewind-ingredients - 13:integer, 2:boolean <- next-ingredient # will find ingredient again + 13:number, 2:boolean <- next-ingredient # will find ingredient again ] +mem: storing 2 in location 12 +mem: storing 0 in location 1 @@ -86,8 +86,8 @@ recipe main [ f 1:literal, 2:literal ] recipe f [ - 12:integer <- ingredient 1:literal # consume second ingredient first - 13:integer, 1:boolean <- next-ingredient # next-ingredient tries to scan past that + 12:number <- ingredient 1:literal # consume second ingredient first + 13:number, 1:boolean <- next-ingredient # next-ingredient tries to scan past that ] +mem: storing 2 in location 12 +mem: storing 0 in location 1 diff --git a/037call_reply.cc b/037call_reply.cc index 11d79e0c..dc743a0a 100644 --- a/037call_reply.cc +++ b/037call_reply.cc @@ -2,12 +2,12 @@ :(scenario reply) recipe main [ - 1:integer, 2:integer <- f 34:literal + 1:number, 2:number <- f 34:literal ] recipe f [ - 12:integer <- next-ingredient - 13:integer <- add 1:literal, 12:integer - reply 12:integer, 13:integer + 12:number <- next-ingredient + 13:number <- add 1:literal, 12:number + reply 12:number, 13:number ] +run: instruction main/0 +mem: storing 34 in location 1 @@ -49,8 +49,8 @@ recipe main [ 3:point <- f 2:literal ] recipe f [ - 12:integer <- next-ingredient - 13:integer <- copy 35:literal + 12:number <- next-ingredient + 13:number <- copy 35:literal reply 12:point ] +run: instruction main/0 @@ -66,12 +66,12 @@ recipe f [ :(scenario reply_same_as_ingredient) % Hide_warnings = true; recipe main [ - 1:integer <- copy 0:literal - 2:integer <- test1 1:integer # call with different ingredient and product + 1:number <- copy 0:literal + 2:number <- test1 1:number # call with different ingredient and product ] recipe test1 [ - 10:address:integer <- next-ingredient - reply 10:address:integer/same-as-ingredient:0 + 10:address:number <- next-ingredient + reply 10:address:number/same-as-ingredient:0 ] +warn: 'same-as-ingredient' result 2 must be location 1 @@ -96,7 +96,7 @@ string to_string(const vector& in) { :(scenario reply_if) recipe main [ - 1:integer <- test1 + 1:number <- test1 ] recipe test1 [ reply-if 0:literal, 34:literal @@ -106,7 +106,7 @@ recipe test1 [ :(scenario reply_if2) recipe main [ - 1:integer <- test1 + 1:number <- test1 ] recipe test1 [ reply-if 1:literal, 34:literal diff --git a/038scheduler.cc b/038scheduler.cc index c6fb712d..8b42e01c 100644 --- a/038scheduler.cc +++ b/038scheduler.cc @@ -6,11 +6,11 @@ recipe f1 [ start-running f2:recipe # wait for f2 to run { - jump-unless 1:integer, -1:literal + jump-unless 1:number, -1:literal } ] recipe f2 [ - 1:integer <- copy 1:literal + 1:number <- copy 1:literal ] +schedule: f1 +schedule: f2 @@ -102,6 +102,7 @@ Routines.clear(); //:: To schedule new routines to run, call 'start-running'. //: 'start-running' will return a unique id for the routine that was created. +//: routine id is a number, but don't do any arithmetic on it :(before "End routine Fields") index_t id; :(before "End Globals") @@ -142,8 +143,8 @@ case START_RUNNING: { :(scenario scheduler_runs_single_routine) % Scheduling_interval = 1; recipe f1 [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal ] +schedule: f1 +run: instruction f1/0 @@ -154,12 +155,12 @@ recipe f1 [ % Scheduling_interval = 1; recipe f1 [ start-running f2:recipe - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal ] recipe f2 [ - 3:integer <- copy 4:literal - 4:integer <- copy 4:literal + 3:number <- copy 4:literal + 4:number <- copy 4:literal ] +schedule: f1 +run: instruction f1/0 @@ -177,36 +178,36 @@ recipe f1 [ start-running f2:recipe, 3:literal # wait for f2 to run { - jump-unless 1:integer, -1:literal + jump-unless 1:number, -1:literal } ] recipe f2 [ - 1:integer <- next-ingredient - 2:integer <- add 1:integer, 1:literal + 1:number <- next-ingredient + 2:number <- add 1:number, 1:literal ] +mem: storing 4 in location 2 :(scenario start_running_returns_routine_id) recipe f1 [ - 1:integer <- start-running f2:recipe + 1:number <- start-running f2:recipe ] recipe f2 [ - 12:integer <- copy 44:literal + 12:number <- copy 44:literal ] +mem: storing 2 in location 1 :(scenario scheduler_skips_completed_routines) # this scenario will require some careful setup in escaped C++ # (straining our tangle capabilities to near-breaking point) -% recipe_number f1 = load("recipe f1 [\n1:integer <- copy 0:literal\n]").front(); -% recipe_number f2 = load("recipe f2 [\n2:integer <- copy 0:literal\n]").front(); +% recipe_number f1 = load("recipe f1 [\n1:number <- copy 0:literal\n]").front(); +% recipe_number f2 = load("recipe f2 [\n2:number <- copy 0:literal\n]").front(); % Routines.push_back(new routine(f1)); // f1 meant to run % Routines.push_back(new routine(f2)); % Routines.back()->state = COMPLETED; // f2 not meant to run #? % Trace_stream->dump_layer = "all"; # must have at least one routine without escaping recipe f3 [ - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] # by interleaving '+' lines with '-' lines, we allow f1 and f3 to run in any order +schedule: f1 @@ -220,8 +221,8 @@ recipe f3 [ % Routines.push_back(new routine(COPY)); % Routines.back()->state = COMPLETED; recipe f1 [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal ] +schedule: f1 -run: idle @@ -234,7 +235,7 @@ recipe main [ # f1 never actually runs because its parent completes without waiting for it ] recipe f1 [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal ] -schedule: f1 @@ -273,13 +274,13 @@ bool has_completed_parent(index_t routine_index) { :(scenario routine_state_test) % Scheduling_interval = 2; recipe f1 [ - 1:integer/child-id <- start-running f2:recipe - 12:integer <- copy 0:literal # race condition since we don't care about location 12 + 1:number/child-id <- start-running f2:recipe + 12:number <- copy 0:literal # race condition since we don't care about location 12 # thanks to Scheduling_interval, f2's one instruction runs in between here and completes - 2:integer/state <- routine-state 1:integer/child-id + 2:number/state <- routine-state 1:number/child-id ] recipe f2 [ - 12:integer <- copy 0:literal + 12:number <- copy 0:literal # trying to run a second instruction marks routine as completed ] # recipe f2 should be in state COMPLETED diff --git a/039wait.cc b/039wait.cc index 82354a53..c7743785 100644 --- a/039wait.cc +++ b/039wait.cc @@ -5,14 +5,14 @@ :(scenario wait_for_location) recipe f1 [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal start-running f2:recipe - wait-for-location 1:integer + wait-for-location 1:number # now wait for f2 to run and modify location 1 before using its value - 2:integer <- copy 1:integer + 2:number <- copy 1:number ] recipe f2 [ - 1:integer <- copy 34:literal + 1:number <- copy 34:literal ] # if we got the synchronization wrong we'd be storing 0 in location 2 +mem: storing 34 in location 2 @@ -67,14 +67,14 @@ for (index_t i = 0; i < Routines.size(); ++i) { :(scenario wait_for_routine) recipe f1 [ - 1:integer <- copy 0:literal - 12:integer/routine <- start-running f2:recipe - wait-for-routine 12:integer/routine + 1:number <- copy 0:literal + 12:number/routine <- start-running f2:recipe + wait-for-routine 12:number/routine # now wait for f2 to run and modify location 1 before using its value - 3:integer <- copy 1:integer + 3:number <- copy 1:number ] recipe f2 [ - 1:integer <- copy 34:literal + 1:number <- copy 34:literal ] +schedule: f1 +run: waiting for routine 2 diff --git a/040brace.cc b/040brace.cc index 4eed9abb..6fde1713 100644 --- a/040brace.cc +++ b/040brace.cc @@ -24,7 +24,7 @@ recipe main [ { break - 1:integer <- copy 0:literal + 1:number <- copy 0:literal } ] +after-brace: recipe main @@ -191,10 +191,10 @@ Recipe_number["loop-unless"] = LOOP_UNLESS; :(scenario loop) recipe main [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal { - 3:integer <- copy 0:literal + 3:number <- copy 0:literal loop } ] @@ -206,7 +206,7 @@ recipe main [ :(scenario break_empty_block) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { break } @@ -217,7 +217,7 @@ recipe main [ :(scenario break_cascading) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { break } @@ -232,11 +232,11 @@ recipe main [ :(scenario break_cascading2) recipe main [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal { break - 3:integer <- copy 0:literal + 3:number <- copy 0:literal } { break @@ -251,11 +251,11 @@ recipe main [ :(scenario break_if) recipe main [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal { - break-if 2:integer - 3:integer <- copy 0:literal + break-if 2:number + 3:number <- copy 0:literal } { break @@ -270,36 +270,36 @@ recipe main [ :(scenario break_nested) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { - 2:integer <- copy 0:literal + 2:number <- copy 0:literal break { - 3:integer <- copy 0:literal + 3:number <- copy 0:literal } - 4:integer <- copy 0:literal + 4:number <- copy 0:literal } ] +after-brace: jump 4:offset :(scenario break_nested_degenerate) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { - 2:integer <- copy 0:literal + 2:number <- copy 0:literal break { } - 4:integer <- copy 0:literal + 4:number <- copy 0:literal } ] +after-brace: jump 3:offset :(scenario break_nested_degenerate2) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { - 2:integer <- copy 0:literal + 2:number <- copy 0:literal break { } @@ -310,7 +310,7 @@ recipe main [ :(scenario break_label) % Hide_warnings = true; recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { break +foo:offset } @@ -319,11 +319,11 @@ recipe main [ :(scenario break_unless) recipe main [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal { - break-unless 2:integer - 3:integer <- copy 0:literal + break-unless 2:number + 3:number <- copy 0:literal } ] +after-brace: recipe main @@ -334,11 +334,11 @@ recipe main [ :(scenario loop_unless) recipe main [ - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal { - loop-unless 2:integer - 3:integer <- copy 0:literal + loop-unless 2:number + 3:number <- copy 0:literal } ] +after-brace: recipe main @@ -349,14 +349,14 @@ recipe main [ :(scenario loop_nested) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal { - 2:integer <- copy 0:literal + 2:number <- copy 0:literal { - 3:integer <- copy 0:literal + 3:number <- copy 0:literal } loop-if 4:boolean - 5:integer <- copy 0:literal + 5:number <- copy 0:literal } ] +after-brace: recipe main @@ -364,9 +364,9 @@ recipe main [ :(scenario loop_label) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +foo - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] +after-brace: recipe main +after-brace: copy ... @@ -377,16 +377,16 @@ recipe main [ :(scenario brace_conversion_and_run) #? % Trace_stream->dump_layer = "run"; recipe test-factorial [ - 1:integer <- copy 5:literal - 2:integer <- copy 1:literal + 1:number <- copy 5:literal + 2:number <- copy 1:literal { - 3:boolean <- equal 1:integer, 1:literal + 3:boolean <- equal 1:number, 1:literal break-if 3:boolean -# $print 1:integer - 2:integer <- multiply 2:integer, 1:integer - 1:integer <- subtract 1:integer, 1:literal +# $print 1:number + 2:number <- multiply 2:number, 1:number + 1:number <- subtract 1:number, 1:literal loop } - 4:integer <- copy 2:integer # trigger a read + 4:number <- copy 2:number # trigger a read ] +mem: location 2 is 120 diff --git a/041name.cc b/041name.cc index e5e9449b..422a79ef 100644 --- a/041name.cc +++ b/041name.cc @@ -4,7 +4,7 @@ :(scenario convert_names) recipe main [ - x:integer <- copy 0:literal + x:number <- copy 0:literal ] +name: assign x 1 +run: instruction main/0 @@ -13,7 +13,7 @@ recipe main [ :(scenario convert_names_warns) % Hide_warnings = true; recipe main [ - x:integer <- copy y:integer + x:number <- copy y:number ] +warn: use before set: y in main @@ -138,7 +138,7 @@ bool is_special_name(const string& s) { :(scenario convert_names_passes_dummy) # _ is just a dummy result that never gets consumed recipe main [ - _, x:integer <- copy 0:literal, 1:literal + _, x:number <- copy 0:literal, 1:literal ] +name: assign x 1 -name: assign _ 1 @@ -146,7 +146,7 @@ recipe main [ //: one reserved word that we'll need later :(scenario convert_names_passes_default_space) recipe main [ - default-space:integer, x:integer <- copy 0:literal, 1:literal + default-space:number, x:number <- copy 0:literal, 1:literal ] +name: assign x 1 -name: assign default-space 1 @@ -154,43 +154,43 @@ recipe main [ //: an escape hatch to suppress name conversion that we'll use later :(scenario convert_names_passes_raw) recipe main [ - x:integer/raw <- copy 0:literal + x:number/raw <- copy 0:literal ] -name: assign x 1 :(scenario convert_names_warns_when_mixing_names_and_numeric_locations) % Hide_warnings = true; recipe main [ - x:integer <- copy 1:integer + x:number <- copy 1:number ] +warn: mixing variable names and numeric addresses in main :(scenario convert_names_warns_when_mixing_names_and_numeric_locations2) % Hide_warnings = true; recipe main [ - x:integer <- copy 1:literal - 1:integer <- copy x:integer + x:number <- copy 1:literal + 1:number <- copy x:number ] +warn: mixing variable names and numeric addresses in main :(scenario convert_names_does_not_warn_when_mixing_names_and_raw_locations) % Hide_warnings = true; recipe main [ - x:integer <- copy 1:integer/raw + x:number <- copy 1:number/raw ] -warn: mixing variable names and numeric addresses in main :(scenario convert_names_does_not_warn_when_mixing_names_and_literals) % Hide_warnings = true; recipe main [ - x:integer <- copy 1:literal + x:number <- copy 1:literal ] -warn: mixing variable names and numeric addresses in main :(scenario convert_names_does_not_warn_when_mixing_special_names_and_numeric_locations) % Hide_warnings = true; recipe main [ - screen:integer <- copy 1:integer + screen:number <- copy 1:number ] -warn: mixing variable names and numeric addresses in main @@ -203,8 +203,8 @@ Type[point].element_names.push_back("y"); :(scenario convert_names_transforms_container_elements) recipe main [ p:address:point <- copy 0:literal # unsafe - a:integer <- get p:address:point/deref, y:offset - b:integer <- get p:address:point/deref, x:offset + a:number <- get p:address:point/deref, y:offset + b:number <- get p:address:point/deref, x:offset ] +name: element y of type point is at offset 1 +name: element x of type point is at offset 0 @@ -229,7 +229,7 @@ if (inst.operation == Recipe_number["get"] :(scenario convert_names_handles_containers) recipe main [ a:point <- copy 0:literal - b:integer <- copy 0:literal + b:number <- copy 0:literal ] +name: assign a 1 +name: assign b 3 @@ -239,12 +239,12 @@ recipe main [ :(scenarios run) :(scenario maybe_convert_named) recipe main [ - 12:integer <- copy 1:literal - 13:integer <- copy 35:literal - 14:integer <- copy 36:literal - 20:address:point <- maybe-convert 12:integer-or-point, p:variant + 12:number <- copy 1:literal + 13:number <- copy 35:literal + 14:number <- copy 36:literal + 20:address:point <- maybe-convert 12:number-or-point, p:variant ] -+name: variant p of type integer-or-point has tag 1 ++name: variant p of type number-or-point has tag 1 +mem: storing 13 in location 20 :(after "Per-recipe Transforms") diff --git a/042new.cc b/042new.cc index 754091c8..a4e00490 100644 --- a/042new.cc +++ b/042new.cc @@ -4,9 +4,9 @@ :(scenario new) # call new two times with identical arguments; you should get back different results recipe main [ - 1:address:integer/raw <- new integer:type - 2:address:integer/raw <- new integer:type - 3:boolean/raw <- equal 1:address:integer/raw, 2:address:integer/raw + 1:address:number/raw <- new number:type + 2:address:number/raw <- new number:type + 3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw ] +mem: storing 0 in location 3 @@ -102,9 +102,9 @@ void ensure_space(size_t size) { :(scenario new_array) recipe main [ - 1:address:array:integer/raw <- new integer:type, 5:literal - 2:address:integer/raw <- new integer:type - 3:integer/raw <- subtract 2:address:integer/raw, 1:address:array:integer/raw + 1:address:array:number/raw <- new number:type, 5:literal + 2:address:number/raw <- new number:type + 3:number/raw <- subtract 2:address:number/raw, 1:address:array:number/raw ] +run: instruction main/0 +mem: array size is 5 @@ -117,18 +117,18 @@ recipe main [ :(scenario new_concurrent) recipe f1 [ start-running f2:recipe - 1:address:integer/raw <- new integer:type + 1:address:number/raw <- new number:type # wait for f2 to complete { - loop-unless 4:integer/raw + loop-unless 4:number/raw } ] recipe f2 [ - 2:address:integer/raw <- new integer:type + 2:address:number/raw <- new number:type # hack: assumes scheduler implementation - 3:boolean/raw <- equal 1:address:integer/raw, 2:address:integer/raw + 3:boolean/raw <- equal 1:address:number/raw, 2:address:number/raw # signal f2 complete - 4:integer/raw <- copy 1:literal + 4:number/raw <- copy 1:literal ] +mem: storing 0 in location 3 @@ -136,7 +136,7 @@ recipe f2 [ :(scenario new_overflow) % Initial_memory_per_routine = 2; recipe main [ - 1:address:integer/raw <- new integer:type + 1:address:number/raw <- new number:type 2:address:point/raw <- new point:type # not enough room in initial page ] +new: routine allocated memory from 1000 to 1002 @@ -149,7 +149,7 @@ recipe main [ 1:address:array:character <- new [abc def] 2:character <- index 1:address:array:character/deref, 5:literal ] -# integer code for 'e' +# number code for 'e' +mem: storing 101 in location 2 :(after "case NEW" following "Primitive Recipe Implementations") @@ -175,7 +175,7 @@ if (isa_literal(current_instruction().ingredients.at(0)) :(scenario new_string_overflow) % Initial_memory_per_routine = 2; recipe main [ - 1:address:integer/raw <- new integer:type + 1:address:number/raw <- new number:type 2:address:array:character/raw <- new [a] # not enough room in initial page, if you take the array size into account ] +new: routine allocated memory from 1000 to 1002 diff --git a/043space.cc b/043space.cc index 2a8ff4fc..88cc5aa3 100644 --- a/043space.cc +++ b/043space.cc @@ -6,22 +6,22 @@ # if default-space is 10, and if an array of 5 locals lies from location 11 to 15 (inclusive), # then location 0 is really location 11, location 1 is really location 12, and so on. recipe main [ - 10:integer <- copy 5:literal # pretend array; in practice we'll use new + 10:number <- copy 5:literal # pretend array; in practice we'll use new default-space:address:array:location <- copy 10:literal - 1:integer <- copy 23:literal + 1:number <- copy 23:literal ] +mem: storing 23 in location 12 :(scenario deref_sidesteps_default_space) recipe main [ # pretend pointer from outside - 3:integer <- copy 34:literal + 3:number <- copy 34:literal # pretend array - 1000:integer <- copy 5:literal + 1000:number <- copy 5:literal # actual start of this function default-space:address:array:location <- copy 1000:literal - 1:address:integer <- copy 3:literal - 8:integer/raw <- copy 1:address:integer/deref + 1:address:number <- copy 3:literal + 8:number/raw <- copy 1:address:number/deref ] +mem: storing 34 in location 8 @@ -56,14 +56,14 @@ result.properties.push_back(pair >("raw", vector( :(scenario deref_sidesteps_default_space_in_get) recipe main [ # pretend pointer to container from outside - 12:integer <- copy 34:literal - 13:integer <- copy 35:literal + 12:number <- copy 34:literal + 13:number <- copy 35:literal # pretend array - 1000:integer <- copy 5:literal + 1000:number <- copy 5:literal # actual start of this function default-space:address:array:location <- copy 1000:literal 1:address:point <- copy 12:literal - 9:integer/raw <- get 1:address:point/deref, 1:offset + 9:number/raw <- get 1:address:point/deref, 1:offset ] +mem: storing 35 in location 9 @@ -75,15 +75,15 @@ tmp.properties.push_back(pair >("raw", vector())) :(scenario deref_sidesteps_default_space_in_index) recipe main [ # pretend pointer to array from outside - 12:integer <- copy 2:literal - 13:integer <- copy 34:literal - 14:integer <- copy 35:literal + 12:number <- copy 2:literal + 13:number <- copy 34:literal + 14:number <- copy 35:literal # pretend array - 1000:integer <- copy 5:literal + 1000:number <- copy 5:literal # actual start of this function default-space:address:array:location <- copy 1000:literal - 1:address:array:integer <- copy 12:literal - 9:integer/raw <- index 1:address:array:integer/deref, 1:literal + 1:address:array:number <- copy 12:literal + 9:number/raw <- index 1:address:array:number/deref, 1:literal ] +mem: storing 35 in location 9 @@ -118,7 +118,7 @@ index_t address(index_t offset, index_t base) { :(scenario get_default_space) recipe main [ default-space:address:array:location <- copy 10:literal - 1:integer/raw <- copy default-space:address:array:location + 1:number/raw <- copy default-space:address:array:location ] +mem: storing 10 in location 1 diff --git a/044space_surround.cc b/044space_surround.cc index b1e4c5e7..21a68fdd 100644 --- a/044space_surround.cc +++ b/044space_surround.cc @@ -7,12 +7,12 @@ :(scenario surrounding_space) # location 1 in space 1 refers to the space surrounding the default space, here 20. recipe main [ - 10:integer <- copy 5:literal # pretend array - 20:integer <- copy 5:literal # pretend array + 10:number <- copy 5:literal # pretend array + 20:number <- copy 5:literal # pretend array default-space:address:array:location <- copy 10:literal 0:address:array:location/names:dummy <- copy 20:literal # later layers will explain the /names: property - 1:integer <- copy 32:literal - 1:integer/space:1 <- copy 33:literal + 1:number <- copy 32:literal + 1:number/space:1 <- copy 33:literal ] +run: instruction main/3 +mem: storing 20 in location 11 diff --git a/045closure_name.cc b/045closure_name.cc index 4cb9411f..2c2f464c 100644 --- a/045closure_name.cc +++ b/045closure_name.cc @@ -9,23 +9,23 @@ recipe main [ 1:address:array:location/names:init-counter <- init-counter #? $print [AAAAAAAAAAAAAAAA] #? $print 1:address:array:location - 2:integer/raw <- increment-counter 1:address:array:location/names:init-counter - 3:integer/raw <- increment-counter 1:address:array:location/names:init-counter + 2:number/raw <- increment-counter 1:address:array:location/names:init-counter + 3:number/raw <- increment-counter 1:address:array:location/names:init-counter ] recipe init-counter [ default-space:address:array:location <- new location:type, 30:literal - x:integer <- copy 23:literal - y:integer <- copy 3:literal # variable that will be incremented + x:number <- copy 23:literal + y:number <- copy 3:literal # variable that will be incremented reply default-space:address:array:location ] recipe increment-counter [ default-space:address:array:location <- new space:literal, 30:literal 0:address:array:location/names:init-counter <- next-ingredient # outer space must be created by 'init-counter' above - y:integer/space:1 <- add y:integer/space:1, 1:literal # increment - y:integer <- copy 234:literal # dummy - reply y:integer/space:1 + y:number/space:1 <- add y:number/space:1, 1:literal # increment + y:number <- copy 234:literal # dummy + reply y:number/space:1 ] +name: recipe increment-counter is surrounded by init-counter diff --git a/046tangle.cc b/046tangle.cc index 0c417322..d77eecf1 100644 --- a/046tangle.cc +++ b/046tangle.cc @@ -4,13 +4,13 @@ :(scenario tangle_before) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -70,15 +70,15 @@ void insert_fragments(const recipe_number r) { :(scenario tangle_before_and_after) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 - 4:integer <- copy 0:literal + 4:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] after +label1 [ - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -90,22 +90,22 @@ $mem: 4 :(scenario tangle_keeps_labels_separate) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 +label2 - 6:integer <- copy 0:literal + 6:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] after +label1 [ - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] before +label2 [ - 4:integer <- copy 0:literal + 4:number <- copy 0:literal ] after +label2 [ - 5:integer <- copy 0:literal + 5:number <- copy 0:literal ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -121,21 +121,21 @@ $mem: 6 :(scenario tangle_stacks_multiple_fragments) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 - 6:integer <- copy 0:literal + 6:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] after +label1 [ - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] before +label1 [ - 4:integer <- copy 0:literal + 4:number <- copy 0:literal ] after +label1 [ - 5:integer <- copy 0:literal + 5:number <- copy 0:literal ] +mem: storing 0 in location 1 # 'before' fragments stack in order @@ -151,17 +151,17 @@ $mem: 6 :(scenario tangle_supports_fragments_with_multiple_instructions) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 - 6:integer <- copy 0:literal + 6:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal - 3:integer <- copy 0:literal + 2:number <- copy 0:literal + 3:number <- copy 0:literal ] after +label1 [ - 4:integer <- copy 0:literal - 5:integer <- copy 0:literal + 4:number <- copy 0:literal + 5:number <- copy 0:literal ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 @@ -175,16 +175,16 @@ $mem: 6 :(scenario tangle_tangles_into_all_labels_with_same_name) recipe main [ - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +label1 +label1 - 4:integer <- copy 0:literal + 4:number <- copy 0:literal ] before +label1 [ - 2:integer <- copy 0:literal + 2:number <- copy 0:literal ] after +label1 [ - 3:integer <- copy 0:literal + 3:number <- copy 0:literal ] +mem: storing 0 in location 1 +mem: storing 0 in location 2 diff --git a/047jump_label.cc b/047jump_label.cc index c9dcb4f5..dd65c432 100644 --- a/047jump_label.cc +++ b/047jump_label.cc @@ -5,7 +5,7 @@ :(scenario jump_to_label) recipe main [ jump +target:offset - 1:integer <- copy 0:literal + 1:number <- copy 0:literal +target ] -mem: storing 0 in location 1 @@ -48,7 +48,7 @@ void replace_offset(reagent& x, /*const*/ map& offset, const in //? cerr << "BBB " << x.to_string() << '\n'; //? 1 assert(!x.initialized); //? cerr << "CCC " << x.to_string() << '\n'; //? 1 - if (is_number(x.name)) return; // non-labels will be handled like other integer operands + if (is_number(x.name)) return; // non-labels will be handled like other number operands //? cerr << "DDD " << x.to_string() << '\n'; //? 1 if (offset.find(x.name) == offset.end()) raise << "can't find label " << x.name << " in routine " << Recipe[r].name << '\n'; @@ -61,7 +61,7 @@ recipe main [ { { break +target:offset - 1:integer <- copy 0:literal + 1:number <- copy 0:literal } } +target @@ -73,7 +73,7 @@ recipe main [ { { jump-if 1:literal, +target:offset - 1:integer <- copy 0:literal + 1:number <- copy 0:literal } } +target @@ -85,7 +85,7 @@ recipe main [ { { loop-unless 0:literal, +target:offset # loop/break with a label don't care about braces - 1:integer <- copy 0:literal + 1:number <- copy 0:literal } } +target @@ -95,13 +95,13 @@ recipe main [ :(scenario jump_runs_code_after_label) recipe main [ # first a few lines of padding to exercise the offset computation - 1:integer <- copy 0:literal - 2:integer <- copy 0:literal - 3:integer <- copy 0:literal + 1:number <- copy 0:literal + 2:number <- copy 0:literal + 3:number <- copy 0:literal jump +target:offset - 4:integer <- copy 0:literal + 4:number <- copy 0:literal +target - 5:integer <- copy 0:literal + 5:number <- copy 0:literal ] +mem: storing 0 in location 5 -mem: storing 0 in location 4 diff --git a/050scenario.cc b/050scenario.cc index c5ff2765..e91cb3ae 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -8,7 +8,7 @@ :(scenario scenario_block) scenario foo [ run [ - 1:integer <- copy 13:literal + 1:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 @@ -19,13 +19,13 @@ scenario foo [ :(scenario scenario_multiple_blocks) scenario foo [ run [ - 1:integer <- copy 13:literal + 1:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 ] run [ - 2:integer <- copy 13:literal + 2:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 @@ -36,7 +36,7 @@ scenario foo [ :(scenario scenario_check_memory_and_trace) scenario foo [ run [ - 1:integer <- copy 13:literal + 1:number <- copy 13:literal trace [a], [a b c] ] memory-should-contain [ @@ -138,7 +138,7 @@ void run_mu_scenario(const scenario& s) { #? % Trace_stream->dump_layer = "all"; recipe main [ run [ - 1:integer <- copy 13:literal + 1:number <- copy 13:literal ] ] +mem: storing 13 in location 1 @@ -165,10 +165,10 @@ case RUN: { :(scenario run_multiple) recipe main [ run [ - 1:integer <- copy 13:literal + 1:number <- copy 13:literal ] run [ - 2:integer <- copy 13:literal + 2:number <- copy 13:literal ] ] +mem: storing 13 in location 1 @@ -275,10 +275,10 @@ recipe main [ :(scenario memory_check_string_length) % Hide_warnings = true; recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 97:literal # 'a' - 3:integer <- copy 98:literal # 'b' - 4:integer <- copy 99:literal # 'c' + 1:number <- copy 3:literal + 2:number <- copy 97:literal # 'a' + 3:number <- copy 98:literal # 'b' + 4:number <- copy 99:literal # 'c' memory-should-contain [ 1:string <- [ab] ] @@ -287,10 +287,10 @@ recipe main [ :(scenario memory_check_string) recipe main [ - 1:integer <- copy 3:literal - 2:integer <- copy 97:literal # 'a' - 3:integer <- copy 98:literal # 'b' - 4:integer <- copy 99:literal # 'c' + 1:number <- copy 3:literal + 2:number <- copy 97:literal # 'a' + 3:number <- copy 98:literal # 'b' + 4:number <- copy 99:literal # 'c' memory-should-contain [ 1:string <- [abc] ] diff --git a/051scenario_test.mu b/051scenario_test.mu index 5064f8a5..88085e9b 100644 --- a/051scenario_test.mu +++ b/051scenario_test.mu @@ -2,7 +2,7 @@ scenario first_scenario_in_mu [ run [ - 1:integer <- add 2:literal, 2:literal + 1:number <- add 2:literal, 2:literal ] memory-should-contain [ 1 <- 4 @@ -12,7 +12,7 @@ scenario first_scenario_in_mu [ scenario scenario_with_comment_in_mu [ run [ # comment - 1:integer <- add 2:literal, 2:literal + 1:number <- add 2:literal, 2:literal ] memory-should-contain [ 1 <- 4 @@ -23,7 +23,7 @@ scenario scenario_with_multiple_comments_in_mu [ run [ # comment1 # comment2 - 1:integer <- add 2:literal, 2:literal + 1:number <- add 2:literal, 2:literal ] memory-should-contain [ 1 <- 4 @@ -32,7 +32,7 @@ scenario scenario_with_multiple_comments_in_mu [ scenario check_string_in_memory [ run [ - 1:integer <- copy 3:literal + 1:number <- copy 3:literal 2:character <- copy 97:literal # 'a' 3:character <- copy 98:literal # 'b' 4:character <- copy 99:literal # 'c' @@ -44,7 +44,7 @@ scenario check_string_in_memory [ scenario check_trace [ run [ - 1:integer <- add 2:literal, 2:literal + 1:number <- add 2:literal, 2:literal ] trace-should-contain [ mem: storing 4 in location 1 @@ -53,7 +53,7 @@ scenario check_trace [ scenario check_trace_negative [ run [ - 1:integer <- add 2:literal, 2:literal + 1:number <- add 2:literal, 2:literal ] trace-should-not-contain [ mem: storing 5 in location 1 diff --git a/060string.mu b/060string.mu index 6b38803b..7b1a3b5d 100644 --- a/060string.mu +++ b/060string.mu @@ -3,30 +3,30 @@ recipe string-equal [ default-space:address:array:location <- new location:type, 30:literal a:address:array:character <- next-ingredient - a-len:integer <- length a:address:array:character/deref + a-len:number <- length a:address:array:character/deref b:address:array:character <- next-ingredient - b-len:integer <- length b:address:array:character/deref + b-len:number <- length b:address:array:character/deref # compare lengths { trace [string-equal], [comparing lengths] - length-equal?:boolean <- equal a-len:integer, b-len:integer + length-equal?:boolean <- equal a-len:number, b-len:number break-if length-equal?:boolean reply 0:literal } # compare each corresponding character trace [string-equal], [comparing characters] - i:integer <- copy 0:literal + i:number <- copy 0:literal { - done?:boolean <- greater-or-equal i:integer, a-len:integer + done?:boolean <- greater-or-equal i:number, a-len:number break-if done?:boolean - a2:character <- index a:address:array:character/deref, i:integer - b2:character <- index b:address:array:character/deref, i:integer + a2:character <- index a:address:array:character/deref, i:number + b2:character <- index b:address:array:character/deref, i:number { chars-match?:boolean <- equal a2:character, b2:character break-if chars-match?:boolean reply 0:literal } - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } reply 1:literal @@ -99,7 +99,7 @@ scenario string-equal-common-lengths-but-distinct [ # A new type to help incrementally construct strings. container buffer [ - length:integer + length:number data:address:array:character ] @@ -108,11 +108,11 @@ recipe init-buffer [ #? $print default-space:address:array:location, [ #? ] result:address:buffer <- new buffer:type - len:address:integer <- get-address result:address:buffer/deref, length:offset - len:address:integer/deref <- copy 0:literal + len:address:number <- get-address result:address:buffer/deref, length:offset + len:address:number/deref <- copy 0:literal s:address:address:array:character <- get-address result:address:buffer/deref, data:offset - capacity:integer <- next-ingredient - s:address:address:array:character/deref <- new character:type, capacity:integer + capacity:number <- next-ingredient + s:address:address:array:character/deref <- new character:type, capacity:number #? $print s:address:address:array:character/deref, [ #? ] reply result:address:buffer @@ -123,19 +123,19 @@ recipe grow-buffer [ in:address:buffer <- next-ingredient # double buffer size x:address:address:array:character <- get-address in:address:buffer/deref, data:offset - oldlen:integer <- length x:address:address:array:character/deref/deref - newlen:integer <- multiply oldlen:integer, 2:literal + oldlen:number <- length x:address:address:array:character/deref/deref + newlen:number <- multiply oldlen:number, 2:literal olddata:address:array:character <- copy x:address:address:array:character/deref - x:address:address:array:character/deref <- new character:type, newlen:integer + x:address:address:array:character/deref <- new character:type, newlen:number # copy old contents - i:integer <- copy 0:literal + i:number <- copy 0:literal { - done?:boolean <- greater-or-equal i:integer, oldlen:integer + done?:boolean <- greater-or-equal i:number, oldlen:number break-if done?:boolean - src:character <- index olddata:address:array:character/deref, i:integer - dest:address:character <- index-address x:address:address:array:character/deref/deref, i:integer + src:character <- index olddata:address:array:character/deref, i:number + dest:address:character <- index-address x:address:address:array:character/deref/deref, i:number dest:address:character/deref <- copy src:character - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } reply in:address:buffer @@ -144,10 +144,10 @@ recipe grow-buffer [ recipe buffer-full? [ default-space:address:array:location <- new location:type, 30:literal in:address:buffer <- next-ingredient - len:integer <- get in:address:buffer/deref, length:offset + len:number <- get in:address:buffer/deref, length:offset s:address:array:character <- get in:address:buffer/deref, data:offset - capacity:integer <- length s:address:array:character/deref - result:boolean <- greater-or-equal len:integer, capacity:integer + capacity:number <- length s:address:array:character/deref + result:boolean <- greater-or-equal len:number, capacity:number reply result:boolean ] @@ -162,11 +162,11 @@ recipe buffer-append [ break-unless full?:boolean in:address:buffer <- grow-buffer in:address:buffer } - len:address:integer <- get-address in:address:buffer/deref, length:offset + len:address:number <- get-address in:address:buffer/deref, length:offset s:address:array:character <- get in:address:buffer/deref, data:offset - dest:address:character <- index-address s:address:array:character/deref, len:address:integer/deref + dest:address:character <- index-address s:address:array:character/deref, len:address:number/deref dest:address:character/deref <- copy c:character - len:address:integer/deref <- add len:address:integer/deref, 1:literal + len:address:number/deref <- add len:address:number/deref, 1:literal reply in:address:buffer/same-as-ingredient:0 ] @@ -182,24 +182,24 @@ scenario buffer-append-works [ 1:boolean/raw <- equal s1:address:array:character, s2:address:array:character #? $print s2:address:array:character, [ #? ] -#? $print 1060:integer/raw, [ +#? $print 1060:number/raw, [ #? ] -#? $print 1061:integer/raw, [ +#? $print 1061:number/raw, [ #? ] -#? $print 1062:integer/raw, [ +#? $print 1062:number/raw, [ #? ] -#? $print 1063:integer/raw, [ +#? $print 1063:number/raw, [ #? ] -#? $print 1064:integer/raw, [ +#? $print 1064:number/raw, [ #? ] -#? $print 1065:integer/raw, [ +#? $print 1065:number/raw, [ #? ] 2:array:character/raw <- copy s2:address:array:character/deref +buffer-filled x:address:buffer <- buffer-append x:address:buffer, 100:literal # 'd' s3:address:array:character <- get x:address:buffer/deref, data:offset 10:boolean/raw <- equal s1:address:array:character, s3:address:array:character - 11:integer/raw <- get x:address:buffer/deref, length:offset + 11:number/raw <- get x:address:buffer/deref, length:offset 12:array:character/raw <- copy s3:address:array:character/deref ] memory-should-contain [ @@ -222,32 +222,32 @@ scenario buffer-append-works [ ] ] -# result:address:array:character <- integer-to-decimal-string n:integer +# result:address:array:character <- integer-to-decimal-string n:number recipe integer-to-decimal-string [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient # is it zero? { - break-if n:integer + break-if n:number result:address:array:character <- new [0] reply result:address:array:character } # save sign negate-result:boolean <- copy 0:literal { - negative?:boolean <- lesser-than n:integer, 0:literal + negative?:boolean <- lesser-than n:number, 0:literal break-unless negative?:boolean negate-result:boolean <- copy 1:literal - n:integer <- multiply n:integer, -1:literal + n:number <- multiply n:number, -1:literal } # add digits from right to left into intermediate buffer tmp:address:buffer <- init-buffer 30:literal - digit-base:integer <- copy 48:literal # '0' + digit-base:number <- copy 48:literal # '0' { - done?:boolean <- equal n:integer, 0:literal + done?:boolean <- equal n:number, 0:literal break-if done?:boolean - n:integer, digit:integer <- divide-with-remainder n:integer, 10:literal - c:character <- add digit-base:integer, digit:integer + n:number, digit:number <- divide-with-remainder n:number, 10:literal + c:character <- add digit-base:number, digit:number tmp:address:buffer <- buffer-append tmp:address:buffer, c:character loop } @@ -257,23 +257,23 @@ recipe integer-to-decimal-string [ tmp:address:buffer <- buffer-append tmp:address:buffer, 45:literal # '-' } # reverse buffer into string result - len:integer <- get tmp:address:buffer/deref, length:offset + len:number <- get tmp:address:buffer/deref, length:offset buf:address:array:character <- get tmp:address:buffer/deref, data:offset - result:address:array:character <- new character:type, len:integer - i:integer <- subtract len:integer, 1:literal - j:integer <- copy 0:literal + result:address:array:character <- new character:type, len:number + i:number <- subtract len:number, 1:literal + j:number <- copy 0:literal { # while i >= 0 - done?:boolean <- lesser-than i:integer, 0:literal + done?:boolean <- lesser-than i:number, 0:literal break-if done?:boolean # result[j] = tmp[i] - src:character <- index buf:address:array:character/deref, i:integer - dest:address:character <- index-address result:address:array:character/deref, j:integer + src:character <- index buf:address:array:character/deref, i:number + dest:address:character <- index-address result:address:array:character/deref, j:number dest:address:character/deref <- copy src:character # ++i - i:integer <- subtract i:integer, 1:literal + i:number <- subtract i:number, 1:literal # --j - j:integer <- add j:integer, 1:literal + j:number <- add j:number, 1:literal loop } reply result:address:array:character @@ -315,42 +315,42 @@ recipe string-append [ default-space:address:array:location <- new location:type, 30:literal # result = new string[a.length + b.length] a:address:array:character <- next-ingredient - a-len:integer <- length a:address:array:character/deref + a-len:number <- length a:address:array:character/deref b:address:array:character <- next-ingredient - b-len:integer <- length b:address:array:character/deref - result-len:integer <- add a-len:integer, b-len:integer - result:address:array:character <- new character:type, result-len:integer + b-len:number <- length b:address:array:character/deref + result-len:number <- add a-len:number, b-len:number + result:address:array:character <- new character:type, result-len:number # copy a into result - result-idx:integer <- copy 0:literal - i:integer <- copy 0:literal + result-idx:number <- copy 0:literal + i:number <- copy 0:literal { # while i < a.length - a-done?:boolean <- greater-or-equal i:integer, a-len:integer + a-done?:boolean <- greater-or-equal i:number, a-len:number break-if a-done?:boolean # result[result-idx] = a[i] - out:address:character <- index-address result:address:array:character/deref, result-idx:integer - in:character <- index a:address:array:character/deref, i:integer + out:address:character <- index-address result:address:array:character/deref, result-idx:number + in:character <- index a:address:array:character/deref, i:number out:address:character/deref <- copy in:character # ++i - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal # ++result-idx - result-idx:integer <- add result-idx:integer, 1:literal + result-idx:number <- add result-idx:number, 1:literal loop } # copy b into result - i:integer <- copy 0:literal + i:number <- copy 0:literal { # while i < b.length - b-done?:boolean <- greater-or-equal i:integer, b-len:integer + b-done?:boolean <- greater-or-equal i:number, b-len:number break-if b-done?:boolean # result[result-idx] = a[i] - out:address:character <- index-address result:address:array:character/deref, result-idx:integer - in:character <- index b:address:array:character/deref, i:integer + out:address:character <- index-address result:address:array:character/deref, result-idx:number + in:character <- index b:address:array:character/deref, i:number out:address:character/deref <- copy in:character # ++i - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal # ++result-idx - result-idx:integer <- add result-idx:integer, 1:literal + result-idx:number <- add result-idx:number, 1:literal loop } reply result:address:array:character @@ -374,27 +374,27 @@ recipe interpolate [ default-space:array:address:location <- new location:type, 60:literal template:address:array:character <- next-ingredient # compute result-len, space to allocate for result - tem-len:integer <- length template:address:array:character/deref - result-len:integer <- copy tem-len:integer + tem-len:number <- length template:address:array:character/deref + result-len:number <- copy tem-len:number { # while arg received a:address:array:character, arg-received?:boolean <- next-ingredient break-unless arg-received?:boolean # result-len = result-len + arg.length - 1 for the 'underscore' being replaced - a-len:integer <- length a:address:array:character/deref - result-len:integer <- add result-len:integer, a-len:integer - result-len:integer <- subtract result-len:integer, 1:literal + a-len:number <- length a:address:array:character/deref + result-len:number <- add result-len:number, a-len:number + result-len:number <- subtract result-len:number, 1:literal loop } -#? $print tem-len:integer, [ ], $result-len:integer, [ #? 1 +#? $print tem-len:number, [ ], $result-len:number, [ #? 1 #? ] #? 1 rewind-ingredients _ <- next-ingredient # skip template # result = new array:character[result-len] - result:address:array:character <- new character:type, result-len:integer + result:address:array:character <- new character:type, result-len:number # repeatedly copy sections of template and 'holes' into result - result-idx:integer <- copy 0:literal - i:integer <- copy 0:literal + result-idx:number <- copy 0:literal + i:number <- copy 0:literal { # while arg received a:address:array:character, arg-received?:boolean <- next-ingredient @@ -402,54 +402,54 @@ recipe interpolate [ # copy template into result until '_' { # while i < template.length - tem-done?:boolean <- greater-or-equal i:integer, tem-len:integer + tem-done?:boolean <- greater-or-equal i:number, tem-len:number break-if tem-done?:boolean, 2:blocks # while template[i] != '_' - in:character <- index template:address:array:character/deref, i:integer + in:character <- index template:address:array:character/deref, i:number underscore?:boolean <- equal in:character, 95:literal # '_' break-if underscore?:boolean # result[result-idx] = template[i] - out:address:character <- index-address result:address:array:character/deref, result-idx:integer + out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++i - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal # ++result-idx - result-idx:integer <- add result-idx:integer, 1:literal + result-idx:number <- add result-idx:number, 1:literal loop } # copy 'a' into result - j:integer <- copy 0:literal + j:number <- copy 0:literal { # while j < a.length - arg-done?:boolean <- greater-or-equal j:integer, a-len:integer + arg-done?:boolean <- greater-or-equal j:number, a-len:number break-if arg-done?:boolean # result[result-idx] = a[j] - in:character <- index a:address:array:character/deref, j:integer - out:address:character <- index-address result:address:array:character/deref, result-idx:integer + in:character <- index a:address:array:character/deref, j:number + out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++j - j:integer <- add j:integer, 1:literal + j:number <- add j:number, 1:literal # ++result-idx - result-idx:integer <- add result-idx:integer, 1:literal + result-idx:number <- add result-idx:number, 1:literal loop } # skip '_' in template - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop # interpolate next arg } # done with holes; copy rest of template directly into result { # while i < template.length - tem-done?:boolean <- greater-or-equal i:integer, tem-len:integer + tem-done?:boolean <- greater-or-equal i:number, tem-len:number break-if tem-done?:boolean # result[result-idx] = template[i] - in:character <- index template:address:array:character/deref, i:integer - out:address:character <- index-address result:address:array:character/deref, result-idx:integer + in:character <- index template:address:array:character/deref, i:number + out:address:character <- index-address result:address:array:character/deref, result-idx:number out:address:character/deref <- copy in:character # ++i - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal # ++result-idx - result-idx:integer <- add result-idx:integer, 1:literal + result-idx:number <- add result-idx:number, 1:literal loop } reply result:address:array:character diff --git a/061channel.mu b/061channel.mu index 99ca660f..bb18f931 100644 --- a/061channel.mu +++ b/061channel.mu @@ -12,7 +12,7 @@ scenario channel [ run [ 1:address:channel <- init-channel 3:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal - 2:integer, 1:address:channel <- read 1:address:channel + 2:number, 1:address:channel <- read 1:address:channel ] memory-should-contain [ 2 <- 34 @@ -23,30 +23,30 @@ container channel [ # To avoid locking, writer and reader will never write to the same location. # So channels will include fields in pairs, one for the writer and one for the # reader. - first-full:integer # for write - first-free:integer # for read + first-full:number # for write + first-free:number # for read # A circular buffer contains values from index first-full up to (but not # including) index first-empty. The reader always modifies it at first-full, # while the writer always modifies it at first-empty. data:address:array:location ] -# result:address:channel <- init-channel capacity:integer +# result:address:channel <- init-channel capacity:number recipe init-channel [ default-space:address:array:location <- new location:type, 30:literal # result = new channel result:address:channel <- new channel:type # result.first-full = 0 - full:address:integer <- get-address result:address:channel/deref, first-full:offset - full:address:integer/deref <- copy 0:literal + full:address:number <- get-address result:address:channel/deref, first-full:offset + full:address:number/deref <- copy 0:literal # result.first-free = 0 - free:address:integer <- get-address result:address:channel/deref, first-free:offset - free:address:integer/deref <- copy 0:literal + free:address:number <- get-address result:address:channel/deref, first-free:offset + free:address:number/deref <- copy 0:literal # result.data = new location[ingredient+1] - capacity:integer <- next-ingredient - capacity:integer <- add capacity:integer, 1:literal # unused slot for 'full?' below + capacity:number <- next-ingredient + capacity:number <- add capacity:number, 1:literal # unused slot for 'full?' below dest:address:address:array:location <- get-address result:address:channel/deref, data:offset - dest:address:address:array:location/deref <- new location:type, capacity:integer + dest:address:address:array:location/deref <- new location:type, capacity:number reply result:address:channel ] @@ -59,22 +59,22 @@ recipe write [ # block if chan is full full:boolean <- channel-full? chan:address:channel break-unless full:boolean - full-address:address:integer <- get-address chan:address:channel/deref, first-full:offset - wait-for-location full-address:address:integer/deref + full-address:address:number <- get-address chan:address:channel/deref, first-full:offset + wait-for-location full-address:address:number/deref } # store val circular-buffer:address:array:location <- get chan:address:channel/deref, data:offset - free:address:integer <- get-address chan:address:channel/deref, first-free:offset - dest:address:location <- index-address circular-buffer:address:array:location/deref, free:address:integer/deref + free:address:number <- get-address chan:address:channel/deref, first-free:offset + dest:address:location <- index-address circular-buffer:address:array:location/deref, free:address:number/deref dest:address:location/deref <- copy val:location # increment free - free:address:integer/deref <- add free:address:integer/deref, 1:literal + free:address:number/deref <- add free:address:number/deref, 1:literal { # wrap free around to 0 if necessary - len:integer <- length circular-buffer:address:array:location/deref - at-end?:boolean <- greater-or-equal free:address:integer/deref, len:integer + len:number <- length circular-buffer:address:array:location/deref + at-end?:boolean <- greater-or-equal free:address:number/deref, len:number break-unless at-end?:boolean - free:address:integer/deref <- copy 0:literal + free:address:number/deref <- copy 0:literal } reply chan:address:channel/same-as-ingredient:0 ] @@ -87,21 +87,21 @@ recipe read [ # block if chan is empty empty:boolean <- channel-empty? chan:address:channel break-unless empty:boolean - free-address:address:integer <- get-address chan:address:channel/deref, first-free:offset - wait-for-location free-address:address:integer/deref + free-address:address:number <- get-address chan:address:channel/deref, first-free:offset + wait-for-location free-address:address:number/deref } # read result - full:address:integer <- get-address chan:address:channel/deref, first-full:offset + full:address:number <- get-address chan:address:channel/deref, first-full:offset circular-buffer:address:array:location <- get chan:address:channel/deref, data:offset - result:location <- index circular-buffer:address:array:location/deref, full:address:integer/deref + result:location <- index circular-buffer:address:array:location/deref, full:address:number/deref # increment full - full:address:integer/deref <- add full:address:integer/deref, 1:literal + full:address:number/deref <- add full:address:number/deref, 1:literal { # wrap full around to 0 if necessary - len:integer <- length circular-buffer:address:array:location/deref - at-end?:boolean <- greater-or-equal full:address:integer/deref, len:integer + len:number <- length circular-buffer:address:array:location/deref + at-end?:boolean <- greater-or-equal full:address:number/deref, len:number break-unless at-end?:boolean - full:address:integer/deref <- copy 0:literal + full:address:number/deref <- copy 0:literal } reply result:location, chan:address:channel/same-as-ingredient:0 ] @@ -120,8 +120,8 @@ recipe clear-channel [ scenario channel-initialization [ run [ 1:address:channel <- init-channel 3:literal/capacity - 2:integer <- get 1:address:channel/deref, first-full:offset - 3:integer <- get 1:address:channel/deref, first-free:offset + 2:number <- get 1:address:channel/deref, first-full:offset + 3:number <- get 1:address:channel/deref, first-free:offset ] memory-should-contain [ 2 <- 0 # first-full @@ -133,8 +133,8 @@ scenario channel-write-increments-free [ run [ 1:address:channel <- init-channel 3:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal - 2:integer <- get 1:address:channel/deref, first-full:offset - 3:integer <- get 1:address:channel/deref, first-free:offset + 2:number <- get 1:address:channel/deref, first-full:offset + 3:number <- get 1:address:channel/deref, first-free:offset ] memory-should-contain [ 2 <- 0 # first-full @@ -147,8 +147,8 @@ scenario channel-read-increments-full [ 1:address:channel <- init-channel 3:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal _, 1:address:channel <- read 1:address:channel - 2:integer <- get 1:address:channel/deref, first-full:offset - 3:integer <- get 1:address:channel/deref, first-free:offset + 2:number <- get 1:address:channel/deref, first-full:offset + 3:number <- get 1:address:channel/deref, first-free:offset ] memory-should-contain [ 2 <- 1 # first-full @@ -164,14 +164,14 @@ scenario channel-wrap [ 1:address:channel <- write 1:address:channel, 34:literal _, 1:address:channel <- read 1:address:channel # first-free will now be 1 - 2:integer <- get 1:address:channel/deref, first-free:offset - 3:integer <- get 1:address:channel/deref, first-free:offset + 2:number <- get 1:address:channel/deref, first-free:offset + 3:number <- get 1:address:channel/deref, first-free:offset # write second value, verify that first-free wraps 1:address:channel <- write 1:address:channel, 34:literal - 4:integer <- get 1:address:channel/deref, first-free:offset + 4:number <- get 1:address:channel/deref, first-free:offset # read second value, verify that first-full wraps _, 1:address:channel <- read 1:address:channel - 5:integer <- get 1:address:channel/deref, first-full:offset + 5:number <- get 1:address:channel/deref, first-full:offset ] memory-should-contain [ 2 <- 1 # first-free after first write @@ -188,9 +188,9 @@ recipe channel-empty? [ default-space:address:array:location <- new location:type, 30:literal chan:address:channel <- next-ingredient # return chan.first-full == chan.first-free - full:integer <- get chan:address:channel/deref, first-full:offset - free:integer <- get chan:address:channel/deref, first-free:offset - result:boolean <- equal full:integer, free:integer + full:number <- get chan:address:channel/deref, first-full:offset + free:number <- get chan:address:channel/deref, first-free:offset + result:boolean <- equal full:number, free:number reply result:boolean ] @@ -200,35 +200,35 @@ recipe channel-full? [ default-space:address:array:location <- new location:type, 30:literal chan:address:channel <- next-ingredient # tmp = chan.first-free + 1 - tmp:integer <- get chan:address:channel/deref, first-free:offset - tmp:integer <- add tmp:integer, 1:literal + tmp:number <- get chan:address:channel/deref, first-free:offset + tmp:number <- add tmp:number, 1:literal { # if tmp == chan.capacity, tmp = 0 - len:integer <- channel-capacity chan:address:channel - at-end?:boolean <- greater-or-equal tmp:integer, len:integer + len:number <- channel-capacity chan:address:channel + at-end?:boolean <- greater-or-equal tmp:number, len:number break-unless at-end?:boolean - tmp:integer <- copy 0:literal + tmp:number <- copy 0:literal } # return chan.first-full == tmp - full:integer <- get chan:address:channel/deref, first-full:offset - result:boolean <- equal full:integer, tmp:integer + full:number <- get chan:address:channel/deref, first-full:offset + result:boolean <- equal full:number, tmp:number reply result:boolean ] -# result:integer <- channel-capacity chan:address:channel +# result:number <- channel-capacity chan:address:channel recipe channel-capacity [ default-space:address:array:location <- new location:type, 30:literal chan:address:channel <- next-ingredient q:address:array:location <- get chan:address:channel/deref, data:offset - result:integer <- length q:address:array:location/deref - reply result:integer + result:number <- length q:address:array:location/deref + reply result:number ] scenario channel-new-empty-not-full [ run [ 1:address:channel <- init-channel 3:literal/capacity - 2:integer <- channel-empty? 1:address:channel - 3:integer <- channel-full? 1:address:channel + 2:boolean <- channel-empty? 1:address:channel + 3:boolean <- channel-full? 1:address:channel ] memory-should-contain [ 2 <- 1 # empty? @@ -240,8 +240,8 @@ scenario channel-write-not-empty [ run [ 1:address:channel <- init-channel 3:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal - 2:integer <- channel-empty? 1:address:channel - 3:integer <- channel-full? 1:address:channel + 2:boolean <- channel-empty? 1:address:channel + 3:boolean <- channel-full? 1:address:channel ] memory-should-contain [ 2 <- 0 # empty? @@ -253,8 +253,8 @@ scenario channel-write-full [ run [ 1:address:channel <- init-channel 1:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal - 2:integer <- channel-empty? 1:address:channel - 3:integer <- channel-full? 1:address:channel + 2:boolean <- channel-empty? 1:address:channel + 3:boolean <- channel-full? 1:address:channel ] memory-should-contain [ 2 <- 0 # empty? @@ -267,8 +267,8 @@ scenario channel-read-not-full [ 1:address:channel <- init-channel 1:literal/capacity 1:address:channel <- write 1:address:channel, 34:literal _, 1:address:channel <- read 1:address:channel - 2:integer <- channel-empty? 1:address:channel - 3:integer <- channel-full? 1:address:channel + 2:boolean <- channel-empty? 1:address:channel + 3:boolean <- channel-full? 1:address:channel ] memory-should-contain [ 2 <- 1 # empty? @@ -298,14 +298,14 @@ recipe buffer-lines [ #? return-to-console #? 2 #? $print [backspace! #? 1 #? ] #? 1 - buffer-length:address:integer <- get-address line:address:buffer/deref, length:offset + buffer-length:address:number <- get-address line:address:buffer/deref, length:offset { - buffer-empty?:boolean <- equal buffer-length:address:integer/deref, 0:literal + buffer-empty?:boolean <- equal buffer-length:address:number/deref, 0:literal break-if buffer-empty?:boolean -#? $print [before: ], buffer-length:address:integer/deref, [ #? 1 +#? $print [before: ], buffer-length:address:number/deref, [ #? 1 #? ] #? 1 - buffer-length:address:integer/deref <- subtract buffer-length:address:integer/deref, 1:literal -#? $print [after: ], buffer-length:address:integer/deref, [ #? 1 + buffer-length:address:number/deref <- subtract buffer-length:address:number/deref, 1:literal +#? $print [after: ], buffer-length:address:number/deref, [ #? 1 #? ] #? 1 } #? $exit #? 2 @@ -320,17 +320,17 @@ recipe buffer-lines [ } #? return-to-console #? 1 # copy line into 'out' - i:integer <- copy 0:literal + i:number <- copy 0:literal line-contents:address:array:character <- get line:address:buffer/deref, data:offset - max:integer <- get line:address:buffer/deref, length:offset + max:number <- get line:address:buffer/deref, length:offset { - done?:boolean <- greater-or-equal i:integer, max:integer + done?:boolean <- greater-or-equal i:number, max:number break-if done?:boolean - c:character <- index line-contents:address:array:character/deref, i:integer + c:character <- index line-contents:address:array:character/deref, i:number out:address:channel <- write out:address:channel, c:character -#? $print [writing ], i:integer, [: ], c:character, [ #? 1 +#? $print [writing ], i:number, [: ], c:character, [ #? 1 #? ] #? 1 - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } #? $dump-trace #? 1 @@ -348,29 +348,29 @@ scenario buffer-lines-blocks-until-newline [ assert 3:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after init] # buffer stdin into buffered-stdin, try to read from buffered-stdin - 4:integer/buffer-routine <- start-running buffer-lines:recipe, 1:address:channel/stdin, 2:address:channel/buffered-stdin - wait-for-routine 4:integer/buffer-routine + 4:number/buffer-routine <- start-running buffer-lines:recipe, 1:address:channel/stdin, 2:address:channel/buffered-stdin + wait-for-routine 4:number/buffer-routine 5:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 5:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after buffer-lines bring-up] # write 'a' 1:address:channel <- write 1:address:channel, 97:literal/a - restart 4:integer/buffer-routine - wait-for-routine 4:integer/buffer-routine + restart 4:number/buffer-routine + wait-for-routine 4:number/buffer-routine 6:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 6:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'a'] # write 'b' 1:address:channel <- write 1:address:channel, 98:literal/b - restart 4:integer/buffer-routine - wait-for-routine 4:integer/buffer-routine + restart 4:number/buffer-routine + wait-for-routine 4:number/buffer-routine 7:boolean <- channel-empty? 2:address:channel/buffered-stdin assert 7:boolean, [ F buffer-lines-blocks-until-newline: channel should be empty after writing 'b'] # write newline 1:address:channel <- write 1:address:channel, 13:literal/newline - restart 4:integer/buffer-routine - wait-for-routine 4:integer/buffer-routine + restart 4:number/buffer-routine + wait-for-routine 4:number/buffer-routine 8:boolean <- channel-empty? 2:address:channel/buffered-stdin 9:boolean/completed? <- not 8:boolean assert 9:boolean/completed?, [ diff --git a/062array.mu b/062array.mu index 95af1412..4369254a 100644 --- a/062array.mu +++ b/062array.mu @@ -14,26 +14,26 @@ scenario array-from-args [ # create an array out of a list of scalar args recipe init-array [ default-space:address:array:location <- new location:type, 30:literal - capacity:integer <- copy 0:literal + capacity:number <- copy 0:literal { # while read curr-value curr-value:location, exists?:boolean <- next-ingredient break-unless exists?:boolean - capacity:integer <- add capacity:integer, 1:literal + capacity:number <- add capacity:number, 1:literal loop } - result:address:array:location <- new location:type, capacity:integer + result:address:array:location <- new location:type, capacity:number rewind-ingredients - i:integer <- copy 0:literal + i:number <- copy 0:literal { # while read curr-value - done?:boolean <- greater-or-equal i:integer, capacity:integer + done?:boolean <- greater-or-equal i:number, capacity:number break-if done?:boolean curr-value:location, exists?:boolean <- next-ingredient assert exists?:boolean, [error in rewinding ingredients to init-array] - tmp:address:location <- index-address result:address:array:location/deref, i:integer + tmp:address:location <- index-address result:address:array:location/deref, i:number tmp:address:location/deref <- copy curr-value:location - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } reply result:address:array:location diff --git a/071print.mu b/071print.mu index f864eef9..411c8319 100644 --- a/071print.mu +++ b/071print.mu @@ -2,27 +2,27 @@ # easier to test. container screen [ - num-rows:integer - num-columns:integer - cursor-row:integer - cursor-column:integer + num-rows:number + num-columns:number + cursor-row:number + cursor-column:number data:address:array:character ] recipe init-fake-screen [ default-space:address:array:location <- new location:type, 30:literal/capacity result:address:screen <- new screen:type - width:address:integer <- get-address result:address:screen/deref, num-columns:offset - width:address:integer/deref <- next-ingredient - height:address:integer <- get-address result:address:screen/deref, num-rows:offset - height:address:integer/deref <- next-ingredient - row:address:integer <- get-address result:address:screen/deref, cursor-row:offset - row:address:integer/deref <- copy 0:literal - column:address:integer <- get-address result:address:screen/deref, cursor-column:offset - column:address:integer/deref <- copy 0:literal - bufsize:integer <- multiply width:address:integer/deref, height:address:integer/deref + width:address:number <- get-address result:address:screen/deref, num-columns:offset + width:address:number/deref <- next-ingredient + height:address:number <- get-address result:address:screen/deref, num-rows:offset + height:address:number/deref <- next-ingredient + row:address:number <- get-address result:address:screen/deref, cursor-row:offset + row:address:number/deref <- copy 0:literal + column:address:number <- get-address result:address:screen/deref, cursor-column:offset + column:address:number/deref <- copy 0:literal + bufsize:number <- multiply width:address:number/deref, height:address:number/deref buf:address:address:array:character <- get-address result:address:screen/deref, data:offset - buf:address:address:array:character/deref <- new character:literal, bufsize:integer + buf:address:address:array:character/deref <- new character:literal, bufsize:number clear-screen result:address:screen reply result:address:screen ] @@ -35,14 +35,14 @@ recipe clear-screen [ break-unless x:address:screen # clear fake screen buf:address:array:character <- get x:address:screen/deref, data:offset - max:integer <- length buf:address:array:character/deref - i:integer <- copy 0:literal + max:number <- length buf:address:array:character/deref + i:number <- copy 0:literal { - done?:boolean <- greater-or-equal i:integer, max:integer + done?:boolean <- greater-or-equal i:number, max:number break-if done?:boolean - c:address:character <- index-address buf:address:array:character/deref, i:integer + c:address:character <- index-address buf:address:array:character/deref, i:number c:address:character/deref <- copy [ ] - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } reply x:address:screen/same-as-ingredient:0 @@ -60,11 +60,11 @@ recipe print-character [ # if x exists # (handle special cases exactly like in the real screen) break-unless x:address:screen - row:address:integer <- get-address x:address:screen/deref, cursor-row:offset - column:address:integer <- get-address x:address:screen/deref, cursor-column:offset - width:integer <- get x:address:screen/deref, num-columns:offset - height:integer <- get x:address:screen/deref, num-rows:offset - max-row:integer <- subtract height:integer, 1:literal + row:address:number <- get-address x:address:screen/deref, cursor-row:offset + column:address:number <- get-address x:address:screen/deref, cursor-column:offset + width:number <- get x:address:screen/deref, num-columns:offset + height:number <- get x:address:screen/deref, num-rows:offset + max-row:number <- subtract height:number, 1:literal # special-case: newline { newline?:boolean <- equal c:character, 13:literal @@ -73,29 +73,29 @@ recipe print-character [ break-unless newline?:boolean { # unless cursor is already at bottom - at-bottom?:boolean <- greater-or-equal row:address:integer/deref, max-row:integer + at-bottom?:boolean <- greater-or-equal row:address:number/deref, max-row:number break-if at-bottom?:boolean # move it to the next row - column:address:integer/deref <- copy 0:literal - row:address:integer/deref <- add row:address:integer/deref, 1:literal + column:address:number/deref <- copy 0:literal + row:address:number/deref <- add row:address:number/deref, 1:literal } reply x:address:screen/same-as-ingredient:0 } # save character in fake screen - index:integer <- multiply row:address:integer/deref, width:integer - index:integer <- add index:integer, column:address:integer/deref + index:number <- multiply row:address:number/deref, width:number + index:number <- add index:number, column:address:number/deref buf:address:array:character <- get x:address:screen/deref, data:offset - cursor:address:character <- index-address buf:address:array:character/deref, index:integer + cursor:address:character <- index-address buf:address:array:character/deref, index:number # special-case: backspace { backspace?:boolean <- equal c:character, 8:literal break-unless backspace?:boolean { # unless cursor is already at left margin - at-left?:boolean <- lesser-or-equal column:address:integer/deref, 0:literal + at-left?:boolean <- lesser-or-equal column:address:number/deref, 0:literal break-if at-left?:boolean # clear previous location - column:address:integer/deref <- subtract column:address:integer/deref, 1:literal + column:address:number/deref <- subtract column:address:number/deref, 1:literal cursor:address:character <- subtract cursor:address:character, 1:literal cursor:address:character/deref <- copy 32:literal/space } @@ -104,9 +104,9 @@ recipe print-character [ cursor:address:character/deref <- copy c:character # increment column unless it's already all the way to the right { - at-right?:boolean <- equal column:address:integer/deref, width:integer + at-right?:boolean <- equal column:address:number/deref, width:number break-if at-right?:boolean - column:address:integer/deref <- add column:address:integer/deref, 1:literal + column:address:number/deref <- add column:address:number/deref, 1:literal } reply x:address:screen/same-as-ingredient:0 } @@ -136,7 +136,7 @@ scenario print-backspace-character [ 1:address:screen <- init-fake-screen 3:literal/width, 2:literal/height 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' 1:address:screen <- print-character 1:address:screen, 8:literal # backspace - 2:integer <- get 1:address:screen/deref, cursor-column:offset + 2:number <- get 1:address:screen/deref, cursor-column:offset 3:address:array:character <- get 1:address:screen/deref, data:offset 4:array:character <- copy 3:address:array:character/deref ] @@ -154,8 +154,8 @@ scenario print-newline-character [ 1:address:screen <- init-fake-screen 3:literal/width, 2:literal/height 1:address:screen <- print-character 1:address:screen, 97:literal # 'a' 1:address:screen <- print-character 1:address:screen, 13:literal/newline - 2:integer <- get 1:address:screen/deref, cursor-row:offset - 3:integer <- get 1:address:screen/deref, cursor-column:offset + 2:number <- get 1:address:screen/deref, cursor-row:offset + 3:number <- get 1:address:screen/deref, cursor-column:offset 4:address:array:character <- get 1:address:screen/deref, data:offset 5:array:character <- copy 4:address:array:character/deref ] @@ -174,21 +174,21 @@ recipe clear-line [ # if x exists, clear line in fake screen { break-unless x:address:screen - n:integer <- get x:address:screen/deref, num-columns:offset - column:address:integer <- get-address x:address:screen/deref, cursor-column:offset - original-column:integer <- copy column:address:integer/deref + n:number <- get x:address:screen/deref, num-columns:offset + column:address:number <- get-address x:address:screen/deref, cursor-column:offset + original-column:number <- copy column:address:number/deref # space over the entire line #? $start-tracing #? 1 { -#? $print column:address:integer/deref, [ #? 1 +#? $print column:address:number/deref, [ #? 1 #? ] #? 1 - done?:boolean <- greater-or-equal column:address:integer/deref, n:integer + done?:boolean <- greater-or-equal column:address:number/deref, n:number break-if done?:boolean print-character x:address:screen, [ ] # implicitly updates 'column' loop } # now back to where the cursor was - column:address:integer/deref <- copy original-column:integer + column:address:number/deref <- copy original-column:number reply x:address:screen/same-as-ingredient:0 } # otherwise, real screen @@ -202,30 +202,30 @@ recipe cursor-position [ # if x exists, lookup cursor in fake screen { break-unless x:address:screen - row:integer <- get x:address:screen/deref, cursor-row:offset - column:integer <- get x:address:screen/deref, cursor-column:offset - reply row:integer, column:integer, x:address:screen/same-as-ingredient:0 + row:number <- get x:address:screen/deref, cursor-row:offset + column:number <- get x:address:screen/deref, cursor-column:offset + reply row:number, column:number, x:address:screen/same-as-ingredient:0 } - row:integer, column:integer <- cursor-position-on-display - reply row:integer, column:integer, x:address:screen/same-as-ingredient:0 + row:number, column:number <- cursor-position-on-display + reply row:number, column:number, x:address:screen/same-as-ingredient:0 ] recipe move-cursor [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient - new-row:integer <- next-ingredient - new-column:integer <- next-ingredient + new-row:number <- next-ingredient + new-column:number <- next-ingredient # if x exists, move cursor in fake screen { break-unless x:address:screen - row:address:integer <- get-address x:address:screen/deref, cursor-row:offset - row:address:integer/deref <- copy new-row:integer - column:address:integer <- get-address x:address:screen/deref, cursor-column:offset - column:address:integer/deref <- copy new-column:integer + row:address:number <- get-address x:address:screen/deref, cursor-row:offset + row:address:number/deref <- copy new-row:number + column:address:number <- get-address x:address:screen/deref, cursor-column:offset + column:address:number/deref <- copy new-column:number reply x:address:screen/same-as-ingredient:0 } # otherwise, real screen - move-cursor-on-display new-row:integer, new-column:integer + move-cursor-on-display new-row:number, new-column:number reply x:address:screen/same-as-ingredient:0 ] @@ -262,15 +262,15 @@ recipe cursor-down [ break-unless x:address:screen { # if row < height - height:integer <- get x:address:screen/deref, num-rows:offset - row:address:integer <- get-address x:address:screen/deref, cursor-row:offset - at-bottom?:boolean <- greater-or-equal row:address:integer/deref, height:integer + height:number <- get x:address:screen/deref, num-rows:offset + row:address:number <- get-address x:address:screen/deref, cursor-row:offset + at-bottom?:boolean <- greater-or-equal row:address:number/deref, height:number break-if at-bottom?:boolean # row = row+1 -#? $print [AAA: ], row:address:integer, [ -> ], row:address:integer/deref, [ #? 1 +#? $print [AAA: ], row:address:number, [ -> ], row:address:number/deref, [ #? 1 #? ] #? 1 - row:address:integer/deref <- add row:address:integer/deref, 1:literal -#? $print [BBB: ], row:address:integer, [ -> ], row:address:integer/deref, [ #? 1 + row:address:number/deref <- add row:address:number/deref, 1:literal +#? $print [BBB: ], row:address:number, [ -> ], row:address:number/deref, [ #? 1 #? ] #? 1 #? $start-tracing #? 1 } @@ -289,11 +289,11 @@ recipe cursor-up [ break-unless x:address:screen { # if row >= 0 - row:address:integer <- get-address x:address:screen/deref, cursor-row:offset - at-top?:boolean <- lesser-than row:address:integer/deref, 0:literal + row:address:number <- get-address x:address:screen/deref, cursor-row:offset + at-top?:boolean <- lesser-than row:address:number/deref, 0:literal break-if at-top?:boolean # row = row-1 - row:address:integer/deref <- subtract row:address:integer/deref, 1:literal + row:address:number/deref <- subtract row:address:number/deref, 1:literal } reply x:address:screen/same-as-ingredient:0 } @@ -310,12 +310,12 @@ recipe cursor-right [ break-unless x:address:screen { # if column < width - width:integer <- get x:address:screen/deref, num-columns:offset - column:address:integer <- get-address x:address:screen/deref, cursor-column:offset - at-bottom?:boolean <- greater-or-equal column:address:integer/deref, width:integer + width:number <- get x:address:screen/deref, num-columns:offset + column:address:number <- get-address x:address:screen/deref, cursor-column:offset + at-bottom?:boolean <- greater-or-equal column:address:number/deref, width:number break-if at-bottom?:boolean # column = column+1 - column:address:integer/deref <- add column:address:integer/deref, 1:literal + column:address:number/deref <- add column:address:number/deref, 1:literal } reply x:address:screen/same-as-ingredient:0 } @@ -332,11 +332,11 @@ recipe cursor-left [ break-unless x:address:screen { # if column >= 0 - column:address:integer <- get-address x:address:screen/deref, cursor-column:offset - at-top?:boolean <- lesser-than column:address:integer/deref, 0:literal + column:address:number <- get-address x:address:screen/deref, cursor-column:offset + at-top?:boolean <- lesser-than column:address:number/deref, 0:literal break-if at-top?:boolean # column = column-1 - column:address:integer/deref <- subtract column:address:integer/deref, 1:literal + column:address:number/deref <- subtract column:address:number/deref, 1:literal } reply x:address:screen/same-as-ingredient:0 } @@ -348,9 +348,9 @@ recipe cursor-left [ recipe cursor-to-start-of-line [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient - row:integer, _, x:address:screen <- cursor-position x:address:screen - column:integer <- copy 0:literal - x:address:screen <- move-cursor x:address:screen, row:integer, column:integer + row:number, _, x:address:screen <- cursor-position x:address:screen + column:number <- copy 0:literal + x:address:screen <- move-cursor x:address:screen, row:number, column:number reply x:address:screen/same-as-ingredient:0 ] @@ -366,14 +366,14 @@ recipe print-string [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient s:address:array:character <- next-ingredient - len:integer <- length s:address:array:character/deref - i:integer <- copy 0:literal + len:number <- length s:address:array:character/deref + i:number <- copy 0:literal { - done?:boolean <- greater-or-equal i:integer, len:integer + done?:boolean <- greater-or-equal i:number, len:number break-if done?:boolean - c:character <- index s:address:array:character/deref, i:integer + c:character <- index s:address:array:character/deref, i:number print-character x:address:screen c:character - i:integer <- add i:integer, 1:literal + i:number <- add i:number, 1:literal loop } reply x:address:screen/same-as-ingredient:0 @@ -382,9 +382,9 @@ recipe print-string [ recipe print-integer [ default-space:address:array:location <- new location:type, 30:literal x:address:screen <- next-ingredient - n:integer <- next-ingredient + n:number <- next-ingredient # todo: other bases besides decimal - s:address:array:character <- integer-to-decimal-string n:integer + s:address:array:character <- integer-to-decimal-string n:number print-string x:address:screen, s:address:array:character reply x:address:screen/same-as-ingredient:0 ] diff --git a/074keyboard.mu b/074keyboard.mu index dd7740e9..fbbaad48 100644 --- a/074keyboard.mu +++ b/074keyboard.mu @@ -2,7 +2,7 @@ # easier to test. container keyboard [ # can't think of another word like screen/display, so real and fake keyboards use the same name - index:integer + index:number data:address:array:character ] @@ -13,8 +13,8 @@ recipe init-fake-keyboard [ #? $start-tracing #? 1 buf:address:address:array:character/deref <- next-ingredient #? $stop-tracing #? 1 - idx:address:integer <- get-address result:address:keyboard/deref, index:offset - idx:address:integer/deref <- copy 0:literal + idx:address:number <- get-address result:address:keyboard/deref, index:offset + idx:address:number/deref <- copy 0:literal reply result:address:keyboard ] @@ -23,16 +23,16 @@ recipe read-key [ x:address:keyboard <- next-ingredient { break-unless x:address:keyboard - idx:address:integer <- get-address x:address:keyboard/deref, index:offset + idx:address:number <- get-address x:address:keyboard/deref, index:offset buf:address:array:character <- get x:address:keyboard/deref, data:offset - max:integer <- length buf:address:array:character/deref + max:number <- length buf:address:array:character/deref { - done?:boolean <- greater-or-equal idx:address:integer/deref, max:integer + done?:boolean <- greater-or-equal idx:address:number/deref, max:number break-unless done?:boolean reply 0:literal, 0:literal/done, x:address:keyboard/same-as-ingredient:0 } - c:character <- index buf:address:array:character/deref, idx:address:integer/deref - idx:address:integer/deref <- add idx:address:integer/deref, 1:literal + c:character <- index buf:address:array:character/deref, idx:address:number/deref + idx:address:number/deref <- add idx:address:number/deref, 1:literal reply c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0 } # real keyboard input is infrequent; avoid polling it too much diff --git a/Readme.md b/Readme.md index ad5510a4..9f59b35e 100644 --- a/Readme.md +++ b/Readme.md @@ -71,18 +71,18 @@ As a sneak peek, here's how you compute factorial in Mu: ```python recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal } # return n * factorial(n - 1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] ``` @@ -99,15 +99,15 @@ number of them. In particular you can have any number of results. For example, you can perform integer division as follows: ```python - quotient:integer, remainder:integer <- divide-with-remainder 11:literal, 3:literal + quotient:number, remainder:number <- divide-with-remainder 11:literal, 3:literal ``` Each reagent provides its name as well as its type separated by a colon. Types can be multiple words, like: ```python - x:array:integer:3 # x is an array of 3 integers - y:list:integer # y is a list of integers + x:array:number:3 # x is an array of 3 integers + y:list:number # y is a list of integers ``` Try out the factorial program now: @@ -124,13 +124,13 @@ its address. Mu maps names to addresses for you like in other languages, but in a more transparent, lightweight, hackable manner. This instruction: ```python - z:integer <- add x:integer, y:integer + z:number <- add x:number, y:number ``` might turn into this: ```python - 3:integer <- add 1:integer, 2:integer + 3:number <- add 1:number, 2:number ``` You shouldn't rely on the specific address Mu chooses for a variable, but it @@ -171,7 +171,7 @@ Once you've chained spaces together, you can access variables in them by adding a 'space' property: ```python - 3:integer/space:1 + 3:number/space:1 ``` This reagent is the integer in slot 3 of the space chained in slot 0 of the @@ -189,9 +189,9 @@ You can append arbitrary properties to reagents besides types and spaces. Just separate them with slashes. ```python - x:array:integer:3/uninitialized + x:array:number:3/uninitialized y:string/tainted:yes - z:list:integer/assign-once:true/assigned:false + z:list:number/assign-once:true/assigned:false ``` Most properties are meaningless to Mu, and it'll silently skip them when @@ -222,7 +222,7 @@ inserting code at them. ```python recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { +base-case: } @@ -231,17 +231,17 @@ inserting code at them. after +base-case [ # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal ] after +recursive-case [ # return n * factorial(n-1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] ``` diff --git a/channel.mu b/channel.mu index 0206c2f9..86378352 100644 --- a/channel.mu +++ b/channel.mu @@ -5,15 +5,15 @@ recipe producer [ default-space:address:array:location <- new location:type, 30:literal chan:address:channel <- next-ingredient # n = 0 - n:integer <- copy 0:literal + n:number <- copy 0:literal { - done?:boolean <- lesser-than n:integer, 5:literal + done?:boolean <- lesser-than n:number, 5:literal break-unless done?:boolean # other threads might get between these prints - $print [produce: ], n:integer, [ + $print [produce: ], n:number, [ ] - chan:address:channel <- write chan:address:channel, n:integer - n:integer <- add n:integer, 1:literal + chan:address:channel <- write chan:address:channel, n:number + n:number <- add n:number, 1:literal loop } ] @@ -24,9 +24,9 @@ recipe consumer [ chan:address:channel <- next-ingredient { # read an integer from the channel - n:integer, chan:address:channel <- read chan:address:channel + n:number, chan:address:channel <- read chan:address:channel # other threads might get between these prints - $print [consume: ], n:integer, [ + $print [consume: ], n:number, [ ] loop } @@ -36,8 +36,8 @@ recipe main [ default-space:address:array:location <- new location:type, 30:literal chan:address:channel <- init-channel 3:literal # create two background 'routines' that communicate by a channel - routine1:integer <- start-running producer:recipe, chan:address:channel - routine2:integer <- start-running consumer:recipe, chan:address:channel - wait-for-routine routine1:integer - wait-for-routine routine2:integer + routine1:number <- start-running producer:recipe, chan:address:channel + routine2:number <- start-running consumer:recipe, chan:address:channel + wait-for-routine routine1:number + wait-for-routine routine2:number ] diff --git a/chessboard.mu b/chessboard.mu index 93867fd4..e6e28611 100644 --- a/chessboard.mu +++ b/chessboard.mu @@ -68,20 +68,20 @@ recipe chessboard [ recipe init-board [ default-space:address:array:location <- new location:type, 30:literal - initial-position:address:array:integer <- next-ingredient + initial-position:address:array:number <- next-ingredient # assert(length(initial-position) == 64) - len:integer <- length initial-position:address:array:integer/deref - correct-length?:boolean <- equal len:integer, 64:literal + len:number <- length initial-position:address:array:number/deref + correct-length?:boolean <- equal len:number, 64:literal assert correct-length?:boolean, [chessboard had incorrect size] # board is an array of pointers to files; file is an array of characters board:address:array:address:array:character <- new location:type, 8:literal - col:integer <- copy 0:literal + col:number <- copy 0:literal { - done?:boolean <- equal col:integer, 8:literal + done?:boolean <- equal col:number, 8:literal break-if done?:boolean - file:address:address:array:character <- index-address board:address:array:address:array:character/deref, col:integer - file:address:address:array:character/deref <- init-file initial-position:address:array:integer, col:integer - col:integer <- add col:integer, 1:literal + file:address:address:array:character <- index-address board:address:array:address:array:character/deref, col:number + file:address:address:array:character/deref <- init-file initial-position:address:array:number, col:number + col:number <- add col:number, 1:literal loop } reply board:address:array:address:array:character @@ -89,18 +89,18 @@ recipe init-board [ recipe init-file [ default-space:address:array:location <- new location:type, 30:literal - position:address:array:integer <- next-ingredient - index:integer <- next-ingredient - index:integer <- multiply index:integer, 8:literal + position:address:array:number <- next-ingredient + index:number <- next-ingredient + index:number <- multiply index:number, 8:literal result:address:array:character <- new character:type, 8:literal - row:integer <- copy 0:literal + row:number <- copy 0:literal { - done?:boolean <- equal row:integer, 8:literal + done?:boolean <- equal row:number, 8:literal break-if done?:boolean - dest:address:character <- index-address result:address:array:character/deref, row:integer - dest:address:character/deref <- index position:address:array:integer/deref, index:integer - row:integer <- add row:integer, 1:literal - index:integer <- add index:integer, 1:literal + dest:address:character <- index-address result:address:array:character/deref, row:number + dest:address:character/deref <- index position:address:array:number/deref, index:number + row:number <- add row:number, 1:literal + index:number <- add index:number, 1:literal loop } reply result:address:array:character @@ -110,29 +110,29 @@ recipe print-board [ default-space:address:array:location <- new location:type, 30:literal screen:address <- next-ingredient board:address:array:address:array:character <- next-ingredient - row:integer <- copy 7:literal # start printing from the top of the board + row:number <- copy 7:literal # start printing from the top of the board # print each row { - done?:boolean <- lesser-than row:integer, 0:literal + done?:boolean <- lesser-than row:number, 0:literal break-if done?:boolean # print rank number as a legend - rank:integer <- add row:integer, 1:literal - print-integer screen:address, rank:integer + rank:number <- add row:number, 1:literal + print-integer screen:address, rank:number s:address:array:character <- new [ | ] print-string screen:address, s:address:array:character # print each square in the row - col:integer <- copy 0:literal + col:number <- copy 0:literal { - done?:boolean <- equal col:integer, 8:literal + done?:boolean <- equal col:number, 8:literal break-if done?:boolean - f:address:array:character <- index board:address:array:address:array:character/deref, col:integer - s:character <- index f:address:array:character/deref, row:integer + f:address:array:character <- index board:address:array:address:array:character/deref, col:number + s:character <- index f:address:array:character/deref, row:number print-character screen:address, s:character print-character screen:address, 32:literal # ' ' - col:integer <- add col:integer, 1:literal + col:number <- add col:number, 1:literal loop } - row:integer <- subtract row:integer, 1:literal + row:number <- subtract row:number, 1:literal cursor-to-next-line screen:address loop } @@ -158,7 +158,7 @@ recipe initial-position [ # B P _ _ _ _ p B # N P _ _ _ _ p n # R P _ _ _ _ p r - initial-position:address:array:integer <- init-array 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 81:literal/Q, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 113:literal/q, 75:literal/K, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 107:literal/k, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r + initial-position:address:array:number <- init-array 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 81:literal/Q, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 113:literal/q, 75:literal/K, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 107:literal/k, 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r #? 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r, #? 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, #? 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, @@ -167,7 +167,7 @@ recipe initial-position [ #? 66:literal/B, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 98:literal/b, #? 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n, #? 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r - board:address:array:address:array:character <- init-board initial-position:address:array:integer + board:address:array:address:array:character <- init-board initial-position:address:array:number reply board:address:array:address:array:character ] @@ -198,10 +198,10 @@ scenario printing-the-board [ container move [ # valid range: 0-7 - from-file:integer - from-rank:integer - to-file:integer - to-rank:integer + from-file:number + from-rank:number + to-file:number + to-rank:number ] # result:address:move, quit?:boolean, error?:boolean <- read-move stdin:address:channel, screen:address @@ -211,26 +211,26 @@ recipe read-move [ stdin:address:channel <- next-ingredient screen:address <- next-ingredient #? $print screen:address #? 1 - from-file:integer, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address + from-file:number, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean #? return-to-console #? 1 # construct the move object result:address:move <- new move:literal - x:address:integer <- get-address result:address:move/deref, from-file:offset - x:address:integer/deref <- copy from-file:integer - x:address:integer <- get-address result:address:move/deref, from-rank:offset - x:address:integer/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address + x:address:number <- get-address result:address:move/deref, from-file:offset + x:address:number/deref <- copy from-file:number + x:address:number <- get-address result:address:move/deref, from-rank:offset + x:address:number/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean error?:boolean <- expect-from-channel stdin:address:channel, 45:literal/dash, screen:address reply-if error?:boolean, 0:literal/dummy, 0:literal/quit, error?:boolean - x:address:integer <- get-address result:address:move/deref, to-file:offset - x:address:integer/deref, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address + x:address:number <- get-address result:address:move/deref, to-file:offset + x:address:number/deref, quit?:boolean, error?:boolean <- read-file stdin:address:channel, screen:address reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean - x:address:integer <- get-address result:address:move/deref, to-rank:offset - x:address:integer/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address + x:address:number <- get-address result:address:move/deref, to-rank:offset + x:address:number/deref, quit?:boolean, error?:boolean <- read-rank stdin:address:channel, screen:address reply-if quit?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean reply-if error?:boolean, 0:literal/dummy, quit?:boolean, error?:boolean #? $exit #? 1 @@ -239,7 +239,7 @@ recipe read-move [ reply result:address:move, quit?:boolean, error?:boolean ] -# file:integer, quit:boolean, error:boolean <- read-file stdin:address:channel, screen:address +# file:number, quit:boolean, error:boolean <- read-file stdin:address:channel, screen:address # valid values for file: 0-7 recipe read-file [ default-space:address:array:location <- new location:type, 30:literal @@ -263,12 +263,12 @@ recipe read-file [ print-string screen:address, error-message:address:array:character reply 0:literal/dummy, 0:literal/quit, 1:literal/error } - file:integer <- subtract c:character, 97:literal # 'a' -#? $print file:integer, [ #? 1 + file:number <- subtract c:character, 97:literal # 'a' +#? $print file:number, [ #? 1 #? ] #? 1 # 'a' <= file <= 'h' { - above-min:boolean <- greater-or-equal file:integer, 0:literal + above-min:boolean <- greater-or-equal file:number, 0:literal break-if above-min:boolean error-message:address:array:character <- new [file too low: ] print-string screen:address, error-message:address:array:character @@ -277,17 +277,17 @@ recipe read-file [ reply 0:literal/dummy, 0:literal/quit, 1:literal/error } { - below-max:boolean <- lesser-than file:integer, 8:literal + below-max:boolean <- lesser-than file:number, 8:literal break-if below-max:boolean error-message:address:array:character <- new [file too high: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character reply 0:literal/dummy, 0:literal/quit, 1:literal/error } - reply file:integer, 0:literal/quit, 0:literal/error + reply file:number, 0:literal/quit, 0:literal/error ] -# rank:integer <- read-rank stdin:address:channel, screen:address +# rank:number <- read-rank stdin:address:channel, screen:address # valid values: 0-7, -1 (quit), -2 (error) recipe read-rank [ default-space:address:array:location <- new location:type, 30:literal @@ -311,12 +311,12 @@ recipe read-rank [ print-string screen:address, error-message:address:array:character reply 0:literal/dummy, 0:literal/quit, 1:literal/error } - rank:integer <- subtract c:character, 49:literal # '1' -#? $print rank:integer, [ #? 1 + rank:number <- subtract c:character, 49:literal # '1' +#? $print rank:number, [ #? 1 #? ] #? 1 # assert'1' <= rank <= '8' { - above-min:boolean <- greater-or-equal rank:integer, 0:literal + above-min:boolean <- greater-or-equal rank:number, 0:literal break-if above-min:boolean error-message:address:array:character <- new [rank too low: ] print-string screen:address, error-message:address:array:character @@ -324,14 +324,14 @@ recipe read-rank [ reply 0:literal/dummy, 0:literal/quit, 1:literal/error } { - below-max:boolean <- lesser-or-equal rank:integer, 7:literal + below-max:boolean <- lesser-or-equal rank:number, 7:literal break-if below-max:boolean error-message:address:array:character <- new [rank too high: ] print-string screen:address, error-message:address:array:character print-character screen:address, c:character reply 0:literal/dummy, 0:literal/quit, 1:literal/error } - reply rank:integer, 0:literal/quit, 0:literal/error + reply rank:number, 0:literal/quit, 0:literal/error ] # read a character from the given channel and check that it's what we expect @@ -359,15 +359,15 @@ scenario read-move-blocking [ 1:address:channel <- init-channel 2:literal #? $print [aaa channel address: ], 1:address:channel, [ #? 1 #? ] #? 1 - 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input - wait-for-routine 2:integer + wait-for-routine 2:number #? $print [bbb channel address: ], 1:address:channel, [ #? 1 #? ] #? 1 - 3:integer <- routine-state 2:integer/id -#? $print [I: routine ], 2:integer, [ state ], 3:integer [ #? 1 + 3:number <- routine-state 2:number/id +#? $print [I: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after coming up (before any keys were pressed)] # press 'a' @@ -375,68 +375,68 @@ F read-move-blocking: routine failed to pause after coming up (before any keys w #? ] #? 1 #? $exit #? 1 1:address:channel <- write 1:address:channel, 97:literal # 'a' - restart 2:integer/routine + restart 2:number/routine # 'read-move' still waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id -#? $print [II: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number/id +#? $print [II: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after rank 'a'] # press '2' 1:address:channel <- write 1:address:channel, 50:literal # '2' - restart 2:integer/routine + restart 2:number/routine # 'read-move' still waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id -#? $print [III: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number/id +#? $print [III: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2'] # press '-' 1:address:channel <- write 1:address:channel, 45:literal # '-' - restart 2:integer/routine + restart 2:number/routine # 'read-move' still waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer -#? $print [IV: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number +#? $print [IV: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after hyphen 'a2-'] # press 'a' 1:address:channel <- write 1:address:channel, 97:literal # 'a' - restart 2:integer/routine + restart 2:number/routine # 'read-move' still waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer -#? $print [V: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number +#? $print [V: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?/routine-state, [ F read-move-blocking: routine failed to pause after rank 'a2-a'] # press '4' 1:address:channel <- write 1:address:channel, 52:literal # '4' - restart 2:integer/routine + restart 2:number/routine # 'read-move' still waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer -#? $print [VI: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number +#? $print [VI: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-blocking: routine failed to pause after file 'a2-a4'] # press 'newline' 1:address:channel <- write 1:address:channel, 13:literal # newline - restart 2:integer/routine + restart 2:number/routine # 'read-move' now completes - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer -#? $print [VII: routine ], 2:integer, [ state ], 3:integer [ #? 1 + wait-for-routine 2:number + 3:number <- routine-state 2:number +#? $print [VII: routine ], 2:number, [ state ], 3:number [ #? 1 #? ] #? 1 - 4:boolean/completed? <- equal 3:integer/routine-state, 1:literal/completed + 4:boolean/completed? <- equal 3:number/routine-state, 1:literal/completed assert 4:boolean/completed?, [ F read-move-blocking: routine failed to terminate on newline] trace [test], [reached end] @@ -450,20 +450,20 @@ scenario read-move-quit [ assume-screen 20:literal/width, 2:literal/height run [ 1:address:channel <- init-channel 2:literal - 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + wait-for-routine 2:number + 3:number <- routine-state 2:number/id + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-quit: routine failed to pause after coming up (before any keys were pressed)] # press 'q' 1:address:channel <- write 1:address:channel, 113:literal # 'q' - restart 2:integer/routine + restart 2:number/routine # 'read-move' completes - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id - 4:boolean/completed? <- equal 3:integer/routine-state, 1:literal/completed + wait-for-routine 2:number + 3:number <- routine-state 2:number/id + 4:boolean/completed? <- equal 3:number/routine-state, 1:literal/completed assert 4:boolean/completed?, [ F read-move-quit: routine failed to terminate on 'q'] trace [test], [reached end] @@ -477,16 +477,16 @@ scenario read-move-illegal-file [ assume-screen 20:literal/width, 2:literal/height run [ 1:address:channel <- init-channel 2:literal - 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + wait-for-routine 2:number + 3:number <- routine-state 2:number/id + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] 1:address:channel <- write 1:address:channel, 50:literal # '2' - restart 2:integer/routine - wait-for-routine 2:integer + restart 2:number/routine + wait-for-routine 2:number ] screen-should-contain [ .file too low: 2 . @@ -498,17 +498,17 @@ scenario read-move-illegal-rank [ assume-screen 20:literal/width, 2:literal/height run [ 1:address:channel <- init-channel 2:literal - 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + wait-for-routine 2:number + 3:number <- routine-state 2:number/id + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] 1:address:channel <- write 1:address:channel, 97:literal # 'a' 1:address:channel <- write 1:address:channel, 97:literal # 'a' - restart 2:integer/routine - wait-for-routine 2:integer + restart 2:number/routine + wait-for-routine 2:number ] screen-should-contain [ .rank too high: a . @@ -520,17 +520,17 @@ scenario read-move-empty [ assume-screen 20:literal/width, 2:literal/height run [ 1:address:channel <- init-channel 2:literal - 2:integer/routine <- start-running read-move:recipe, 1:address:channel, screen:address + 2:number/routine <- start-running read-move:recipe, 1:address:channel, screen:address # 'read-move' is waiting for input - wait-for-routine 2:integer - 3:integer <- routine-state 2:integer/id - 4:boolean/waiting? <- equal 3:integer/routine-state, 2:literal/waiting + wait-for-routine 2:number + 3:number <- routine-state 2:number/id + 4:boolean/waiting? <- equal 3:number/routine-state, 2:literal/waiting assert 4:boolean/waiting?, [ F read-move-file: routine failed to pause after coming up (before any keys were pressed)] 1:address:channel <- write 1:address:channel, 13:literal/newline 1:address:channel <- write 1:address:channel, 97:literal # 'a' - restart 2:integer/routine - wait-for-routine 2:integer + restart 2:number/routine + wait-for-routine 2:number ] screen-should-contain [ .that's not enough . @@ -542,22 +542,22 @@ recipe make-move [ default-space:address:array:location <- new location:type, 30:literal b:address:array:address:array:character <- next-ingredient m:address:move <- next-ingredient - from-file:integer <- get m:address:move/deref, from-file:offset -#? $print from-file:integer, [ #? 1 + from-file:number <- get m:address:move/deref, from-file:offset +#? $print from-file:number, [ #? 1 #? ] #? 1 - from-rank:integer <- get m:address:move/deref, from-rank:offset -#? $print from-rank:integer, [ #? 1 + from-rank:number <- get m:address:move/deref, from-rank:offset +#? $print from-rank:number, [ #? 1 #? ] #? 1 - to-file:integer <- get m:address:move/deref, to-file:offset -#? $print to-file:integer, [ #? 1 + to-file:number <- get m:address:move/deref, to-file:offset +#? $print to-file:number, [ #? 1 #? ] #? 1 - to-rank:integer <- get m:address:move/deref, to-rank:offset -#? $print to-rank:integer, [ #? 1 + to-rank:number <- get m:address:move/deref, to-rank:offset +#? $print to-rank:number, [ #? 1 #? ] #? 1 - f:address:array:character <- index b:address:array:address:array:character/deref, from-file:integer - src:address:character/square <- index-address f:address:array:character/deref, from-rank:integer - f:address:array:character <- index b:address:array:address:array:character/deref, to-file:integer - dest:address:character/square <- index-address f:address:array:character/deref, to-rank:integer + f:address:array:character <- index b:address:array:address:array:character/deref, from-file:number + src:address:character/square <- index-address f:address:array:character/deref, from-rank:number + f:address:array:character <- index b:address:array:address:array:character/deref, to-file:number + dest:address:character/square <- index-address f:address:array:character/deref, to-rank:number #? $print src:address:character/deref, [ #? 1 #? ] #? 1 dest:address:character/deref/square <- copy src:address:character/deref/square @@ -570,14 +570,14 @@ scenario making-a-move [ run [ 2:address:array:address:array:character/board <- initial-position 3:address:move <- new move:type - 4:address:integer <- get-address 3:address:move/deref, from-file:offset - 4:address:integer/deref <- copy 6:literal/g - 5:address:integer <- get-address 3:address:move/deref, from-rank:offset - 5:address:integer/deref <- copy 1:literal/2 - 6:address:integer <- get-address 3:address:move/deref, to-file:offset - 6:address:integer/deref <- copy 6:literal/g - 7:address:integer <- get-address 3:address:move/deref, to-rank:offset - 7:address:integer/deref <- copy 3:literal/4 + 4:address:number <- get-address 3:address:move/deref, from-file:offset + 4:address:number/deref <- copy 6:literal/g + 5:address:number <- get-address 3:address:move/deref, from-rank:offset + 5:address:number/deref <- copy 1:literal/2 + 6:address:number <- get-address 3:address:move/deref, to-file:offset + 6:address:number/deref <- copy 6:literal/g + 7:address:number <- get-address 3:address:move/deref, to-rank:offset + 7:address:number/deref <- copy 3:literal/4 2:address:array:address:array:character/board <- make-move 2:address:array:address:array:character/board, 3:address:move screen:address <- print-board screen:address, 2:address:array:address:array:character/board ] diff --git a/counters.mu b/counters.mu index ef841400..71d9cfc9 100644 --- a/counters.mu +++ b/counters.mu @@ -3,16 +3,16 @@ recipe init-counter [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient reply default-space:address:space ] recipe increment-counter [ default-space:address:array:location <- new location:type, 30:literal 0:address:array:location/names:init-counter <- next-ingredient # setup outer space; it *must* come from 'init-counter' - x:integer <- next-ingredient - n:integer/space:1 <- add n:integer/space:1, x:integer - reply n:integer/space:1 + x:number <- next-ingredient + n:number/space:1 <- add n:number/space:1, x:number + reply n:number/space:1 ] recipe main [ @@ -23,12 +23,12 @@ recipe main [ b:address:space <- init-counter 23:literal # increment both by 2 but in different ways increment-counter a:address:space, 1:literal - b-value:integer <- increment-counter b:address:space, 2:literal - a-value:integer <- increment-counter a:address:space, 1:literal + b-value:number <- increment-counter b:address:space, 2:literal + a-value:number <- increment-counter a:address:space, 1:literal # check results $print [Contents of counters ] # trailing space in next line is to help with syntax highlighting - $print [a: ], a-value:integer, [ b: ], b-value:integer, [ + $print [a: ], a-value:number, [ b: ], b-value:number, [ ] ] diff --git a/display.mu b/display.mu index bff74a5d..a0c33e5d 100644 --- a/display.mu +++ b/display.mu @@ -3,7 +3,7 @@ recipe main [ switch-to-display print-character-to-display 97:literal - 1:integer/raw, 2:integer/raw <- cursor-position-on-display + 1:number/raw, 2:number/raw <- cursor-position-on-display wait-for-key-from-keyboard clear-display move-cursor-on-display 0:literal, 4:literal diff --git a/factorial.mu b/factorial.mu index 4b2126a8..a52cb8ae 100644 --- a/factorial.mu +++ b/factorial.mu @@ -2,31 +2,31 @@ recipe main [ default-space:address:space <- new location:type, 30:literal - x:integer <- factorial 5:literal - $print [result: ], x:integer, [ + x:number <- factorial 5:literal + $print [result: ], x:number, [ ] ] recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal } # return n * factorial(n - 1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] # unit test scenario factorial-test [ run [ - 1:integer <- factorial 5:literal + 1:number <- factorial 5:literal ] memory should contain [ 1 <- 120 diff --git a/screen.mu b/screen.mu index fedffa5d..cd0839f4 100644 --- a/screen.mu +++ b/screen.mu @@ -6,7 +6,7 @@ recipe main [ switch-to-display print-character 0:literal/screen, 97:literal - 1:integer/raw, 2:integer/raw <- cursor-position 0:literal/screen + 1:number/raw, 2:number/raw <- cursor-position 0:literal/screen wait-for-key 0:literal/keyboard clear-screen 0:literal/screen move-cursor 0:literal/screen, 0:literal/row, 4:literal/column diff --git a/tangle.mu b/tangle.mu index cb322e46..9d04863c 100644 --- a/tangle.mu +++ b/tangle.mu @@ -8,7 +8,7 @@ recipe factorial [ default-space:address:array:location <- new location:type, 30:literal - n:integer <- next-ingredient + n:number <- next-ingredient { +base-case } @@ -17,21 +17,21 @@ recipe factorial [ after +base-case [ # if n=0 return 1 - zero?:boolean <- equal n:integer, 0:literal + zero?:boolean <- equal n:number, 0:literal break-unless zero?:boolean reply 1:literal ] after +recursive-case [ # return n * factorial(n - 1) - x:integer <- subtract n:integer, 1:literal - subresult:integer <- factorial x:integer - result:integer <- multiply subresult:integer, n:integer - reply result:integer + x:number <- subtract n:number, 1:literal + subresult:number <- factorial x:number + result:number <- multiply subresult:number, n:number + reply result:number ] recipe main [ - 1:integer <- factorial 5:literal - $print [result: ], 1:integer, [ + 1:number <- factorial 5:literal + $print [result: ], 1:number, [ ] ] diff --git a/x.mu b/x.mu index 7f80f845..15dded23 100644 --- a/x.mu +++ b/x.mu @@ -1,8 +1,8 @@ # example program: add two numbers recipe main [ - 11:integer <- copy 1:literal - 12:integer <- copy 3:literal - 13:integer <- add 11:integer, 12:integer + 11:number <- copy 1:literal + 12:number <- copy 3:literal + 13:number <- add 11:number, 12:number $dump-memory ] -- cgit 1.4.1-2-gfad0