VarNode.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 01:00:17 +0100
changeset 218 748b4c509a51
parent 199 1b3b350a3f59
child 243 cdc1424ddaac
permissions -rw-r--r--
use new BlockVar instructions
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
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    20
!VariableNode class methodsFor:'documentation'!
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
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    40
! !
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    41
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    42
!VariableNode class methodsFor:'instance creation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    43
98
claus
parents: 53
diff changeset
    44
type:t class:class name:n
claus
parents: 53
diff changeset
    45
    ^ (self basicNew) type:t class:class name:n
claus
parents: 53
diff changeset
    46
!
claus
parents: 53
diff changeset
    47
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    48
type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    49
    ^ (self basicNew) type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    50
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    51
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    52
type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    53
    ^ (self basicNew) type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
    ^ (self basicNew) type:t name:n index:i selfClass:s
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 selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
    ^ (self basicNew) type:t name:n index:i selfValue:s
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    62
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    63
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    64
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    65
    ^ (self basicNew) type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    66
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    67
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    68
type:t name:n token:tok index:i block:b
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    69
    ^ (self basicNew) type:t name:n token:tok index:i block:b
14
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 value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    73
    ^ (self basicNew) type:t name:n value:val
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 token:tok
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    77
    ^ (self basicNew) type:t token:tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    78
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    79
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    80
type:t token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    81
    ^ (self basicNew) type:t token:tok index:i
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 block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    85
    ^ (self basicNew) type:t token:tok index:i block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    86
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    87
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    88
!VariableNode methodsFor:'accessing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    89
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    90
index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    91
    ^ index
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    92
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    93
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    94
name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
    ^ name
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
type:t class:class name:n
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    99
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   100
    value := nil.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   101
    name := n.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
    selfClass := class 
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   103
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   104
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   105
type:t index:i selfValue:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   106
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   107
    value := nil.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   108
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   109
    selfValue := s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   110
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   111
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   112
type:t name:n
98
claus
parents: 53
diff changeset
   113
    type := t.
claus
parents: 53
diff changeset
   114
    value := nil.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   115
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   116
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   117
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   118
type:t name:n index:i selfClass:s
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   119
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   120
    value := nil.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   121
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   122
    selfClass := s.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   123
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   124
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   125
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   126
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   127
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   128
    value := nil.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   130
    selfValue := s.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    name := n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   134
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   135
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   136
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   137
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   138
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   139
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   140
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   141
type:t name:n token:tok index:i block:b
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   142
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   143
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   144
    block := b.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   145
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   146
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   147
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   148
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   149
type:t name:n value:val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   150
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   151
    name := n.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   152
    value := val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   153
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   154
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   155
type:t token:tok
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   156
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   157
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   158
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   159
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   160
type:t token:tok index:i
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   161
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   162
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   163
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   164
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   165
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   166
type:t token:tok index:i block:b
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   167
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   168
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   169
    block := b.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   170
    token := tok
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   171
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   172
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   173
!VariableNode methodsFor:'code generation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   174
104
claus
parents: 103
diff changeset
   175
codeForSideEffectOn:aStream inBlock:b for:aCompiler
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   176
    "no code at all"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   177
    ^ self
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   178
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   179
104
claus
parents: 103
diff changeset
   180
codeOn:aStream inBlock:codeBlock for:aCompiler
117
claus
parents: 106
diff changeset
   181
    |theCode b deltaLevel litIndex|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   182
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   183
    (type == #MethodArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   184
        (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   185
            aStream nextPut:(#(pushMethodArg1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   186
                               pushMethodArg2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   187
                               pushMethodArg3 
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   188
                               pushMethodArg4) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   189
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   190
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   191
        aStream nextPut:#pushMethodArg; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   192
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   193
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   194
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   195
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   196
            aStream nextPut:(#(pushMethodVar1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   197
                               pushMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   198
                               pushMethodVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   199
                               pushMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   200
                               pushMethodVar5
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   201
                               pushMethodVar6) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   202
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   203
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   204
        aStream nextPut:#pushMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   205
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   206
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   207
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   208
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   209
            theCode := #(pushInstVar1 pushInstVar2 pushInstVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   210
                         pushInstVar4 pushInstVar5 pushInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   211
                         pushInstVar7 pushInstVar8 pushInstVar9
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   212
                         pushInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   213
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   214
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   215
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   216
        aStream nextPut:#pushInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   217
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   218
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   219
    (type == #BlockArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   220
        "find deltaLevel to block, where argument was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   221
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   222
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   223
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   224
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   225
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   226
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   227
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   228
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   229
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   230
            (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   231
                theCode := #(pushBlockArg1 pushBlockArg2 pushBlockArg3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   232
                             pushBlockArg4) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   233
                aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   234
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   235
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   236
            aStream nextPut:#pushBlockArg.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   237
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   238
            (deltaLevel == 1) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   239
                aStream nextPut:#pushOuter1BlockArg
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   240
            ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   241
                (deltaLevel == 2) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   242
                    aStream nextPut:#pushOuter2BlockArg
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   243
                ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   244
                    aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   245
                ]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   246
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   247
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   248
        aStream nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   249
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   250
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   251
    (type == #GlobalVariable) ifTrue:[
117
claus
parents: 106
diff changeset
   252
"/        aStream nextPut:#pushGlobal; nextPut:name.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   253
        litIndex := aCompiler addLiteral:name asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   254
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   255
            aStream nextPut:#pushGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   256
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   257
            aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   258
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   259
        "slot for generation and cell address (6 byte)"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   260
        aStream next:6 put:0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   261
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   262
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   263
    (type == #ClassVariable) ifTrue:[
117
claus
parents: 106
diff changeset
   264
"/        aStream nextPut:#pushClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   265
        litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   266
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   267
            aStream nextPut:#pushClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   268
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   269
            aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   270
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   271
        "slot for generation and cell address (6 byte)"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   272
        aStream next:6 put:0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   273
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   274
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   275
    (type == #BlockVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   276
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   277
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   278
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   279
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   280
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   281
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   282
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   283
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   284
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   285
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   286
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   287
            index <= 3 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   288
                aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   289
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   290
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   291
            aStream nextPut:#pushBlockVar.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   292
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   293
            aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel.
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:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   296
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   297
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   298
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   299
        aStream nextPut:#pushClassInstVar; 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 == #ThisContext) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   303
        aStream nextPut:#pushThisContext. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   304
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   305
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   306
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   307
    self halt:'bad type'.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   308
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   309
    "Modified: 29.2.1996 / 23:54:18 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   310
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   311
104
claus
parents: 103
diff changeset
   312
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
117
claus
parents: 106
diff changeset
   313
    |theCode b deltaLevel litIndex|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   314
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   315
    valueNeeded ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   316
        aStream nextPut:#dup
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   317
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   318
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   319
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   320
            theCode := #(storeMethodVar1 storeMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   321
                         storeMethodVar3 storeMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   322
                         storeMethodVar5 storeMethodVar6) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   323
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   324
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   325
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   326
        aStream nextPut:#storeMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   327
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   328
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   329
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   330
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   331
            theCode := #(storeInstVar1 storeInstVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   332
                         storeInstVar3 storeInstVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   333
                         storeInstVar5 storeInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   334
                         storeInstVar7 storeInstVar8
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   335
                         storeInstVar9 storeInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   336
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   337
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   338
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   339
        aStream nextPut:#storeInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   340
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   341
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   342
    (type == #BlockVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   343
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   344
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   345
        deltaLevel := 0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   346
        [b notNil and:[b ~~ block]] whileTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   347
            b inlineBlock ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   348
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   349
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   350
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   351
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   352
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   353
        (deltaLevel == 0) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   354
            index <= 3 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   355
                aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   356
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   357
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   358
            aStream nextPut:#storeBlockVar
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   359
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   360
            aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel
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:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   363
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   364
    ].
117
claus
parents: 106
diff changeset
   365
    (type == #GlobalVariable) ifTrue:[
claus
parents: 106
diff changeset
   366
"/        aStream nextPut:#storeGlobal; nextPut:name.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   367
        litIndex := aCompiler addLiteral:name asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   368
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   369
            aStream nextPut:#storeGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   370
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   371
            aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   372
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   373
        "slot for generation and cell address (6 byte)"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   374
        aStream next:6 put:0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   375
        ^ self
117
claus
parents: 106
diff changeset
   376
    ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   377
    (type == #ClassVariable) ifTrue:[
117
claus
parents: 106
diff changeset
   378
"/        aStream nextPut:#storeClassVar; nextPut:(selfClass name , ':' , name) asSymbol.
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
        "slot for generation and cell address (6 byte)"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   386
        aStream next:6 put:0.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   387
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   388
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   389
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   390
        aStream nextPut:#storeClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   391
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   392
    ].
106
claus
parents: 104
diff changeset
   393
    "not reached"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   394
    ^ self error:'bad assignment'
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   395
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   396
    "Modified: 29.2.1996 / 23:54:38 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   397
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   398
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   399
!VariableNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   400
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   401
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   402
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   403
    or:[type == #BlockArg
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   404
    or:[type == #BlockVariable]]) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   405
	^ token variableValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   406
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   407
    (type == #InstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   408
	^ selfValue instVarAt:index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   409
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   410
    (type == #GlobalVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   411
	(Smalltalk includesKey:name) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   412
	    ^ Smalltalk at:name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   413
	].
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
	self error:('global ' , name , ' is undefined').
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   416
"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   417
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   418
	^ UndefinedVariable name:name.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   419
	^ nil
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   420
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   421
    (type == #ClassVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   422
	^ Smalltalk at:(selfClass name , ':' , name) asSymbol
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   423
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   424
    (type == #ClassInstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   425
	^ selfClass instVarAt:index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   426
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   427
    (type == #ThisContext) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   428
	^ thisContext
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   429
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   430
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   431
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   432
    ^ value
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   433
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   434
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   435
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   436
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   437
    or:[type == #BlockVariable]) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   438
	token value:aValue. ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   439
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   440
    (type == #InstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   441
	^ selfValue instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   442
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   443
    (type == #GlobalVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   444
	^ Smalltalk at:name put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   445
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   446
    (type == #ClassVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   447
	^ Smalltalk at:(selfClass name , ':' , name) asSymbol put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   448
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   449
    (type == #ClassInstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   450
	^ selfClass instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   451
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   452
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   453
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   454
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   455
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   456
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   457
!VariableNode methodsFor:'printing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   458
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   459
displayString
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   460
    ^ 'InterpreterVariable(' , self printString , ')'
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   461
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   462
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   463
printOn:aStream indent:i
98
claus
parents: 53
diff changeset
   464
claus
parents: 53
diff changeset
   465
    (type == #MethodArg              "/ actually only a debug-check
claus
parents: 53
diff changeset
   466
    or:[type == #MethodVariable
claus
parents: 53
diff changeset
   467
    or:[type == #InstanceVariable
claus
parents: 53
diff changeset
   468
    or:[type == #BlockArg
claus
parents: 53
diff changeset
   469
    or:[type == #GlobalVariable
claus
parents: 53
diff changeset
   470
    or:[type == #ClassVariable
claus
parents: 53
diff changeset
   471
    or:[type == #BlockVariable
claus
parents: 53
diff changeset
   472
    or:[type == #ClassInstanceVariable]]]]]]]) ifTrue:[
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
   473
	aStream nextPutAll:name. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   474
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   475
    (type == #ThisContext) ifTrue:[
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
   476
	aStream nextPutAll:'thisContext'. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   477
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   478
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   479
    self halt:'bad type'.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   480
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   481
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   482
!VariableNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   483
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   484
isGlobal
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   485
    "return true, if this is a node for a global variable"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   486
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   487
    ^ (type == #GlobalVariable) and:[Smalltalk includesKey:name]
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   488
!
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   489
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   490
isLocal
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   491
    "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
   492
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   493
    ^ (type == #MethodVariable) or:[type == #BlockVariable]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   494
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   495
    "Created: 1.3.1996 / 00:03:53 / cg"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   496
    "Modified: 1.3.1996 / 00:04:46 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   497
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   498
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   499
!VariableNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   500
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   501
version
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   502
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/VarNode.st,v 1.16 1996-03-01 00:00:17 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   503
! !