22 |
val hashstring = HashString.hashString |
val hashstring = HashString.hashString |
23 |
fun stringToString s = String.concat["\"", s, "\""] |
fun stringToString s = String.concat["\"", s, "\""] |
24 |
|
|
25 |
(* required helper functions for the mask tyoe *) |
(* required helper functions for the mask type *) |
26 |
type mask = bool list |
type mask = bool list |
27 |
val samemask : (mask * mask -> bool) = (op =) |
val samemask : (mask * mask -> bool) = (op =) |
28 |
fun hashmask m = |
fun hashmask m = |
66 |
| Kernel of Kernel.kernel |
| Kernel of Kernel.kernel |
67 |
| LoadImage of ImageInfo.info |
| LoadImage of ImageInfo.info |
68 |
| Convolve |
| Convolve |
69 |
| Inside |
| Inside of ty |
70 |
| Field of FieldDef.field_def |
| Field of FieldDef.field_def |
71 |
| AddField |
| AddField |
72 |
| ScaleField |
| ScaleField |
73 |
| NegField |
| NegField |
74 |
| DiffField |
| DiffField |
75 |
| Probe |
| Probe of ty * ty |
76 |
| Input of string |
| Input of ty * string |
77 |
| InputWithDefault of string |
| InputWithDefault of ty * string |
78 |
|
|
79 |
fun arity (Add _) = 2 |
fun arity (Add _) = 2 |
80 |
| arity (Sub _) = 2 |
| arity (Sub _) = 2 |
110 |
| arity (Kernel _) = 0 |
| arity (Kernel _) = 0 |
111 |
| arity (LoadImage _) = 0 |
| arity (LoadImage _) = 0 |
112 |
| arity Convolve = 2 |
| arity Convolve = 2 |
113 |
| arity Inside = 2 |
| arity (Inside _) = 2 |
114 |
| arity (Field _) = 0 |
| arity (Field _) = 0 |
115 |
| arity AddField = 2 |
| arity AddField = 2 |
116 |
| arity ScaleField = 2 |
| arity ScaleField = 2 |
117 |
| arity NegField = 1 |
| arity NegField = 1 |
118 |
| arity DiffField = 1 |
| arity DiffField = 1 |
119 |
| arity Probe = 2 |
| arity (Probe _) = 2 |
120 |
| arity (Input _) = 0 |
| arity (Input _) = 0 |
121 |
| arity (InputWithDefault _) = 1 |
| arity (InputWithDefault _) = 1 |
122 |
|
|
154 |
| same (Kernel(a0), Kernel(b0)) = Kernel.same(a0, b0) |
| same (Kernel(a0), Kernel(b0)) = Kernel.same(a0, b0) |
155 |
| same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0) |
| same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0) |
156 |
| same (Convolve, Convolve) = true |
| same (Convolve, Convolve) = true |
157 |
| same (Inside, Inside) = true |
| same (Inside(a0), Inside(b0)) = samety(a0, b0) |
158 |
| same (Field(a0), Field(b0)) = FieldDef.same(a0, b0) |
| same (Field(a0), Field(b0)) = FieldDef.same(a0, b0) |
159 |
| same (AddField, AddField) = true |
| same (AddField, AddField) = true |
160 |
| same (ScaleField, ScaleField) = true |
| same (ScaleField, ScaleField) = true |
161 |
| same (NegField, NegField) = true |
| same (NegField, NegField) = true |
162 |
| same (DiffField, DiffField) = true |
| same (DiffField, DiffField) = true |
163 |
| same (Probe, Probe) = true |
| same (Probe(a0,a1), Probe(b0,b1)) = samety(a0, b0) andalso samety(a1, b1) |
164 |
| same (Input(a0), Input(b0)) = samestring(a0, b0) |
| same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1) |
165 |
| same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0) |
| same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1) |
166 |
| same _ = false |
| same _ = false |
167 |
|
|
168 |
fun hash (Add(a0)) = 0w3 + hashty a0 |
fun hash (Add(a0)) = 0w3 + hashty a0 |
199 |
| hash (Kernel(a0)) = 0w137 + Kernel.hash a0 |
| hash (Kernel(a0)) = 0w137 + Kernel.hash a0 |
200 |
| hash (LoadImage(a0)) = 0w139 + ImageInfo.hash a0 |
| hash (LoadImage(a0)) = 0w139 + ImageInfo.hash a0 |
201 |
| hash Convolve = 0w149 |
| hash Convolve = 0w149 |
202 |
| hash Inside = 0w151 |
| hash (Inside(a0)) = 0w151 + hashty a0 |
203 |
| hash (Field(a0)) = 0w157 + FieldDef.hash a0 |
| hash (Field(a0)) = 0w157 + FieldDef.hash a0 |
204 |
| hash AddField = 0w163 |
| hash AddField = 0w163 |
205 |
| hash ScaleField = 0w167 |
| hash ScaleField = 0w167 |
206 |
| hash NegField = 0w173 |
| hash NegField = 0w173 |
207 |
| hash DiffField = 0w179 |
| hash DiffField = 0w179 |
208 |
| hash Probe = 0w181 |
| hash (Probe(a0,a1)) = 0w181 + hashty a0 + hashty a1 |
209 |
| hash (Input(a0)) = 0w191 + hashstring a0 |
| hash (Input(a0,a1)) = 0w191 + hashty a0 + hashstring a1 |
210 |
| hash (InputWithDefault(a0)) = 0w193 + hashstring a0 |
| hash (InputWithDefault(a0,a1)) = 0w193 + hashty a0 + hashstring a1 |
211 |
|
|
212 |
fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"] |
fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"] |
213 |
| toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"] |
| toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"] |
243 |
| toString (Kernel(a0)) = concat["Kernel<", Kernel.toString a0, ">"] |
| toString (Kernel(a0)) = concat["Kernel<", Kernel.toString a0, ">"] |
244 |
| toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"] |
| toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"] |
245 |
| toString Convolve = "Convolve" |
| toString Convolve = "Convolve" |
246 |
| toString Inside = "Inside" |
| toString (Inside(a0)) = concat["Inside<", tyToString a0, ">"] |
247 |
| toString (Field(a0)) = concat["Field<", FieldDef.toString a0, ">"] |
| toString (Field(a0)) = concat["Field<", FieldDef.toString a0, ">"] |
248 |
| toString AddField = "AddField" |
| toString AddField = "AddField" |
249 |
| toString ScaleField = "ScaleField" |
| toString ScaleField = "ScaleField" |
250 |
| toString NegField = "NegField" |
| toString NegField = "NegField" |
251 |
| toString DiffField = "DiffField" |
| toString DiffField = "DiffField" |
252 |
| toString Probe = "Probe" |
| toString (Probe(a0,a1)) = concat["Probe<", tyToString a0, ",", tyToString a1, ">"] |
253 |
| toString (Input(a0)) = concat["Input<", stringToString a0, ">"] |
| toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"] |
254 |
| toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"] |
| toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"] |
255 |
|
|
256 |
end |
end |
257 |
|
|