diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-11 22:24:33 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-11 22:24:33 -0700 |
commit | 39f77cc54ea08cd1feac8796aaa617d00a35f835 (patch) | |
tree | 955598deb246b3d1c3362fdc777fdd19aba7de38 | |
parent | 3074c36136ff848b02755aa6806f7d392f04facc (diff) | |
download | mu-39f77cc54ea08cd1feac8796aaa617d00a35f835.tar.gz |
1050
-rw-r--r-- | cpp/.traces/string-equal-common-lengths-but-distinct | 64 | ||||
-rw-r--r-- | cpp/.traces/string-equal-distinct-lengths | 6 | ||||
-rw-r--r-- | cpp/.traces/string-equal-identical | 78 | ||||
-rw-r--r-- | cpp/.traces/string-equal-reflexive | 78 | ||||
-rw-r--r-- | cpp/.traces/string-equal-with-empty | 6 | ||||
-rw-r--r-- | cpp/040string.mu | 2 |
6 files changed, 126 insertions, 108 deletions
diff --git a/cpp/.traces/string-equal-common-lengths-but-distinct b/cpp/.traces/string-equal-common-lengths-but-distinct index ac5a12ce..58112874 100644 --- a/cpp/.traces/string-equal-common-lengths-but-distinct +++ b/cpp/.traces/string-equal-common-lengths-but-distinct @@ -46,32 +46,36 @@ run/0: instruction string-equal/4 mem/0: location 1042 is 1034 mem/0: storing 3 in location 1043 run/0: instruction string-equal/6 +string-equal/0: comparing lengths +run/0: instruction string-equal/7 run/0: ingredient 0 is a-len mem/0: location 1041 is 3 run/0: ingredient 1 is b-len mem/0: location 1043 is 3 run/0: product 0 is 1 mem/0: storing 1 in location 1044 -run/0: instruction string-equal/7 +run/0: instruction string-equal/8 mem/0: location 1044 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 9 -run/0: instruction string-equal/10 +run/0: jumping to instruction 10 +run/0: instruction string-equal/11 +string-equal/0: comparing characters +run/0: instruction string-equal/12 run/0: ingredient 0 is 0 mem/0: storing 0 in location 1045 -run/0: instruction string-equal/12 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 0 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -81,7 +85,7 @@ run/0: its type is 8 mem/0: location 1031 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -91,39 +95,39 @@ run/0: its type is 8 mem/0: location 1035 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 97 run/0: ingredient 1 is b2 mem/0: location 1048 is 97 run/0: product 0 is 1 mem/0: storing 1 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1045 is 0 run/0: ingredient 1 is 1 run/0: product 0 is 1 mem/0: storing 1 in location 1045 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 1 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -133,7 +137,7 @@ run/0: its type is 8 mem/0: location 1032 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -143,39 +147,39 @@ run/0: its type is 8 mem/0: location 1036 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 98 run/0: ingredient 1 is b2 mem/0: location 1048 is 98 run/0: product 0 is 1 mem/0: storing 1 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1045 is 1 run/0: ingredient 1 is 1 run/0: product 0 is 2 mem/0: storing 2 in location 1045 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 2 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -185,7 +189,7 @@ run/0: its type is 8 mem/0: location 1033 is 99 run/0: product 0 is 99 mem/0: storing 99 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -195,17 +199,17 @@ run/0: its type is 8 mem/0: location 1037 is 100 run/0: product 0 is 100 mem/0: storing 100 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 99 run/0: ingredient 1 is b2 mem/0: location 1048 is 100 run/0: product 0 is 0 mem/0: storing 0 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/19 +run/0: instruction string-equal/21 run/0: result 0 is 0 mem/0: storing 0 in location 3 diff --git a/cpp/.traces/string-equal-distinct-lengths b/cpp/.traces/string-equal-distinct-lengths index 98444b85..6008eaf4 100644 --- a/cpp/.traces/string-equal-distinct-lengths +++ b/cpp/.traces/string-equal-distinct-lengths @@ -46,16 +46,18 @@ run/0: instruction string-equal/4 mem/0: location 1043 is 1034 mem/0: storing 4 in location 1044 run/0: instruction string-equal/6 +string-equal/0: comparing lengths +run/0: instruction string-equal/7 run/0: ingredient 0 is a-len mem/0: location 1042 is 3 run/0: ingredient 1 is b-len mem/0: location 1044 is 4 run/0: product 0 is 0 mem/0: storing 0 in location 1045 -run/0: instruction string-equal/7 +run/0: instruction string-equal/8 mem/0: location 1045 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/8 +run/0: instruction string-equal/9 run/0: result 0 is 0 mem/0: storing 0 in location 3 diff --git a/cpp/.traces/string-equal-identical b/cpp/.traces/string-equal-identical index 4a878121..ad2db713 100644 --- a/cpp/.traces/string-equal-identical +++ b/cpp/.traces/string-equal-identical @@ -46,32 +46,36 @@ run/0: instruction string-equal/4 mem/0: location 1042 is 1034 mem/0: storing 3 in location 1043 run/0: instruction string-equal/6 +string-equal/0: comparing lengths +run/0: instruction string-equal/7 run/0: ingredient 0 is a-len mem/0: location 1041 is 3 run/0: ingredient 1 is b-len mem/0: location 1043 is 3 run/0: product 0 is 1 mem/0: storing 1 in location 1044 -run/0: instruction string-equal/7 +run/0: instruction string-equal/8 mem/0: location 1044 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 9 -run/0: instruction string-equal/10 +run/0: jumping to instruction 10 +run/0: instruction string-equal/11 +string-equal/0: comparing characters +run/0: instruction string-equal/12 run/0: ingredient 0 is 0 mem/0: storing 0 in location 1045 -run/0: instruction string-equal/12 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 0 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -81,7 +85,7 @@ run/0: its type is 8 mem/0: location 1031 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -91,39 +95,39 @@ run/0: its type is 8 mem/0: location 1035 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 97 run/0: ingredient 1 is b2 mem/0: location 1048 is 97 run/0: product 0 is 1 mem/0: storing 1 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1045 is 0 run/0: ingredient 1 is 1 run/0: product 0 is 1 mem/0: storing 1 in location 1045 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 1 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -133,7 +137,7 @@ run/0: its type is 8 mem/0: location 1032 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -143,39 +147,39 @@ run/0: its type is 8 mem/0: location 1036 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 98 run/0: ingredient 1 is b2 mem/0: location 1048 is 98 run/0: product 0 is 1 mem/0: storing 1 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1045 is 1 run/0: ingredient 1 is 1 run/0: product 0 is 2 mem/0: storing 2 in location 1045 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 2 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1040 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -185,7 +189,7 @@ run/0: its type is 8 mem/0: location 1033 is 99 run/0: product 0 is 99 mem/0: storing 99 in location 1047 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1042 is 1034 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -195,39 +199,39 @@ run/0: its type is 8 mem/0: location 1037 is 99 run/0: product 0 is 99 mem/0: storing 99 in location 1048 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1047 is 99 run/0: ingredient 1 is b2 mem/0: location 1048 is 99 run/0: product 0 is 1 mem/0: storing 1 in location 1049 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1049 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1045 is 2 run/0: ingredient 1 is 1 run/0: product 0 is 3 mem/0: storing 3 in location 1045 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1045 is 3 run/0: ingredient 1 is a-len mem/0: location 1041 is 3 run/0: product 0 is 1 mem/0: storing 1 in location 1046 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1046 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 23 -run/0: instruction string-equal/24 +run/0: jumping to instruction 25 +run/0: instruction string-equal/26 run/0: result 0 is 1 mem/0: storing 1 in location 3 diff --git a/cpp/.traces/string-equal-reflexive b/cpp/.traces/string-equal-reflexive index 11d0aadf..be1548bb 100644 --- a/cpp/.traces/string-equal-reflexive +++ b/cpp/.traces/string-equal-reflexive @@ -38,32 +38,36 @@ run/0: instruction string-equal/4 mem/0: location 1038 is 1030 mem/0: storing 3 in location 1039 run/0: instruction string-equal/6 +string-equal/0: comparing lengths +run/0: instruction string-equal/7 run/0: ingredient 0 is a-len mem/0: location 1037 is 3 run/0: ingredient 1 is b-len mem/0: location 1039 is 3 run/0: product 0 is 1 mem/0: storing 1 in location 1040 -run/0: instruction string-equal/7 +run/0: instruction string-equal/8 mem/0: location 1040 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 9 -run/0: instruction string-equal/10 +run/0: jumping to instruction 10 +run/0: instruction string-equal/11 +string-equal/0: comparing characters +run/0: instruction string-equal/12 run/0: ingredient 0 is 0 mem/0: storing 0 in location 1041 -run/0: instruction string-equal/12 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1041 is 0 run/0: ingredient 1 is a-len mem/0: location 1037 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1042 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1042 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1036 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -73,7 +77,7 @@ run/0: its type is 8 mem/0: location 1031 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1043 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1038 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -83,39 +87,39 @@ run/0: its type is 8 mem/0: location 1031 is 97 run/0: product 0 is 97 mem/0: storing 97 in location 1044 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1043 is 97 run/0: ingredient 1 is b2 mem/0: location 1044 is 97 run/0: product 0 is 1 mem/0: storing 1 in location 1045 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1045 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1041 is 0 run/0: ingredient 1 is 1 run/0: product 0 is 1 mem/0: storing 1 in location 1041 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1041 is 1 run/0: ingredient 1 is a-len mem/0: location 1037 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1042 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1042 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1036 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -125,7 +129,7 @@ run/0: its type is 8 mem/0: location 1032 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1043 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1038 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -135,39 +139,39 @@ run/0: its type is 8 mem/0: location 1032 is 98 run/0: product 0 is 98 mem/0: storing 98 in location 1044 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1043 is 98 run/0: ingredient 1 is b2 mem/0: location 1044 is 98 run/0: product 0 is 1 mem/0: storing 1 in location 1045 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1045 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1041 is 1 run/0: ingredient 1 is 1 run/0: product 0 is 2 mem/0: storing 2 in location 1041 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1041 is 2 run/0: ingredient 1 is a-len mem/0: location 1037 is 3 run/0: product 0 is 0 mem/0: storing 0 in location 1042 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1042 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/14 +run/0: instruction string-equal/16 run/0: ingredient 0 is {name: "a", value: 1, type: 2-5-8, properties: ["a": "address":"array":"character", "deref": ]} mem/0: location 1036 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -177,7 +181,7 @@ run/0: its type is 8 mem/0: location 1033 is 99 run/0: product 0 is 99 mem/0: storing 99 in location 1043 -run/0: instruction string-equal/15 +run/0: instruction string-equal/17 run/0: ingredient 0 is {name: "b", value: 3, type: 2-5-8, properties: ["b": "address":"array":"character", "deref": ]} mem/0: location 1038 is 1030 run/0: ingredient 1 is {name: "i", value: 6, type: 1, properties: ["i": "integer"]} @@ -187,39 +191,39 @@ run/0: its type is 8 mem/0: location 1033 is 99 run/0: product 0 is 99 mem/0: storing 99 in location 1044 -run/0: instruction string-equal/17 +run/0: instruction string-equal/19 run/0: ingredient 0 is a2 mem/0: location 1043 is 99 run/0: ingredient 1 is b2 mem/0: location 1044 is 99 run/0: product 0 is 1 mem/0: storing 1 in location 1045 -run/0: instruction string-equal/18 +run/0: instruction string-equal/20 mem/0: location 1045 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 20 -run/0: instruction string-equal/21 +run/0: jumping to instruction 22 +run/0: instruction string-equal/23 run/0: ingredient 0 is i mem/0: location 1041 is 2 run/0: ingredient 1 is 1 run/0: product 0 is 3 mem/0: storing 3 in location 1041 -run/0: instruction string-equal/22 +run/0: instruction string-equal/24 run/0: ingredient 0 is -11 -run/0: pc now 11 -run/0: instruction string-equal/12 +run/0: pc now 13 +run/0: instruction string-equal/14 run/0: ingredient 0 is i mem/0: location 1041 is 3 run/0: ingredient 1 is a-len mem/0: location 1037 is 3 run/0: product 0 is 1 mem/0: storing 1 in location 1042 -run/0: instruction string-equal/13 +run/0: instruction string-equal/15 mem/0: location 1042 is 1 run/0: ingredient 0 is 1 run/0: ingredient 1 is -run/0: jumping to instruction 23 -run/0: instruction string-equal/24 +run/0: jumping to instruction 25 +run/0: instruction string-equal/26 run/0: result 0 is 1 mem/0: storing 1 in location 3 diff --git a/cpp/.traces/string-equal-with-empty b/cpp/.traces/string-equal-with-empty index 12dcd23f..13f64aac 100644 --- a/cpp/.traces/string-equal-with-empty +++ b/cpp/.traces/string-equal-with-empty @@ -46,16 +46,18 @@ run/0: instruction string-equal/4 mem/0: location 1040 is 1031 mem/0: storing 4 in location 1041 run/0: instruction string-equal/6 +string-equal/0: comparing lengths +run/0: instruction string-equal/7 run/0: ingredient 0 is a-len mem/0: location 1039 is 0 run/0: ingredient 1 is b-len mem/0: location 1041 is 4 run/0: product 0 is 0 mem/0: storing 0 in location 1042 -run/0: instruction string-equal/7 +run/0: instruction string-equal/8 mem/0: location 1042 is 0 run/0: ingredient 0 is 0 run/0: jump-if fell through -run/0: instruction string-equal/8 +run/0: instruction string-equal/9 run/0: result 0 is 0 mem/0: storing 0 in location 3 diff --git a/cpp/040string.mu b/cpp/040string.mu index 17608e5f..b42fbc9c 100644 --- a/cpp/040string.mu +++ b/cpp/040string.mu @@ -6,11 +6,13 @@ recipe string-equal [ b-len:integer <- length b:address:array:character/deref # compare lengths { + trace [string-equal], [comparing lengths] length-equal?:boolean <- equal a-len:integer, b-len:integer break-if length-equal?:boolean reply 0:literal } # compare each corresponding character + trace [string-equal], [comparing characters] i:integer <- copy 0:literal { done?:boolean <- greater-or-equal i:integer, a-len:integer |