forked from pharo-project/pharo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pharo-project#6655 from dionisiydk/specialVarRefactor
Rename special variables into reserved variables
- Loading branch information
Showing
18 changed files
with
213 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Extension { #name : #RBVariableNode } | ||
|
||
{ #category : #'*Deprecated90' } | ||
RBVariableNode >> isSpecialVariable [ | ||
self | ||
deprecated: 'Use #isReservedVariable instead.' | ||
transformWith: '`@receiver isSpecialVariable' -> '`@receiver isReservedVariable'. | ||
|
||
^ self isReservedVariable | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/OpalCompiler-Core/OCStoreIntoReservedVariableError.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Class { | ||
#name : #OCStoreIntoReservedVariableError, | ||
#superclass : #OCSemanticError, | ||
#category : #'OpalCompiler-Core-Exception' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
" | ||
I model self, thisContext and super | ||
" | ||
Class { | ||
#name : #ReservedVariable, | ||
#superclass : #Variable, | ||
#classInstVars : [ | ||
'instance' | ||
], | ||
#category : #'OpalCompiler-Core-Semantics' | ||
} | ||
|
||
{ #category : #accessing } | ||
ReservedVariable class >> instance [ | ||
^instance ifNil: [ instance := self new ] | ||
] | ||
|
||
{ #category : #testing } | ||
ReservedVariable class >> isAbstract [ | ||
^self = ReservedVariable | ||
] | ||
|
||
{ #category : #converting } | ||
ReservedVariable >> asString [ | ||
|
||
^ self name | ||
] | ||
|
||
{ #category : #'code generation' } | ||
ReservedVariable >> emitStore: methodBuilder [ | ||
|
||
self shouldNotImplement | ||
] | ||
|
||
{ #category : #testing } | ||
ReservedVariable >> isReservedVariable [ | ||
^true | ||
] | ||
|
||
{ #category : #testing } | ||
ReservedVariable >> isWritable [ | ||
^ false | ||
] | ||
|
||
{ #category : #printing } | ||
ReservedVariable >> printOn: stream [ | ||
|
||
stream nextPutAll: self name | ||
] | ||
|
||
{ #category : #debugging } | ||
ReservedVariable >> write: aValue inContext: aContext [ | ||
|
||
self error: name, ' is reserved word and cant be modified' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
" | ||
I model ""self"" keyword | ||
" | ||
Class { | ||
#name : #SelfVariable, | ||
#superclass : #ReservedVariable, | ||
#category : #'OpalCompiler-Core-Semantics' | ||
} | ||
|
||
{ #category : #accessing } | ||
SelfVariable class >> semanticNodeClass [ | ||
|
||
^RBSelfNode | ||
] | ||
|
||
{ #category : #emitting } | ||
SelfVariable >> emitValue: methodBuilder [ | ||
|
||
methodBuilder pushReceiver | ||
] | ||
|
||
{ #category : #initialization } | ||
SelfVariable >> initialize [ | ||
super initialize. | ||
|
||
name := 'self' | ||
] | ||
|
||
{ #category : #testing } | ||
SelfVariable >> isSelf [ | ||
^true | ||
] | ||
|
||
{ #category : #debugging } | ||
SelfVariable >> readInContext: aContext [ | ||
^aContext receiver | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
" | ||
I model ""super"" keyword | ||
" | ||
Class { | ||
#name : #SuperVariable, | ||
#superclass : #ReservedVariable, | ||
#category : #'OpalCompiler-Core-Semantics' | ||
} | ||
|
||
{ #category : #accessing } | ||
SuperVariable class >> semanticNodeClass [ | ||
|
||
^RBSuperNode | ||
] | ||
|
||
{ #category : #emitting } | ||
SuperVariable >> emitValue: methodBuilder [ | ||
"super references the receiver, send that follows is a super send (the message lookup starts in the superclass)" | ||
methodBuilder pushReceiver | ||
] | ||
|
||
{ #category : #initialization } | ||
SuperVariable >> initialize [ | ||
super initialize. | ||
|
||
name := 'super' | ||
] | ||
|
||
{ #category : #testing } | ||
SuperVariable >> isSuper [ | ||
^true | ||
] | ||
|
||
{ #category : #debugging } | ||
SuperVariable >> readInContext: aContext [ | ||
^aContext receiver | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
" | ||
I model thisContext keyword | ||
" | ||
Class { | ||
#name : #ThisContextVariable, | ||
#superclass : #ReservedVariable, | ||
#category : #'OpalCompiler-Core-Semantics' | ||
} | ||
|
||
{ #category : #accessing } | ||
ThisContextVariable class >> semanticNodeClass [ | ||
|
||
^RBThisContextNode | ||
] | ||
|
||
{ #category : #emitting } | ||
ThisContextVariable >> emitValue: methodBuilder [ | ||
|
||
methodBuilder pushThisContext | ||
] | ||
|
||
{ #category : #initialization } | ||
ThisContextVariable >> initialize [ | ||
super initialize. | ||
|
||
name := 'thisContext' | ||
] | ||
|
||
{ #category : #testing } | ||
ThisContextVariable >> isThisContext [ | ||
^true | ||
] | ||
|
||
{ #category : #debugging } | ||
ThisContextVariable >> readInContext: aContext [ | ||
^aContext | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters