ConstNode.st
author Claus Gittinger <cg@exept.de>
Thu, 14 May 1998 19:24:30 +0200
changeset 710 fc74f135494d
parent 612 2748896a66c8
child 711 25b9a501b97d
permissions -rw-r--r--
ignore lineNumber assignment
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
710
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   132
lineNr:ignoredLineNumber
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   133
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   134
    "Created: / 14.5.1998 / 19:24:17 / cg"
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   135
!
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   136
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   137
type:t value:val
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   138
    type := t.
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   139
    value := val
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   140
! !
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   141
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   142
!ConstantNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   143
104
claus
parents: 103
diff changeset
   144
codeOn:aStream inBlock:b for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   145
    "generated code for the constant"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   146
104
claus
parents: 103
diff changeset
   147
    |code index|
96
claus
parents: 62
diff changeset
   148
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   149
    (type == #Integer) ifTrue:[
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   150
	(value between: -128 and:127) ifTrue:[
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   151
	    (value == 0) ifTrue:[
96
claus
parents: 62
diff changeset
   152
		code := #push0
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   153
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   154
	    (value == 1) ifTrue:[
96
claus
parents: 62
diff changeset
   155
		code := #push1.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   156
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   157
	    (value == 2) ifTrue:[
96
claus
parents: 62
diff changeset
   158
		code := #push2.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   159
	    ].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   160
	    (value == -1) ifTrue:[
96
claus
parents: 62
diff changeset
   161
		code := #pushMinus1.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   162
	    ].
96
claus
parents: 62
diff changeset
   163
	    code notNil ifTrue:[
claus
parents: 62
diff changeset
   164
		aStream nextPut:code. ^ self
claus
parents: 62
diff changeset
   165
	    ].
claus
parents: 62
diff changeset
   166
claus
parents: 62
diff changeset
   167
	    aStream nextPut:#pushNum; nextPut:value.
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   168
	    ^ self
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   169
	].
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   170
	(value between:16r-8000 and:16r7FFF) ifTrue:[
96
claus
parents: 62
diff changeset
   171
	    aStream nextPut:#pushNum16; nextPut:value; nextPut:0. 
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   172
	    ^ self
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
   173
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   174
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   175
    (type == #Nil) ifTrue:[
96
claus
parents: 62
diff changeset
   176
	code := #pushNil.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   177
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   178
    (type == #True) ifTrue:[
96
claus
parents: 62
diff changeset
   179
	code := #pushTrue.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   180
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   181
    (type == #False) ifTrue:[
96
claus
parents: 62
diff changeset
   182
	code := #pushFalse.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   183
    ].
96
claus
parents: 62
diff changeset
   184
    code notNil ifTrue:[
claus
parents: 62
diff changeset
   185
	aStream nextPut:code. ^ self
claus
parents: 62
diff changeset
   186
    ].
106
claus
parents: 104
diff changeset
   187
claus
parents: 104
diff changeset
   188
    "/ kludge for backward compatibility
claus
parents: 104
diff changeset
   189
    aCompiler isNil ifTrue:[
claus
parents: 104
diff changeset
   190
	aStream nextPut:#pushLit; nextPut:value.
claus
parents: 104
diff changeset
   191
	^ self.
claus
parents: 104
diff changeset
   192
    ].
claus
parents: 104
diff changeset
   193
104
claus
parents: 103
diff changeset
   194
    index := aCompiler addLiteral:value.
claus
parents: 103
diff changeset
   195
    index <= 8 ifTrue:[
claus
parents: 103
diff changeset
   196
	aStream nextPut:(#(pushLit1 pushLit2 pushLit3 pushLit4
claus
parents: 103
diff changeset
   197
			   pushLit5 pushLit6 pushLit7 pushLit8) at:index).
claus
parents: 103
diff changeset
   198
    ] ifFalse:[
106
claus
parents: 104
diff changeset
   199
	index < 256 ifTrue:[
claus
parents: 104
diff changeset
   200
	    aStream nextPut:#pushLitS; nextPut:index
claus
parents: 104
diff changeset
   201
	] ifFalse:[
claus
parents: 104
diff changeset
   202
	    aStream nextPut:#pushLitL; nextPut:index; nextPut:0
claus
parents: 104
diff changeset
   203
	].
104
claus
parents: 103
diff changeset
   204
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   205
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   206
104
claus
parents: 103
diff changeset
   207
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   208
    "not sent - parser checks for this"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   209
7ad01559b262 Initial revision
claus
parents:
diff changeset
   210
    ^ self error:'assignment to literals not allowed'
7ad01559b262 Initial revision
claus
parents:
diff changeset
   211
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   213
!ConstantNode methodsFor:'enumeration'!
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
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   216
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   217
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   218
    ^ anEnumerator doLiteral:self value:value
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   219
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   220
    "Modified: 19.6.1997 / 16:40:59 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   221
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   222
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   223
!ConstantNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   224
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   225
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   226
    ^ value
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   227
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   228
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   229
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
    "not reached - parser checks for this"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   231
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   232
    self error:'store not allowed'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   233
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   234
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   235
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   236
!ConstantNode methodsFor:'printing'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   237
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   238
displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   239
    "return a printed representation of the receiver for displaying"
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   240
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   241
    ^ value displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   242
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   243
    "Modified: 20.9.1997 / 11:39:07 / cg"
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   244
!
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   245
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   246
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   247
    value storeOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   248
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   249
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   250
!ConstantNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   251
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   252
canReuseAsArg:anotherNode
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   253
    |otherValue|
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   254
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   255
    anotherNode isConstant ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   256
        anotherNode type ~~ type ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   257
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   258
        otherValue := anotherNode evaluate.
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   259
        (value isMemberOf:SmallInteger) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   260
            (value == 0) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   261
            (value == 1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   262
            (value == 2) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   263
            (value == -1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   264
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   265
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   266
        (value isMemberOf:Float) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   267
            ^ (otherValue isMemberOf:Float)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   268
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   269
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   270
        (value isMemberOf:Symbol) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   271
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   272
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   273
        (value isMemberOf:String) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   274
            ^ (otherValue isMemberOf:String)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   275
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   276
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   277
    ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   278
    ^ false
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   279
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   280
    "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
   281
    "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
   282
!
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   283
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   284
isConstant
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   285
    ^ true
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   286
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   287
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   288
!ConstantNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   289
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   290
version
710
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   291
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ConstNode.st,v 1.25 1998-05-14 17:24:30 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   292
! !