diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-07-22 14:00:12 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-07-22 14:00:48 -0700 |
commit | be6e752626711047064fe176843972be5eaa2add (patch) | |
tree | 81048e7ccad554ece3d69806366e6c9ea0d9d28b | |
parent | 0c1ae52feb9ee7cc1858237d0c17da1cf863c2cc (diff) | |
download | mu-be6e752626711047064fe176843972be5eaa2add.tar.gz |
3124
Reorganize data structure for lambda cells. Create our first real unit test for the compiler in the process.
-rw-r--r-- | 036refcount.cc | 1 | ||||
-rw-r--r-- | lambda-to-mu.mu | 49 |
2 files changed, 28 insertions, 22 deletions
diff --git a/036refcount.cc b/036refcount.cc index 02af0ab9..e1954cc8 100644 --- a/036refcount.cc +++ b/036refcount.cc @@ -316,7 +316,6 @@ void compute_container_address_offsets(type_tree* type) { void append_addresses(int base_offset, const type_tree* type, map<set<tag_condition_info>, set<address_element_info> >& out, const set<tag_condition_info>& key) { const type_info& info = get(Type, type->value); if (type->name == "address") { - assert(type->right && type->right->name != "array"); // array types can't be handled without a full reagent and its value get_or_insert(out, key).insert(address_element_info(base_offset, new type_tree(*type->right))); return; } diff --git a/lambda-to-mu.mu b/lambda-to-mu.mu index 0ad61e51..4feb5ac9 100644 --- a/lambda-to-mu.mu +++ b/lambda-to-mu.mu @@ -10,51 +10,58 @@ result <- add a t1] ] ] -container cell [ - first:address:cell-value - rest:address:cell +def lambda-to-mu in:address:array:character -> out:address:array:character [ + local-scope + load-ingredients + out <- copy 0 + tmp:address:cell <- parse in + out <- to-mu tmp ] -exclusive-container cell-value [ +exclusive-container cell [ atom:address:array:character - cell:address:cell + pair:pair +] + +container pair [ + first:address:cell + rest:address:cell ] def new-atom name:address:array:character -> result:address:cell [ local-scope load-ingredients - cv:address:cell-value <- new cell-value:type - *cv <- merge 0/tag:atom, name result <- new cell:type - *result <- merge cv, 0/rest + *result <- merge 0/tag:atom, name ] def new-cell a:address:cell, b:address:cell -> result:address:cell [ local-scope load-ingredients - cv:address:cell-value <- new cell-value:type - *cv <- merge 1/tag:cell, a result <- new cell:type - *result <- merge cv/first, b/rest + *result <- merge 1/tag:pair, a/first, b/rest ] def is-atom? x:address:cell -> result:boolean [ + local-scope + load-ingredients reply-unless x, 0/false - cv:address:cell-value <- get *x, first:offset - reply-unless cv, 0/false - _, result <- maybe-convert *cv, atom:variant + _, result <- maybe-convert *x, atom:variant ] def is-cell? x:address:cell -> result:boolean [ + local-scope + load-ingredients reply-unless x, 0/false - cv:address:cell-value <- get *x, first:offset - reply-unless cv, 0/false - _, result <- maybe-convert *cv, atom:variant + _, result <- maybe-convert *x, pair:variant ] -def lambda-to-mu in:address:array:character -> out:address:array:character [ +scenario atom-operations [ local-scope - load-ingredients - tmp <- parse in - out <- to-mu tmp + s:address:array:character <- new [a] + x:address:cell <- new-atom s + 10:boolean/raw <- is-atom? x + memory-should-contain [ + 10 <- 1 + ] ] |