[svn:parrot] r44856 - in branches/ops_pct/compilers/opsc: . src/Ops src/Ops/Compiler src/Ops/Trans
cotto at svn.parrot.org
cotto at svn.parrot.org
Wed Mar 10 17:20:57 UTC 2010
Author: cotto
Date: Wed Mar 10 17:20:53 2010
New Revision: 44856
URL: https://trac.parrot.org/parrot/changeset/44856
Log:
[opsc] make jump flags accessible to Trans, remove a mostly-done TODO item
Modified:
branches/ops_pct/compilers/opsc/TODO
branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm
branches/ops_pct/compilers/opsc/src/Ops/Op.pm
branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
Modified: branches/ops_pct/compilers/opsc/TODO
==============================================================================
--- branches/ops_pct/compilers/opsc/TODO Wed Mar 10 10:19:00 2010 (r44855)
+++ branches/ops_pct/compilers/opsc/TODO Wed Mar 10 17:20:53 2010 (r44856)
@@ -13,16 +13,3 @@
Nice to have:
* Profiling and performance tuning of ops parsing (we need pmichaud).
* Use ops.num for assigning Op.code.
- * Generate something more meaningfull for Ops::Op.body instead of munched string.
- E.g. "{ ...; restart OFFSET($1); ... };" can generate something like:
- Block (
- Op(:inline, '...'),
- Op(:call, :name('restart_offset'),
- Var(:name('$1'))
- ),
- Op(:inline, '...'),
- )
- and Op.source will generate end-code recursively as any other compilers do.
- Problems:
- - LTM still doesn't work.
- - "munch_body" is reverting natural flow of PCT.
Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm Wed Mar 10 10:19:00 2010 (r44855)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm Wed Mar 10 17:20:53 2010 (r44856)
@@ -81,7 +81,9 @@
$op.push($_);
}
- # FIXME op.jump($<op_body>.ast<jump>);
+ for $<op_body>.ast<jump> {
+ $op.add_jump($_);
+ }
$op<flags> := %flags;
$op<args> := @args;
$op<type> := ~$<op_type>;
@@ -233,7 +235,7 @@
my $past := PAST::Stmts.new(
:node($/),
);
- $past<jump> := 0;
+ $past<jump> := list();
my $prev_words := '';
for $<body_word> {
if $prev_words && $_<word> {
@@ -254,6 +256,9 @@
}
elsif $_<op_macro> {
$past.push($_<op_macro>.ast);
+ for $_<op_macro>.ast<jump> {
+ $past<jump>.push($_);
+ }
}
}
}
@@ -298,15 +303,18 @@
method op_macro($/) {
#say('# op_macro');
my $macro_name := ~$<macro_type> ~ '_' ~ lc(~$<macro_destination>);
- #if $macro_name eq 'restart_offset' || $macro_name eq 'goto_offset' {
- # $past<jump> := 'PARROT_JUMP_RELATIVE';
- #}
my $past := PAST::Op.new(
:pasttype('call'),
:name($macro_name),
);
+ $past<jump> := list();
+
+ if $macro_name eq 'restart_offset' || $macro_name eq 'goto_offset' {
+ $past<jump>.push('PARROT_JUMP_RELATIVE');
+ }
+
for $<body_word> {
$past.push($_.ast);
}
Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm Wed Mar 10 10:19:00 2010 (r44855)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm Wed Mar 10 17:20:53 2010 (r44856)
@@ -128,13 +128,6 @@
]
}
-rule macro_arg {
- #XXX; needs to match balanced parens
- '('
- <body_word>*?
- ')'
-}
-
token identifier {
<.ident>
}
Modified: branches/ops_pct/compilers/opsc/src/Ops/Op.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Op.pm Wed Mar 10 10:19:00 2010 (r44855)
+++ branches/ops_pct/compilers/opsc/src/Ops/Op.pm Wed Mar 10 17:20:53 2010 (r44856)
@@ -199,6 +199,50 @@
=begin
+=item C<add_jump($jump)>
+
+=item C<add_jump($jump)>
+
+Add a jump flag to this op if it's not there already.
+
+=end
+
+method add_jump($jump) {
+ my $found_jump := 0;
+
+ unless self.jump { self.jump(list()) }
+
+ for self.jump {
+ if $_ eq $jump { $found_jump := 1 }
+ }
+
+ unless $found_jump {
+ self.jump.push($jump);
+ }
+}
+
+=begin
+
+=item C<get_jump()>
+
+=item C<get_jump()>
+
+Get the jump flags that apply to this op.
+
+=end
+
+method get_jump() {
+
+ if self.jump {
+ return join( '|', |self.jump );
+ }
+ else {
+ return '0';
+ }
+}
+
+=begin
+
=item C<source($trans, $op)>
Returns the L<C<body()>> of the op with substitutions made by
Modified: branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm Wed Mar 10 10:19:00 2010 (r44855)
+++ branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm Wed Mar 10 17:20:53 2010 (r44856)
@@ -197,7 +197,7 @@
my $full_name := $op.full_name;
my $func_name := $op.func_name( self );
my $body := $op.body;
- my $jump := $op.jump;
+ my $jump := $op.get_jump;
my $arg_count := $op.size;
## 0 inserted if arrays are empty to prevent msvc compiler errors
More information about the parrot-commits
mailing list