_SystemArray.icl 7.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
implementation module _SystemArray

class Array .a e where
	select				:: !.(a .e) !Int	-> .e
	uselect				:: !u:(a e) !Int	-> *(e, !u:(a e))
	size				:: !.(a .e)			-> Int
	usize				:: !u:(a .e)		-> *(!Int, !u:(a .e))
	update				:: !*(a .e) !Int .e -> *(a .e)	
	createArray			:: !Int e			-> *(a e)
	_createArray		:: !Int				-> *(a .e)
	replace				:: !*(a .e) !Int .e -> *(.e, !*(a .e))

instance Array {#} Int where
	select arr index =
		code
		{
			select INT 0 1
		}
19
	uselect	:: !u:{# Int} !Int -> *(!Int, !u:{# Int})
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
	uselect arr index =
		code
		{
			push_a 0
			select INT 0 1
		}
	size arr =
		code
		{
			push_arraysize INT 0 1
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize INT 0 1
		}
37
	update :: !*{# e:Int} !Int !e:Int -> *{# e:Int}	
38 39 40 41 42
	update arr index el =
		code
		{	
			update INT 0 1
		}
43
	createArray :: !Int !Int -> *{# Int}
44 45 46 47
	createArray size el =
		code
		{	
			create_array INT 0 1
48 49
		}
	replace :: !*{# e:Int} !Int !e:Int -> *(!e:Int, !*{# e:Int})
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	replace arr index el =
		code
		{	
			replace INT 0 1
		}
	_createArray size =
		code
		{	
			create_array_ INT 0 1
		}

instance Array {#} Char where
	select arr index =
		code
		{
			select CHAR 0 1
		}
67
	uselect :: !u:{# Char} !Int -> *(!Char, !u:{# Char})
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
	uselect arr index =
		code
		{
			push_a 0
			select CHAR 0 1
		}
	size arr =
		code
		{
			push_arraysize CHAR 0 1
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize CHAR 0 1
		}
85
	update :: !*{# e:Char} !Int !e:Char -> *{# e:Char}
86 87 88 89 90
	update arr index el =
		code
		{	
			update CHAR 0 1
		}
91
	createArray :: !Int !Char -> *{# Char}
92 93 94 95 96
	createArray size el =
		code
		{	
			create_array CHAR 0 1
		}		
97
	replace :: !*{# e:Char} !Int !e:Char -> *(!e:Char, !*{# e:Char})
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
	replace arr index el =
		code
		{	
			replace CHAR 0 1
		}
	_createArray size =
		code
		{	
			create_array_ CHAR 0 1
		}

instance Array {#} Real where
	select arr index =
		code
		{
			select REAL 0 1
		}
115
	uselect :: !u:{# Real} !Int -> *(!Real, !u:{# Real})
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
	uselect arr index =
		code
		{
			push_a 0
			select REAL 0 1
		}
	size arr =
		code
		{
			push_arraysize REAL 0 1
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize REAL 0 1
		}
133
	update :: !*{# e:Real} !Int !e:Real -> *{# e:Real}
134 135 136 137 138
	update arr index el =
		code
		{	
			update REAL 0 1
		}
139
	createArray :: !Int !Real -> *{# Real}
140 141 142 143 144
	createArray size el =
		code
		{	
			create_array REAL 0 1
		}		
145
	replace :: !*{# e:Real} !Int !e:Real -> *(!e:Real, !*{# e:Real})
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
	replace arr index el =
		code
		{	
			replace REAL 0 1
		}
	_createArray size =
		code
		{	
			create_array_ REAL 0 1
		}

instance Array {#} Bool where
	select arr index =
		code
		{
			select BOOL 0 1
		}
163
	uselect :: !u:{# Bool} !Int -> *(!Bool, !u:{# Bool})
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
	uselect arr index =
		code
		{
			push_a 0
			select BOOL 0 1
		}
	size arr =
		code
		{
			push_arraysize BOOL 0 1
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize BOOL 0 1
		}
181
	update :: !*{# e:Bool} !Int !e:Bool -> *{# e:Bool}
182 183 184 185 186
	update arr index el =
		code
		{	
			update BOOL 0 1
		}
187
	createArray :: !Int !Bool -> *{# Bool}
188 189 190 191 192
	createArray size el =
		code
		{	
			create_array BOOL 0 1
		}		
193
	replace :: !*{# e:Bool} !Int !e:Bool -> *(!e:Bool, !*{# e:Bool})
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
	replace arr index el =
		code
		{	
			replace BOOL 0 1
		}
	_createArray size =
		code
		{	
			create_array_ BOOL 0 1
		}

instance Array {#} {#.a} where
	select arr index =
		code
		{
			select _ 1 0
		}
211
	uselect :: !u:{#{#.a}} !Int -> *(!{#.a},!u:{#{#.a}})
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
	uselect arr index =
		code
		{
			push_a 0
			select _ 1 0
		}
	size arr =
		code
		{
			push_arraysize _ 1 0
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize _ 1 0
		}
229
	update :: !*{#u:{#.a}} !Int !u:{#.a} -> *{#u:{#.a}}
230 231 232 233 234
	update arr index el =
		code
		{	
			update _ 1 0
		}
235
	createArray :: !Int !{#.a} -> *{# {#.a}}
236 237 238 239
	createArray size el =
		code
		{	
			create_array _ 1 0
240 241
		}
	replace :: !*{#u:{#.a}} !Int !u:{#.a} -> *(!u:{#.a},!*{#u:{#.a}})
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
	replace arr index el =
		code
		{	
			replace _ 1 0
		}
	_createArray size =
		code
		{	
			create_array_ _ 1 0
		}

instance Array {#} {!.a} where
	select arr index =
		code
		{
			select _ 1 0
		}
259
	uselect :: !u:{#{!.a}} !Int -> *(!{!.a},!u:{#{!.a}})
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
	uselect arr index =
		code
		{
			push_a 0
			select _ 1 0
		}
	size arr =
		code
		{
			push_arraysize _ 1 0
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize _ 1 0
		}
277
	update :: !*{#u:{!.a}} !Int !u:{!.a} -> *{#u:{!.a}}
278 279 280 281 282
	update arr index el =
		code
		{	
			update _ 1 0
		}
283
	createArray :: !Int !{!.a} -> *{# {!.a}}
284 285 286 287
	createArray size el =
		code
		{	
			create_array _ 1 0
288 289
		}
	replace :: !*{#u:{!.a}} !Int !u:{!.a} -> *(!u:{!.a},!*{#u:{!.a}})
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
	replace arr index el =
		code
		{	
			replace _ 1 0
		}
	_createArray size =
		code
		{	
			create_array_ _ 1 0
		}

instance Array {#} {.a} where
	select arr index =
		code
		{
			select _ 1 0
		}
307
	uselect :: !u:{#{.a}} !Int -> *(!{.a},!u:{#{.a}})
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
	uselect arr index =
		code
		{
			push_a 0
			select _ 1 0
		}
	size arr =
		code
		{
			push_arraysize _ 1 0
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize _ 1 0
		}
325
	update :: !*{#u:{.a}} !Int !u:{.a} -> *{#u:{.a}}
326 327 328 329 330
	update arr index el =
		code
		{	
			update _ 1 0
		}
331
	createArray :: !Int !{.a} -> *{# {.a}}
332 333 334 335
	createArray size el =
		code
		{	
			create_array _ 1 0
336 337
		}
	replace :: !*{#u:{.a}} !Int !u:{.a} -> *(!u:{.a},!*{#u:{.a}})
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
	replace arr index el =
		code
		{	
			replace _ 1 0
		}
	_createArray size =
		code
		{	
			create_array_ _ 1 0
		}

instance Array {#} a where
	select arr index =
		code
		{
			buildAC "StdArray:select ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
359
	uselect :: !u:{# e} !Int -> *(!e, !u:{# e})
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
	uselect arr index =
		code
		{
			buildAC "StdArray:uselect ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
	size arr =
		code
		{
			buildAC "StdArray:size ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
	usize arr =
		code
		{
			buildAC "StdArray:usize ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
387
	update :: !*{# .e} !Int !.e -> *{# .e}
388 389 390 391 392 393 394 395 396
	update arr index el =
		code
		{
			buildAC "StdArray:update ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
397
	createArray :: !Int !e -> *{# e}
398 399 400 401 402 403 404 405 406
	createArray size el =
		code
		{
			buildAC "StdArray:createArray ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}		
407
	replace :: !*{# .e} !Int !.e -> *(!.e, !*{# .e})
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
	replace arr index el =
		code
		{
			buildAC "StdArray:replace ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}
	_createArray size =
		code
		{
			buildAC "StdArray:_createArray ({#} a) should not be called"
		.d 1 0
			jsr print_string_
		.o 0 0
			halt
		}

instance Array {!} a where
	select arr index =
		code
		{
			select _ 1 0
		}
433
	uselect :: !u:{! e} !Int -> *(!e, !u:{! e})
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
	uselect arr index =
		code
		{
			push_a 0
			select _ 1 0
		}
	size arr =
		code
		{
			push_arraysize _ 1 0
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize _ 1 0
		}
451
	update :: !*{! .e} !Int !.e -> *{! .e}
452 453 454 455 456
	update arr index el =
		code
		{	
			update _ 1 0
		}
457
	createArray :: !Int !e -> *{! e}
458 459 460 461 462
	createArray size el =
		code
		{	
			create_array _ 1 0
		}		
463
	replace :: !*{! .e} !Int !.e -> *(!.e, !*{! .e})
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
	replace arr index el =
		code
		{	
			replace _ 1 0
		}
	_createArray size =
		code
		{	
			create_array_ _ 1 0
		}

instance Array {} a where
	select arr index =
		code
		{
			select _ 1 0
			jsr_eval 0
		}
	uselect arr index =
		code
		{
			push_a 0
			select _ 1 0
		}
	size arr =
		code
		{
			push_arraysize _ 1 0
		}
	usize arr =
		code
		{
			push_a 0
			push_arraysize _ 1 0
		}
	update arr index el =
		code
		{	
			update _ 1 0
		}
	createArray size el =
		code
		{	
			create_array _ 1 0
		}		
	replace arr index el =
		code
		{	
			replace _ 1 0
		}
	_createArray size =
		code
		{	
			create_array_ _ 1 0
		}