VarNode.st
author Claus Gittinger <cg@exept.de>
Sat, 12 Oct 1996 19:58:07 +0200
changeset 356 bb3beb18de1f
parent 355 f3ecff58fb62
child 360 9b26a5a4da70
permissions -rw-r--r--
6empty slots in GLOBL/CLASSVAR bytecodes removed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     1
"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
     3
	      All Rights Reserved
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     4
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    11
"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    12
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    13
PrimaryNode subclass:#VariableNode
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    14
	instanceVariableNames:'name token selfValue selfClass index block'
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    15
	classVariableNames:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    16
	poolDictionaries:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    17
	category:'System-Compiler-Support'
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    18
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    19
355
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    20
!VariableNode  class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    21
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    22
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    23
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
    25
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    26
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    27
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    28
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    30
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    31
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    32
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    33
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    34
!
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    35
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    36
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    37
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    38
    node for parse-trees, representing variables
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 243
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: 14
diff changeset
    43
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    44
! !
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    45
355
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    46
!VariableNode  class methodsFor:'instance creation'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    47
98
claus
parents: 53
diff changeset
    48
type:t class:class name:n
claus
parents: 53
diff changeset
    49
    ^ (self basicNew) type:t class:class name:n
claus
parents: 53
diff changeset
    50
!
claus
parents: 53
diff changeset
    51
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    52
type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    53
    ^ (self basicNew) type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    54
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    55
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
    ^ (self basicNew) type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    58
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    59
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    60
type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
    ^ (self basicNew) type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    62
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    63
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    64
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    65
    ^ (self basicNew) type:t name:n index:i selfValue:s
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    66
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    67
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    68
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    69
    ^ (self basicNew) type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    70
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    71
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    72
type:t name:n token:tok index:i block:b
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    73
    ^ (self basicNew) type:t name:n token:tok index:i block:b
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    74
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    75
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    76
type:t name:n value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    77
    ^ (self basicNew) type:t name:n value:val
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    78
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    79
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    80
type:t token:tok
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    81
    ^ (self basicNew) type:t token:tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    82
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    83
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    84
type:t token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    85
    ^ (self basicNew) type:t token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    86
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    87
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    88
type:t token:tok index:i block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    89
    ^ (self basicNew) type:t token:tok index:i block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    90
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    91
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    92
!VariableNode methodsFor:'accessing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    93
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    94
index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
    ^ index
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    96
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    97
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
    ^ name
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   100
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   101
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
type:t class:class name:n
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   103
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   104
    value := nil.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
    name := n.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   106
    selfClass := class 
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   107
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   108
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   109
type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   110
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   111
    value := nil.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   112
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   113
    selfValue := s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   114
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   115
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
type:t name:n
98
claus
parents: 53
diff changeset
   117
    type := t.
claus
parents: 53
diff changeset
   118
    value := nil.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   119
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   120
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   121
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   122
type:t name:n index:i selfClass:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   123
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   124
    value := nil.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   125
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   126
    selfClass := s.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   127
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   128
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   129
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   130
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
    value := nil.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   134
    selfValue := s.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   135
    name := n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   136
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   137
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   138
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   139
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   140
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   141
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   142
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   143
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   144
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   145
type:t name:n token:tok index:i block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   146
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   147
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   148
    block := b.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   149
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   150
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   151
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   152
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
type:t name:n value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
    name := n.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   156
    value := val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   158
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   159
type:t token:tok
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   161
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   162
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   163
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   164
type:t token:tok index:i
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   165
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   166
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   167
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   168
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   169
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   170
type:t token:tok index:i block:b
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   171
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   172
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   173
    block := b.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   174
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   175
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   176
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   177
!VariableNode methodsFor:'code generation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   178
104
claus
parents: 103
diff changeset
   179
codeForSideEffectOn:aStream inBlock:b for:aCompiler
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   180
    "no code at all"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   181
    ^ self
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   182
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   183
104
claus
parents: 103
diff changeset
   184
codeOn:aStream inBlock:codeBlock for:aCompiler
117
claus
parents: 106
diff changeset
   185
    |theCode b deltaLevel litIndex|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   186
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   187
    (type == #MethodArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   188
        (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   189
            aStream nextPut:(#(pushMethodArg1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   190
                               pushMethodArg2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   191
                               pushMethodArg3 
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   192
                               pushMethodArg4) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   193
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   194
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   195
        aStream nextPut:#pushMethodArg; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   196
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   197
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   198
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   199
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   200
            aStream nextPut:(#(pushMethodVar1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   201
                               pushMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   202
                               pushMethodVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   203
                               pushMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   204
                               pushMethodVar5
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   205
                               pushMethodVar6) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   206
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   207
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   208
        aStream nextPut:#pushMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   209
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   210
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   211
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   212
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   213
            theCode := #(pushInstVar1 pushInstVar2 pushInstVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   214
                         pushInstVar4 pushInstVar5 pushInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   215
                         pushInstVar7 pushInstVar8 pushInstVar9
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   216
                         pushInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   217
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   218
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   219
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   220
        aStream nextPut:#pushInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   221
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   222
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   223
    (type == #BlockArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   224
        "find deltaLevel to block, where argument was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   225
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   226
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   227
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   228
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   229
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   230
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   231
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   232
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   233
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   234
            (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   235
                theCode := #(pushBlockArg1 pushBlockArg2 pushBlockArg3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   236
                             pushBlockArg4) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   237
                aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   238
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   239
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   240
            aStream nextPut:#pushBlockArg.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   241
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   242
            (deltaLevel == 1) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   243
                aStream nextPut:#pushOuter1BlockArg
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   244
            ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   245
                (deltaLevel == 2) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   246
                    aStream nextPut:#pushOuter2BlockArg
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   247
                ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   248
                    aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   249
                ]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   250
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   251
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   252
        aStream nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   253
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   254
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   255
    (type == #GlobalVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   256
        litIndex := aCompiler addLiteral:name asSymbol.
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   257
        (aCompiler isSpecialGlobalSymbol:name) ifTrue:[
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   258
            aStream nextPut:#pushSpecialGlobal; nextPut:(aCompiler specialGlobalCodeFor:name).
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   259
            ^ self
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   260
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   261
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   262
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   263
            aStream nextPut:#pushGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   264
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   265
            aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   266
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   267
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   268
    ].
355
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   269
    ((type == #ClassVariable) 
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   270
    or:[type == #PrivateClass]) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   271
        litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   272
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   273
            aStream nextPut:#pushClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   274
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   275
            aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   276
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   277
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   278
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   279
    (type == #BlockVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   280
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   281
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   282
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   283
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   284
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   285
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   286
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   287
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   288
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   289
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   290
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   291
            index <= 3 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   292
                aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   293
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   294
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   295
            aStream nextPut:#pushBlockVar.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   296
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   297
            aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   298
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   299
        aStream nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   300
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   301
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   302
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   303
        aStream nextPut:#pushClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   304
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   305
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   306
    (type == #ThisContext) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   307
        aStream nextPut:#pushThisContext. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   308
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   309
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   310
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   311
    self halt:'bad type'.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   312
355
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   313
    "Modified: 11.10.1996 / 19:17:06 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   314
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   315
104
claus
parents: 103
diff changeset
   316
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
117
claus
parents: 106
diff changeset
   317
    |theCode b deltaLevel litIndex|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   318
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   319
    valueNeeded ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   320
        aStream nextPut:#dup
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   321
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   322
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   323
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   324
            theCode := #(storeMethodVar1 storeMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   325
                         storeMethodVar3 storeMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   326
                         storeMethodVar5 storeMethodVar6) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   327
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   328
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   329
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   330
        aStream nextPut:#storeMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   331
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   332
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   333
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   334
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   335
            theCode := #(storeInstVar1 storeInstVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   336
                         storeInstVar3 storeInstVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   337
                         storeInstVar5 storeInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   338
                         storeInstVar7 storeInstVar8
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   339
                         storeInstVar9 storeInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   340
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   341
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   342
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   343
        aStream nextPut:#storeInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   344
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   345
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   346
    (type == #BlockVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   347
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   348
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   349
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   350
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   351
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   352
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   353
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   354
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   355
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   356
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   357
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   358
            index <= 3 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   359
                aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   360
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   361
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   362
            aStream nextPut:#storeBlockVar
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   363
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   364
            aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   365
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   366
        aStream nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   367
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   368
    ].
117
claus
parents: 106
diff changeset
   369
    (type == #GlobalVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   370
        litIndex := aCompiler addLiteral:name asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   371
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   372
            aStream nextPut:#storeGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   373
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   374
            aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   375
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   376
        ^ self
117
claus
parents: 106
diff changeset
   377
    ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   378
    (type == #ClassVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   379
        litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   380
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   381
            aStream nextPut:#storeClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   382
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   383
            aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   384
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   385
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   386
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   387
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   388
        aStream nextPut:#storeClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   389
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   390
    ].
106
claus
parents: 104
diff changeset
   391
    "not reached"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   392
    ^ self error:'bad assignment'
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   393
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   394
    "Modified: 29.2.1996 / 23:54:38 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   395
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   396
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   397
!VariableNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   398
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   399
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   400
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   401
    or:[type == #BlockArg
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   402
    or:[type == #BlockVariable]]) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   403
	^ token variableValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   404
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   405
    (type == #InstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   406
	^ selfValue instVarAt:index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   407
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   408
    (type == #GlobalVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   409
	(Smalltalk includesKey:name) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   410
	    ^ Smalltalk at:name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   411
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   412
"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   413
	self error:('global ' , name , ' is undefined').
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   414
"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   415
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   416
	^ UndefinedVariable name:name.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   417
	^ nil
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   418
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   419
    (type == #ClassVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   420
	^ Smalltalk at:(selfClass name , ':' , name) asSymbol
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   421
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   422
    (type == #ClassInstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   423
	^ selfClass instVarAt:index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   424
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   425
    (type == #ThisContext) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   426
	^ thisContext
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   427
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   428
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   429
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   430
    ^ value
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   431
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   432
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   433
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   434
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   435
    or:[type == #BlockVariable]) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   436
	token value:aValue. ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   437
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   438
    (type == #InstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   439
	^ selfValue instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   440
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   441
    (type == #GlobalVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   442
	^ Smalltalk at:name put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   443
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   444
    (type == #ClassVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   445
	^ Smalltalk at:(selfClass name , ':' , name) asSymbol put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   446
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   447
    (type == #ClassInstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   448
	^ selfClass instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   449
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   450
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   451
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   452
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   453
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   454
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   455
!VariableNode methodsFor:'printing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   456
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   457
displayString
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   458
    ^ 'InterpreterVariable(' , self printString , ')'
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   459
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   460
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   461
printOn:aStream indent:i
98
claus
parents: 53
diff changeset
   462
claus
parents: 53
diff changeset
   463
    (type == #MethodArg              "/ actually only a debug-check
claus
parents: 53
diff changeset
   464
    or:[type == #MethodVariable
claus
parents: 53
diff changeset
   465
    or:[type == #InstanceVariable
claus
parents: 53
diff changeset
   466
    or:[type == #BlockArg
claus
parents: 53
diff changeset
   467
    or:[type == #GlobalVariable
claus
parents: 53
diff changeset
   468
    or:[type == #ClassVariable
claus
parents: 53
diff changeset
   469
    or:[type == #BlockVariable
claus
parents: 53
diff changeset
   470
    or:[type == #ClassInstanceVariable]]]]]]]) ifTrue:[
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
   471
	aStream nextPutAll:name. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   472
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   473
    (type == #ThisContext) ifTrue:[
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
   474
	aStream nextPutAll:'thisContext'. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   475
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   476
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   477
    self halt:'bad type'.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   478
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   479
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   480
!VariableNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   481
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   482
canReuseAsArg:anotherNode
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   483
    anotherNode isVariable ifTrue:[
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   484
        anotherNode type ~~ type ifTrue:[^ false].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   485
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   486
        (type == #ThisContext) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   487
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   488
        index notNil ifTrue:[
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   489
            anotherNode index ~~ index ifTrue:[^ false].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   490
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   491
        (type == #MethodArg) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   492
        (type == #MethodVariable) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   493
        (type == #InstanceVariable) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   494
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   495
        name notNil ifTrue:[
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   496
            anotherNode name ~~ name ifTrue:[^ false].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   497
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   498
        (type == #GlobalVariable) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   499
        (type == #ClassVariable) ifTrue:[^ true].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   500
    ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   501
    ^ false
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   502
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   503
    "Created: 14.4.1996 / 00:46:18 / cg"
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   504
    "Modified: 14.4.1996 / 00:55:25 / cg"
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   505
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   506
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   507
isGlobal
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   508
    "return true, if this is a node for a global variable"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   509
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   510
    ^ (type == #GlobalVariable) and:[Smalltalk includesKey:name]
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   511
!
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   512
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   513
isLocal
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   514
    "return true, if this is a node for a local (block or method) variable"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   515
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   516
    ^ (type == #MethodVariable) or:[type == #BlockVariable]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   517
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   518
    "Created: 1.3.1996 / 00:03:53 / cg"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   519
    "Modified: 1.3.1996 / 00:04:46 / cg"
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   520
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   521
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   522
isVariable
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   523
    "return true, if this is a node for a variable"
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   524
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   525
    ^ true
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   526
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   527
    "Created: 14.4.1996 / 00:46:32 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   528
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   529
355
f3ecff58fb62 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   530
!VariableNode  class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   531
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   532
version
356
bb3beb18de1f 6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   533
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.21 1996-10-12 17:58:07 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   534
! !