Permalink
Browse files

Add PAST::Optimizer and PAST::Optimizer::Pass.

  • Loading branch information...
1 parent 91e9a41 commit c7ba4aa04b71bada93f9d428c32d669eff6de2c7 tcurtis committed Aug 8, 2010
Showing with 53 additions and 0 deletions.
  1. +12 −0 setup.nqp
  2. +16 −0 src/PAST/Optimizer.nqp
  3. +5 −0 src/PAST/Optimizer/CombinedPass.nqp
  4. +5 −0 src/PAST/Optimizer/Pass.nqp
  5. +15 −0 src/PAST/Optimizer/Transformers.nqp
View
@@ -22,6 +22,10 @@ sub MAIN() {
# build
pir_nqp => unflatten(
+ 'build/PAST/Optimizer.pir', 'src/PAST/Optimizer.nqp',
+ 'build/PAST/Optimizer/CombinedPass.pir', 'src/PAST/Optimizer/CombinedPass.nqp',
+ 'build/PAST/Optimizer/Pass.pir', 'src/PAST/Optimizer/Pass.nqp',
+ 'build/PAST/Optimizer/Transformers.pir', 'src/PAST/Optimizer/Transformers.nqp',
'build/PAST/Pattern.pir', 'src/PAST/Pattern.nqp',
'build/PAST/Pattern/Transformer.pir', 'src/PAST/Pattern/Transformer.nqp',
'build/PAST/Transformer.pir', 'src/PAST/Transformer.nqp',
@@ -44,6 +48,10 @@ sub MAIN() {
'build/Tree/Walker.pir', 'src/Tree/Walker.nqp',
),
pbc_pir => unflatten(
+ 'build/PAST/Optimizer.pbc', 'build/PAST/Optimizer.pir',
+ 'build/PAST/Optimizer/CombinedPass.pbc', 'build/PAST/Optimizer/CombinedPass.pir',
+ 'build/PAST/Optimizer/Pass.pbc', 'build/PAST/Optimizer/Pass.pir',
+ 'build/PAST/Optimizer/Transformers.pbc', 'build/PAST/Optimizer/Transformers.pir',
'build/PAST/Pattern.pbc', 'build/PAST/Pattern.pir',
'build/PAST/Pattern/Transformer.pbc', 'build/PAST/Pattern/Transformer.pir',
'build/PAST/Transformer.pbc', 'build/PAST/Transformer.pir',
@@ -73,6 +81,10 @@ sub MAIN() {
# install
inst_lib => <
+ build/PAST/Optimizer.pbc
+ build/PAST/Optimizer/CombinedPass.pbc
+ build/PAST/Optimizer/Pass.pbc
+ build/PAST/Optimizer/Transformers.pbc
build/PAST/Pattern.pbc
build/PAST/Pattern/Transformer.pbc
build/PAST/Transformer.pbc
@@ -0,0 +1,16 @@
+INIT {
+ pir::load_bytecode('Tree/Optimizer.pbc');
+ pir::load_bytecode('PAST/Optimizer/Pass.pbc');
+ pir::load_bytecode('PAST/Optimizer/CombinedPass.pbc');
+ pir::load_bytecode('PAST/Optimizer/Transformers.pbc');
+}
+
+class PAST::Optimizer is Tree::Optimizer;
+
+method pass-class () {
+ PAST::Optimizer::Pass;
+}
+
+method combine-passes (*@passes) {
+ PAST::Optimizer::CombinedPass.new(@passes);
+}
@@ -0,0 +1,5 @@
+class PAST::Optimizer::CombinedPass is Tree::Optimizer::CombinedPass;
+
+method transformer-class () {
+ PAST::Optimizer::Transformer::Combined;
+}
@@ -0,0 +1,5 @@
+class PAST::Optimizer::Pass is Tree::Optimizer::Pass;
+
+method transformer-class () {
+ PAST::Optimizer::Transformer::Single;
+}
@@ -0,0 +1,15 @@
+class PAST::Optimizer::Transformer::Single
+ is Tree::Optimizer::Transformer::Single { }
+
+class PAST::Optimizer::Transformer::Combined
+ is Tree::Optimizer::Transformer::Combined { }
+
+INIT {
+ pir::load_bytecode('PAST/Transformer.pbc');
+ my $class := PAST::Optimizer::Transformer::Single;
+ $class.HOW.add_parent($class,
+ PAST::Transformer);
+ $class := PAST::Optimizer::Transformer::Combined;
+ $class.HOW.add_parent($class,
+ PAST::Transformer);
+}

0 comments on commit c7ba4aa

Please sign in to comment.