ConstNode.st
author Claus Gittinger <cg@exept.de>
Thu, 19 Jun 1997 16:58:23 +0200
changeset 539 69a1cd05c7d6
parent 263 3b21d0991eff
child 612 2748896a66c8
permissions -rw-r--r--
added node-walk facility (ST80 compatibility)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     1
"
4
f6fd83437415 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
     3
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
7ad01559b262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
7ad01559b262 Initial revision
claus
parents:
diff changeset
    13
PrimaryNode subclass:#ConstantNode
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    14
	instanceVariableNames:''
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    15
	classVariableNames:'TrueNode FalseNode NilNode Const0Node Const1Node Float0Node'
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    16
	poolDictionaries:''
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    17
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    18
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    19
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    20
!ConstantNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    21
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    22
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    23
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    25
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    26
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    27
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    28
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    30
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    31
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    32
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    33
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    34
!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    35
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    36
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    37
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    38
    node for parse-trees, representing literal constants
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    39
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    40
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    41
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    43
"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    44
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
    45
7ad01559b262 Initial revision
claus
parents:
diff changeset
    46
!ConstantNode class methodsFor:'instance creation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
7ad01559b262 Initial revision
claus
parents:
diff changeset
    48
type:t value:val
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
    49
    "some constant nodes are used so often, its worth caching them"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    50
    (t == #True) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    51
	TrueNode isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    52
	    TrueNode := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    53
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    54
	^ TrueNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    55
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    56
    (t == #False) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    57
	FalseNode isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    58
	    FalseNode := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    59
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    60
	^ FalseNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    61
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    62
    (t == #Nil) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    63
	NilNode isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    64
	    NilNode := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    65
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    66
	^ NilNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    67
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    68
    (t == #Integer) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    69
	(val == 0) ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    70
	    Const0Node isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    71
		Const0Node := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    72
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    73
	    ^ Const0Node
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    74
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    75
	(val == 1) ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    76
	    Const1Node isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    77
		Const1Node := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    78
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    79
	    ^ Const1Node
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    80
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    81
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    82
    (t == #Float) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    83
	(val = 0.0) ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    84
	    Float0Node isNil ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    85
		Float0Node := (self basicNew) type:t value:val
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    86
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    87
	    ^ Float0Node
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    88
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    89
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    90
    ^ (self basicNew) type:t value:val
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    91
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    92
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    93
value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    94
    ^ self type:(self typeOfConstant:val) value:val 
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    96
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    97
!ConstantNode class methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
typeOfConstant:anObject
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   100
    "return the constantNode type for an object"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   101
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
    "the most common case first ..."
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   103
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   104
    (anObject isMemberOf:SmallInteger) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
	^ #Integer
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   106
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   107
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
    anObject isNil ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   109
	^ #Nil
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   110
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   111
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   112
    anObject isNumber ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   113
	"the most common case first ..."
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   114
	(anObject isMemberOf:Float) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
	    ^ #Float
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
	anObject isInteger ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   118
	    ^ #Integer
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   119
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   120
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   121
    (anObject == true) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   122
	^ #True
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   123
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
    (anObject == false) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   125
	^ #False
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   126
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   127
    ^ #Literal
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   128
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   129
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   130
!ConstantNode methodsFor:'accessing'!
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   131
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   132
type:t value:val
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   133
    type := t.
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   134
    value := val
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   135
! !
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   136
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   137
!ConstantNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   138
104
claus
parents: 103
diff changeset
   139
codeOn:aStream inBlock:b for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   140
    "generated code for the constant"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   141
104
claus
parents: 103
diff changeset
   142
    |code index|
96
claus
parents: 62
diff changeset
   143
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   144
    (type == #Integer) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   145
	(value between: -128 and:127) ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   146
	    (value == 0) ifTrue:[
96
claus
parents: 62
diff changeset
   147
		code := #push0
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   148
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   149
	    (value == 1) ifTrue:[
96
claus
parents: 62
diff changeset
   150
		code := #push1.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   151
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   152
	    (value == 2) ifTrue:[
96
claus
parents: 62
diff changeset
   153
		code := #push2.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   154
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   155
	    (value == -1) ifTrue:[
96
claus
parents: 62
diff changeset
   156
		code := #pushMinus1.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   157
	    ].
96
claus
parents: 62
diff changeset
   158
	    code notNil ifTrue:[
claus
parents: 62
diff changeset
   159
		aStream nextPut:code. ^ self
claus
parents: 62
diff changeset
   160
	    ].
claus
parents: 62
diff changeset
   161
claus
parents: 62
diff changeset
   162
	    aStream nextPut:#pushNum; nextPut:value.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   163
	    ^ self
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   164
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   165
	(value between:16r-8000 and:16r7FFF) ifTrue:[
96
claus
parents: 62
diff changeset
   166
	    aStream nextPut:#pushNum16; nextPut:value; nextPut:0. 
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   167
	    ^ self
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   168
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   169
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   170
    (type == #Nil) ifTrue:[
96
claus
parents: 62
diff changeset
   171
	code := #pushNil.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   172
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   173
    (type == #True) ifTrue:[
96
claus
parents: 62
diff changeset
   174
	code := #pushTrue.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   175
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   176
    (type == #False) ifTrue:[
96
claus
parents: 62
diff changeset
   177
	code := #pushFalse.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   178
    ].
96
claus
parents: 62
diff changeset
   179
    code notNil ifTrue:[
claus
parents: 62
diff changeset
   180
	aStream nextPut:code. ^ self
claus
parents: 62
diff changeset
   181
    ].
106
claus
parents: 104
diff changeset
   182
claus
parents: 104
diff changeset
   183
    "/ kludge for backward compatibility
claus
parents: 104
diff changeset
   184
    aCompiler isNil ifTrue:[
claus
parents: 104
diff changeset
   185
	aStream nextPut:#pushLit; nextPut:value.
claus
parents: 104
diff changeset
   186
	^ self.
claus
parents: 104
diff changeset
   187
    ].
claus
parents: 104
diff changeset
   188
104
claus
parents: 103
diff changeset
   189
    index := aCompiler addLiteral:value.
claus
parents: 103
diff changeset
   190
    index <= 8 ifTrue:[
claus
parents: 103
diff changeset
   191
	aStream nextPut:(#(pushLit1 pushLit2 pushLit3 pushLit4
claus
parents: 103
diff changeset
   192
			   pushLit5 pushLit6 pushLit7 pushLit8) at:index).
claus
parents: 103
diff changeset
   193
    ] ifFalse:[
106
claus
parents: 104
diff changeset
   194
	index < 256 ifTrue:[
claus
parents: 104
diff changeset
   195
	    aStream nextPut:#pushLitS; nextPut:index
claus
parents: 104
diff changeset
   196
	] ifFalse:[
claus
parents: 104
diff changeset
   197
	    aStream nextPut:#pushLitL; nextPut:index; nextPut:0
claus
parents: 104
diff changeset
   198
	].
104
claus
parents: 103
diff changeset
   199
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   200
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   201
104
claus
parents: 103
diff changeset
   202
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   203
    "not sent - parser checks for this"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   204
7ad01559b262 Initial revision
claus
parents:
diff changeset
   205
    ^ self error:'assignment to literals not allowed'
7ad01559b262 Initial revision
claus
parents:
diff changeset
   206
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   207
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   208
!ConstantNode methodsFor:'enumeration'!
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   209
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   210
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   211
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   212
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   213
    ^ anEnumerator doLiteral:self value:value
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   214
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   215
    "Modified: 19.6.1997 / 16:40:59 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   216
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   217
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   218
!ConstantNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   219
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   220
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   221
    ^ value
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   222
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   223
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   224
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   225
    "not reached - parser checks for this"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   226
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   227
    self error:'store not allowed'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   228
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   229
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   231
!ConstantNode methodsFor:'printing'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   232
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   233
displayString
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   234
    ^ value displayString
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   235
!
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   236
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   237
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   238
    value storeOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   239
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   240
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   241
!ConstantNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   242
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   243
canReuseAsArg:anotherNode
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   244
    |otherValue|
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   245
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   246
    anotherNode isConstant ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   247
        anotherNode type ~~ type ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   248
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   249
        otherValue := anotherNode evaluate.
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   250
        (value isMemberOf:SmallInteger) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   251
            (value == 0) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   252
            (value == 1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   253
            (value == 2) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   254
            (value == -1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   255
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   256
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   257
        (value isMemberOf:Float) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   258
            ^ (otherValue isMemberOf:Float)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   259
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   260
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   261
        (value isMemberOf:Symbol) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   262
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   263
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   264
        (value isMemberOf:String) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   265
            ^ (otherValue isMemberOf:String)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   266
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   267
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   268
    ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   269
    ^ false
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   270
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   271
    "Created: 14.4.1996 / 00:43:14 / cg"
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   272
    "Modified: 14.4.1996 / 01:00:29 / cg"
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   273
!
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   274
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   275
isConstant
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   276
    ^ true
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   277
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   278
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   279
!ConstantNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   280
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   281
version
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   282
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ConstNode.st,v 1.23 1997-06-19 14:57:42 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   283
! !