CheapBlock.st
author Claus Gittinger <cg@exept.de>
Tue, 16 Apr 1996 11:27:45 +0200
changeset 1181 6637fee79d7b
parent 920 006dded1f4e6
child 1254 48c2748b5197
permissions -rw-r--r--
only Block & CheapBlock are fixed - subclasses may look different
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     1
"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     3
	      All Rights Reserved
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     4
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    11
"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    12
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    13
Block subclass:#CheapBlock
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    14
	instanceVariableNames:'selfValue method'
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    15
	classVariableNames:''
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    16
	poolDictionaries:''
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    17
	category:'Kernel-Methods'
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    18
!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    19
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    20
!CheapBlock class methodsFor:'documentation'!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    21
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    22
copyright
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    23
"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    25
	      All Rights Reserved
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    26
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    27
 This software is furnished under a license and may be used
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    32
 hereby transferred.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    33
"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    34
!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    35
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    36
documentation
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    37
"
222
85fee82884dd commenting
claus
parents: 213
diff changeset
    38
    CheapBlocks are blocks which do not need their home-context
85fee82884dd commenting
claus
parents: 213
diff changeset
    39
    (i.e. blocks that do not access any method arguments or method locals).
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    40
    Since they have no reference to the home, they must store their
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    41
    creating method explicitely - otherwise, the system had no chance of
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    42
    finding the source-position of the block.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    43
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    44
    Instance variables:
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    45
222
85fee82884dd commenting
claus
parents: 213
diff changeset
    46
      selfValue   <Object>          value to use for self if its a copying block
85fee82884dd commenting
claus
parents: 213
diff changeset
    47
85fee82884dd commenting
claus
parents: 213
diff changeset
    48
      method      <Method>          method where block was created 
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    49
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    50
    NOTICE: layout known by runtime system and compiler - do not change
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    51
"
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    52
! !
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    53
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    54
!CheapBlock class methodsFor:'queries'!
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    55
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    56
isBuiltInClass
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    57
    "this class is known by the run-time-system"
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    58
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    59
    ^ self == CheapBlock
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    60
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    61
    "Created: 16.4.1996 / 11:25:23 / cg"
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    62
! !
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    63
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    64
!CheapBlock methodsFor:'accessing'!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    65
161
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    66
method
213
3b56a17534fd *** empty log message ***
claus
parents: 161
diff changeset
    67
    "return the receivers home method.
161
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    68
     Thats the method where the block was created."
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    69
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    70
    ^ method
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    71
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    72
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    73
selfValue
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    74
    "return the copied self"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    75
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    76
    ^ selfValue
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    77
! !
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    78
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    79
!CheapBlock methodsFor:'printing & storing'!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    80
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    81
printOn:aStream
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    82
    "append a a printed representation of the block to aStream"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    83
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    84
    |class selector pair|
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    85
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    86
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    87
     cheap blocks have no home context, but a method instead
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    88
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    89
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    90
    aStream nextPutAll:'[] in '.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    91
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    92
     find out, for which class this method was for ...
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    93
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    94
    method notNil ifTrue:[
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    95
	pair := method who.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    96
	pair notNil ifTrue:[
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    97
	    class := pair at:1.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    98
	    selector := pair at:2.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    99
	    aStream nextPutAll:(class name , '-' , selector).
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   100
	    aStream nextPutAll:' (optimized)'.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   101
	    ^ self
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   102
	].
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   103
    ].
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   104
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   105
     currently, some cheap blocks don't know where they have been created
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   106
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   107
    aStream nextPutAll:' ??? (optimized)'.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   108
    ^ self
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   109
! !
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   110
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   111
!CheapBlock class methodsFor:'documentation'!
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   112
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   113
version
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   114
    ^ '$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.11 1996-04-16 09:27:45 cg Exp $'
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   115
! !