Structure.st
changeset 282 7f91d09a768b
child 283 3fdbe3ef9a1d
equal deleted inserted replaced
281:e8affee2ae5f 282:7f91d09a768b
       
     1 Object subclass:#Structure
       
     2 	instanceVariableNames:'superclass flags selectorArray methodArray otherSupers instSize
       
     3 		i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18
       
     4 		i19 i20'
       
     5 	classVariableNames:'OneInstance DummyClass'
       
     6 	poolDictionaries:''
       
     7 	category:'Collections-Arrayed'
       
     8 !
       
     9 
       
    10 
       
    11 !Structure class methodsFor:'documentation'!
       
    12 
       
    13 documentation
       
    14 "
       
    15     are you tired of using arrays or identityDictionaries, when
       
    16     multiple values have to be returned from some method, AND
       
    17     you dont want to add many stupid dummy data-holder classes to
       
    18     avoid the above ?
       
    19     (for example, the value returned by someMethod>>who) 
       
    20 
       
    21     Here is a goody to return an object which is class-less,
       
    22     only holding some values, and provides a protocol to access
       
    23     those fields. In addition, it supports the array-protocol,
       
    24     so it can be used as a backward compatible replacement in
       
    25     places where arrays were returned.
       
    26     
       
    27     For example, in Method>>who, instead of returning:
       
    28 	^ Array with:cls with:selector
       
    29     you can also return:
       
    30 	^ Structure with:#containingClass->cls with:#selector->selector
       
    31 
       
    32     and access these values either as:
       
    33 	retVal at:1	-> returns the cls
       
    34 	retVal at:2	-> returns the selector
       
    35     or (much more convenient and readable) as:
       
    36 	retVal containingClass
       
    37 	retVal selector
       
    38 
       
    39     implementation note:
       
    40 	this is a very tricky (but fully legal) implementation,
       
    41 	creating an objects which is its own class. Therefore, no additional
       
    42 	overhead by extra objects is involved.
       
    43 	
       
    44 	Another prove that smalltalk is a powerful & flexible programming language.
       
    45 	However, some smalltalk systems crash if your try this ;-)
       
    46 
       
    47     [author:]
       
    48 	Claus Gittinger
       
    49 
       
    50     [see also:]
       
    51 	Array 
       
    52 	Behavior
       
    53 "
       
    54 !
       
    55 
       
    56 examples
       
    57 "
       
    58     								[exBegin]
       
    59     (Structure names:#(foo bar)) inspect
       
    60 								[exEnd]
       
    61 
       
    62     								[exBegin]
       
    63     (Structure with:#foo->'foo value') inspect
       
    64 								[exEnd]
       
    65 
       
    66     								[exBegin]
       
    67     (Structure with:#foo->'foo value' with:#bar->'bar value') inspect
       
    68 								[exEnd]
       
    69 
       
    70     								[exBegin]
       
    71     (Structure with:#foo->'hello' with:#bar->true with:#baz->'world') inspect
       
    72 								[exEnd]
       
    73 
       
    74 "
       
    75 ! !
       
    76 
       
    77 !Structure class methodsFor:'initialization'!
       
    78 
       
    79 initialize
       
    80     OneInstance isNil ifTrue:[
       
    81         OneInstance := self basicNew.
       
    82 
       
    83         DummyClass := Behavior shallowCopy.
       
    84         DummyClass flags:(Behavior flagBehavior bitOr:Behavior flagPointers).
       
    85     ].
       
    86 
       
    87     "
       
    88      OneInstance := nil
       
    89      self initialize
       
    90     "
       
    91 
       
    92 ! !
       
    93 
       
    94 !Structure class methodsFor:'instance creation'!
       
    95 
       
    96 newWith:names
       
    97     "return a new structure containing fields as passed in the names collection.
       
    98      The argument must be a sequenceable collection of symbols.
       
    99      The new structures values are all nil."
       
   100 
       
   101      ^ self newWith:names values:nil
       
   102 
       
   103     "
       
   104      Structure newWith:#(foo bar)
       
   105     "
       
   106 
       
   107     "Created: 13.5.1996 / 20:03:42 / cg"
       
   108 !
       
   109 
       
   110 newWith:names values:values
       
   111     "return a new structure containing fields as passed in the names collection.
       
   112      The argument must be a sequenceable collection of symbols.
       
   113      The new structures values are set to corresponding values from the second argument, values."
       
   114 
       
   115     |cls arr sels mthds dummyClass|
       
   116 
       
   117     sels := names collect:[:nm | nm asSymbol].
       
   118     sels := sels , (names collect:[:nm | (nm , ':') asSymbol]).
       
   119     sels := sels , #(#doesNotUnderstand: #class #at: #at:put: #basicAt: #basicAt:put:).
       
   120 
       
   121     mthds := (1 to:names size) 
       
   122                 collect:[:i | (self compiledMethodAt:('i',i printString)asSymbol)].
       
   123     mthds := mthds , 
       
   124              ( (1 to:names size) 
       
   125                 collect:[:i | (self compiledMethodAt:('i',i printString,':')asSymbol)]).
       
   126 
       
   127     mthds := mthds , (Array 
       
   128                        with:(self compiledMethodAt:#doesNotUnderstand:)
       
   129                        with:(Object compiledMethodAt:#class)
       
   130                      )
       
   131                    , (Array
       
   132                        with:(Object compiledMethodAt:#at:)
       
   133                        with:(Object compiledMethodAt:#at:put:)
       
   134                        with:(Object compiledMethodAt:#basicAt:)
       
   135                        with:(Object compiledMethodAt:#basicAt:put:)
       
   136                      ).
       
   137 
       
   138     arr := Array new:(names size + 6).
       
   139     arr at:1 put:nil.                                                   "/ superclass
       
   140     arr at:2 put:(Behavior flagBehavior bitOr:Behavior flagPointers).   "/ flags
       
   141     arr at:3 put:sels asArray.                                          "/ selectors
       
   142     arr at:4 put:mthds asArray.                                         "/ methods
       
   143     arr at:5 put:nil.                                                   "/ other supers
       
   144     arr at:6 put:6.                                                     "/ instSize 
       
   145 
       
   146     arr changeClassTo:DummyClass.
       
   147     arr changeClassTo:arr.
       
   148 
       
   149     values notNil ifTrue:[
       
   150         values keysAndValuesDo:[:i :val |
       
   151             arr at:i put:val
       
   152         ]
       
   153     ].
       
   154 
       
   155     ^ arr.  
       
   156 
       
   157     "
       
   158      Structure newWith:#(foo bar) values:#('foo' 'bar')
       
   159     "
       
   160 
       
   161     "Created: 13.5.1996 / 20:03:42 / cg"
       
   162 !
       
   163 
       
   164 with:assoc
       
   165     "return a new structure with a single field, named to the assocs key,
       
   166      and initialized with assocs value."
       
   167 
       
   168      ^ self newWith:(Array with:assoc key) values:(Array with:assoc value)
       
   169 
       
   170     "
       
   171      Structure with:#foo->'foo'
       
   172     "
       
   173 !
       
   174 
       
   175 with:assoc1 with:assoc2
       
   176     "return a new structure with two fields, named as defined by the arguments'
       
   177      keys, and and initialized with the assocs' values."
       
   178 
       
   179      ^ self newWith:(Array with:assoc1 key
       
   180                            with:assoc2 key) 
       
   181              values:(Array with:assoc1 value
       
   182                            with:assoc2 value)
       
   183 
       
   184     "
       
   185      Structure with:#foo->'foo' with:#bar->'bar'
       
   186     "
       
   187 !
       
   188 
       
   189 with:assoc1 with:assoc2 with:assoc3
       
   190     "return a new structure with three fields, named as defined by the arguments'
       
   191      keys, and and initialized with the assocs' values."
       
   192 
       
   193      ^ self newWith:(Array with:assoc1 key
       
   194                            with:assoc2 key
       
   195                            with:assoc3 key) 
       
   196              values:(Array with:assoc1 value
       
   197                            with:assoc2 value
       
   198                            with:assoc3 value)
       
   199 
       
   200     "
       
   201      Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz'
       
   202     "
       
   203 !
       
   204 
       
   205 with:assoc1 with:assoc2 with:assoc3 with:assoc4
       
   206     "return a new structure with four fields, named as defined by the arguments'
       
   207      keys, and and initialized with the assocs' values."
       
   208 
       
   209      ^ self newWith:(Array with:assoc1 key 
       
   210                            with:assoc2 key 
       
   211                            with:assoc3 key 
       
   212                            with:assoc4 key) 
       
   213              values:(Array with:assoc1 value 
       
   214                            with:assoc2 value 
       
   215                            with:assoc3 value 
       
   216                            with:assoc4 value)
       
   217 
       
   218     "
       
   219      Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello'
       
   220     "
       
   221 !
       
   222 
       
   223 with:assoc1 with:assoc2 with:assoc3 with:assoc4 with:assoc5
       
   224     "return a new structure with five fields, named as defined by the arguments'
       
   225      keys, and and initialized with the assocs' values."
       
   226 
       
   227      ^ self newWith:(Array with:assoc1 key 
       
   228                            with:assoc2 key 
       
   229                            with:assoc3 key 
       
   230                            with:assoc4 key      
       
   231                            with:assoc5 key) 
       
   232              values:(Array with:assoc1 value 
       
   233                            with:assoc2 value 
       
   234                            with:assoc3 value 
       
   235                            with:assoc4 value 
       
   236                            with:assoc5 value)
       
   237 
       
   238     "
       
   239      Structure with:#foo->'foo' with:#bar->'bar' with:#baz->'baz' with:#hello->'hello' with:#world->'world'
       
   240     "
       
   241 ! !
       
   242 
       
   243 !Structure methodsFor:'accessing'!
       
   244 
       
   245 flags
       
   246     "return the flags - required class protocol"
       
   247 
       
   248     ^ flags
       
   249 
       
   250     "Created: 13.5.1996 / 21:19:23 / cg"
       
   251 !
       
   252 
       
   253 flags:something
       
   254     "set the flags - required class protocol"
       
   255 
       
   256     flags := something.
       
   257 
       
   258     "Created: 13.5.1996 / 21:19:23 / cg"
       
   259 !
       
   260 
       
   261 i1
       
   262     "return the first instance variable"
       
   263 
       
   264     ^ i1
       
   265 
       
   266     "Created: 13.5.1996 / 21:19:25 / cg"
       
   267 !
       
   268 
       
   269 i10
       
   270     "return i10"
       
   271 
       
   272     ^ i10
       
   273 
       
   274     "Created: 13.5.1996 / 21:19:27 / cg"
       
   275 !
       
   276 
       
   277 i10:something
       
   278     "set i10"
       
   279 
       
   280     i10 := something.
       
   281 
       
   282     "Created: 13.5.1996 / 21:19:27 / cg"
       
   283 !
       
   284 
       
   285 i11
       
   286     "return i11"
       
   287 
       
   288     ^ i11
       
   289 
       
   290     "Created: 13.5.1996 / 21:19:27 / cg"
       
   291 !
       
   292 
       
   293 i11:something
       
   294     "set i11"
       
   295 
       
   296     i11 := something.
       
   297 
       
   298     "Created: 13.5.1996 / 21:19:27 / cg"
       
   299 !
       
   300 
       
   301 i12
       
   302     "return i12"
       
   303 
       
   304     ^ i12
       
   305 
       
   306     "Created: 13.5.1996 / 21:19:27 / cg"
       
   307 !
       
   308 
       
   309 i12:something
       
   310     "set i12"
       
   311 
       
   312     i12 := something.
       
   313 
       
   314     "Created: 13.5.1996 / 21:19:27 / cg"
       
   315 !
       
   316 
       
   317 i13
       
   318     "return i13"
       
   319 
       
   320     ^ i13
       
   321 
       
   322     "Created: 13.5.1996 / 21:19:28 / cg"
       
   323 !
       
   324 
       
   325 i13:something
       
   326     "set i13"
       
   327 
       
   328     i13 := something.
       
   329 
       
   330     "Created: 13.5.1996 / 21:19:28 / cg"
       
   331 !
       
   332 
       
   333 i14
       
   334     "return i14"
       
   335 
       
   336     ^ i14
       
   337 
       
   338     "Created: 13.5.1996 / 21:19:28 / cg"
       
   339 !
       
   340 
       
   341 i14:something
       
   342     "set i14"
       
   343 
       
   344     i14 := something.
       
   345 
       
   346     "Created: 13.5.1996 / 21:19:28 / cg"
       
   347 !
       
   348 
       
   349 i15
       
   350     "return i15"
       
   351 
       
   352     ^ i15
       
   353 
       
   354     "Created: 13.5.1996 / 21:19:28 / cg"
       
   355 !
       
   356 
       
   357 i15:something
       
   358     "set i15"
       
   359 
       
   360     i15 := something.
       
   361 
       
   362     "Created: 13.5.1996 / 21:19:28 / cg"
       
   363 !
       
   364 
       
   365 i16
       
   366     "return i16"
       
   367 
       
   368     ^ i16
       
   369 
       
   370     "Created: 13.5.1996 / 21:19:28 / cg"
       
   371 !
       
   372 
       
   373 i16:something
       
   374     "set i16"
       
   375 
       
   376     i16 := something.
       
   377 
       
   378     "Created: 13.5.1996 / 21:19:28 / cg"
       
   379 !
       
   380 
       
   381 i17
       
   382     "return i17"
       
   383 
       
   384     ^ i17
       
   385 
       
   386     "Created: 13.5.1996 / 21:19:28 / cg"
       
   387 !
       
   388 
       
   389 i17:something
       
   390     "set i17"
       
   391 
       
   392     i17 := something.
       
   393 
       
   394     "Created: 13.5.1996 / 21:19:29 / cg"
       
   395 !
       
   396 
       
   397 i18
       
   398     "return i18"
       
   399 
       
   400     ^ i18
       
   401 
       
   402     "Created: 13.5.1996 / 21:19:29 / cg"
       
   403 !
       
   404 
       
   405 i18:something
       
   406     "set i18"
       
   407 
       
   408     i18 := something.
       
   409 
       
   410     "Created: 13.5.1996 / 21:19:29 / cg"
       
   411 !
       
   412 
       
   413 i19
       
   414     "return i19"
       
   415 
       
   416     ^ i19
       
   417 
       
   418     "Created: 13.5.1996 / 21:19:29 / cg"
       
   419 !
       
   420 
       
   421 i19:something
       
   422     "set i19"
       
   423 
       
   424     i19 := something.
       
   425 
       
   426     "Created: 13.5.1996 / 21:19:29 / cg"
       
   427 !
       
   428 
       
   429 i1:something
       
   430     "set i1"
       
   431 
       
   432     i1 := something.
       
   433 
       
   434     "Created: 13.5.1996 / 21:19:25 / cg"
       
   435 !
       
   436 
       
   437 i2
       
   438     "return i2"
       
   439 
       
   440     ^ i2
       
   441 
       
   442     "Created: 13.5.1996 / 21:19:25 / cg"
       
   443 !
       
   444 
       
   445 i20
       
   446     "return i20"
       
   447 
       
   448     ^ i20
       
   449 
       
   450     "Created: 13.5.1996 / 21:19:29 / cg"
       
   451 !
       
   452 
       
   453 i20:something
       
   454     "set i20"
       
   455 
       
   456     i20 := something.
       
   457 
       
   458     "Created: 13.5.1996 / 21:19:29 / cg"
       
   459 !
       
   460 
       
   461 i2:something
       
   462     "set i2"
       
   463 
       
   464     i2 := something.
       
   465 
       
   466     "Created: 13.5.1996 / 21:19:25 / cg"
       
   467 !
       
   468 
       
   469 i3
       
   470     "return i3"
       
   471 
       
   472     ^ i3
       
   473 
       
   474     "Created: 13.5.1996 / 21:19:25 / cg"
       
   475 !
       
   476 
       
   477 i3:something
       
   478     "set i3"
       
   479 
       
   480     i3 := something.
       
   481 
       
   482     "Created: 13.5.1996 / 21:19:25 / cg"
       
   483 !
       
   484 
       
   485 i4
       
   486     "return i4"
       
   487 
       
   488     ^ i4
       
   489 
       
   490     "Created: 13.5.1996 / 21:19:25 / cg"
       
   491 !
       
   492 
       
   493 i4:something
       
   494     "set i4"
       
   495 
       
   496     i4 := something.
       
   497 
       
   498     "Created: 13.5.1996 / 21:19:25 / cg"
       
   499 !
       
   500 
       
   501 i5
       
   502     "return i5"
       
   503 
       
   504     ^ i5
       
   505 
       
   506     "Created: 13.5.1996 / 21:19:26 / cg"
       
   507 !
       
   508 
       
   509 i5:something
       
   510     "set i5"
       
   511 
       
   512     i5 := something.
       
   513 
       
   514     "Created: 13.5.1996 / 21:19:26 / cg"
       
   515 !
       
   516 
       
   517 i6
       
   518     "return i6"
       
   519 
       
   520     ^ i6
       
   521 
       
   522     "Created: 13.5.1996 / 21:19:26 / cg"
       
   523 !
       
   524 
       
   525 i6:something
       
   526     "set i6"
       
   527 
       
   528     i6 := something.
       
   529 
       
   530     "Created: 13.5.1996 / 21:19:26 / cg"
       
   531 !
       
   532 
       
   533 i7
       
   534     "return i7"
       
   535 
       
   536     ^ i7
       
   537 
       
   538     "Created: 13.5.1996 / 21:19:26 / cg"
       
   539 !
       
   540 
       
   541 i7:something
       
   542     "set i7"
       
   543 
       
   544     i7 := something.
       
   545 
       
   546     "Created: 13.5.1996 / 21:19:26 / cg"
       
   547 !
       
   548 
       
   549 i8
       
   550     "return i8"
       
   551 
       
   552     ^ i8
       
   553 
       
   554     "Created: 13.5.1996 / 21:19:26 / cg"
       
   555 !
       
   556 
       
   557 i8:something
       
   558     "set i8"
       
   559 
       
   560     i8 := something.
       
   561 
       
   562     "Created: 13.5.1996 / 21:19:26 / cg"
       
   563 !
       
   564 
       
   565 i9
       
   566     "return i9"
       
   567 
       
   568     ^ i9
       
   569 
       
   570     "Created: 13.5.1996 / 21:19:26 / cg"
       
   571 !
       
   572 
       
   573 i9:something
       
   574     "set i9"
       
   575 
       
   576     i9 := something.
       
   577 
       
   578     "Created: 13.5.1996 / 21:19:27 / cg"
       
   579 !
       
   580 
       
   581 instSize
       
   582     "return instSize - required class protocol"
       
   583 
       
   584     ^ instSize
       
   585 
       
   586     "Created: 13.5.1996 / 21:19:24 / cg"
       
   587 !
       
   588 
       
   589 instSize:something
       
   590     "set instSize - required class protocol"
       
   591 
       
   592     instSize := something.
       
   593 
       
   594     "Created: 13.5.1996 / 21:19:25 / cg"
       
   595 !
       
   596 
       
   597 methodArray
       
   598     "return methodArray - required class protocol"
       
   599 
       
   600     ^ methodArray
       
   601 
       
   602     "Created: 13.5.1996 / 21:19:24 / cg"
       
   603 !
       
   604 
       
   605 methodArray:something
       
   606     "set methodArray - required class protocol"
       
   607 
       
   608     methodArray := something.
       
   609 
       
   610     "Created: 13.5.1996 / 21:19:24 / cg"
       
   611 !
       
   612 
       
   613 otherSupers
       
   614     "return otherSupers"
       
   615 
       
   616     ^ otherSupers
       
   617 
       
   618     "Created: 13.5.1996 / 21:19:24 / cg"
       
   619 !
       
   620 
       
   621 otherSupers:something
       
   622     "set otherSupers"
       
   623 
       
   624     otherSupers := something.
       
   625 
       
   626     "Created: 13.5.1996 / 21:19:24 / cg"
       
   627 !
       
   628 
       
   629 selectorArray
       
   630     "return selectorArray - required class protocol"
       
   631 
       
   632     ^ selectorArray
       
   633 
       
   634     "Created: 13.5.1996 / 21:19:24 / cg"
       
   635 !
       
   636 
       
   637 selectorArray:something
       
   638     "set selectorArray - required class protocol"
       
   639 
       
   640     selectorArray := something.
       
   641 
       
   642     "Created: 13.5.1996 / 21:19:24 / cg"
       
   643 !
       
   644 
       
   645 superclass
       
   646     "return superclass - required class protocol"
       
   647 
       
   648     ^ superclass
       
   649 
       
   650     "Created: 13.5.1996 / 21:19:23 / cg"
       
   651 !
       
   652 
       
   653 superclass:something
       
   654     "set superclass - required class protocol"
       
   655 
       
   656     superclass := something.
       
   657 
       
   658     "Created: 13.5.1996 / 21:19:23 / cg"
       
   659 ! !
       
   660 
       
   661 !Structure methodsFor:'stubs'!
       
   662 
       
   663 doesNotUnderstand:aMessage
       
   664     "catch unimplemented messages - pass some to the superclass"
       
   665 
       
   666     |sel args names sz s|
       
   667 
       
   668     "/ instance protocol
       
   669 
       
   670     sel := aMessage selector.
       
   671     args := aMessage arguments.
       
   672 
       
   673     sel == #displayString ifTrue:[
       
   674          ^ super displayString
       
   675     ].
       
   676 
       
   677     sel == #printString ifTrue:[
       
   678          ^ super printString
       
   679     ].
       
   680 
       
   681     sel == #printOn: ifTrue:[
       
   682        s := args at:1.
       
   683        s nextPutAll:'Structure('.
       
   684         names := self allInstVarNames.
       
   685         names keysAndValuesDo:[:idx :nm |
       
   686             s nextPutAll:nm; nextPutAll:'->'.
       
   687             s nextPutAll:(self at:idx) displayString.
       
   688             s space
       
   689         ].
       
   690         s nextPutAll:')'.
       
   691         ^ self
       
   692     ].
       
   693 
       
   694     sel == #basicInspect ifTrue:[
       
   695         ^ InspectorView openOn:self
       
   696     ].
       
   697 
       
   698     sel == #inspect ifTrue:[
       
   699         ^ InspectorView openOn:self
       
   700     ].
       
   701 
       
   702     sel == #instVarAt: ifTrue:[
       
   703         |nr|
       
   704 
       
   705         nr := args at:1.
       
   706         nr == 1 ifTrue:[^ i1].
       
   707         nr == 2 ifTrue:[^ i2].
       
   708         nr == 3 ifTrue:[^ i3].
       
   709         nr == 4 ifTrue:[^ i4].
       
   710         nr == 5 ifTrue:[^ i5].
       
   711         nr == 6 ifTrue:[^ i6].
       
   712         ^ nil
       
   713     ].
       
   714 
       
   715     (sel == #size
       
   716     or:[sel == #basicSize]) ifTrue:[
       
   717          ^ super basicSize
       
   718     ].
       
   719 
       
   720     (sel == #at:
       
   721     or:[sel == #basicAt:]) ifTrue:[
       
   722          ^ super basicAt:(args at:1)
       
   723     ].
       
   724 
       
   725     (sel == #at:put:
       
   726     or:[sel == #basicAt:put:]) ifTrue:[
       
   727          ^ super basicAt:(args at:1) put:(args at:2)
       
   728     ].
       
   729 
       
   730     sel == #== ifTrue:[
       
   731          ^ self == (args at:1)
       
   732     ].
       
   733 
       
   734     "/ class protocol
       
   735 
       
   736     (sel := aMessage selector) == #name ifTrue:[
       
   737         ^ 'Structure'
       
   738     ].
       
   739 
       
   740     sel == #instSize ifTrue:[
       
   741         ^ instSize
       
   742     ].
       
   743 
       
   744     sel == #isVariable ifTrue:[
       
   745          ^ false
       
   746     ].
       
   747 
       
   748     sel == #isClass ifTrue:[
       
   749          ^ false
       
   750     ].
       
   751 
       
   752     sel == #isMeta ifTrue:[
       
   753          ^ false
       
   754     ].
       
   755 
       
   756     sel == #isBehavior ifTrue:[
       
   757          ^ false
       
   758     ].
       
   759 
       
   760     sel == #respondsTo: ifTrue:[
       
   761         (args at:1) printNL.
       
   762          ^ false
       
   763     ].
       
   764 
       
   765     sel == #evaluatorClass ifTrue:[
       
   766         ^ Compiler
       
   767     ].
       
   768 
       
   769     sel == #classNameWithArticle ifTrue:[
       
   770          ^ self displayString
       
   771     ].
       
   772 
       
   773     sel == #allSubclasses ifTrue:[
       
   774         ^ #()
       
   775     ].
       
   776 
       
   777     sel == #allClassVarNames ifTrue:[
       
   778         ^ #()
       
   779     ].
       
   780 
       
   781     sel == #allInstVarNames ifTrue:[
       
   782         sz := super basicSize.
       
   783         names := Array new:sz.
       
   784 
       
   785         selectorArray copy with:methodArray copy do:[:sel :mthd|
       
   786             |index|
       
   787             (sel endsWith:$:) ifFalse:[
       
   788                 (sel ~~ #class) ifTrue:[
       
   789                     "/
       
   790                     "/ which method is it ?
       
   791                     "/
       
   792                     (1 to:20) do:[:i |
       
   793                         |mysel|
       
   794 
       
   795                         mysel := ('i' , i printString) asSymbol.
       
   796                         mthd == (Structure compiledMethodAt:mysel) ifTrue:[
       
   797                             index := i
       
   798                         ]
       
   799                     ].
       
   800 
       
   801                     index isNil ifTrue:[
       
   802                         'oops' printNL.
       
   803                         ^ nil
       
   804                     ].
       
   805 
       
   806                     names at:index put:sel.                
       
   807                 ]
       
   808             ]
       
   809         ].
       
   810         "/ must now sort by index ...
       
   811         
       
   812          ^ names
       
   813     ].
       
   814 
       
   815     aMessage printNL.
       
   816     'args ' print. args printNL.
       
   817 
       
   818 ^ nil.
       
   819 
       
   820     "Created: 13.5.1996 / 20:22:22 / cg"
       
   821     "Modified: 13.5.1996 / 21:12:54 / cg"
       
   822 ! !
       
   823 
       
   824 !Structure class methodsFor:'documentation'!
       
   825 
       
   826 version
       
   827     ^ '$Header: /cvs/stx/stx/libcomp/Structure.st,v 1.1 1996-05-24 15:00:36 cg Exp $'
       
   828 ! !
       
   829 
       
   830 Structure initialize!