compiler/PPCPass.st
changeset 532 132d7898a2a1
child 534 a949c4fe44df
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCPass.st	Wed Aug 26 23:01:00 2015 +0100
@@ -0,0 +1,55 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+"{ NameSpace: Smalltalk }"
+
+PPCNodeVisitor subclass:#PPCPass
+	instanceVariableNames:'context'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Visitors'
+!
+
+!PPCPass class methodsFor:'running'!
+
+run: ir in: context
+    "Run the pass on passed IR in given compilation context.
+     Return (possibly transformed or completely new) IR."
+
+    ^ self new run: ir in: context
+
+    "Created: / 26-08-2015 / 22:31:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPCPass methodsFor:'accessing'!
+
+context: aPPCCompilationContext
+    context := aPPCCompilationContext.
+
+    "Created: / 26-08-2015 / 22:05:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPCPass methodsFor:'running'!
+
+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>"
+!
+
+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>"
+! !
+