ConstantNode.st
changeset 98 ccc7f9389a8e
parent 96 ae3b3d960476
child 102 77e4d1119ff2
equal deleted inserted replaced
97:3b0d380771e9 98:ccc7f9389a8e
    20 
    20 
    21 ConstantNode comment:'
    21 ConstantNode comment:'
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    23 	      All Rights Reserved
    23 	      All Rights Reserved
    24 
    24 
    25 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.11 1995-06-27 02:17:11 claus Exp $
    25 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.12 1995-07-23 02:23:30 claus Exp $
    26 '!
    26 '!
    27 
    27 
    28 !ConstantNode class methodsFor:'documentation'!
    28 !ConstantNode class methodsFor:'documentation'!
    29 
    29 
    30 copyright
    30 copyright
    41 "
    41 "
    42 !
    42 !
    43 
    43 
    44 version
    44 version
    45 "
    45 "
    46 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.11 1995-06-27 02:17:11 claus Exp $
    46 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.12 1995-07-23 02:23:30 claus Exp $
    47 "
    47 "
    48 !
    48 !
    49 
    49 
    50 documentation
    50 documentation
    51 "
    51 "
    60 
    60 
    61     "the most common case first ..."
    61     "the most common case first ..."
    62 
    62 
    63     (anObject isMemberOf:SmallInteger) ifTrue:[
    63     (anObject isMemberOf:SmallInteger) ifTrue:[
    64 	^ #Integer
    64 	^ #Integer
       
    65     ].
       
    66 
       
    67     anObject isNil ifTrue:[
       
    68 	^ #Nil
    65     ].
    69     ].
    66 
    70 
    67     anObject isNumber ifTrue:[
    71     anObject isNumber ifTrue:[
    68 	"the most common case first ..."
    72 	"the most common case first ..."
    69 	(anObject isMemberOf:Float) ifTrue:[
    73 	(anObject isMemberOf:Float) ifTrue:[
    71 	].
    75 	].
    72 	anObject isInteger ifTrue:[
    76 	anObject isInteger ifTrue:[
    73 	    ^ #Integer
    77 	    ^ #Integer
    74 	].
    78 	].
    75     ].
    79     ].
    76     anObject isNil ifTrue:[
       
    77 	^ #Nil
       
    78     ].
       
    79     (anObject == true) ifTrue:[
    80     (anObject == true) ifTrue:[
    80 	^ #True
    81 	^ #True
    81     ].
    82     ].
    82     (anObject == false) ifTrue:[
    83     (anObject == false) ifTrue:[
    83 	^ #False
    84 	^ #False
    84     ].
    85     ].
    85     ^ #Literal
    86     ^ #Literal
    86 ! !
    87 ! !
    87 
    88 
    88 !ConstantNode class methodsFor:'instance creation'!
    89 !ConstantNode class methodsFor:'instance creation'!
       
    90 
       
    91 value:val
       
    92     ^ self type:(self typeOfConstant:val) value:val 
       
    93 !
    89 
    94 
    90 type:t value:val
    95 type:t value:val
    91     "some constant nodes are used so often, its worth caching them"
    96     "some constant nodes are used so often, its worth caching them"
    92     (t == #True) ifTrue:[
    97     (t == #True) ifTrue:[
    93 	TrueNode isNil ifTrue:[
    98 	TrueNode isNil ifTrue:[