VariableNode.st
author Claus Gittinger <cg@exept.de>
Sat, 31 Aug 2013 13:30:27 +0200
changeset 3309 cea9c487db04
parent 3303 786da23ce823
child 3316 9705847df22f
permissions -rw-r--r--
class: UnaryNode comment/format in: #plausibilityCheckIn:
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
"
1076
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    12
"{ Package: 'stx:libcomp' }"
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    14
PrimaryNode subclass:#VariableNode
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    15
	instanceVariableNames:'name token index block'
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    16
	classVariableNames:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    17
	poolDictionaries:''
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    18
	category:'System-Compiler-Support'
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    19
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    20
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
    21
!VariableNode class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    22
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    23
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    24
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    25
 COPYRIGHT (c) 1994 by Claus Gittinger
53
c5dd7abf8431 *** empty log message ***
claus
parents: 31
diff changeset
    26
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    27
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    28
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    29
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    31
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    32
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    33
 hereby transferred.
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
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    37
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    38
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    39
    node for parse-trees, representing variables
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    40
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    41
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    44
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    45
! !
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    46
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
    47
!VariableNode class methodsFor:'instance creation'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    48
1932
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    49
blockArgumentNamed:n
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    50
    ^ (self basicNew) type:#BlockArg name:n asSymbol
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    51
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    52
    "Created: / 22-10-2006 / 11:59:10 / cg"
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    53
!
5df424cd0a3c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    54
3301
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    55
globalNamed:n                                   
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    56
    "because this is called even for invalid (partial) names,
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    57
     and we do not want to create zillions of unused symbols,
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    58
     no asSymbol is done here. So the name kept is actually a string.
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    59
     A symbol will be created when code is actually created for it"
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    60
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    61
    ^ (self basicNew) type:#GlobalVariable name:n "asSymbol"
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    62
dbb08322934c class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3166
diff changeset
    63
    "Modified (comment): / 29-08-2013 / 01:10:02 / cg"
1310
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
    64
!
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
    65
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    66
methodArgumentNamed:n
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    67
    ^ (self basicNew) type:#MethodArg name:n asSymbol
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    68
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    69
    "Created: / 06-08-2006 / 01:12:55 / cg"
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    70
!
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    71
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    72
methodLocalNamed:n
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    73
    ^ (self basicNew) type:#MethodVariable name:n asSymbol
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    74
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    75
    "Created: / 06-08-2006 / 13:43:41 / cg"
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    76
!
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
    77
98
claus
parents: 53
diff changeset
    78
type:t class:class name:n
claus
parents: 53
diff changeset
    79
    ^ (self basicNew) type:t class:class name:n
claus
parents: 53
diff changeset
    80
!
claus
parents: 53
diff changeset
    81
642
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
    82
type:t context:aContext
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
    83
    ^ (self basicNew) type:t context:aContext
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    84
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    85
    "Created: / 17.1.1998 / 04:00:35 / cg"
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    86
!
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    87
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
    88
type:t holder:holder name:n
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
    89
    ^ (self basicNew) type:t holder:holder name:n
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
    90
!
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
    91
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    92
type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    93
    ^ (self basicNew) type:t name:n
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    94
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    95
642
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
    96
type:t name:n context:aContext index:i
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
    97
    ^ (self basicNew) type:t name:n context:aContext index:i
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    98
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
    99
    "Created: / 17.1.1998 / 02:40:32 / cg"
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   100
!
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   101
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   103
    ^ (self basicNew) type:t name:n index:i selfClass:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   104
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   106
type:t name:n index:i selfValue:s
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   107
    ^ (self basicNew) type:t name:n index:i selfValue:s
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   108
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   109
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   110
type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   111
    ^ (self basicNew) type:t name:n token:tok index:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   112
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   113
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   114
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
   115
    ^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   116
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   117
    "Modified: 2.7.1997 / 10:55:48 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   118
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   119
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   120
!VariableNode methodsFor:'accessing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   121
577
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   122
block
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   123
    ^ block
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   124
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   125
    "Created: 2.7.1997 / 18:53:38 / cg"
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   126
!
efda2402cd70 oops - more fixes
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   127
2507
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   128
block:something
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   129
    block := something.
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   130
!
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   131
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
index
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
    ^ index
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   134
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   135
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   136
index:anIntegerIndex
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   137
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   138
    index := anIntegerIndex.
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   139
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   140
    "Modified: / 15-11-2011 / 19:10:08 / cg"
2507
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   141
!
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   142
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   143
name
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   144
    ^ name
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   145
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   146
2507
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   147
name:something
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   148
    name := something.
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   149
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   150
    "Modified: / 28-06-2011 / 22:14:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   151
!
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   152
2677
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   153
startPosition:start endPosition: end
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   154
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   155
    "/self assert: (end - start + 1) = name size.
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   156
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   157
    ^super startPosition:start endPosition: end
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   158
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   159
    "Created: / 25-08-2011 / 11:46:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   160
!
113a73795590 Fixes in start/endPosition for Variable node
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2599
diff changeset
   161
875
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   162
token
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   163
    ^ token
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   164
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   165
    "Created: 2.7.1997 / 18:53:38 / cg"
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   166
!
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   167
2507
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   168
token:something
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   169
    token := something.
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   170
!
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
   171
869
c483b1e6a0c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   172
type
c483b1e6a0c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   173
    ^ type
c483b1e6a0c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   174
!
c483b1e6a0c3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   175
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   176
type:t class:class name:n
2116
83852100750d leftOver halt.
Claus Gittinger <cg@exept.de>
parents: 2069
diff changeset
   177
    "/ type == #PoolVariable ifTrue:[self breakPoint:#cg].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   178
    type := t.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   179
    name := n.
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   180
    value := class
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   181
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   182
    "Modified: / 17.1.1998 / 04:03:55 / cg"
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   183
!
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   184
642
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
   185
type:t context:aContext
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   186
    type := t.
642
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
   187
    value := aContext.
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   188
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   189
    "Modified: / 17.1.1998 / 04:01:55 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   190
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   191
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   192
type:t holder:holder name:n
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   193
    type := t.
875
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   194
    token := holder.
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   195
    name := n
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   196
!
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   197
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
type:t name:n
98
claus
parents: 53
diff changeset
   199
    type := t.
claus
parents: 53
diff changeset
   200
    value := nil.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   201
    name := n
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   202
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   203
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   204
type:t name:n context:aContext index:anIntegerIndex
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   205
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   206
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   207
    index := anIntegerIndex.
642
de97c93c4f49 renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
   208
    value := aContext.
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   209
    name := n
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   210
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   211
    "Created: / 17-01-1998 / 02:40:55 / cg"
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   212
    "Modified: / 15-11-2011 / 19:10:18 / cg"
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   213
!
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   214
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   215
type:t name:n index:anIntegerIndex selfClass:s
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   216
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   217
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   218
    index := anIntegerIndex.
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   219
    value := s.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   220
    name := n
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   221
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   222
    "Modified: / 15-11-2011 / 19:10:21 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   223
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   224
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   225
type:t name:n index:anIntegerIndex selfValue:s
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   226
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   227
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   228
    index := anIntegerIndex.
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   229
    value := s.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
    name := n
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   231
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   232
    "Modified: / 15-11-2011 / 19:10:24 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   233
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   234
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   235
type:t name:n token:tok index:anIntegerIndex
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   236
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   237
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   238
    index := anIntegerIndex.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   239
    token := tok.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   240
    name := n
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   241
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   242
    "Modified: / 15-11-2011 / 19:10:30 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   243
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   244
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   245
type:t name:n token:tok index:anIntegerIndex block:variableBlock from:codeBlock
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   246
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   247
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   248
    index := anIntegerIndex.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   249
    block := variableBlock.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   250
    token := tok.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   251
    name := n.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   252
    (type == #BlockArg) ifTrue:[
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   253
        variableBlock blockArgAccessed:true.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   254
    ].
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   255
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   256
    codeBlock ~~ variableBlock ifTrue:[
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   257
        codeBlock rememberOuterBlockVarAccess:self
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   258
    ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   259
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   260
    "Created: / 02-07-1997 / 10:54:50 / cg"
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   261
    "Modified: / 15-11-2011 / 19:10:35 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   262
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   263
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   264
type:t token:tok index:anIntegerIndex block:b
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   265
    type := t.
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   266
"/    self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]).
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   267
    index := anIntegerIndex.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   268
    block := b.
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   269
    token := tok.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   270
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   271
    (type == #BlockArg) ifTrue:[
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   272
        b blockArgAccessed:true.
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   273
    ].
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   274
2757
a86f78669293 comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
   275
    "Modified: / 15-11-2011 / 19:10:04 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   276
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   277
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   278
!VariableNode methodsFor:'code generation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   279
104
claus
parents: 103
diff changeset
   280
codeForSideEffectOn:aStream inBlock:b for:aCompiler
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   281
    "no code at all"
2066
9873763eb1f8 sharedPool access in doIts
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
   282
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   283
    ^ self
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   284
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   285
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   286
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   287
    |code idx|
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   288
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   289
    lineNrOrNil notNil ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   290
        self codeLineNumber:lineNrOrNil on:aStream for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   291
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   292
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   293
    (type == #InstanceVariable) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   294
        (index <= 8) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   295
            code := #( retInstVar1
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   296
                       retInstVar2
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   297
                       retInstVar3
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   298
                       retInstVar4
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   299
                       retInstVar5
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   300
                       retInstVar6
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   301
                       retInstVar7
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   302
                       retInstVar8) at:index.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   303
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   304
            aStream nextPut:code.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   305
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   306
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   307
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   308
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   309
    (type == #MethodVariable) ifTrue:[
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   310
        idx := index.
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   311
        idx isNil ifTrue:[ idx := self indexIn: aCompiler ].
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   312
        (idx <= 6) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   313
            code := #( retMethodVar1
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   314
                       retMethodVar2
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   315
                       retMethodVar3
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   316
                       retMethodVar4
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   317
                       retMethodVar5
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   318
                       retMethodVar6) at:idx.
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   319
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   320
            aStream nextPut:code.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   321
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   322
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   323
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   324
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   325
    (type == #MethodArg) ifTrue:[
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   326
        idx := index.
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   327
        idx isNil ifTrue:[ idx := self indexIn: aCompiler ].
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   328
        (idx <= 2) ifTrue:[
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   329
            code := #(retMethodArg1
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   330
                      retMethodArg2) at:idx.
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   331
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   332
            aStream nextPut:code.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   333
            ^ self
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   334
        ]
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   335
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   336
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   337
    "/ anything else must be pushed, then top rturned
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   338
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   339
    self codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   340
    aStream nextPut:#retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   341
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   342
    "Modified: / 06-08-2006 / 22:59:28 / cg"
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   343
!
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 789
diff changeset
   344
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   345
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   346
    |theCode b deltaLevel litIndex specialGlobalIndex
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   347
     bvIdx bvTyp blocksCode selLitIdx |
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   348
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   349
    (type == #MethodArg) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   350
        (index <= 4) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   351
            aStream nextPut:(#(pushMethodArg1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   352
                               pushMethodArg2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   353
                               pushMethodArg3 
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   354
                               pushMethodArg4) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   355
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   356
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   357
        aStream nextPut:#pushMethodArg; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   358
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   359
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   360
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   361
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   362
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   363
            aStream nextPut:(#(pushMethodVar1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   364
                               pushMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   365
                               pushMethodVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   366
                               pushMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   367
                               pushMethodVar5
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   368
                               pushMethodVar6) at:index).
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   369
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   370
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   371
        aStream nextPut:#pushMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   372
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   373
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   374
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   375
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   376
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   377
            theCode := #(pushInstVar1 pushInstVar2 pushInstVar3
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   378
                         pushInstVar4 pushInstVar5 pushInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   379
                         pushInstVar7 pushInstVar8 pushInstVar9
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   380
                         pushInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   381
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   382
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   383
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   384
        aStream nextPut:#pushInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   385
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   386
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   387
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   388
    ((type == #BlockArg) 
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   389
    or:[type == #BlockVariable]) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   390
        "/ compiling for codeBlock; accessing variable in block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   391
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   392
        bvIdx := index.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   393
        bvTyp := type.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   394
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   395
        "/ find the context where that variable is contained physically
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   396
        blocksCode := block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   397
        [blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   398
            blocksCode := blocksCode home
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   399
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   400
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   401
        "/ find deltaLevel from code-context to the containing block
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   402
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   403
        deltaLevel := 0.
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   404
        [b notNil and:[b ~~ blocksCode]] whileTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   405
            b isInlineBlock ifFalse:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   406
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   407
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   408
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   409
        ].
535
713142116e40 remember access to blockArgs
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
   410
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   411
        b isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   412
            codeBlock isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   413
                "/ 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
   414
                "/ Generate a pushMVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   415
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   416
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   417
                type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   418
                    bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   419
                ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   420
                ^ self 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   421
                    codeLoadOn:aStream
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   422
                    type:#MethodVariable
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   423
                    index:bvIdx
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   424
                    inBlock:codeBlock
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   425
                    for:aCompiler
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
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   428
            "/ 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
   429
            "/ Generate a pushBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   430
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   431
            bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   432
            type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   433
                bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   434
            ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   435
            bvTyp := #BlockVariable.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   436
        ] ifFalse:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   437
            block isInlineBlock ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   438
                "/ 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
   439
                "/ Generate a pushBVAR / pushOuterBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   440
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   441
                type == #BlockVariable ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   442
                    bvIdx := bvIdx + block numArgs
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   443
                ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   444
                bvTyp := #BlockVariable.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   445
            ]
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   446
        ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   447
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   448
        (bvTyp == #BlockVariable) ifTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   449
            (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   450
                bvIdx <= 3 ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   451
                    aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx).
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   452
                    ^ self
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   453
                ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   454
                aStream nextPut:#pushBlockVar.
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   455
            ] ifFalse:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   456
                aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   457
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   458
        ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   459
            (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   460
                (bvIdx <= 4) ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   461
                    aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   462
                                       pushBlockArg4) at:bvIdx).
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   463
                    ^ self
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   464
                ].
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   465
                aStream nextPut:#pushBlockArg.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   466
            ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   467
                (deltaLevel == 1) ifTrue:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   468
                    aStream nextPut:#pushOuter1BlockArg
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   469
                ] ifFalse:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   470
                    (deltaLevel == 2) ifTrue:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   471
                        aStream nextPut:#pushOuter2BlockArg
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   472
                    ] ifFalse:[
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   473
                        aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   474
                    ]
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   475
                ].
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   476
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   477
        ].
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   478
        aStream nextPut:bvIdx.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   479
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   480
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   481
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   482
    (type == #GlobalVariable) ifTrue:[
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   483
        "for browsing, we put it into the literal-array; even if its a specal global"
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   484
        litIndex := aCompiler addLiteral:name asSymbol.
531
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   485
        specialGlobalIndex := aCompiler specialGlobalCodeFor:name.
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   486
        specialGlobalIndex notNil ifTrue:[
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 465
diff changeset
   487
            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
   488
            ^ self
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   489
        ].
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   490
        self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   491
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   492
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   493
1553
1657d0843c64 sharedPools
ca
parents: 1462
diff changeset
   494
    ((type == #ClassVariable) or:[ type == #PoolVariable ]) ifTrue:[
1314
782d4cc1d588 slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 1310
diff changeset
   495
        litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name).
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   496
        litIndex <= 255 ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   497
            aStream nextPut:#pushClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   498
        ] ifFalse:[
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   499
            litIndex <= 16rFFFF ifTrue:[
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   500
                aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   501
            ] ifFalse:[
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   502
                aStream nextPut:#pushClassVarVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   503
            ].
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   504
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   505
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   506
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   507
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   508
    (type == #PrivateClass) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   509
        litIndex := aCompiler addLiteral:(value name , '::' , name) asSymbol.
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   510
        self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler.
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   511
        ^ self
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
   512
    ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   513
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   514
    (type == #ClassInstanceVariable) ifTrue:[
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   515
        "theoretically, this allows for an instance method to access a classInstVar;
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   516
         However, the parser blocks this and we never arrive here."
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   517
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   518
        aStream nextPut:#pushClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   519
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   520
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   521
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   522
    (type == #ThisContext) ifTrue:[
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   523
        aStream nextPut:#pushThisContext. 
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   524
        ^ self
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   525
    ].
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   526
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   527
    (type == #WorkspaceVariable
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   528
    or:[type == #DoItTemporary]) ifTrue:[
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   529
        "/ this is done by keeping the valueHolder in the literalArray,
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   530
        "/ and coding a #value message here.
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   531
875
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   532
        litIndex := aCompiler addLiteral:token.
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   533
        self emitPushLiteralIndex:litIndex on:aStream for:aCompiler.
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   534
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   535
        selLitIdx := aCompiler addLiteral:#value.
3166
6d6abf8f4439 Do not generate #lineno16 byte codes if still on the same line
Stefan Vogel <sv@exept.de>
parents: 3148
diff changeset
   536
        self emitSendLiteralIndex:selLitIdx numArgs:0 line:("lineNr ?" 1) on:aStream for:aCompiler.
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   537
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   538
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   539
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   540
    "not reached"
1462
bf3d40b72bf3 Do not use #halt
Stefan Vogel <sv@exept.de>
parents: 1384
diff changeset
   541
    self error:'bad type'.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   542
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   543
    "Created: / 25.6.1997 / 16:14:17 / cg"
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   544
    "Modified: / 17.1.1998 / 04:04:17 / cg"
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   545
!
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   546
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   547
codeOn:aStream inBlock:codeBlock for:aCompiler
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   548
    |idx|
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   549
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   550
    idx := (index isNil) 
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   551
            ifTrue:[ self indexIn: aCompiler ]
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   552
            ifFalse:[ index ].
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   553
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   554
    self
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   555
        codeLoadOn:aStream type:type index:idx inBlock:codeBlock for:aCompiler
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   556
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   557
    "Modified: / 06-08-2006 / 16:04:54 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   558
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   559
104
claus
parents: 103
diff changeset
   560
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   561
    |idx|
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   562
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   563
    idx := (index isNil) 
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   564
            ifTrue:[ self indexIn: aCompiler ]
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   565
            ifFalse:[ index ].
1821
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   566
    idx == 0 ifTrue:[
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   567
        self error
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   568
    ].
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   569
    self
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   570
        codeStoreOn:aStream type:type index:idx
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   571
        inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   572
1821
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   573
    "Modified: / 12-08-2006 / 15:54:52 / cg"
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   574
!
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   575
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   576
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   577
    |theCode b deltaLevel litIndex bvIdx blocksCode selLitIdx|
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   578
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   579
    "/ value to be stored is on TOP of stack.
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   580
    valueNeeded ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   581
        aStream nextPut:#dup
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   582
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   583
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   584
    (type == #MethodVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   585
        (index <= 6) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   586
            theCode := #(storeMethodVar1 storeMethodVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   587
                         storeMethodVar3 storeMethodVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   588
                         storeMethodVar5 storeMethodVar6) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   589
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   590
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   591
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   592
        aStream nextPut:#storeMethodVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   593
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   594
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   595
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   596
    (type == #InstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   597
        (index <= 10) ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   598
            theCode := #(storeInstVar1 storeInstVar2
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   599
                         storeInstVar3 storeInstVar4
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   600
                         storeInstVar5 storeInstVar6
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   601
                         storeInstVar7 storeInstVar8
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   602
                         storeInstVar9 storeInstVar10) at:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   603
            aStream nextPut:theCode.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   604
            ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   605
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   606
        aStream nextPut:#storeInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   607
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   608
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   609
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   610
    ((type == #BlockVariable)
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   611
    "/ the following cannot be encountered with Smalltalk code;
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   612
    "/ however, the VM supports it for other languages (JavaScript, in particular)
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   613
    or:[(type == #BlockArg)]) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   614
        bvIdx := index.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   615
        
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   616
        "/ find the context where that variable is contained physically
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   617
        blocksCode := block.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   618
        [blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   619
            blocksCode := blocksCode home
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   620
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   621
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   622
        "find deltaLevel to block, where variable was defined"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   623
        b := codeBlock.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   624
        deltaLevel := 0.
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   625
        [b notNil and:[b ~~ blocksCode]] whileTrue:[
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   626
            b isInlineBlock ifFalse:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   627
                deltaLevel := deltaLevel + 1
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   628
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   629
            b := b home
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   630
        ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   631
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   632
        b isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   633
            codeBlock isNil ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   634
                "/ a block which is inlined in the method. 
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   635
                "/ Generate a storeMVAR
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   636
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   637
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   638
                bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   639
                ^ self
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   640
                    codeStoreOn:aStream 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   641
                    type:#MethodVariable index:bvIdx 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   642
                    inBlock:codeBlock 
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   643
                    valueNeeded:false       "/ already dupped if value is needed
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   644
                    for:aCompiler
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   645
            ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   646
            "/ 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
   647
            "/ Generate a pushBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   648
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   649
            bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   650
            bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   651
        ] ifFalse:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   652
            block isInlineBlock ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   653
                "/ 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
   654
                "/ Generate a pushBVAR / pushOuterBVAR
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   655
                bvIdx := block indexOfFirstTemp + index - 1.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   656
                bvIdx := bvIdx + block numArgs.
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   657
            ]
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   658
        ].
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   659
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   660
        (type == #BlockArg) ifTrue:[
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   661
            (deltaLevel == 0) ifTrue:[
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   662
                aStream nextPut:#storeBlockLocal
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   663
            ] ifFalse:[
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   664
                aStream nextPut:#storeOuterBlockLocal; nextPut:deltaLevel
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   665
            ].
2755
a59c6adef58f changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   666
            aStream nextPut:bvIdx-1.
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   667
            ^ self
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   668
        ].
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   669
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   670
        (deltaLevel == 0) ifTrue:[
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   671
            bvIdx <= 3 ifTrue:[
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   672
                aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx).
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   673
                ^ self
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   674
            ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   675
            aStream nextPut:#storeBlockVar
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   676
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   677
            aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   678
        ].
559
42cf4afd99b3 inline blocks withs args
Claus Gittinger <cg@exept.de>
parents: 554
diff changeset
   679
        aStream nextPut:bvIdx.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   680
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   681
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   682
117
claus
parents: 106
diff changeset
   683
    (type == #GlobalVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   684
        litIndex := aCompiler addLiteral:name asSymbol.
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   685
        self emitStoreGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler.
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   686
        ^ self
117
claus
parents: 106
diff changeset
   687
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   688
1553
1657d0843c64 sharedPools
ca
parents: 1462
diff changeset
   689
    ((type == #ClassVariable) or:[type == #PoolVariable]) ifTrue:[
1314
782d4cc1d588 slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 1310
diff changeset
   690
        litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name).
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   691
        litIndex < 256 ifTrue:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   692
            aStream nextPut:#storeClassVarS; nextPut:litIndex
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   693
        ] ifFalse:[
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   694
            aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   695
        ].
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   696
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   697
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   698
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   699
    (type == #ClassInstanceVariable) ifTrue:[
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   700
        aStream nextPut:#storeClassInstVar; nextPut:index.
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   701
        ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   702
    ].
554
d5e548c4d49d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   703
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   704
    (type == #WorkspaceVariable
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   705
    or:[type == #DoItTemporary]) ifTrue:[
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   706
        "/ this is done by keeping the valueHolder in the literalArray,
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   707
        "/ and coding a #value: message here.
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   708
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   709
        litIndex := aCompiler addLiteral:token.
1808
29b197bc6939 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1784
diff changeset
   710
        self emitPushLiteralIndex:litIndex on:aStream for:aCompiler.
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   711
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   712
        "/ need to exchange top 2 items (sigh - there is no exch instruction)
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   713
        "/ now, we have:
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   714
        "/   TOS:  holder
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   715
        "/   NOS:  value
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   716
        "/
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   717
        "/ for the send, I need them as:
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   718
        "/   TOS:  value
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   719
        "/   NOS:  holder
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   720
        aStream nextPut:#over.
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   721
        "/ now, we have:
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   722
        "/   TOS:  value
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   723
        "/   NOS:  holder
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   724
        "/         value
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   725
        selLitIdx := aCompiler addLiteral:#'value:'.
3166
6d6abf8f4439 Do not generate #lineno16 byte codes if still on the same line
Stefan Vogel <sv@exept.de>
parents: 3148
diff changeset
   726
        self emitSendLiteralIndex:selLitIdx numArgs:1 line:("lineNr ?" 1) on:aStream for:aCompiler.
1296
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   727
        "/ now, we have:
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   728
        "/   TOS:  retVal from value:
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   729
        "/   NOS:  value
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   730
        aStream nextPut:#drop.
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   731
        aStream nextPut:#drop.
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   732
        ^ self
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   733
    ].
7c535a2cd7ff WorkspaceVars
Claus Gittinger <cg@exept.de>
parents: 1179
diff changeset
   734
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   735
    "/ the following cannot be encountered with Smalltalk code;
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   736
    "/ however, the VM supports it for other languages (JavaScript, in particular)
1821
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   737
    (type == #MethodArg) ifTrue:[
2754
81d1bb6dd8d6 changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
   738
        aStream nextPut:#storeMethodLocal; nextPut:index-1.
1821
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   739
        ^ self
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   740
    ].
7cfd8464cace *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1808
diff changeset
   741
106
claus
parents: 104
diff changeset
   742
    "not reached"
941
0ae34d664798 error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents: 875
diff changeset
   743
    self error:'bad assignment'
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   744
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   745
    "Created: / 25-06-1997 / 16:14:40 / cg"
2755
a59c6adef58f changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2754
diff changeset
   746
    "Modified: / 25-10-2011 / 23:41:59 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   747
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   748
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   749
!VariableNode methodsFor:'enumerating'!
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   750
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   751
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   752
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   753
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   754
    ^ anEnumerator doVariable:self name:name
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   755
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   756
    "Created: 19.6.1997 / 16:41:35 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   757
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 535
diff changeset
   758
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
   759
!VariableNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   760
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   761
evaluateIn:anEnvironment
980
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   762
    |nameSym|
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   763
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   764
    (type == #ContextVariable) ifTrue:[
1137
43db3cacab5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
   765
"/        value method isWrapped ifTrue:[^ nil].
1178
f8065fd945a8 care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
   766
        index > value size ifTrue:[
f8065fd945a8 care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
   767
            "/ this can happen ,if a wrapped method is not yet entered
f8065fd945a8 care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
   768
            ^ nil
f8065fd945a8 care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents: 1137
diff changeset
   769
        ].
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   770
        ^ value at:index
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   771
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   772
    (type == #MethodVariable
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   773
    or:[type == #MethodArg
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   774
    or:[type == #BlockArg
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   775
    or:[type == #BlockVariable]]]) ifTrue:[
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   776
        ^ token variableValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   777
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   778
    (type == #InstanceVariable) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   779
        ^ value instVarAt:index
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   780
    ].
1088
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   781
    (type == #JavaVariable) ifTrue:[
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   782
        nameSym := name asSymbolIfInterned.
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   783
        nameSym notNil ifTrue:[
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   784
            ^ JAVA at:name
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   785
        ].
2420
914eb1c66bda Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents: 2126
diff changeset
   786
"/        ^ nil.
914eb1c66bda Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents: 2126
diff changeset
   787
        ^ Parser undefinedVariableError raiseRequestWith:name errorString:('undefined: ',name).
1088
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   788
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   789
    (type == #GlobalVariable) ifTrue:[
980
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   790
        nameSym := name asSymbolIfInterned.
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   791
        nameSym notNil ifTrue:[
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   792
            (Smalltalk includesKey:nameSym) ifTrue:[
3303
786da23ce823 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   793
                ^ Smalltalk at:nameSym
980
1818e8c13e2a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 965
diff changeset
   794
            ]
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   795
        ].
2420
914eb1c66bda Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents: 2126
diff changeset
   796
"/        ^ nil.
914eb1c66bda Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents: 2126
diff changeset
   797
        ^ Parser undefinedVariableError raiseRequestWith:name errorString:('undefined: ',name).
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   798
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   799
    (type == #ClassVariable) ifTrue:[
1314
782d4cc1d588 slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 1310
diff changeset
   800
        ^ value classVarAt:name asSymbol
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   801
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   802
    (type == #ClassInstanceVariable) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   803
        ^ value instVarAt:index
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   804
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   805
    (type == #ThisContext) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   806
        value notNil ifTrue:[
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   807
            ^ value
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   808
        ].
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   809
        ^ thisContext
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   810
    ].
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   811
    (type == #PrivateClass) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   812
        ^ value privateClassesAt:name asSymbol
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   813
    ].
1918
e02187d205c0 poolvars in a doIT
fm
parents: 1821
diff changeset
   814
    (type == #PoolVariable) ifTrue:[
e02187d205c0 poolvars in a doIT
fm
parents: 1821
diff changeset
   815
        ^ value classVarAt:name asSymbol
e02187d205c0 poolvars in a doIT
fm
parents: 1821
diff changeset
   816
    ].
719
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   817
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   818
    "/ synthetic; for evaluation only
1179
b411ceb395f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1178
diff changeset
   819
    (type == #EvaluationContextLocal
b411ceb395f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1178
diff changeset
   820
    or:[type == #EvaluationContextVar
b411ceb395f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1178
diff changeset
   821
    or:[type == #EvaluationContextArg]]) ifTrue:[
719
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   822
        ^ token variableValue
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   823
    ].
1179
b411ceb395f8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1178
diff changeset
   824
1092
77de350f525c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   825
    "/ synthetic; for evaluation only
1606
eaf685612275 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   826
    ((type == #WorkspaceVariable) or:[type == #DoItTemporary]) ifTrue:[
1092
77de350f525c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   827
        ^ token value
77de350f525c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1088
diff changeset
   828
    ].
719
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   829
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   830
    "not reached"
1320
5d004fcfd006 Use #error: insead of #halt.
Stefan Vogel <sv@exept.de>
parents: 1314
diff changeset
   831
    self error:'internal error - bad variable type:' , type mayProceed:true.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   832
    ^ value
420
ad567fb4e732 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 360
diff changeset
   833
1918
e02187d205c0 poolvars in a doIT
fm
parents: 1821
diff changeset
   834
    "Modified: / 11-09-2006 / 14:22:38 / User"
3303
786da23ce823 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
   835
    "Modified: / 29-08-2013 / 01:19:53 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   836
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   837
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   838
store:aValue
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   839
    (type == #ContextVariable) ifTrue:[
1137
43db3cacab5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
   840
"/        value method isWrapped ifTrue:[
43db3cacab5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
   841
"/            self warn:'The method has not yet been entered (in breakpoint stub)\Please perform a singleStep first' withCRs.
43db3cacab5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
   842
"/            ^ aValue
43db3cacab5f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1136
diff changeset
   843
"/        ].
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   844
        value at:index put:aValue. ^ aValue
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   845
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   846
    (type == #MethodVariable
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   847
    or:[type == #BlockVariable]) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   848
        token value:aValue. ^ aValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   849
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   850
    (type == #InstanceVariable) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   851
        ^ value instVarAt:index put:aValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   852
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   853
    (type == #GlobalVariable) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   854
        ^ Smalltalk at:name put:aValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   855
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   856
    (type == #ClassVariable) ifTrue:[
1314
782d4cc1d588 slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 1310
diff changeset
   857
        ^ value classVarAt:name asSymbol put:aValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   858
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   859
    (type == #ClassInstanceVariable) ifTrue:[
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   860
        ^ value instVarAt:index put:aValue
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   861
    ].
719
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   862
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   863
    "/ synthetic; for evaluation only
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   864
    (type == #EvaluationContextLocal) ifTrue:[
875
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   865
        token value:aValue. ^ aValue
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   866
    ].
2764
9acca5d69f54 changed: #store:
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
   867
    ((type == #WorkspaceVariable) or:[type == #DoItTemporary]) ifTrue:[
875
2561654973eb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
   868
        token value:aValue. ^ aValue
719
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   869
    ].
9ccbae6ba13e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 642
diff changeset
   870
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   871
    "not reached"
1320
5d004fcfd006 Use #error: insead of #halt.
Stefan Vogel <sv@exept.de>
parents: 1314
diff changeset
   872
    self error:'bad variable node type' mayProceed:true.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   873
    ^ aValue
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   874
2764
9acca5d69f54 changed: #store:
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
   875
    "Modified: / 05-12-2011 / 18:43:56 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   876
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   877
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1076
diff changeset
   878
!VariableNode methodsFor:'printing & storing'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   879
2898
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   880
displayOn:aGCOrStream
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   881
    "Compatibility
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   882
     append a printed desription on some stream (Dolphin,  Squeak)
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   883
     OR:
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   884
     display the receiver in a graphicsContext at 0@0 (ST80).
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   885
     This method allows for any object to be displayed in some view
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   886
     (although the fallBack is to display its printString ...)"
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   887
2898
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   888
    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   889
    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   890
    aGCOrStream isStream ifFalse:[
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   891
        ^ super displayOn:aGCOrStream.
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   892
    ].
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 577
diff changeset
   893
2898
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   894
    aGCOrStream 
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   895
        nextPutAll:self class name;
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   896
        nextPut:$(.
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   897
    self printOn:aGCOrStream. 
bb61af1f77a1 Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents: 2864
diff changeset
   898
    aGCOrStream nextPut:$)
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   899
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   900
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   901
printOn:aStream indent:i
98
claus
parents: 53
diff changeset
   902
641
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   903
    "/ actually only a debug-check
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   904
    (
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   905
    type == #ContextVariable              
e18daf10662c added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   906
    or:[type == #MethodArg            
98
claus
parents: 53
diff changeset
   907
    or:[type == #MethodVariable
claus
parents: 53
diff changeset
   908
    or:[type == #InstanceVariable
claus
parents: 53
diff changeset
   909
    or:[type == #BlockArg
claus
parents: 53
diff changeset
   910
    or:[type == #GlobalVariable
1088
029b67b39d1b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   911
    or:[type == #JavaVariable
98
claus
parents: 53
diff changeset
   912
    or:[type == #ClassVariable
2066
9873763eb1f8 sharedPool access in doIts
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
   913
    or:[type == #PoolVariable
98
claus
parents: 53
diff changeset
   914
    or:[type == #BlockVariable
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   915
    or:[type == #PrivateClass
872
7cf38a8125e6 support for workspace variables.
Claus Gittinger <cg@exept.de>
parents: 869
diff changeset
   916
    or:[type == #WorkspaceVariable
1101
84db57980ac5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1092
diff changeset
   917
    or:[type == #EvaluationContextArg
720
6b3d43ba7273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   918
    or:[type == #EvaluationContextLocal
2066
9873763eb1f8 sharedPool access in doIts
Claus Gittinger <cg@exept.de>
parents: 1997
diff changeset
   919
    or:[type == #ClassInstanceVariable]]]]]]]]]]]]]]) ifTrue:[
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   920
        aStream nextPutAll:name. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   921
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   922
    (type == #ThisContext) ifTrue:[
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   923
        aStream nextPutAll:'thisContext'. ^ self
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   924
    ].
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   925
    "not reached"
1320
5d004fcfd006 Use #error: insead of #halt.
Stefan Vogel <sv@exept.de>
parents: 1314
diff changeset
   926
    self error:'bad variable node type' mayProceed:true.
465
67e5205a81cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 420
diff changeset
   927
720
6b3d43ba7273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 719
diff changeset
   928
    "Modified: / 17.5.1998 / 00:17:12 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   929
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   930
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   931
!VariableNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   932
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   933
canReuseAsArg:anotherNode
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   934
    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
   935
        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
   936
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   937
        (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
   938
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   939
        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
   940
            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
   941
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   942
        (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
   943
        (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
   944
        (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
   945
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   946
        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
   947
            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
   948
        ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   949
        (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
   950
        (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
   951
    ].
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   952
    ^ false
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   953
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   954
    "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
   955
    "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
   956
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
   957
1784
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   958
indexIn: aCompiler
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   959
    (type == #MethodVariable) ifTrue:[
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   960
        ^ aCompiler methodVars indexOf:name.
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   961
    ].
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   962
    (type == #MethodArg) ifTrue:[
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   963
        ^ aCompiler methodArgs indexOf:name.
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   964
    ].
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   965
    ^ index
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   966
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   967
    "Created: / 06-08-2006 / 16:03:56 / cg"
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   968
!
4380f89e1a91 allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents: 1606
diff changeset
   969
566
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   970
isArgument
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   971
    "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
   972
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   973
    ^ (type == #MethodArg) or:[type == #BlockArg]
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   974
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   975
    "Created: 27.6.1997 / 13:07:05 / cg"
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   976
    "Modified: 27.6.1997 / 13:07:19 / cg"
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   977
!
90969df02c85 added #isArgument query
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
   978
1076
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   979
isClassVariable
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   980
    ^ type == #ClassVariable
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   981
!
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   982
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   983
isGlobal
2957
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
   984
    "return true, if this is a node for an existing!! global variable"
789
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   985
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   986
    ^ (type == #GlobalVariable) 
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   987
      and:[name isSymbol
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   988
      and:[Smalltalk includesKey:name]]
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   989
d9bbb0970239 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   990
    "Modified: / 19.10.1998 / 19:43:04 / cg"
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   991
!
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   992
1997
4ec97f7ce416 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1996
diff changeset
   993
isGlobalNamed:nameWanted
1996
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   994
    "return true, if this is a node for a particular global variable"
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   995
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   996
    ^ (type == #GlobalVariable) 
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   997
      and:[name = nameWanted
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   998
      and:[name isSymbol
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
   999
      and:[Smalltalk includesKey:name]]]
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
  1000
1997
4ec97f7ce416 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1996
diff changeset
  1001
    "Created: / 05-03-2007 / 13:35:07 / cg"
1996
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
  1002
!
6d70e53e9f14 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1932
diff changeset
  1003
1310
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1004
isGlobalVariable
2957
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1005
    "return true, if this is a node for global variable"
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1006
1310
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1007
    ^ type == #GlobalVariable
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1008
!
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1009
1076
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1010
isInstanceVariable
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1011
    ^ type == #InstanceVariable
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1012
!
b393dc61463e added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  1013
2864
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1014
isJAVA
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1015
    "Return true, if receiver is global variable node JAVA.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1016
     Used to highlight Java class references."
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1017
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1018
    ^ (type == #GlobalVariable) and:[name = 'JAVA']
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1019
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1020
    "Created: / 19-04-2012 / 09:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1021
!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1022
218
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1023
isLocal
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1024
    "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
  1025
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1026
    ^ (type == #MethodVariable) or:[type == #BlockVariable]
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1027
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1028
    "Created: 1.3.1996 / 00:03:53 / cg"
748b4c509a51 use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1029
    "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
  1030
!
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1031
1310
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1032
isMethodArg
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1033
    ^ type == #MethodArg
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1034
!
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1035
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1036
isMethodVariable
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1037
    ^ type == #MethodVariable
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1038
!
feb30ab0c221 better variabletype queries.
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1039
2957
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1040
isPoolVariable
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1041
    ^ type == #PoolVariable
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1042
!
b23f798ffa70 added: #isPoolVariable
Claus Gittinger <cg@exept.de>
parents: 2898
diff changeset
  1043
965
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1044
isUndeclared
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1045
    type == #PrivateClass ifTrue:[
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1046
        ^ (Smalltalk includesKey:(value name , '::' , name) asSymbol) not
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1047
    ].
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1048
    type == #GlobalVariable ifTrue:[
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1049
        ^ (Smalltalk includesKey:name) not
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1050
    ].
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1051
    ^ false
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1052
!
5f893e013e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1053
243
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1054
isVariable
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1055
    "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
  1056
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1057
    ^ true
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1058
cdc1424ddaac use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents: 218
diff changeset
  1059
    "Created: 14.4.1996 / 00:46:32 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1060
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1061
2864
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1062
!VariableNode methodsFor:'testing'!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1063
3148
05da92cb7ca7 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 2957
diff changeset
  1064
isInstance 
05da92cb7ca7 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 2957
diff changeset
  1065
    ^ (type == #InstanceVariable)
05da92cb7ca7 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 2957
diff changeset
  1066
!
05da92cb7ca7 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 2957
diff changeset
  1067
2864
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1068
isJavaPackageReference
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1069
    "Return true, given node is JAVA package reference in form:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1070
        JAVA package1 package2 
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1071
    "
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1072
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1073
    ^self isJAVA
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1074
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1075
    "Created: / 19-04-2012 / 09:53:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1076
! !
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2764
diff changeset
  1077
2599
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1078
!VariableNode methodsFor:'visiting'!
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1079
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1080
acceptVisitor:aVisitor 
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1081
    "Double dispatch back to the visitor, passing my type encoded in
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1082
     the selector (visitor pattern)"
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1083
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1084
    "stub code automatically generated - please change if required"
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1085
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1086
    ^ aVisitor visitVariableNode:self
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1087
! !
c09d340dae29 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2507
diff changeset
  1088
360
9b26a5a4da70 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  1089
!VariableNode class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  1090
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  1091
version
3303
786da23ce823 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
  1092
    ^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.90 2013-08-28 23:21:37 cg Exp $'
2507
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
  1093
!
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
  1094
Claus Gittinger <cg@exept.de>
parents: 2420
diff changeset
  1095
version_CVS
3303
786da23ce823 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 3301
diff changeset
  1096
    ^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.90 2013-08-28 23:21:37 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  1097
! !
3148
05da92cb7ca7 class: VariableNode
Claus Gittinger <cg@exept.de>
parents: 2957
diff changeset
  1098