| 1 |
(******************************************************************************* |
|---|
| 2 |
Copyright 2008 Sun Microsystems, Inc., |
|---|
| 3 |
4150 Network Circle, Santa Clara, California 95054, U.S.A. |
|---|
| 4 |
All rights reserved. |
|---|
| 5 |
|
|---|
| 6 |
U.S. Government Rights - Commercial software. |
|---|
| 7 |
Government users are subject to the Sun Microsystems, Inc. standard |
|---|
| 8 |
license agreement and applicable provisions of the FAR and its supplements. |
|---|
| 9 |
|
|---|
| 10 |
Use is subject to license terms. |
|---|
| 11 |
|
|---|
| 12 |
This distribution may include materials developed by third parties. |
|---|
| 13 |
|
|---|
| 14 |
Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered |
|---|
| 15 |
trademarks of Sun Microsystems, Inc. in the U.S. and other countries. |
|---|
| 16 |
******************************************************************************) |
|---|
| 17 |
|
|---|
| 18 |
component XXXarrayTest |
|---|
| 19 |
export Executable |
|---|
| 20 |
|
|---|
| 21 |
trait T extends ZZ32[9] |
|---|
| 22 |
end |
|---|
| 23 |
|
|---|
| 24 |
trait Rank[\ nat n \] |
|---|
| 25 |
end |
|---|
| 26 |
|
|---|
| 27 |
trait Indexed1[\ nat n \] |
|---|
| 28 |
end |
|---|
| 29 |
|
|---|
| 30 |
trait Indexed2[\ nat n \] |
|---|
| 31 |
end |
|---|
| 32 |
|
|---|
| 33 |
trait Indexed3[\ nat n \] |
|---|
| 34 |
end |
|---|
| 35 |
|
|---|
| 36 |
trait Array1[\T, nat b0, nat s0\] extends {Indexed1 [\ s0 \], Rank[\ 1 \]} |
|---|
| 37 |
(* Get and put come from implementation. *) |
|---|
| 38 |
get(i:ZZ32):T |
|---|
| 39 |
put(i:ZZ32, v:T) |
|---|
| 40 |
|
|---|
| 41 |
opr[i:ZZ32]:T = self.get(i-b0) |
|---|
| 42 |
opr[i:ZZ32]:= (v:T) = self.put(i-b0,v) |
|---|
| 43 |
|
|---|
| 44 |
end |
|---|
| 45 |
|
|---|
| 46 |
trait Array2[\T, nat b0, nat s0, nat b1, nat s1\] extends { |
|---|
| 47 |
Indexed1 [\ s0 \], Indexed2 [\ s1 \] , Rank[\ 2 \]} |
|---|
| 48 |
opr[i:ZZ32, j:ZZ32] : T |
|---|
| 49 |
opr[i:ZZ32, j:ZZ32]:= (v:T) |
|---|
| 50 |
end |
|---|
| 51 |
|
|---|
| 52 |
trait Array3[\T, nat b0, nat s0, nat b1, nat s1, nat b2, nat s2\] extends |
|---|
| 53 |
{Indexed1[\ s0 \], Indexed2[\ s1 \], Indexed3[\ s2 \] , Rank[\ 3 \]} |
|---|
| 54 |
|
|---|
| 55 |
opr[i:ZZ32, j:ZZ32, k:ZZ32] : T |
|---|
| 56 |
opr[i:ZZ32, j:ZZ32, k:ZZ32]:= (v:T) |
|---|
| 57 |
end |
|---|
| 58 |
|
|---|
| 59 |
run(args:String...):()=do |
|---|
| 60 |
|
|---|
| 61 |
z:Array1[\String, 0, 3\] = array1[\String, 0, 3\]() |
|---|
| 62 |
z[0]:="cat" |
|---|
| 63 |
z[1]:="dog" |
|---|
| 64 |
z[2]:="bat" |
|---|
| 65 |
println( z[0] " " z[1] " " z[2] ); |
|---|
| 66 |
|
|---|
| 67 |
a:ZZ32[3] = [1 2 3] |
|---|
| 68 |
b:ZZ32[2,2] = [ 10 11 ; 12 13 ] |
|---|
| 69 |
b2:ZZ32[2,2] = [ 10 11 |
|---|
| 70 |
12 13 ] |
|---|
| 71 |
|
|---|
| 72 |
c:ZZ32[2,2,2] = [ 111 112 ; |
|---|
| 73 |
121 122 ;; |
|---|
| 74 |
211 212 ; |
|---|
| 75 |
221 222 ] |
|---|
| 76 |
d:ZZ32[4,2,2] = [ c ;; |
|---|
| 77 |
311 312 ; |
|---|
| 78 |
321 322 ;; |
|---|
| 79 |
411 412 ; |
|---|
| 80 |
421 422 |
|---|
| 81 |
] |
|---|
| 82 |
|
|---|
| 83 |
(* |
|---|
| 84 |
e:ZZ32^(2 BY 2) = [ 101 102 ; 201 202 ] |
|---|
| 85 |
*) |
|---|
| 86 |
|
|---|
| 87 |
end |
|---|
| 88 |
|
|---|
| 89 |
end |
|---|