CheapBlock.st
author Claus Gittinger <cg@exept.de>
Mon, 22 Apr 1996 16:38:21 +0200
changeset 1254 48c2748b5197
parent 1181 6637fee79d7b
child 1264 8d916aa63bce
permissions -rw-r--r--
commentary
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
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    39
    (i.e. blocks that do not access any method arguments 
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    40
     or method locals).
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    41
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    42
    CheapBlocks are never created explicitely; the only creation
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    43
    is done by the compilers, when some sourceCode is compiled to either
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    44
    machine or byteCode.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    45
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    46
    Since they have no reference to the home, they must store their
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    47
    creating method explicitely - otherwise, the system had no 
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    48
    chance of finding the source-position of the block.
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    49
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    50
    Instance variables:
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    51
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    52
      selfValue   <Object>          copied self value
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
    53
                                    (if its a copying block)
222
85fee82884dd commenting
claus
parents: 213
diff changeset
    54
85fee82884dd commenting
claus
parents: 213
diff changeset
    55
      method      <Method>          method where block was created 
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    56
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    57
    NOTICE: layout known by runtime system and compiler - do not change
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    58
"
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    59
! !
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
!CheapBlock class methodsFor:'queries'!
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    62
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    63
isBuiltInClass
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    64
    "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
    65
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    66
    ^ self == CheapBlock
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    67
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
    68
    "Created: 16.4.1996 / 11:25:23 / cg"
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    69
! !
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    70
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    71
!CheapBlock methodsFor:'accessing'!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    72
161
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    73
method
213
3b56a17534fd *** empty log message ***
claus
parents: 161
diff changeset
    74
    "return the receivers home method.
161
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    75
     Thats the method where the block was created."
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    76
ed36169f354d *** empty log message ***
claus
parents: 156
diff changeset
    77
    ^ method
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    78
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    79
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    80
selfValue
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    81
    "return the copied self"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    82
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    83
    ^ selfValue
156
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    84
! !
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    85
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    86
!CheapBlock methodsFor:'printing & storing'!
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    87
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    88
printOn:aStream
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    89
    "append a a printed representation of the block to aStream"
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    90
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    91
    |class selector pair|
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    92
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    93
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    94
     cheap blocks have no home context, but a method instead
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    95
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    96
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    97
    aStream nextPutAll:'[] in '.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    98
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
    99
     find out, for which class this method was for ...
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   100
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   101
    method notNil ifTrue:[
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   102
	pair := method who.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   103
	pair notNil ifTrue:[
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   104
	    class := pair at:1.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   105
	    selector := pair at:2.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   106
	    aStream nextPutAll:(class name , '-' , selector).
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
	].
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   110
    ].
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   111
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   112
     currently, some cheap blocks don't know where they have been created
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   113
    "
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   114
    aStream nextPutAll:' ??? (optimized)'.
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   115
    ^ self
f03b8fb5e778 Initial revision
claus
parents:
diff changeset
   116
! !
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   117
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   118
!CheapBlock class methodsFor:'documentation'!
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   119
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   120
version
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1181
diff changeset
   121
    ^ '$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.12 1996-04-22 14:38:21 cg Exp $'
1181
6637fee79d7b only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 920
diff changeset
   122
! !