| 1 | (******************************************************************************* |
|---|
| 2 | Generator-of-Generators Library is copyrighted free software by Kento Emoto |
|---|
| 3 | <emoto[at]ipl.t.u-tokyo.ac.jp> developed under the collaborative |
|---|
| 4 | research on Fortress Programming Language between Sun Microsystems, |
|---|
| 5 | Inc. and the University of Tokyo. |
|---|
| 6 | |
|---|
| 7 | You can redistribute it and/or modify it under the following |
|---|
| 8 | BSD-style license or the Sun Contributor Agreement that Kento Emoto signed. |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | Copyright (c) 2009 by Kento Emoto |
|---|
| 12 | All rights reserved. |
|---|
| 13 | |
|---|
| 14 | Redistribution and use in source and binary forms, with or without |
|---|
| 15 | modification, are permitted provided that the following conditions |
|---|
| 16 | are met: |
|---|
| 17 | |
|---|
| 18 | * Redistributions of source code must retain the above copyright |
|---|
| 19 | notice, this list of conditions and the following disclaimer. |
|---|
| 20 | * Redistributions in binary form must reproduce the above copyright |
|---|
| 21 | notice, this list of conditions and the following disclaimer |
|---|
| 22 | in the documentation and/or other materials provided with the |
|---|
| 23 | distribution. |
|---|
| 24 | * Neither the name of Kento Emoto nor the names of its |
|---|
| 25 | contributors may be used to endorse or promote products derived |
|---|
| 26 | from this software without specific prior written permission. |
|---|
| 27 | |
|---|
| 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 29 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|---|
| 30 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 31 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|---|
| 32 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|---|
| 33 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|---|
| 34 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|---|
| 35 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|---|
| 36 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|---|
| 37 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|---|
| 38 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | ******************************************************************************) |
|---|
| 42 | |
|---|
| 43 | api Generator22D |
|---|
| 44 | |
|---|
| 45 | import List.{...} |
|---|
| 46 | import Generator2.{...} |
|---|
| 47 | |
|---|
| 48 | (* Generator2 Rows *) |
|---|
| 49 | object Rows[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) extends Generator2[\ E \] |
|---|
| 50 | getter seed() : Generator[\ E \] |
|---|
| 51 | toString() : String |
|---|
| 52 | |
|---|
| 53 | (* actual generation the nested data structure *) |
|---|
| 54 | generate[\ R \](r : Reduction[\ R \], body : Generator[\ E \] -> R) : R |
|---|
| 55 | end |
|---|
| 56 | |
|---|
| 57 | rows[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) : Rows[\E, b0, s0, b1, s1\] |
|---|
| 58 | |
|---|
| 59 | (* Generator2 Cols *) |
|---|
| 60 | object Cols[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) extends Generator2[\ E \] |
|---|
| 61 | getter seed() : Generator[\ E \] |
|---|
| 62 | toString() : String |
|---|
| 63 | |
|---|
| 64 | (* actual generation the nested data structure *) |
|---|
| 65 | generate[\ R \](r : Reduction[\ R \], body : Generator[\ E \] -> R) : R |
|---|
| 66 | end |
|---|
| 67 | |
|---|
| 68 | cols[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) : Cols[\E, b0, s0, b1, s1\] |
|---|
| 69 | |
|---|
| 70 | (* Generator2 Rects *) |
|---|
| 71 | object Rects[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) extends Generator2[\ E \] |
|---|
| 72 | getter seed() : Generator[\ E \] |
|---|
| 73 | toString() : String |
|---|
| 74 | |
|---|
| 75 | (* actual generation the nested data structure *) |
|---|
| 76 | generate[\ R \](r : Reduction[\ R \], body : Generator[\ E \] -> R) : R |
|---|
| 77 | end |
|---|
| 78 | |
|---|
| 79 | rects[\ E, nat b0, nat s0, nat b1, nat s1 \](g : Array2[\E, b0, s0, b1, s1\]) : Rects[\E, b0, s0, b1, s1\] |
|---|
| 80 | |
|---|
| 81 | end |
|---|