diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-10-07 14:03:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-10-07 14:03:09 -0700 |
commit | 239328e4239420fd5d74b66b0759e3d95dbc6469 (patch) | |
tree | d87110f4e9e4354ca619f13a784d0e53b9198805 | |
parent | fde987b54f32ecb7c26c42322ab5df48e317c236 (diff) | |
download | mu-239328e4239420fd5d74b66b0759e3d95dbc6469.tar.gz |
121 - finally I can alloc a 2D array
-rw-r--r-- | edit.arc.t | 40 | ||||
-rw-r--r-- | edit.mu | 20 |
2 files changed, 37 insertions, 23 deletions
diff --git a/edit.arc.t b/edit.arc.t index 19daeb7d..6272699b 100644 --- a/edit.arc.t +++ b/edit.arc.t @@ -2,24 +2,36 @@ (reset) (new-trace "new-screen") +;? (set dump-trace*) (add-fns:readfile "edit.mu") (add-fns '((test-new-screen ((curr-screen screen-address) <- new-screen (5 literal) (5 literal)) ))) -(run 'test-new-screen) -(prn memory*) - -;? (reset) -;? (add-fns:readfile "edit.mu") -;? (add-fns -;? '((test-redraw -;? ((curr-screen screen-address) <- new-screen (5 literal) (5 literal)) -;? ((x line-address) <- get-address (curr-screen screen) (2 offset)) -;? ((y character-address) <- get-address (x line-address deref) (4 offset)) -;? ((y character-address deref) <- copy (literal "a")) -;? ))) -;? (run 'test-redraw) -;? (prn memory*) +;? (each stmt function*!new-screen +;? (prn stmt)) +(let before Memory-in-use-until + (run 'test-new-screen) +;? (prn memory*) + (when (~is (- Memory-in-use-until before) 36) ; 5+1 * 5+1 + (prn "F - new-screen didn't allocate enough memory: @(- Memory-in-use-until before)")) +;? (prn memory*!curr-screen) + (when (~is (memory* memory*!curr-screen) 5) ; number of rows + (prn "F - newly-allocated screen doesn't have the right number of rows: @(memory* memory*!curr-screen)")) + (let row-pointers (let base (+ 1 memory*!curr-screen) + (range base (+ base 4))) +;? (prn row-pointers) + (when (some nil (map memory* row-pointers)) + (prn "F - newly-allocated screen didn't initialize all of its row pointers")) +;? (when (~iso (prn:map memory* row-pointers) + (when (~iso (map memory* row-pointers) + (list (+ before 6) + (+ before 12) + (+ before 18) + (+ before 24) + (+ before 30))) + (prn "F - newly-allocated screen incorrectly initialized its row pointers")) + (when (~all 5 (map memory* (map memory* row-pointers))) + (prn "F - newly-allocated screen didn't initialize all of its row lengths")))) (reset) diff --git a/edit.mu b/edit.mu index ac71f748..05ada379 100644 --- a/edit.mu +++ b/edit.mu @@ -22,13 +22,15 @@ ((ncols integer) <- arg) ((result screen-address) <- new (screen type) (nrows integer)) ((result integer-address deref) <- copy (nrows integer)) - ((rowidx integer) <- literal 0) - ((foo integer) <- literal 1000) - ((curr-dest line-address-address) <- index (foo screen-address deref) (rowidx integer)) -;? ((curr-dest line-address-address) <- index-address (result screen-address) (rowidx integer)) -;? ((curr-dest line-address deref) + ((rowidx integer) <- copy (0 literal)) + { begin + ((curr-line-address-address line-address-address) <- index-address (result screen-address deref) (rowidx integer)) + ((curr-line-address-address line-address-address deref) <- new (line type) (ncols integer)) + ((curr-line-address line-address) <- copy (curr-line-address-address line-address-address deref)) + ((curr-line-address integer-address deref) <- copy (ncols integer)) + ((rowidx integer) <- add (rowidx integer) (1 literal)) + ((x boolean) <- neq (rowidx integer) (nrows integer)) + (continueif (x boolean)) + } + (reply (result screen-address)) ) - -;? (redraw -;? ( -;? ) |