ConstantNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 09 Jul 2011 22:09:55 +0200
changeset 2547 55ec27b3306c
parent 2500 3178ecc11a5e
child 2566 a39e9ce2610f
permissions -rw-r--r--
ParserErrorNode now inherits from ParseNode
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
"
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    12
"{ Package: 'stx:libcomp' }"
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    14
PrimaryNode subclass:#ConstantNode
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    15
	instanceVariableNames:''
2500
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
    16
	classVariableNames:'TrueNode FalseNode NilNode Const0Node Const1Node Float0Node
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
    17
		endLineNr endCharIndex'
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    18
	poolDictionaries:''
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    19
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    20
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    22
!ConstantNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    23
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    24
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    25
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
47
f861ad42703e *** empty log message ***
claus
parents: 33
diff changeset
    27
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    29
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    30
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    33
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    34
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    35
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    36
!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    37
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    38
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    40
    node for parse-trees, representing literal constants
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
    41
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    44
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    45
"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    46
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
7ad01559b262 Initial revision
claus
parents:
diff changeset
    48
!ConstantNode class methodsFor:'instance creation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    49
7ad01559b262 Initial revision
claus
parents:
diff changeset
    50
type:t value:val
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
    51
    "some constant nodes are used so often, its worth caching them"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    52
    (t == #True) ifTrue:[
1348
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    53
        TrueNode isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    54
            TrueNode := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    55
        ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    56
        ^ TrueNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    57
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    58
    (t == #False) ifTrue:[
1348
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    59
        FalseNode isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    60
            FalseNode := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    61
        ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    62
        ^ FalseNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    63
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    64
    (t == #Nil) ifTrue:[
1348
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    65
        NilNode isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    66
            NilNode := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    67
        ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    68
        ^ NilNode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    69
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    70
    (t == #Integer) ifTrue:[
1348
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    71
        (val == 0) ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    72
            Const0Node isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    73
                Const0Node := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    74
            ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    75
            ^ Const0Node
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    76
        ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    77
        (val == 1) ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    78
            Const1Node isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    79
                Const1Node := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    80
            ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    81
            ^ Const1Node
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    82
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    83
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    84
    (t == #Float) ifTrue:[
1348
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    85
        (val = 0.0) ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    86
            "/ care for negative0 (which compares = to 0.0)
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    87
            val isNegativeZero ifFalse:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    88
                Float0Node isNil ifTrue:[
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    89
                    Float0Node := (self basicNew) type:t value:val
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    90
                ].
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    91
                ^ Float0Node
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    92
            ]
d7cc3ebd5312 do not reuse node for -0.0
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    93
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    94
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
    95
    ^ (self basicNew) type:t value:val
140
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
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
    ^ self type:(self typeOfConstant:val) value:val 
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   100
! !
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
!ConstantNode class methodsFor:'queries'!
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
typeOfConstant:anObject
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
    "return the constantNode type for an object"
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
    "the most common case first ..."
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   109
    (anObject isMemberOf:SmallInteger) ifTrue:[
1381
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   110
        ^ #Integer
140
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
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   113
    anObject isNil ifTrue:[
1381
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   114
        ^ #Nil
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
    ].
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 isNumber ifTrue:[
1381
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   118
        "the most common case first ..."
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   119
        (anObject isMemberOf:Float) ifTrue:[
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   120
            ^ #Float
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   121
        ].
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   122
        anObject isInteger ifTrue:[
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   123
            ^ #Integer
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   124
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   125
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   126
    (anObject == true) ifTrue:[
1381
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   127
        ^ #True
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   128
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
    (anObject == false) ifTrue:[
1381
695fa03a5795 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1348
diff changeset
   130
        ^ #False
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
    ^ #Literal
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   133
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   134
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   135
!ConstantNode methodsFor:'accessing'!
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   136
2500
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   137
endCharIndex
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   138
^endCharIndex.
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   139
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   140
    "Created: / 23-02-2011 / 20:57:13 / Jakub <zelenja7@fel.cvut.cz>"
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   141
!
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   142
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   143
endCharIndex:val
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   144
endCharIndex:=val.
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   145
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   146
    "Created: / 23-02-2011 / 20:57:23 / Jakub <zelenja7@fel.cvut.cz>"
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   147
!
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   148
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   149
endLineNr
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   150
^endLineNr.
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   151
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   152
    "Created: / 23-02-2011 / 20:53:25 / Jakub <zelenja7@fel.cvut.cz>"
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   153
!
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   154
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   155
endLineNr:val 
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   156
    endLineNr := val.
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   157
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   158
    "Created: / 23-02-2011 / 20:53:47 / Jakub <zelenja7@fel.cvut.cz>"
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   159
!
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   160
711
25b9a501b97d lineNr -> lineNumber
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   161
lineNumber:ignoredLineNumber
710
fc74f135494d ignore lineNumber assignment
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   162
711
25b9a501b97d lineNr -> lineNumber
Claus Gittinger <cg@exept.de>
parents: 710
diff changeset
   163
    "Created: / 14.5.1998 / 19:31:48 / cg"
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   164
! !
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   165
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   166
!ConstantNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   167
1560
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   168
codeForSideEffectOn:aStream inBlock:b for:aCompiler
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   169
    "no code at all"
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   170
1995
dad0adb22a38 comment
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   171
    "/ but remember symbolic literals (such as #TODO)
1560
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   172
    value isSymbol ifTrue:[
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   173
        aCompiler addLiteral:value.
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   174
    ].
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   175
    ^ self
1995
dad0adb22a38 comment
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   176
dad0adb22a38 comment
Claus Gittinger <cg@exept.de>
parents: 1805
diff changeset
   177
    "Modified: / 04-03-2007 / 15:29:54 / cg"
1560
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   178
!
a3be357f8c4d symbolic literal constants are remeembered,
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
   179
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   180
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   181
    lineNrOrNil notNil ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   182
        self codeLineNumber:lineNrOrNil on:aStream for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   183
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   184
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   185
    (type == #Nil) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   186
        aStream nextPut:#retNil.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   187
        ^self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   188
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   189
    (type == #True) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   190
        aStream nextPut:#retTrue.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   191
        ^self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   192
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   193
    (type == #False) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   194
        aStream nextPut:#retFalse.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   195
        ^self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   196
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   197
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   198
    (type == #Integer) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   199
        (value between: -128 and:127) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   200
            (value == 0) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   201
                aStream nextPut:#ret0.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   202
                ^ self.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   203
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   204
            aStream nextPut:#retNum; nextPut:value.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   205
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   206
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   207
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   208
1401
d9a2949c6229 Fix typos
Stefan Vogel <sv@exept.de>
parents: 1384
diff changeset
   209
    "/ anything else must be pushed, then top returned
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   210
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   211
    self codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   212
    aStream nextPut:#retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   213
!
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   214
104
claus
parents: 103
diff changeset
   215
codeOn:aStream inBlock:b for:aCompiler
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   216
    "generate code for the constant"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   217
104
claus
parents: 103
diff changeset
   218
    |code index|
96
claus
parents: 62
diff changeset
   219
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   220
    (type == #Integer) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   221
        (value between: -128 and:127) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   222
            (value == 0) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   223
                code := #push0
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   224
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   225
            (value == 1) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   226
                code := #push1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   227
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   228
            (value == 2) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   229
                code := #push2.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   230
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   231
            (value == -1) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   232
                code := #pushMinus1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   233
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   234
            code notNil ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   235
                aStream nextPut:code. ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   236
            ].
96
claus
parents: 62
diff changeset
   237
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   238
            aStream nextPut:#pushNum; nextPut:value.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   239
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   240
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   241
        (value between:16r-8000 and:16r7FFF) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   242
            aStream nextPut:#pushNum16; nextPut:value; nextPut:0. 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   243
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   244
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   245
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   246
    (type == #Nil) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   247
        code := #pushNil.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   248
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   249
    (type == #True) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   250
        code := #pushTrue.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   251
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   252
    (type == #False) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   253
        code := #pushFalse.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   254
    ].
96
claus
parents: 62
diff changeset
   255
    code notNil ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   256
        aStream nextPut:code. ^ self
96
claus
parents: 62
diff changeset
   257
    ].
106
claus
parents: 104
diff changeset
   258
claus
parents: 104
diff changeset
   259
    "/ kludge for backward compatibility
claus
parents: 104
diff changeset
   260
    aCompiler isNil ifTrue:[
2118
Claus Gittinger <cg@exept.de>
parents: 1995
diff changeset
   261
        self halt:'strange literal constant'.
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   262
        aStream nextPut:#pushLit; nextPut:value.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   263
        ^ self.
106
claus
parents: 104
diff changeset
   264
    ].
claus
parents: 104
diff changeset
   265
1805
d8f8075615dc some code savers for common code-emit
Claus Gittinger <cg@exept.de>
parents: 1797
diff changeset
   266
    self emitPushLiteral:value on:aStream for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   267
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   268
104
claus
parents: 103
diff changeset
   269
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   270
    "not sent - parser checks for this"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   271
7ad01559b262 Initial revision
claus
parents:
diff changeset
   272
    ^ self error:'assignment to literals not allowed'
7ad01559b262 Initial revision
claus
parents:
diff changeset
   273
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   274
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   275
!ConstantNode methodsFor:'enumerating'!
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   276
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   277
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   278
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   279
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   280
    ^ anEnumerator doLiteral:self value:value
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   281
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   282
    "Modified: 19.6.1997 / 16:40:59 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   283
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   284
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   285
!ConstantNode methodsFor:'evaluation'!
140
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
evaluate
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   288
    "exists for performance only"
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   289
    ^ value
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   290
!
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   291
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   292
evaluateIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   293
    ^ value
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   294
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   295
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   296
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   297
    "not reached - parser checks for this"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   298
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   299
    self error:'store not allowed'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   300
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   301
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   302
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   303
!ConstantNode methodsFor:'printing & storing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   304
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   305
displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   306
    "return a printed representation of the receiver for displaying"
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   307
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   308
    ^ value displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   309
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   310
    "Modified: 20.9.1997 / 11:39:07 / cg"
13
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   311
!
30e69e21d1d1 *** empty log message ***
claus
parents: 10
diff changeset
   312
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   313
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   314
    value storeOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   315
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   316
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   317
!ConstantNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   318
242
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   319
canReuseAsArg:anotherNode
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   320
    |otherValue|
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   321
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   322
    anotherNode isConstant ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   323
        anotherNode type ~~ type ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   324
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   325
        otherValue := anotherNode evaluate.
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   326
        (value isMemberOf:SmallInteger) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   327
            (value == 0) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   328
            (value == 1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   329
            (value == 2) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   330
            (value == -1) ifTrue:[^ false].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   331
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   332
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   333
        (value isMemberOf:Float) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   334
            ^ (otherValue isMemberOf:Float)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   335
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   336
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   337
        (value isMemberOf:Symbol) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   338
            ^ otherValue == value
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   339
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   340
        (value isMemberOf:String) ifTrue:[
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   341
            ^ (otherValue isMemberOf:String)
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   342
              and:[otherValue = value]
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   343
        ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   344
    ].
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   345
    ^ false
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   346
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   347
    "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
   348
    "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
   349
!
3cca9ffd2620 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   350
2266
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   351
withConstantValueDo:aBlock
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   352
    "return true, if this evaluates to a constant value
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   353
     and evaluate aBlock with it"
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   354
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   355
    aBlock value:value.
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   356
    ^ true
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   357
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   358
2320
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   359
!ConstantNode methodsFor:'testing'!
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   360
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   361
isConstant
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   362
    ^ true
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   363
! !
4e58d12c5c1a category change
Claus Gittinger <cg@exept.de>
parents: 2266
diff changeset
   364
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   365
!ConstantNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   366
2500
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   367
version_CVS
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   368
    ^ '$Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.46 2011-06-28 20:00:02 vrany Exp $'
2266
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   369
!
Claus Gittinger <cg@exept.de>
parents: 2118
diff changeset
   370
2500
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   371
version_SVN
3178ecc11a5e Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2320
diff changeset
   372
    ^ ' Id '
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   373
! !