logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

src/d2c/runtime/dylan macros-iteration.dylan, NONE, 1.1 Dylan.lid, 1.7, 1.8: msg#00191

Subject: src/d2c/runtime/dylan macros-iteration.dylan, NONE, 1.1 Dylan.lid, 1.7, 1.8 array.dylan, 1.4, 1.5 deque.dylan, 1.9, 1.10 limited-collection.dylan, 1.6, 1.7 stretchy.dylan, 1.11, 1.12 string.dylan, 1.6, 1.7 vector.dylan, 1.6, 1.7
Update of /scm/cvs/src/d2c/runtime/dylan
In directory gauss.gwydiondylan.org:/tmp/cvs-serv60344

Modified Files:
        Dylan.lid array.dylan deque.dylan limited-collection.dylan 
        stretchy.dylan string.dylan vector.dylan 
Added Files:
        macros-iteration.dylan 
Log Message:
Job: gd25
Refactored the duplicated "outlined-iterator" into a macro.


--- NEW FILE: macros-iteration.dylan ---
copyright: see below
module: dylan-viscera

//======================================================================
//
// Copyright (c) 1995 - 1997  Carnegie Mellon University
// Copyright (c) 1998 - 2004  Gwydion Dylan Maintainers
// All rights reserved.
// 
// Use and copying of this software and preparation of derivative
// works based on this software are permitted, including commercial
// use, provided that the following conditions are observed:
// 
// 1. This copyright notice must be retained in full on any copies
//    and on appropriate parts of any derivative works.
// 2. Documentation (paper or online) accompanying any system that
//    incorporates this software, or any part of it, must acknowledge
//    the contribution of the Gwydion Project at Carnegie Mellon
//    University, and the Gwydion Dylan Maintainers.
// 
// This software is made available "as is".  Neither the authors nor
// Carnegie Mellon University make any warranty about the software,
// its performance, or its conformity to any specification.
// 
// Bug reports should be sent to <gd-bugs@xxxxxxxxxxxxxxxx>; questions,
// comments and suggestions are welcome at <gd-hackers@xxxxxxxxxxxxxxxx>.
// Also, see http://www.gwydiondylan.org/ for updates and documentation. 
//
//======================================================================

// outlined-forward-iteration-protocol-definer -- internal macro
//
// Defines a specialised outlined forward iteration protocol method
// on a collection class.
//

define macro outlined-forward-iteration-protocol-definer
  { define ?adjectives:* outlined-forward-iteration-protocol ?class:name }
    => { define ?adjectives method forward-iteration-protocol (array :: ?class)
          => (initial-state :: <integer>,
              limit :: <integer>,
              next-state :: <function>,
              finished-state? :: <function>,
              current-key :: <function>,
              current-element :: <function>,
              current-element-setter :: <function>,
              copy-state :: <function>);
           values(0,
                  array.size,
                  method (array :: ?class, state :: <integer>)
                   => new-state :: <integer>;
                    state + 1;
                  end,
                  method (array :: ?class, state :: <integer>,
                          limit :: <integer>)
                   => done? :: <boolean>;
                    // We use >= instead of == so that the constraint 
propagation
                    // stuff can tell that state is < limit if this returns #f.
                    state >= limit;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => key :: <integer>;
                    state;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => element :: <object>;
                    element(array, state);
                  end,
                  method (new-value :: <object>, array :: ?class,
                          state :: <integer>)
                   => new-value :: <object>;
                    element(array, state) := new-value;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => state-copy :: <integer>;
                    state;
                  end);
         end; }
end macro;


// outlined-backward-iteration-protocol-definer -- internal macro
//
// Defines a specialised outlined backward iteration protocol method
// on a collection class.
//

define macro outlined-backward-iteration-protocol-definer
  { define ?adjectives:* outlined-backward-iteration-protocol ?class:name }
    => { define ?adjectives method backward-iteration-protocol (array :: ?class)
          => (initial-state :: <integer>,
              limit :: <integer>,
              next-state :: <function>,
              finished-state? :: <function>,
              current-key :: <function>,
              current-element :: <function>,
              current-element-setter :: <function>,
              copy-state :: <function>);
           values(array.size - 1,
                  -1,
                  method (array :: ?class, state :: <integer>)
                   => next-state :: <integer>;
                    state - 1;
                  end,
                  method (array :: ?class, state :: <integer>,
                          limit :: <integer>)
                   => done :: <boolean>;
                    state == limit;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => key :: <integer>;
                    state;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => element :: <object>;
                    element(array, state);
                  end,
                  method (new-value :: <object>, array :: ?class,
                          state :: <integer>)
                   => new-value :: <object>;
                    element(array, state) := new-value;
                  end,
                  method (array :: ?class, state :: <integer>)
                   => state-copy :: <integer>;
                    state;
                  end);
         end; }
end macro;

Index: Dylan.lid
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/Dylan.lid,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Dylan.lid   24 Sep 2004 21:18:08 -0000      1.7
+++ Dylan.lid   20 Oct 2004 17:08:33 -0000      1.8
@@ -3,6 +3,7 @@
 
 bootstrap.dylan
 macros.dylan
+macros-iteration.dylan
 exports.dylan
 object.dylan
 misc.dylan

Index: array.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/array.dylan,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- array.dylan 15 Sep 2004 05:08:07 -0000      1.4
+++ array.dylan 20 Oct 2004 17:08:33 -0000      1.5
@@ -116,90 +116,8 @@
 
 // Default methods.
 
-// This method is duplicated in several places, except that the duplicates
-// are more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define inline method forward-iteration-protocol (array :: <array>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <array>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <array>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <array>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
-
-define inline method backward-iteration-protocol (array :: <array>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(array.size - 1,
-        -1,
-        method (array :: <array>, state :: <integer>)
-            => next-state :: <integer>;
-          state - 1;
-        end,
-        method (array :: <array>, state :: <integer>,
-                limit :: <integer>)
-            => done :: <boolean>;
-          state == limit;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <array>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <array>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define inline outlined-backward-iteration-protocol <array>;
+define inline outlined-forward-iteration-protocol  <array>;
 
 define inline method size (array :: <array>) => size :: <integer>;
   reduce(\*, 1, array.dimensions);

Index: deque.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/deque.dylan,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- deque.dylan 21 Aug 2004 01:38:08 -0000      1.9
+++ deque.dylan 20 Oct 2004 17:08:33 -0000      1.10
@@ -234,52 +234,7 @@
 end;
 
 
-// This method is identical to the one in "array.dylan", except that it
-// is more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define inline method forward-iteration-protocol
-    (array :: <object-deque>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <object-deque>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <object-deque>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <object-deque>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <object-deque>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <object-deque>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <object-deque>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define inline outlined-forward-iteration-protocol <object-deque>;
 
 
 define inline method empty? (deq :: <object-deque>)

Index: limited-collection.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/limited-collection.dylan,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- limited-collection.dylan    15 Sep 2004 05:08:07 -0000      1.6
+++ limited-collection.dylan    20 Oct 2004 17:08:33 -0000      1.7
@@ -280,51 +280,7 @@
               default;
             end;
           end;
-           // This method is identical to the one in "array.dylan", except
-           // that it is more tightly specialized to a single sealed class.
-           // If you need to make a general change, you should probably grep
-           // for "outlined-iterator" and change all matching locations.
-           //
-           define sealed inline method forward-iteration-protocol (array :: 
?name)
-           => (initial-state :: <integer>,
-               limit :: <integer>,
-               next-state :: <function>,
-               finished-state? :: <function>,
-               current-key :: <function>,
-               current-element :: <function>,
-               current-element-setter :: <function>,
-               copy-state :: <function>);
-            values(0,
-                   array.size,
-                   method (array :: ?name, state :: <integer>)
-                    => new-state :: <integer>;
-                     state + 1;
-                   end,
-                   method (array :: ?name, state :: <integer>,
-                           limit :: <integer>)
-                    => done? :: <boolean>;
-                     // We use >= instead of == so that the constraint 
propagation
-                     // stuff can tell that state is < limit if this returns 
#f.
-                     state >= limit;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => key :: <integer>;
-                     state;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => element :: ?element-type;
-                     element(array, state);
-                   end,
-                   method (new-value :: ?element-type, array :: ?name,
-                           state :: <integer>)
-                    => new-value :: ?element-type;
-                     element(array, state) := new-value;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => state-copy :: <integer>;
-                     state;
-                   end);
-          end;
+           define sealed inline outlined-forward-iteration-protocol ?name;
          end; }
 end macro;
 

Index: stretchy.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/stretchy.dylan,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- stretchy.dylan      15 Sep 2004 05:08:07 -0000      1.11
+++ stretchy.dylan      20 Oct 2004 17:08:33 -0000      1.12
@@ -187,52 +187,7 @@
   %element(v.ssv-data, i) := newVal;
 end;
 
-// This method is identical to the one in "array.dylan", except that it
-// is more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define inline method forward-iteration-protocol
-    (array :: <stretchy-object-vector>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <stretchy-object-vector>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <stretchy-object-vector>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <stretchy-object-vector>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <stretchy-object-vector>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <stretchy-object-vector>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <stretchy-object-vector>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define inline outlined-forward-iteration-protocol <stretchy-object-vector>;
 
 define inline method empty? (ssv :: <stretchy-object-vector>)
  => res :: <boolean>;
@@ -452,53 +407,7 @@
               check-type(ssv.ssv-data, ?compname)[key] := value;
             end if;
           end method element-setter;
-
-          // This method is identical to the one in "array.dylan", except
-          // that it is more tightly specialized to a single sealed class.
-          // If you need to make a general change, you should probably grep
-          // for "outlined-iterator" and change all matching locations.
-          //
-          define inline method forward-iteration-protocol (array :: ?name)
-           => (initial-state :: <integer>,
-               limit :: <integer>,
-               next-state :: <function>,
-               finished-state? :: <function>,
-               current-key :: <function>,
-               current-element :: <function>,
-               current-element-setter :: <function>,
-               copy-state :: <function>);
-            values(0,
-                   array.size,
-                   method (array :: ?name, state :: <integer>)
-                    => new-state :: <integer>;
-                     state + 1;
-                   end,
-                   method (array :: ?name, state :: <integer>,
-                           limit :: <integer>)
-                    => done? :: <boolean>;
-                     // We use >= instead of == so that the constraint
-                     // propagation stuff can tell that state is < limit if
-                     // this returns #f.
-                     state >= limit;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => key :: <integer>;
-                     state;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => element :: ?element-type;
-                     element(array, state);
-                   end,
-                   method (new-value :: ?element-type, array :: ?name,
-                           state :: <integer>)
-                    => new-value :: ?element-type;
-                     element(array, state) := new-value;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => state-copy :: <integer>;
-                     state;
-                   end);
-          end;
+           define inline outlined-forward-iteration-protocol ?name;
            define sealed inline method add!
               (ssv :: ?name, new-element :: ?element-type)
            => ssv :: ?name;

Index: string.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/string.dylan,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- string.dylan        15 Sep 2004 05:08:07 -0000      1.6
+++ string.dylan        20 Oct 2004 17:08:33 -0000      1.7
@@ -174,51 +174,7 @@
   end;
 end;
 
-// This method is identical to the one in "array.dylan", except that it
-// is more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define inline method forward-iteration-protocol (array :: <unicode-string>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <unicode-string>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <unicode-string>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <unicode-string>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <unicode-string>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <unicode-string>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <unicode-string>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define inline outlined-forward-iteration-protocol <unicode-string>;
 
 
 // Byte strings.
@@ -269,51 +225,7 @@
   end;
 end;
 
-// This method is identical to the one in "array.dylan", except that it
-// is more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define inline method forward-iteration-protocol (array :: <byte-string>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <byte-string>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <byte-string>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <byte-string>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <byte-string>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <byte-string>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <byte-string>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define inline outlined-forward-iteration-protocol <byte-string>;
 
 define method \= (str1 :: <byte-string>, str2 :: <byte-string>)
  => (res :: <boolean>);

Index: vector.dylan
===================================================================
RCS file: /scm/cvs/src/d2c/runtime/dylan/vector.dylan,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- vector.dylan        15 Sep 2004 05:08:08 -0000      1.6
+++ vector.dylan        20 Oct 2004 17:08:33 -0000      1.7
@@ -164,52 +164,7 @@
   end;
 end;
 
-// This method is identical to the one in "array.dylan", except that it
-// is more tightly specialized to a single sealed class.  If you need to 
-// make a general change, you should probably grep for "outlined-iterator" 
-// and change all matching locations.
-//
-define sealed inline method forward-iteration-protocol
-    (array :: <simple-object-vector>)
-    => (initial-state :: <integer>,
-       limit :: <integer>,
-       next-state :: <function>,
-       finished-state? :: <function>,
-       current-key :: <function>,
-       current-element :: <function>,
-       current-element-setter :: <function>,
-       copy-state :: <function>);
-  values(0,
-        array.size,
-        method (array :: <simple-object-vector>, state :: <integer>)
-            => new-state :: <integer>;
-          state + 1;
-        end,
-        method (array :: <simple-object-vector>, state :: <integer>,
-                limit :: <integer>)
-            => done? :: <boolean>;
-          // We use >= instead of == so that the constraint propagation
-          // stuff can tell that state is < limit if this returns #f.
-          state >= limit;
-        end,
-        method (array :: <simple-object-vector>, state :: <integer>)
-            => key :: <integer>;
-          state;
-        end,
-        method (array :: <simple-object-vector>, state :: <integer>)
-            => element :: <object>;
-          element(array, state);
-        end,
-        method (new-value :: <object>, array :: <simple-object-vector>,
-                state :: <integer>)
-            => new-value :: <object>;
-          element(array, state) := new-value;
-        end,
-        method (array :: <simple-object-vector>, state :: <integer>)
-            => state-copy :: <integer>;
-          state;
-        end);
-end;
+define sealed inline outlined-forward-iteration-protocol 
<simple-object-vector>;
 
 define sealed inline method fill!
     (vec :: <simple-vector>, value :: <object>,
@@ -313,51 +268,7 @@
               element-error(vec, index);
             end;
           end;
-           // This method is identical to the one in "array.dylan", except
-           // that it is more tightly specialized to a single sealed class.
-           // If you need to make a general change, you should probably grep
-           // for "outlined-iterator" and change all matching locations.
-           //
-           define sealed inline method forward-iteration-protocol (array :: 
?name)
-           => (initial-state :: <integer>,
-               limit :: <integer>,
-               next-state :: <function>,
-               finished-state? :: <function>,
-               current-key :: <function>,
-               current-element :: <function>,
-               current-element-setter :: <function>,
-               copy-state :: <function>);
-            values(0,
-                   array.size,
-                   method (array :: ?name, state :: <integer>)
-                    => new-state :: <integer>;
-                     state + 1;
-                   end,
-                   method (array :: ?name, state :: <integer>,
-                           limit :: <integer>)
-                    => done? :: <boolean>;
-                     // We use >= instead of == so that the constraint 
propagation
-                     // stuff can tell that state is < limit if this returns 
#f.
-                     state >= limit;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => key :: <integer>;
-                     state;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => element :: ?element-type;
-                     element(array, state);
-                   end,
-                   method (new-value :: ?element-type, array :: ?name,
-                           state :: <integer>)
-                    => new-value :: ?element-type;
-                     element(array, state) := new-value;
-                   end,
-                   method (array :: ?name, state :: <integer>)
-                    => state-copy :: <integer>;
-                     state;
-                   end);
-          end;
+           define sealed inline outlined-forward-iteration-protocol ?name;
          end; }
 end macro;
 

_______________________________________________
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter



<Prev in Thread] Current Thread [Next in Thread>