about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-10-28 11:41:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-10-28 11:41:59 -0700
commit61c82b8e8f63cd89c923b0246fc5bee2d1be951d (patch)
tree0594f87744f8bdbda7abc8db1f652e0af84ac756
parent67109edfd93509c2a19c624929b6e400390b8dd8 (diff)
downloadmu-61c82b8e8f63cd89c923b0246fc5bee2d1be951d.tar.gz
160 - fix stale editor test
-rw-r--r--edit.arc.t35
-rw-r--r--edit.mu26
-rw-r--r--mu.arc6
3 files changed, 24 insertions, 43 deletions
diff --git a/edit.arc.t b/edit.arc.t
index 3986cbfc..402a4265 100644
--- a/edit.arc.t
+++ b/edit.arc.t
@@ -1,37 +1,12 @@
 (load "mu.arc")
 
-(on-init
-  (= types* (obj
-              ; Each type must be scalar or array, sum or product or primitive
-              location (obj size 1)
-              integer (obj size 1)
-              boolean (obj size 1)
-              boolean-address (obj size 1  address t)
-              byte (obj size 1)
-;?               string (obj array t  elem 'byte)  ; inspired by Go
-              character (obj size 1)  ; int32 like a Go rune
-              character-address (obj size 1  address t  elem 'character)
-              string (obj size 1)  ; temporary hack
-              ; arrays consist of an integer length followed by the right number of elems
-              integer-array (obj array t  elem 'integer)
-              integer-address (obj size 1  address t  elem 'integer)  ; pointer to int
-              ; records consist of a series of elems, corresponding to a list of types
-              integer-boolean-pair (obj size 2  record t  elems '(integer boolean))
-              ; editor
-              line (obj array t  elem 'character)
-              line-address (obj size 1  address t  elem 'line)
-              line-address-address (obj size 1  address t  elem 'line-address)
-              screen (obj array t  elem 'line-address)
-              screen-address (obj size 1  address t  elem 'screen)
-              )))
-
 (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))
+      ((2001 screen-address) <- new-screen (5 literal) (5 literal))
       )))
 ;? (each stmt function*!new-screen
 ;?   (prn stmt))
@@ -40,10 +15,10 @@
 ;?   (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)
+;?   (prn memory*!2001)
+  (when (~is (memory* memory*!2001) 5)  ; number of rows
+    (prn "F - newly-allocated screen doesn't have the right number of rows: @(memory* memory*!2001)"))
+  (let row-pointers (let base (+ 1 memory*!2001)
                       (range base (+ base 4)))
 ;?     (prn row-pointers)
     (when (some nil (map memory* row-pointers))
diff --git a/edit.mu b/edit.mu
index 56aee23d..87433cb2 100644
--- a/edit.mu
+++ b/edit.mu
@@ -1,19 +1,19 @@
 ; a screen is an array of pointers to lines, in turn arrays of characters
 
 (new-screen
-  ((nrows integer) <- arg)
-  ((ncols integer) <- arg)
-  ((result screen-address) <- new (screen type) (nrows integer))
-  ((result integer-address deref) <- copy (nrows integer))
-  ((rowidx integer) <- copy (0 literal))
+  ((601 integer) <- arg)
+  ((602 integer) <- arg)
+  ((603 screen-address) <- new (screen type) (601 integer))
+  ((603 integer-address deref) <- copy (601 integer))
+  ((604 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))
+    ((606 line-address-address) <- index-address (603 screen-address deref) (604 integer))
+    ((606 line-address-address deref) <- new (line type) (602 integer))
+    ((605 line-address) <- copy (606 line-address-address deref))
+    ((605 integer-address deref) <- copy (602 integer))
+    ((604 integer) <- add (604 integer) (1 literal))
+    ((607 boolean) <- neq (604 integer) (601 integer))
+    (continue-if (607 boolean))
   }
-  (reply (result screen-address))
+  (reply (603 screen-address))
 )
diff --git a/mu.arc b/mu.arc
index ce47032b..34cdd48d 100644
--- a/mu.arc
+++ b/mu.arc
@@ -52,6 +52,12 @@
               list (obj size 2  record t  elems '(tagged-value list-address))
               list-address (obj size 1  address t  elem 'list)
               list-address-address (obj size 1  address t  elem 'list-address)
+              ; editor
+              line (obj array t  elem 'character)
+              line-address (obj size 1  address t  elem 'line)
+              line-address-address (obj size 1  address t  elem 'line-address)
+              screen (obj array t  elem 'line-address)
+              screen-address (obj size 1  address t  elem 'screen)
               )))
 
 ;; persisting and checking traces for each test