VariableNode.st
author Claus Gittinger <cg@exept.de>
Sat, 20 Sep 1997 23:03:33 +0200
changeset 612 2748896a66c8
parent 577 efda2402cd70
child 641 e18daf10662c
permissions -rw-r--r--
comments
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
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
    13
'From Smalltalk/X, Version:3.1.10 on 20-sep-1997 at 11:47:04 pm'                !
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
    14
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    15
PrimaryNode subclass:#VariableNode
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    16
	instanceVariableNames:'name token selfValue selfClass index block'
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    17
	classVariableNames:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    18
	poolDictionaries:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    19
	category:'System-Compiler-Support'
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    20
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    21
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
    22
!VariableNode class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    23
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    24
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    25
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    26
 COPYRIGHT (c) 1994 by Claus Gittinger
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
    27
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    29
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    30
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    33
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    34
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    35
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    36
!
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    37
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    38
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    40
    node for parse-trees, representing variables
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    41
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    44
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    45
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    46
! !
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    47
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
    48
!VariableNode class methodsFor:'instance creation'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    49
98
claus
parents: 53
diff changeset
    50
type:t class:class name:n
claus
parents: 53
diff changeset
    51
    ^ (self basicNew) type:t class:class name:n
claus
parents: 53
diff changeset
    52
!
claus
parents: 53
diff changeset
    53
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
    ^ (self basicNew) type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    58
type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    59
    ^ (self basicNew) type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    60
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    62
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    63
    ^ (self basicNew) type:t name:n index:i selfValue:s
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    64
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    65
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    66
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    67
    ^ (self basicNew) type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    68
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    69
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    70
type:t name:n token:tok index:i block:b from:codeBlock
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    71
    ^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    72
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
    73
    "Modified: 2.7.1997 / 10:55:48 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    74
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    75
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    76
!VariableNode methodsFor:'accessing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    77
577
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    78
block
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    79
    ^ block
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    80
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    81
    "Created: 2.7.1997 / 18:53:38 / cg"
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    82
!
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
    83
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    84
index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    85
    ^ index
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    86
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    87
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    88
name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    89
    ^ name
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    90
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    91
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    92
type:t class:class name:n
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    93
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    94
    value := nil.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
    name := n.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    96
    selfClass := class 
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    97
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    98
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
type:t name:n
98
claus
parents: 53
diff changeset
   100
    type := t.
claus
parents: 53
diff changeset
   101
    value := nil.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   102
    name := n
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 name:n index:i selfClass: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
    selfClass := s.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   110
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   111
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   112
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   113
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   114
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   115
    value := nil.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   116
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
    selfValue := s.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   118
    name := n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   119
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   120
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   121
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   122
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   123
    index := i.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   124
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   125
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   126
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   127
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   128
type:t name:n token:tok index:i block:variableBlock from:codeBlock
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   129
    type := t.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   130
    index := i.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   131
    block := variableBlock.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   132
    token := tok.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   133
    name := n.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   134
    (type == #BlockArg) ifTrue:[
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   135
        variableBlock blockArgAccessed:true.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   136
    ].
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   137
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   138
    codeBlock ~~ variableBlock ifTrue:[
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   139
        codeBlock rememberOuterBlockVarAccess:self
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   140
    ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   141
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   142
    "Created: 2.7.1997 / 10:54:50 / cg"
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   143
    "Modified: 2.7.1997 / 11:12:58 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   144
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   145
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   146
type:t token:tok index:i block:b
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   147
    type := t.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   148
    index := i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   149
    block := b.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   150
    token := tok.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   151
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   152
    (type == #BlockArg) ifTrue:[
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   153
        b blockArgAccessed:true.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   154
    ].
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   155
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   156
    "Modified: 18.6.1997 / 11:41:05 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   157
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   158
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   159
!VariableNode methodsFor:'code generation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   160
104
claus
parents: 103
diff changeset
   161
codeForSideEffectOn:aStream inBlock:b for:aCompiler
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   162
    "no code at all"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   163
    ^ self
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   164
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   165
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   166
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   167
    |theCode b deltaLevel litIndex specialGlobalIndex
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   168
     bvIdx bvTyp blocksCode|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   169
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   170
    (type == #MethodArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   171
        (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   172
            aStream nextPut:(#(pushMethodArg1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   173
                               pushMethodArg2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   174
                               pushMethodArg3 
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   175
                               pushMethodArg4) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   176
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   177
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   178
        aStream nextPut:#pushMethodArg; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   179
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   180
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   181
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   182
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   183
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   184
            aStream nextPut:(#(pushMethodVar1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   185
                               pushMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   186
                               pushMethodVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   187
                               pushMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   188
                               pushMethodVar5
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   189
                               pushMethodVar6) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   190
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   191
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   192
        aStream nextPut:#pushMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   193
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   194
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   195
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   196
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   197
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   198
            theCode := #(pushInstVar1 pushInstVar2 pushInstVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   199
                         pushInstVar4 pushInstVar5 pushInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   200
                         pushInstVar7 pushInstVar8 pushInstVar9
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   201
                         pushInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   202
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   203
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   204
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   205
        aStream nextPut:#pushInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   206
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   207
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   208
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   209
    ((type == #BlockArg) 
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   210
    or:[type == #BlockVariable]) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   211
        "/ compiling for codeBlock; accessing variable in block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   212
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   213
        bvIdx := index.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   214
        bvTyp := type.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   215
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   216
        "/ find the context where that variable is contained physically
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   217
        blocksCode := block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   218
        [blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   219
            blocksCode := blocksCode home
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   220
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   221
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   222
        "/ find deltaLevel from code-context to the containing block
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   223
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   224
        deltaLevel := 0.
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   225
        [b notNil and:[b ~~ blocksCode]] whileTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   226
            b isInlineBlock ifFalse:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   227
                deltaLevel := deltaLevel + 1
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
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   230
        ].
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   231
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   232
        b isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   233
            codeBlock isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   234
                "/ a var of a block which is inlined in the method. 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   235
                "/ Generate a pushMVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   236
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   237
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   238
                type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   239
                    bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   240
                ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   241
                ^ self 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   242
                    codeLoadOn:aStream
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   243
                    type:#MethodVariable
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   244
                    index:bvIdx
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   245
                    inBlock:codeBlock
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   246
                    for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   247
            ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   248
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   249
            "/ a var of a block which is inlined in the outer block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   250
            "/ Generate a pushBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   251
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   252
            bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   253
            type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   254
                bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   255
            ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   256
            bvTyp := #BlockVariable.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   257
        ] ifFalse:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   258
            block isInlineBlock ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   259
                "/ a var of a block which is inlined in another block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   260
                "/ Generate a pushBVAR / pushOuterBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   261
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   262
                type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   263
                    bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   264
                ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   265
                bvTyp := #BlockVariable.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   266
            ]
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   267
        ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   268
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   269
        (bvTyp == #BlockVariable) ifTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   270
            (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   271
                bvIdx <= 3 ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   272
                    aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx).
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   273
                    ^ self
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   274
                ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   275
                aStream nextPut:#pushBlockVar.
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   276
            ] ifFalse:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   277
                aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   278
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   279
        ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   280
            (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   281
                (bvIdx <= 4) ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   282
                    aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   283
                                       pushBlockArg4) at:bvIdx).
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   284
                    ^ self
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   285
                ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   286
                aStream nextPut:#pushBlockArg.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   287
            ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   288
                (deltaLevel == 1) ifTrue:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   289
                    aStream nextPut:#pushOuter1BlockArg
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   290
                ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   291
                    (deltaLevel == 2) ifTrue:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   292
                        aStream nextPut:#pushOuter2BlockArg
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   293
                    ] ifFalse:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   294
                        aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   295
                    ]
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   296
                ].
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   297
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   298
        ].
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   299
        aStream nextPut:bvIdx.
218
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
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   302
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   303
    (type == #GlobalVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   304
        litIndex := aCompiler addLiteral:name asSymbol.
531
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   305
        specialGlobalIndex := aCompiler specialGlobalCodeFor:name.
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   306
        specialGlobalIndex notNil ifTrue:[
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   307
            aStream nextPut:#pushSpecialGlobal; nextPut:specialGlobalIndex.
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   308
            ^ self
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   309
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   310
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   311
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   312
            aStream nextPut:#pushGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   313
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   314
            aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   315
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   316
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   317
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   318
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   319
    (type == #ClassVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   320
        litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   321
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   322
            aStream nextPut:#pushClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   323
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   324
            aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
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
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   327
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   328
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   329
    (type == #PrivateClass) ifTrue:[
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   330
        litIndex := aCompiler addLiteral:(selfClass name , '::' , name) asSymbol.
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   331
        litIndex < 256 ifTrue:[
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   332
            aStream nextPut:#pushGlobalS; nextPut:litIndex
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   333
        ] ifFalse:[
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   334
            aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   335
        ].
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   336
        ^ self
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   337
    ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   338
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   339
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   340
        aStream nextPut:#pushClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   341
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   342
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   343
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   344
    (type == #ThisContext) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   345
        aStream nextPut:#pushThisContext. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   346
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   347
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   348
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   349
    self halt:'bad type'.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   350
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   351
    "Created: 25.6.1997 / 16:14:17 / cg"
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   352
    "Modified: 26.6.1997 / 10:15:11 / cg"
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   353
!
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   354
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   355
codeOn:aStream inBlock:codeBlock for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   356
    self
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   357
        codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   358
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   359
    "Modified: 26.6.1997 / 10:06:10 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   360
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   361
104
claus
parents: 103
diff changeset
   362
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   363
    self
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   364
        codeStoreOn:aStream type:type index:index
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   365
        inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   366
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   367
    "Modified: 25.6.1997 / 16:15:28 / cg"
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   368
!
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   369
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   370
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   371
    |theCode b deltaLevel litIndex bvIdx blocksCode|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   372
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   373
    valueNeeded ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   374
        aStream nextPut:#dup
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   375
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   376
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   377
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   378
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   379
            theCode := #(storeMethodVar1 storeMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   380
                         storeMethodVar3 storeMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   381
                         storeMethodVar5 storeMethodVar6) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   382
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   383
            ^ self
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
        aStream nextPut:#storeMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   386
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   387
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   388
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   389
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   390
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   391
            theCode := #(storeInstVar1 storeInstVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   392
                         storeInstVar3 storeInstVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   393
                         storeInstVar5 storeInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   394
                         storeInstVar7 storeInstVar8
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   395
                         storeInstVar9 storeInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   396
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   397
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   398
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   399
        aStream nextPut:#storeInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   400
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   401
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   402
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   403
    (type == #BlockVariable) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   404
        bvIdx := index.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   405
        
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   406
        "/ find the context where that variable is contained physically
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   407
        blocksCode := block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   408
        [blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   409
            blocksCode := blocksCode home
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   410
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   411
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   412
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   413
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   414
        deltaLevel := 0.
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   415
        [b notNil and:[b ~~ blocksCode]] whileTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   416
            b isInlineBlock ifFalse:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   417
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   418
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   419
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   420
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   421
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   422
        b isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   423
            codeBlock isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   424
                "/ a block which is inlined in the method. 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   425
                "/ Generate a pushMVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   426
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   427
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   428
                bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   429
                ^ self
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   430
                    codeStoreOn:aStream 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   431
                    type:#MethodVariable index:bvIdx 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   432
                    inBlock:codeBlock 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   433
                    valueNeeded:false       "/ already dupped if value is needed
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   434
                    for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   435
            ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   436
            "/ a var of a block which is inlined in the outer block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   437
            "/ Generate a pushBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   438
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   439
            bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   440
            bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   441
        ] ifFalse:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   442
            block isInlineBlock ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   443
                "/ a var of a block which is inlined in another block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   444
                "/ Generate a pushBVAR / pushOuterBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   445
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   446
                bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   447
            ]
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   448
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   449
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   450
        (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   451
            bvIdx <= 3 ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   452
                aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx).
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   453
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   454
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   455
            aStream nextPut:#storeBlockVar
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   456
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   457
            aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   458
        ].
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   459
        aStream nextPut:bvIdx.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   460
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   461
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   462
117
claus
parents: 106
diff changeset
   463
    (type == #GlobalVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   464
        litIndex := aCompiler addLiteral:name asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   465
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   466
            aStream nextPut:#storeGlobalS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   467
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   468
            aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   469
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   470
        ^ self
117
claus
parents: 106
diff changeset
   471
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   472
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   473
    (type == #ClassVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   474
        litIndex := aCompiler addLiteral:(selfClass name , ':' , name) asSymbol.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   475
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   476
            aStream nextPut:#storeClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   477
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   478
            aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   479
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   480
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   481
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   482
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   483
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   484
        aStream nextPut:#storeClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   485
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   486
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   487
106
claus
parents: 104
diff changeset
   488
    "not reached"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   489
    ^ self error:'bad assignment'
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   490
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   491
    "Created: 25.6.1997 / 16:14:40 / cg"
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   492
    "Modified: 26.6.1997 / 10:18:53 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   493
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   494
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   495
!VariableNode methodsFor:'enumeration'!
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   496
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   497
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   498
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   499
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   500
    ^ anEnumerator doVariable:self name:name
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   501
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   502
    "Created: 19.6.1997 / 16:41:35 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   503
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   504
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   505
!VariableNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   506
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   507
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   508
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   509
    or:[type == #BlockArg
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   510
    or:[type == #BlockVariable]]) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   511
        ^ token variableValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   512
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   513
    (type == #InstanceVariable) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   514
        ^ selfValue instVarAt:index
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   515
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   516
    (type == #GlobalVariable) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   517
        (Smalltalk includesKey:name) ifTrue:[
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   518
            ^ Smalltalk at:name
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   519
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   520
"
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   521
        self error:('global ' , name , ' is undefined').
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   522
"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   523
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   524
        ^ UndefinedVariable name:name.
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   525
        ^ nil
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   526
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   527
    (type == #ClassVariable) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   528
        ^ Smalltalk at:(selfClass name , ':' , name) asSymbol
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   529
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   530
    (type == #ClassInstanceVariable) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   531
        ^ selfClass instVarAt:index
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   532
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   533
    (type == #ThisContext) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   534
        ^ thisContext
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   535
    ].
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   536
    (type == #PrivateClass) ifTrue:[
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   537
        ^ selfClass privateClassesAt:name asSymbol
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   538
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   539
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   540
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   541
    ^ value
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   542
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   543
    "Modified: 6.11.1996 / 17:28:17 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   544
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   545
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   546
store:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   547
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   548
    or:[type == #BlockVariable]) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   549
	token value:aValue. ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   550
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   551
    (type == #InstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   552
	^ selfValue instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   553
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   554
    (type == #GlobalVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   555
	^ Smalltalk at:name put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   556
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   557
    (type == #ClassVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   558
	^ Smalltalk at:(selfClass name , ':' , name) asSymbol put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   559
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   560
    (type == #ClassInstanceVariable) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   561
	^ selfClass instVarAt:index put:aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   562
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   563
    "not reached"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   564
    self halt:'bad type'.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   565
    ^ aValue
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   566
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   567
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   568
!VariableNode methodsFor:'printing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   569
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   570
displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   571
    "return a string for display in inspectors etc."
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   572
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   573
    ^ 'InterpreterVariable(' , self printString , ')'
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   574
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   575
    "Modified: 20.9.1997 / 11:42:07 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   576
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   577
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   578
printOn:aStream indent:i
98
claus
parents: 53
diff changeset
   579
claus
parents: 53
diff changeset
   580
    (type == #MethodArg              "/ actually only a debug-check
claus
parents: 53
diff changeset
   581
    or:[type == #MethodVariable
claus
parents: 53
diff changeset
   582
    or:[type == #InstanceVariable
claus
parents: 53
diff changeset
   583
    or:[type == #BlockArg
claus
parents: 53
diff changeset
   584
    or:[type == #GlobalVariable
claus
parents: 53
diff changeset
   585
    or:[type == #ClassVariable
claus
parents: 53
diff changeset
   586
    or:[type == #BlockVariable
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   587
    or:[type == #PrivateClass
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   588
    or:[type == #ClassInstanceVariable]]]]]]]]) ifTrue:[
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   589
        aStream nextPutAll:name. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   590
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   591
    (type == #ThisContext) ifTrue:[
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   592
        aStream nextPutAll:'thisContext'. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   593
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   594
    "not reached"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   595
    self halt:'bad type'.
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   596
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   597
    "Modified: 5.1.1997 / 16:42:39 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   598
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   599
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   600
!VariableNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   601
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   602
canReuseAsArg:anotherNode
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   603
    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
   604
        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
   605
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   606
        (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
   607
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   608
        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
   609
            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
   610
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   611
        (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
   612
        (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
   613
        (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
   614
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   615
        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
   616
            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
   617
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   618
        (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
   619
        (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
   620
    ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   621
    ^ false
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   622
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   623
    "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
   624
    "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
   625
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   626
566
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   627
isArgument
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   628
    "return true, if this is a node for an argument (block or method)"
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   629
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   630
    ^ (type == #MethodArg) or:[type == #BlockArg]
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   631
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   632
    "Created: 27.6.1997 / 13:07:05 / cg"
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   633
    "Modified: 27.6.1997 / 13:07:19 / cg"
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   634
!
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   635
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   636
isGlobal
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   637
    "return true, if this is a node for a global variable"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   638
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   639
    ^ (type == #GlobalVariable) and:[Smalltalk includesKey:name]
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   640
!
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   641
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   642
isLocal
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   643
    "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
   644
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   645
    ^ (type == #MethodVariable) or:[type == #BlockVariable]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   646
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   647
    "Created: 1.3.1996 / 00:03:53 / cg"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   648
    "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
   649
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   650
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   651
isVariable
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   652
    "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
   653
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   654
    ^ true
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   655
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   656
    "Created: 14.4.1996 / 00:46:32 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   657
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   658
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   659
!VariableNode class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   660
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   661
version
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   662
    ^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.33 1997-09-20 21:03:33 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   663
! !