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