[svn:parrot] r44675 - branches/ops_pct/compilers/opsc/src/Ops

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Mar 6 01:38:21 UTC 2010


Author: bacek
Date: Sat Mar  6 01:38:20 2010
New Revision: 44675
URL: https://trac.parrot.org/parrot/changeset/44675

Log:
Add more stubs for Ops body rewriting

Modified:
   branches/ops_pct/compilers/opsc/src/Ops/Op.pm

Modified: branches/ops_pct/compilers/opsc/src/Ops/Op.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Op.pm	Sat Mar  6 01:37:56 2010	(r44674)
+++ branches/ops_pct/compilers/opsc/src/Ops/Op.pm	Sat Mar  6 01:38:20 2010	(r44675)
@@ -188,15 +188,24 @@
 
 =begin
 
-=begin
+=item C<source($trans)>
 
-# Called from rewrite_body() to perform the actual substitutions.
-sub _substitute {
-    my $self           = shift;
-    local $_           = shift;
-    my $trans          = shift;
-    my $preamble_only  = shift;
+Returns the L<C<body()>> of the op with substitutions made by
+C<$trans> (a subclass of C<Ops::Trans>).
+
+=end
+
+method source( $trans ) {
+
+    my $prelude := $trans.body_prelude;
+    self.rewrite_body( $prelude ~ self.body, $trans );
+}
 
+
+# Called from rewrite_body() to perform the actual substitutions.
+method _substitute($str, $trans) {
+    $str;
+=begin
     my $rewrote_access =
         s/{{\@([^{]*?)}}/   $trans->access_arg($self->arg_type($1 - 1), $1, $self); /me;
 
@@ -217,8 +226,11 @@
     s/{{\^([^{]*?)}}/     $trans->expr_address($1); /me;
 
     return $_;
+=end
 }
 
+=begin
+
 =item C<rewrite_body($body, $trans, [$preamble])>
 
 Performs the various macro substitutions using the specified transform,
@@ -228,55 +240,29 @@
 C<VTABLE_> macros are enforced by converting C<<< I<< x >>->vtable->I<<
 method >> >>> to C<VTABLE_I<method>>.
 
-=cut
+=end
 
-sub rewrite_body {
-    my ( $self, $body, $trans, $preamble_only ) = @_;
+method rewrite_body( $body, $trans ) {
 
     # use vtable macros
-    $body =~ s!
-        (?:
-            {{\@\d+\}}
-            |
-            \b\w+(?:->\w+)*
-        )->vtable->\s*(\w+)\(
-        !VTABLE_$1(!sgx;
+#    $body =~ s!
+#        (?:
+#            {{\@\d+\}}
+#            |
+#            \b\w+(?:->\w+)*
+#        )->vtable->\s*(\w+)\(
+#        !VTABLE_$1(!sgx;
 
     while (1) {
-        my $new_body = $self->_substitute( $body, $trans, !!$preamble_only );
+        my $new_body := self._substitute( $body, $trans );
 
-        last if $body eq $new_body;
+        return $body if $body eq $new_body;
 
-        $body = $new_body;
+        $body := $new_body;
     }
-
-    return $body;
 }
 
-=item C<source($trans)>
-
-Returns the L<C<full_body()>> of the op with substitutions made by
-C<$trans> (a subclass of C<Ops::OpTrans>).
-
-=cut
-
-sub source {
-    my ( $self, $trans ) = @_;
-
-    my $flags = $self->flags;
-
-    if (exists($$flags{pic})
-        && !( ref($trans) eq 'Ops::OpTrans::CGP' || ref($trans) eq 'Ops::OpTrans::CSwitch' ) )
-    {
-        return qq{PANIC(interp, "How did you do that");\n};
-    }
-
-    my $prelude = $trans->can( 'add_body_prelude' )
-                ? $trans->add_body_prelude()
-                : '';
-
-    return $self->rewrite_body( $prelude . $self->full_body, $trans );
-}
+=begin
 
 =item C<size()>
 


More information about the parrot-commits mailing list