[svn:parrot] r38666 - in branches/pmc_pct: compilers/pmcc compilers/pmcc/src/emitter compilers/pmcc/t compilers/pmcc/t/data config/gen/makefiles
bacek at svn.parrot.org
bacek at svn.parrot.org
Sun May 10 03:43:53 UTC 2009
Author: bacek
Date: Sun May 10 03:43:52 2009
New Revision: 38666
URL: https://trac.parrot.org/parrot/changeset/38666
Log:
Initial support for MACRO substitution
Modified:
branches/pmc_pct/compilers/pmcc/pmcc.pir
branches/pmc_pct/compilers/pmcc/src/emitter/c.pir
branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
branches/pmc_pct/compilers/pmcc/t/06-body.t
branches/pmc_pct/compilers/pmcc/t/data/class26.pmc
branches/pmc_pct/config/gen/makefiles/pmcc.in
Modified: branches/pmc_pct/compilers/pmcc/pmcc.pir
==============================================================================
--- branches/pmc_pct/compilers/pmcc/pmcc.pir Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/compilers/pmcc/pmcc.pir Sun May 10 03:43:52 2009 (r38666)
@@ -35,6 +35,7 @@
.include 'src/gen_emitter.pir'
.include 'src/emitter/gen_pmc.pir'
+.include 'src/emitter/gen_c.pir'
.include 'src/gen_vtable_info.pir'
.include 'src/parser/gen_grammar.pir'
.include 'src/parser/gen_actions.pir'
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/c.pir
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/c.pir Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/c.pir Sun May 10 03:43:52 2009 (r38666)
@@ -21,9 +21,9 @@
=cut
-.sub 'emit'
+.sub 'emit' :method
.param pmc entry
- .tailcall '!generate_children_body_part'(entry, entry)
+ .tailcall self.'!generate_children_body_part'(entry, entry)
.end
=item C<!generate_body_part>
@@ -34,25 +34,24 @@
=cut
-.sub '!generate_body_part' :multi(_, ['PAST';'Op'])
+.sub '!generate_body_part' :method :multi(_, _, ['PAST';'Op'])
.param pmc pmclass
.param pmc past
- $S0 = past['inline']
- .return ($S0)
+ .tailcall self.'rewrite_op'(pmclass, past)
.end
-.sub '!generate_body_part' :multi(_, ['PAST';'Stmts'])
+.sub '!generate_body_part' :method :multi(_, _, ['PAST';'Stmts'])
.param pmc pmclass
.param pmc past
.local string res
res = "{\n"
- $S0 = '!generate_children_body_part'(pmclass, past)
+ $S0 = self.'!generate_children_body_part'(pmclass, past)
concat res, $S0
concat res, "}\n"
.return (res)
.end
-.sub '!generate_children_body_part'
+.sub '!generate_children_body_part' :method
.param pmc pmclass
.param pmc entry
@@ -64,7 +63,7 @@
$P1 = shift $P0
#print 'P1 '
#say $P1
- $S0 = '!generate_body_part'(pmclass, $P1)
+ $S0 = self.'!generate_body_part'(pmclass, $P1)
push res, $S0
goto loop
done:
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Sun May 10 03:43:52 2009 (r38666)
@@ -320,7 +320,7 @@
for %vtables {
my $entry := %vtables{$_};
@res.push(self.generate_signature($entry, ""));
- @res.push(PMC::Emitter::C::emit($entry));
+ @res.push(PMC::Emitter::C.new.emit($entry));
}
join('', @res);
@@ -345,7 +345,7 @@
my $past := self.past;
if ($past<class_init>) {
@res.push("/* class_init */\n");
- @res.push(PMC::Emitter::C::emit($past<class_init>));
+ @res.push(PMC::Emitter::C.new().emit($past<class_init>));
}
@res.push("\n}\n");
Modified: branches/pmc_pct/compilers/pmcc/t/06-body.t
==============================================================================
--- branches/pmc_pct/compilers/pmcc/t/06-body.t Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/compilers/pmcc/t/06-body.t Sun May 10 03:43:52 2009 (r38666)
@@ -8,7 +8,7 @@
load_bytecode 'pmcc.pbc'
.local int total
- plan(4)
+ plan(7)
.local string filename
@@ -21,8 +21,15 @@
$S0 = _slurp('t/data/class14.pmc')
check_one_file(filename, $S0, "'Small_Object_Pool *List_chunks'", "class_init body almost preserved")
+
+ filename = 't/data/class26.pmc'
+ $S0 = _slurp('t/data/class26.pmc')
+ check_one_file(filename, $S0, "'VTABLE_Integer_decrement(interp, pmc)'", "SELF.decrement was rewriten")
+ check_one_file(filename, $S0, "'VTABLE_Integer_add_int'", "SELF.add_int was rewriten")
+ check_one_file(filename, $S0, "'VTABLE_Integer_add_int(interp, pmc, 2)'", "SELF.add_int was rewriten")
.end
+
# Check genrated header.
# Parse passed string, generate header, check against supplied pattern
.sub 'check_one_file'
Modified: branches/pmc_pct/compilers/pmcc/t/data/class26.pmc
==============================================================================
--- branches/pmc_pct/compilers/pmcc/t/data/class26.pmc Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/compilers/pmcc/t/data/class26.pmc Sun May 10 03:43:52 2009 (r38666)
@@ -1,8 +1,8 @@
pmclass Integer {
VTABLE void increment() {
+ SELF.decrement();
if (1) {
SELF.add_int(2);
}
- SELF.dec_int(1);
}
}
Modified: branches/pmc_pct/config/gen/makefiles/pmcc.in
==============================================================================
--- branches/pmc_pct/config/gen/makefiles/pmcc.in Sun May 10 03:43:22 2009 (r38665)
+++ branches/pmc_pct/config/gen/makefiles/pmcc.in Sun May 10 03:43:52 2009 (r38666)
@@ -18,8 +18,10 @@
pmcc.pir \
src/nodes.pir \
src/vtable_info.pir \
+ src/emitter/pmc.pir \
src/emitter/gen_pmc.pir \
src/emitter/c.pir \
+ src/emitter/gen_c.pir \
src/parser/gen_grammar.pir \
src/parser/gen_actions.pir \
src/gen_emitter.pir \
@@ -45,6 +47,10 @@
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/emitter/gen_pmc.pir \
--target=pir src/emitter/pmc.pm
+src/emitter/gen_c.pir: $(NQP) $(PCT) src/emitter/c.pm
+ $(PARROT) $(PARROT_ARGS) $(NQP) --output=src/emitter/gen_c.pir \
+ --target=pir src/emitter/c.pm
+
src/gen_emitter.pir: $(NQP) $(PCT) src/emitter.pm
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_emitter.pir \
--target=pir src/emitter.pm
@@ -59,7 +65,7 @@
@echo ""
@echo "Following targets are available for the user:"
@echo ""
- @echo " all: nqp.pbc"
+ @echo " all: pmcc.pbc"
@echo " This is the default."
@echo "Testing:"
@echo " test: Run the test suite."
@@ -86,6 +92,7 @@
src/parser/gen_actions.pir \
src/gen_emitter.pir \
src/emitter/gen_pmc.pir \
+ src/emitter/gen_c.pir \
src/gen_vtable_info.pir
More information about the parrot-commits
mailing list