BlockContext.st
author claus
Thu, 02 Feb 1995 13:23:05 +0100
changeset 216 a8abff749575
parent 165 63341654cfb8
child 241 6f30be88e314
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Context subclass:#BlockContext
       instanceVariableNames:''  "do not add instvars here"
       classVariableNames:''
       poolDictionaries:''
       category:'Kernel-Methods'
!

BlockContext comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.10 1995-02-02 12:20:35 claus Exp $
'!

!BlockContext class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

version
"
$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.10 1995-02-02 12:20:35 claus Exp $
"
!

documentation
"
    BlockContexts represent the stack context objects of blocks. 
    The layout is the same as for other contexts - this class has been added 
    to avoid a flag in an instance variable.
    (has become necessary with cheap blocks, which have no home).

    WARNING: layout and size known by compiler and runtime system - 
	     do not change.
"
! !

!BlockContext methodsFor:'accessing'!

isBlockContext
    "return true, iff the receiver is a BlockContext, false otherwise"

    ^ true
!

methodHome
    "return the method-home for block contexts"

    |con h|

    home isNil ifTrue:[^ nil]. "XXX will change soon"
    home isContext ifFalse:[^ nil]. "copying blocks have no method home"

    con := self.
    h := home.
    [h notNil] whileTrue:[
	con := h.
	h := con home
    ].
    ^ con
!

method
    "return the method in which the current contexts block was created."

    home notNil ifTrue:[^ home method].
    ^ nil
!

home
    "return the immediate home of the receiver.
     normally this is the methodcontext, where the block was created,
     for nested block contexts, this is the surrounding blocks context."

    home isContext ifFalse:[^ nil]. "copying blocks have no home"
    ^ home
!

selector
    "return the selector of the context - which is one of the value
     selectors"

    |nargs|

    nargs := self numArgs.
    (nargs == 0) ifTrue:[^ #value].
    (nargs == 1) ifTrue:[^ #value:].
    (nargs == 2) ifTrue:[^ #value:value:].
    (nargs == 3) ifTrue:[^ #value:value:value:].
    (nargs == 4) ifTrue:[^ #value:value:value:value:].
    (nargs == 5) ifTrue:[^ #value:value:value:value:value:].
    ^ nil
! !

!BlockContext methodsFor:'printing & storing'!

receiverPrintString
    home isNil ifTrue:[
	^ '[] optimized'
    ].
    home isContext ifFalse:[
	"a copying block"

	"receiverClassName := home selfValue class name."
	^ '[] optimized'
    ].

    ^ '[] in ' , receiver class name , '-' , self methodHome selector printString
!

printReceiver
    "print the contexts receiver on the standard output"

    self receiverPrintString print
!
    
printString
    "return a string describing the context" 

    ^ self receiverPrintString , ' ' , self selector printString
! !