79 lines
1.8 KiB
Smalltalk
79 lines
1.8 KiB
Smalltalk
Class {
|
|
#name : 'PPCPassVisitor',
|
|
#superclass : 'PPCNodeVisitor',
|
|
#instVars : [
|
|
'context'
|
|
],
|
|
#category : 'PetitCompiler-Visitors'
|
|
}
|
|
|
|
{ #category : 'converting' }
|
|
PPCPassVisitor class >> asPPCPass [
|
|
^ self new
|
|
|
|
"Created: / 29-08-2015 / 07:12:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
]
|
|
|
|
{ #category : 'converting' }
|
|
PPCPassVisitor >> asPPCPass [
|
|
^ self
|
|
|
|
"Created: / 29-08-2015 / 07:13:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCPassVisitor >> context [
|
|
^ context
|
|
]
|
|
|
|
{ #category : 'accessing' }
|
|
PPCPassVisitor >> context: aPPCCompilationContext [
|
|
context := aPPCCompilationContext.
|
|
|
|
"Created: / 26-08-2015 / 22:05:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
]
|
|
|
|
{ #category : 'history' }
|
|
PPCPassVisitor >> copyPassResult: result [
|
|
^ result transform: [ :e | e copy ]
|
|
]
|
|
|
|
{ #category : 'history' }
|
|
PPCPassVisitor >> passName [
|
|
^ self class name
|
|
]
|
|
|
|
{ #category : 'history' }
|
|
PPCPassVisitor >> rememberResult: result to: history [
|
|
| key value |
|
|
key := self passName.
|
|
value := self copyPassResult: result.
|
|
|
|
history add: key -> value
|
|
]
|
|
|
|
{ #category : 'running' }
|
|
PPCPassVisitor >> run: ir [
|
|
"Actually run the pass on given IR (tree of PPCNode) and return
|
|
(possibly transformed or completely new) another IR."
|
|
|
|
context isNil ifTrue:[
|
|
PPCCompilationError new signal: 'oops, no context set, use #context: before running a pass!'.
|
|
].
|
|
^ self visit: ir.
|
|
|
|
"Created: / 26-08-2015 / 22:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
]
|
|
|
|
{ #category : 'running' }
|
|
PPCPassVisitor >> run: ir in: ctx [
|
|
"Actually run the pass on given IR (tree of PPCNode) in given
|
|
compilation context and return (possibly transformed or completely
|
|
new) another IR."
|
|
|
|
context := ctx.
|
|
^ self run: ir.
|
|
|
|
"Created: / 26-08-2015 / 22:33:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
]
|