-
Notifications
You must be signed in to change notification settings - Fork 0
/
idol.icn
1316 lines (1222 loc) · 41 KB
/
idol.icn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package Compiler
link io #LK:
global imported #GV:
#
# classspec database (DBM) entry
#
record db_entry(dir, entry)
#PD:
#: find a class specification, along the IPATH if necessary
#:
procedure fetchspec(name)
static white, #SV: holds the applicable whitespace
#: characters for reading class
#: specifications
nonwhite #SV: holds the inverse of white
local basedir := ".", #LV: hold the base directory in which
#: to find the class database, defaults
#: to the current working directory
tmplst := tail(name), #LV: tempory to hold the split of name
#: when name is a specified file path
dir #LV: used for the directory currently
#: being looked at
ipath, #LV: hold the current paths that are
#: to be searched if cannot find the
#: class database in the specified
#: directory in name or current
#: working directory
f, #LV: temporary to hold a file descriptor
#: for the class database being accessed
s #LV: temporary to hold the selected
#: string value from the class database
initial {
#
# whitespace is defaulted to space and tab
#
white := " \t"
#
# however, if this is running under Microsoft Windows then we add ";" to
# the list of valid whitespace characters
#
if &features == "MS Windows NT" then {
white ++:= ';'
}
#
# we can now create the complement of white and assign to nonwhite
#
nonwhite := &cset -- white
}
basedir := ("" ~== tmplst[1])
name := tmplst[2]
if f := open(basedir || "/" || env, "dr") then {
if s := fetch(f, name) then {
close(f)
return db_entry(basedir, s)
}
close(f)
}
if basedir ~== "." then {
fail # if it gave a path, don't search IPATH
}
ipath := ipaths()
#
# search the ipath list of directories for the class database which holds
# the class/package specified by name
#
\ipath ? {
tab(many(white))
dir := ""
while dir ||:= tab(many(nonwhite)) do {
#
# collect the parts of a path that contains whitespace
#
if *dir > 0 & dir[1] == "\"" & dir[-1] ~== "\"" then {
dir ||:= tab(many(white)) | { fail }
} else {
#
# remove " from a path containing whitespace from the start and end
#
if dir[1] == dir[-1] == "\"" then {
dir := dir[2:-1]
}
#
# check if the selected path contains a class database, and if
# it does check to see if it has the specified class/package in it
#
if f := open(dir || "/" || env, "dr") then {
if s := fetch(f, name) then {
close(f)
return db_entry(dir, s)
}
close(f)
}
#
# skip whitespace between paths
#
tab(many(white))
dir := ""
}
}
}
end
#PD:
#: initialise the global variables needed for searching for classes
#
procedure reinitialize()
classes := taque()
links := []
imports := []
imported := table()
imported_classes := table()
thePackage := &null
end
#PD:
#: procedure to read a single Idol source file
#:
procedure readspec(name)
local s, #LV: local temporary for string processing
dbe, #LV: storage for the db_entry returned
#: for the class/package specified by name
L, #LV: holds a list of records from the
#: class database record for name,
#: records are specified by a newline
#: appearing in various positions in
#: the class databse record
decl #LV: used as a temporaty to hold the
#: declaration information found in the
#: class declaration in the class database
if not (dbe := fetchspec(name)) then {
stop("fatal: can't read spec for class ", name)
}
s := dbe.entry
yyfilename := name
fLine := 0
#
#Code Review Required
#
# this code should be changed to either fail or display error and stop
# this needs discussion with Clinton as to what should be happening here
#
if /s then {
write("fetchspec ", name, " returned null")
}
#
# from the class database record, create a list of lines determined. This is
# detern=mined by the \n appearing in the class database record
#
s ? {
L := []
while line := tab(find("\n") | 0) do {
put(L, line)
move(1)
#
#Code Review Required
#
# is this extraneous code? as control expression will fail after hitting
# the end of string and there should not be any reason to have to test
# for end of string to stop processing
#
if pos(0) then break
}
}
#
# the first field/record extracted from the class database record is the
# filename of the source code file associated with this class database
# record
#
fromfile := pop(L)
#
# process eacjh of the other fields/records extracted from the class database
# reocrd, one for each of the global definitions within the source file
#
while line := pop(L) do {
line ? {
#
# skip any extraneous whitespace at start of line
#
tab(many(white))
#
# the only valid values to be found are "class", "procedure", "record",
# "global" and "link". The value "const" is no longer valid in unicon source.
# "method" should never be found as it should fail the unicon compile
# process.
#
# changes here need to be discussed with Clinton as to what and how
# he would like the code changed
#
if ="class" then { # process the class definition information
decl := Class()
decl.dir := dbe.dir
decl.linkfile := fromfile
decl.Read(line,L)
#insert into table for lookup, but not into list for generation
classes.insert_t(decl,decl$name())
}
else if ="procedure" then { # process the procedure definiton information
if comp = 0 then comp := 1
decl := Method("")
decl$Read(line)
decl$Write(fout,"")
}
else if ="record" then { # process the record definition information
if comp = 0 then comp := 1
decl := declaration(line)
decl$Write(fout,"")
}
else if =("global" | "link") then { # process the global/link definition information
if comp = 0 then comp := 1
tab(many(white))
if pos(0) then line ||:= readln("wrap")
decl := vardecl(line)
decl$Write(fout,"")
}
else if ="const" then { # deprecated as it is not found in any unicon class
# database file
ct$append ( constdcl(line) )
}https://www.youtube.com/user/flash001USA/videos
else if ="method" then { # deprecated as it is not found in any uniocn class
# database file
halt("readinput: method outside class")
}
else if upto(nonwhite) then { # this would cover all errors including "const"and "method"
halt("expected declaration of \"class\", \"procedure\", \"record\", \"global\" or \"link\" on: ",line)
}
}
#
#Code Review Required
#
# is this extraneous code? as control expression will fail after hitting
# the end of string and there should not be any reason to have to test
# for end of string to stop processing
#
if pos(0) then break
}
end
#PD:
#:
#:
procedure methodstaque(node, cl, taq)
/taq := taque()
case type(node) of {
"treenode": {
if (node.label ~=== "global") & (node.label ~=== "record") then {
if *node.children > 0 then
every methodstaque(!node.children, cl, taq)
else write("leaf ", node.label)
}
else {
cl.insertglobal(node)
}
}
"Method__state": {
node.Class := cl
if not (taq$insert(node, node$name())) then {
uni_error("method " || node$name() ||
" redeclared in " || cl.name)
}
}
"null": { }
"token": {
write("token ", tokenstr(node.tok), " line ", node.line, " file ", node.filename)
}
"declaration__state" : {
# Record declaration.
cl.insertglobal(node)
}
default: {
write("methods Taque on ", type(node), " : ", image(node))
}
}
return taq
end
#PD:
#: This needs to be looked at carefully to determine what it is actually trying
#: to achieve. Code needs to be commented as to what/why
#:
procedure import_class(node)
local s, #LV:
pack, #LV:
tempp #LV:
/imported := ::table()
if ::type(node) == "treenode" & node.label == "implist" then {
import_class(node.children[1])
import_class(node.children[3])
} else if node.tok = IDENT then {
tempp := Package(node.s)
if /tempp.dir then {
uni_error("Unable to import (1) package " || image(node.s))
}
tempp.add_imported()
} else if node.tok = STRINGLIT then {
node.s ? {
move(1)
pack := ""
while pack ||:= tab(upto('/\\')) || move(1)
if pack ||:= tab(find(".")) then {
move(1)
s := tab(-1)
} else {
pack ||:= tab(-1)
}
}
tempp := Package(pack)
if /tempp.dir then {
uni_error("Unable to import (2) package " || image(pack))
}
tempp.add_imported(s)
}
end
###############################################################################
###############################################################################
#
# Class definitions from IDOL used in the Unicon Compiler
#
###############################################################################
###############################################################################
#CD:
#: class Table
#: This class corresponds to an Icon table, with the difference a key and its
#: associated value can only be inserted once, therafter no update is allowed
#: against the key value.
#:
#: If used in a class hieraarchy, the table storage value will be created on the
#: first key inserted. If no keys have been inserted, the size will always
#: remain at 0
#:
#: Any key that has not been previously inserted will always return &null, unlike
#: the default value that can be specified for a normal Icon table
#:
class Table(
__table #CV: holds a unicon/icon table value
)
#MD:
#: returns the size of the allocated table and if not allocated return 0
#:
method size()
return (* \__table) | 0
end
#MD:
#: Insert a new key and its associated value, if an update to the value is
#: attempted, the insert will fail. If the key is not supplied, the value
#: becomes the key
#:
method insert(x, key)
/__table := ::table()
/key := x
if (/ (__table[key])) := x then {
return
}
end
#MD:
#: Lookup the value associated with the supplied key and return it. If the
#: key is not in the table then return &null.
#:
method lookup(key)
if \__table then {
return __table[key]
}
return
end
#MD:
#: returns the values associated with each key in the table. No particular
#: order is defined
#:
method foreach()
if \__table then {
suspend !__table
}
end
#MD:
#: if the class Table is called by itself, it will initialise the class variable
#: __table to an unicon/icon table value
#:
initially()
/__table := ::table()
end
#CD:
#: class taque
#: This class represents a tabular queues defining objects which maintain
#: synchronized list and table reps
#:
#: Is this comment true or false : Well, what is really provided are
#: loosely-coordinated list/tables
#:
class taque : Table (
__list #CV: holds the list representation of
#: keys that have been inserted into
#: the Table portion of this object
)
#MD:
#: returns the size of the allocated list and if not allocated return 0
#:
method size()
return (* \__list) | 0
end
#MD:
#: insert a key-value pair into the object, with the values being appended
#: to the list representation only if the insertion has successfully occurred
#: into the table.
#:
method insert(x, key)
/__list := []
if self$Table.insert(x, key) then {
::put(__list, x)
return
}
end
#MD:
#: insert a key-value pair into the object, with the values being prepended
#: to the list representation only if the insertion has successfully occurred
#: into the table.
#:
method Push(x, key)
/__list := []
if self$Table.insert(x, key) then {
::push(__list, x)
return
}
end
#MD:
#: alternative name for the insert method
#:
method Put(x, key)
return insert(x, key)
end
#MD:
#: returns each key in the table storage, in the sequence/order that they
#: were inserted
#:
method foreach()
if \__list then {
suspend !__list
}
end
#MD:
#: insert the key-value pair into the table portion of the object, with no
#: insertion of the key into the list protion of the object
#:
method insert_t(x, key)
return self$Table.insert(x, key)
end
method foreach_t()
suspend self$Table.foreach()
end
#MD:
#: if the class taque is called by itself, it will initialise the class variable
#: __list to an unicon/icon list value and the corresponding __table to an
#: unicon/icon list value
#:
initially()
/__list := []
self$Table.initially()
end
#CD:
#: class idTaque
#: support for taques found as lists of ids separated by punctuation
#:
class idTaque : taque(
__punc #CV: the seperator character to be used
)
method parse(s)
local name
s ? {
tab(many(white))
while name := tab(find(self.punc)) do {
self$insert(trim(name,white))
move(1)
tab(many(white))
}
if any(nonwhite) then {
self$insert(trim(tab(0),white))
}
}
return
end
#MD:
#: Traverse a given subtree, adding its contents to myself.
#: Routinely called in the constructor after a comma-separated
#: list of identifiers have been parsed; also called on "local"
#: declarations in classes to append them onto the initial list.
#:
method traverse(nod, isClassLocal)
local accum
case ::type(nod) of {
"treenode": {
if *nod.children > 0 then {
if nod.label == ("arg" || (2 to 8)) then {
if /isClassLocal then {
insert(nod, nod.children[1].s)
} else {
insert(nod.children[1].s)
}
} else if nod.label == "varlist2" then {
if /isClassLocal then {
insert(nod, nod.children[1].s)
} else {
insert(nod.children[1].s)
nod := copy(nod)
nod.label := "assign"
return nod
}
} else if nod.label==("varlist3"|"varlist4") then {
traverse(nod.children[1], isClassLocal)
if /isClassLocal then {
insert(nod, nod.children[3].s)
} else {
insert(nod.children[3].s)
}
} else {
accum := []
every \(x := traverse(!nod.children, isClassLocal)) do {
put(accum, x)
}
accumtree := &null
while x := pull(accum) do {
accumtree := node("procbody", x, ";", accumtree)
}
return accumtree
}
} else {
write("leaf ", nod.label)
}
}
"token": {
if nod.tok = IDENT then {
insert(nod.s)
}
}
"string": {
if (nod ~== self.punc) & (nod ~== ";") then {
write("idTaque on ", type(nod), " : ", image(nod), " (punc was ",image(punc),")")
}
}
"null": { }
default: {
write("idTaque on ", type(nod), " : ", image(nod))
}
}
return
end
#MD:
#: display this object as a string value
#:
method String()
local out, #LV: used to construct the string representation
#: of the object
id #LV: temporary to hold each element of
#: the taque
#
# if there is nothing stored in the object yet, just return the empty
# string as the representation
#
if /__list then {
return ""
}
out := ""
every id := !__list do {
if ::type(id) == "treenode" then {
id := id.children[1].s
}
out ||:= id || self.punc
}
#
# don't return the last punctuation character
#
return out[1:-1]
end
#MD:
#: if the class is called with no value as the seperator, this will be set to " "
#: most uses of idTaque will specify the required seperator character
#:
#: since no parameter fields are specified, the object fields will be filled
#: directly by the class call
#:
initially
local argtree #LV: holds whatever value was used when
#: the object was created during the
#: compiler parsing process
/__punc := " "
self$taque.initially()
if ::type(\__list) ~== "list" then {
argtree := __list
__list := []
if ::type(argtree) == "token" then {
insert(argtree.s)
} else {
traverse(argtree)
}
}
end
#CD:
#: Abstract class for objects resulting from parsing lines of the form
#: tag name ( field1 , field2, ... )
#:
class declaration(
__name, #CV:
__fields, #CV:
__tag, #CV:
lptoken, #CV:
rptoken #CV:
)
#MD:
#: return the name associated with this declaration
#:
method name()
return __name
end
#MD:
#: set the name associated with this declaration
#:
method setname(s)
__name := s
end
#MD:
#: parse a declaration string into its components
#:
method Read(decl)
decl ? (
#
# skip whitespace if any
#
(tab(many(white)) | ""),
#
# get my tag, this will be a procedure, class, method, record or package
# declaration
#
(self.tag := =("procedure" | "class" | "method" | "record" | "package")),
#
# skip whitespace if any
#
(tab(many(white)) | "") ,
#
# get my name, a standard identifier, the following is not quite correct,
# need to check if there are any situations in which this will not give
# the correct result.
#
(self.name := tab(many(alpha))) ,
#
# we expect to find ( as the next character
#
(tab(find("(")+1))\1,
(tab(many(white)) | "") ,
((self.fields := classFields())$parse(tab(find(")")\1))),
=")",
(tab(many(white)) | ""),
pos(0)
) | halt("declaration/read can't parse decl ",decl)
end
#
# write a declaration
#
method Write(f)
yyprint(tag)
yyprint(name)
yyprint(lptoken)
yyprint(fields)
yyprint(rptoken)
end
#
# convert self to a string
#
method String()
flds := (\(self.fields))$String() | ""
if / (self.tag) then {
write("null tag in ", image(self.name), " object ", image(self))
}
return self.tag || " " || self.name || "(" || flds || ")"
end
initially
tmpcount := 0
end
#CD:
#: parameter lists in which the final argument may have a trailing []
#: The "[]" varg parameter is passed in by the parser if it is present.
#:
class argList : idTaque(
__varg #CV:
)
#MD:
#:
#:
method ispublic()
::write("Idol class: argList.ispublic()")
fail
end
#MD:
#:
#:
method coercions()
local first, #LV:
x, #LV:
v #LV:
::write("Idol class: argList.coercions()")
every x := !\__list do {
if ::type(x) == "treenode" then {
if /first := 1 then {
::write(yyout)
}
v := x.children[1].s
if x.label == ("arg3" | "arg4") then {
::write(yyout, "/", v, " := ", x.children[-1].s)
} else if x.label == ("arg5" | "arg6") then {
::write(yyout, "/", v, " := &", x.children[-1].children[-1].s)
} else if x.label == ("arg7" | "arg8") then {
::write(yyout, "/", v, " := []")
}
if x.label == ("arg2" | "arg4" | "arg6") then {
case x.children[3].s of {
"integer" | "string" | "numeric" | "cset" | "real": {
::writes(yyout, v, " := ", x.children[3].s, "(", v, ") |")
}
default: {
::writes(yyout, "(type(", v, ")==\"", x.children[3].s, "\") |")
}
}
::writes(yyout, " runerr(")
::writes(yyout,
case x.children[3].s of {
"integer": 101
"numeric": 102
"string": 103
"cset": 104
"file": 105
"list": 108
"set": 119
"table": 124
"window": 140
default: 123
})
::write(yyout, ", ", v, ")")
}
}
}
end
#MD:
#:
#:
method String()
::write("Idol class: argList.String()")
return self$idTaque.String() || ((\self.__varg & "[]") | "")
end
#MD:
#:
#:
method Write(f)
::write("Idol class: argList.Write()")
::writes(f, String())
end
#MD:
#:
#:
initially
write("Idol class: argList.initially()")
self.__punc := ","
self$idTaque.initially()
end
#CD:
#: Idol class field lists in which fields may be preceded by a "public" keyword
#:
class classFields : argList(
__publics #CV:
)
#MD:
#: This should always fail, need to check where this is called and adjust code
#: accordingly
#:
method ispublic(s)
write("Idol class: classFields.ispublic()")
if \self.__publics then {
suspend !self.__publics == s
}
end
#MD:
#: since "public" is not an option, this part of the code should be able to
#: be deleted and the insert method of arglist, called directly.
#:
method insert(s)
write("Idol class: classFields.insert()")
s ? {
if ="public" & tab(many(white)) then {
s := tab(0)
/self.publics := []
put(self.publics, s)
}
}
return self$argList.insert(s)
end
end
#CD:
#: Attributes and operations of classes
#:
class Class : declaration (
__supers, #CV:
__methods, #CV:
text, #CV:
imethods, #CV:
ifields, #CV:
__glob, #CV:
linkfile, #CV:
dir, #CV:
unmangled_name, #CV:
supers_node #CV:
)
method ismethod(id)
write("Idol class: Class.ismethod()")
if \ (self.methods$lookup(id)) | (!\self.imethods).ident == id then
return
end
method isfield(id)
write("Idol class: Class.isfield()")
if \ (self.fields$lookup(id)) | (!\self.ifields).ident == id then
return
end
#MD:
#:
#:
method Read(line, L)
write("Idol class: Class.Read()")
self$declaration.Read(line)
self.__supers := idTaque(":")
self.__supers.parse(line[find(":",line)+1:find("(",line)] | "")
self.__methods := taque()
self$ReadBody(0, L)
end
#MD:
#:
#:
method ReadBody(depth, L)
write("Idol class: Class.ReadBody()")
while line := pop(L) do {
line ? {
tab(many(white))
if ="initially" then {
(cf := classFields()).parse("")
decl := Method(self.name, self.text, , cf, "method")
decl.setname("initially")
self.__methods.insert(decl, "initially")
} else if ="method" then {
decl := Method(self.name)
decl.Read(line, phase)
self.__methods.insert(decl, decl$name())
} else if ="end" & pos(0) then {
# "end" is tossed here. see "initially" above
return
} else if ="procedure" then {
decl := Method("")
decl.Read(line, phase)
insertglobal(decl)
} else if ="global" then {
insertglobal(vardecl(line))
} else if ="record" then {
insertglobal(declaration(line))
} else if upto(nonwhite) then {
decl := Method(self.name)
decl.Read("method " || line || "()", phase)
self.methods.insert(decl,decl$name())
}
}
}
if depth = 0 then
halt("class/read syntax error: eof inside a class definition")
end
#
# Miscellaneous methods on classes
#
method has_initially()
write("Idol class: Class.has_initially()")
return (methods$foreach())$name() == "initially"
end
#MD:
#:
#:
method ispublic(fieldname)
write("Idol class: Class.ispublic()")
if self.__fields.ispublic(fieldname) then {
return fieldname
}
end
#MD:
#:
#:
method foreachmethod()
write("Idol class: Class.foreachmethod()")
suspend __methods.foreach()
end
#MD:
#:
#:
method foreachsuper()
write("Idol class: Class.foreachsuper()")
suspend __supers.foreach()
end
#MD:
#:
#:
method foreachfield()
write("Idol class: Class.foreachfield()")
suspend __fields.foreach()
end
method insertglobal(glob)
/__glob := []
::put(__glob, glob)
return self
end
method isvarg(s)
write("Idol class: Class.isvarg()")
if self.fields$isvarg(s) then return s
end
method transitive_closure()
write("Idol class: Class.transitive_closure()")
count := supers$size()
while count > 0 do {
added := taque()
every sc := supers$foreach() do {
if /(super := classes$lookup(sc)) then
halt("class/transitive_closure: couldn't find superclass ",sc)
every supersuper := super$foreachsuper() do {
if / self.supers$lookup(supersuper) &
/added$lookup(supersuper) then {
added$insert(supersuper)
}
}
}
count := added$size()
every self.supers$insert(added$foreach())
}
end
#
# write the class declaration: if s is "class" write as a spec
# otherwise, write as a constructor
#
method writedecl(f,s)
write("Idol class: Class.writedecl()")