SelfNode.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Nov 2004 15:30:33 +0100
changeset 1561 175735dcd732
parent 1384 0db9682870d9
child 2323 e6bb6ed129a9
permissions -rw-r--r--
do not check for endOfInput if parsing from a Stream
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     1
"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
104
claus
parents: 103
diff changeset
     3
	      All Rights Reserved
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     4
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    11
"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    12
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
"{ Package: 'stx:libcomp' }"
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    14
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    15
PrimaryNode subclass:#SelfNode
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    16
	instanceVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    17
	classVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    18
	poolDictionaries:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    19
	category:'System-Compiler-Support'
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    20
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    21
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    22
!SelfNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    23
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    24
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    25
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    26
 COPYRIGHT (c) 1994 by Claus Gittinger
104
claus
parents: 103
diff changeset
    27
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    29
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    30
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    33
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    34
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    35
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    36
!
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    37
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    38
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    40
    node for parse-trees, representing self
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    41
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    44
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    45
"
f8dd8ba75205 *** empty log message ***
claus
parents: 14
diff changeset
    46
! !
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    47
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    48
!SelfNode class methodsFor:'instance creation'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    49
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    50
value:val
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    51
    ^ (self basicNew) value:val
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    52
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    53
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    54
!SelfNode methodsFor:'accessing'!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    55
542
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    56
name
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    57
    ^ 'self'
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    58
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    59
    "Created: 19.6.1997 / 17:20:22 / cg"
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    60
!
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    61
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    62
value:val
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    63
    type := #Self.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    64
    value := val.
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    65
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    66
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    67
!SelfNode methodsFor:'code generation'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    68
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    69
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    70
    lineNrOrNil notNil ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    71
        self codeLineNumber:lineNrOrNil on:aStream for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    72
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    73
    aStream nextPut:#retSelf
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    74
!
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
    75
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    76
codeOn:aStream inBlock:codeBlock for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    77
    aStream nextPut:#pushSelf
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    78
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    79
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    80
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    81
    "not reached - parser has already checked this"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    82
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    83
    ^ self error:'store into self - cannot happen'
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    84
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    85
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 862
diff changeset
    86
!SelfNode methodsFor:'enumerating'!
542
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    87
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    88
nodeDo:anEnumerator
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    89
    "helper for parse tree walking"
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    90
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    91
    ^ anEnumerator doVariable:self name:'self'
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    92
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    93
    "Created: 19.6.1997 / 17:20:02 / cg"
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    94
! !
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    95
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 862
diff changeset
    96
!SelfNode methodsFor:'evaluation'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
    97
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    98
evaluateIn:anEnvironment
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
    99
    anEnvironment notNil ifTrue:[
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   100
        ^ anEnvironment receiver.
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   101
    ].
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   102
    ^ value
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   103
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   104
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   105
store:aValue
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   106
    "not reached - parser has already checked this"
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   107
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   108
    self error:'store into self - cannot happen'
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   109
! !
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   110
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   111
!SelfNode methodsFor:'printing & storing'!
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   112
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   113
displayString
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   114
    "return a string for display in inspectors etc."
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   115
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   116
    ^ 'InterpreterVariable(self)'
612
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   117
2748896a66c8 comments
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   118
    "Modified: 20.9.1997 / 11:41:41 / cg"
14
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   119
!
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   120
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   121
printOn:aStream indent:i
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   122
    aStream nextPutAll:'self'
f08ffd9958a5 Initial revision
claus
parents:
diff changeset
   123
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
862
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   125
!SelfNode methodsFor:'queries'!
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   126
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   127
isSelf
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   128
    "return true, if this is a self-node"
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   129
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   130
    ^ self class == SelfNode
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   131
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   132
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   133
! !
2e3aefb24308 added #isSelf
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
   134
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   135
!SelfNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   136
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   137
version
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   138
    ^ '$Header: /cvs/stx/stx/libcomp/SelfNode.st,v 1.19 2003-03-28 14:41:13 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   139
! !