[svn:parrot] r39467 - in branches/pmc_pct/compilers/pmcc: . src src/emitter t
cotto at svn.parrot.org
cotto at svn.parrot.org
Tue Jun 9 08:40:50 UTC 2009
Author: cotto
Date: Tue Jun 9 08:40:49 2009
New Revision: 39467
URL: https://trac.parrot.org/parrot/changeset/39467
Log:
[pmcc] store vtable info as a member of the emitter and don't generate VTABLE function prototypes in the header, plus a few minor fixes
Modified:
branches/pmc_pct/compilers/pmcc/pmcc.pir
branches/pmc_pct/compilers/pmcc/src/emitter.pm
branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
branches/pmc_pct/compilers/pmcc/t/05-header.t
branches/pmc_pct/compilers/pmcc/t/07-default.t
Modified: branches/pmc_pct/compilers/pmcc/pmcc.pir
==============================================================================
--- branches/pmc_pct/compilers/pmcc/pmcc.pir Tue Jun 9 08:22:59 2009 (r39466)
+++ branches/pmc_pct/compilers/pmcc/pmcc.pir Tue Jun 9 08:40:49 2009 (r39467)
@@ -80,8 +80,10 @@
vtdump_filename = adverbs['vtdump']
if vtdump_filename != '' goto read_dump
- $P0 = getstderr
- print $P0, "Error: no vtable.freeze specified."
+ #temporary code to make manually running pmcc simpler
+ vtdump_filename = '../../vtable.frozen'
+ #$P0 = getstderr
+ #print $P0, "Error: no vtable.freeze specified."
read_dump:
$P0 = new ['FileHandle']
vtdump_str = $P0.'readall'(vtdump_filename)
@@ -91,14 +93,14 @@
$P0 = get_hll_global ['PMC';'Emitter'], '$?pmc_name'
pmc_name = $P0
+ #XXX: Splitting paths based on '/' is too simplistic.
pmc_dir = pmc_filename
$P1 = split '/', pmc_dir
$I0 = $P1
delete $P1[$I0]
pmc_dir = join '/', $P1
- $I0 = pmc_dir
- unless $I0 == 0 goto emit_files
+ unless pmc_dir == '' goto emit_files
pmc_dir = '.'
emit_files:
@@ -106,6 +108,7 @@
.local string dump_contents, c_contents, header_contents
emitter = new ['PMC';'Emitter']
+ emitter.'set_vtable_info'(vtdump)
c_filename = concat pmc_dir, '/'
c_filename = concat c_filename, pmc_name
Modified: branches/pmc_pct/compilers/pmcc/src/emitter.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter.pm Tue Jun 9 08:22:59 2009 (r39466)
+++ branches/pmc_pct/compilers/pmcc/src/emitter.pm Tue Jun 9 08:40:49 2009 (r39467)
@@ -69,6 +69,15 @@
our $?filename := $name;
}
+method vtable_info() {
+ our $?vtable_info;
+ $?vtable_info;
+}
+
+method set_vtable_info($info) {
+ our $?vtable_info := $info;
+}
+
# Get (specific) PMC emitter
# Try to create specific emitter. In case of failure create generic one.
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Tue Jun 9 08:22:59 2009 (r39466)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Tue Jun 9 08:40:49 2009 (r39467)
@@ -23,7 +23,7 @@
'#ifndef ' ~ $guard ~ "\n",
'#define ' ~ $guard ~ "\n\n",
- self.generate_header_functions(), "\n",
+ self.generate_vtable_function_prototypes(), "\n",
self.generate_attr_struct(), "\n",
@@ -467,7 +467,7 @@
method generate_signature($entry, $prefix) {
my @res;
- @res.push('PARROT_EXPORT ' ~ $entry.returns() ~ ' Parrot_' ~ self.name ~ '_' ~ $entry.name);
+ @res.push('static ' ~ $entry.returns() ~ ' Parrot_' ~ self.name ~ '_' ~ $entry.name);
@res.push('(PARROT_INTERP');
for @($entry<parameters>) {
@@ -478,6 +478,17 @@
join('', @res);
}
+method generate_vtable_function_prototypes() {
+ my @res;
+
+ @res.push('PARROT_EXPORT VTABLE* Parrot_'~ self.name ~ '_update_vtable(ARGMOD(VTABLE*));');
+ @res.push('PARROT_EXPORT VTABLE* Parrot_'~ self.name ~ '_ro_update_vtable(ARGMOD(VTABLE*));');
+ @res.push('PARROT_EXPORT VTABLE* Parrot_'~ self.name ~ '_get_vtable(ARGMOD(VTABLE*));');
+ @res.push('PARROT_EXPORT VTABLE* Parrot_'~ self.name ~ '_ro_get_vtable(ARGMOD(VTABLE*));');
+
+ join("\n", @res);
+}
+
=item C<pre_method_gen>
Method for generating PMC-specific VTABLE functions. E.g. C<default> and C<null> implementations.
Modified: branches/pmc_pct/compilers/pmcc/t/05-header.t
==============================================================================
--- branches/pmc_pct/compilers/pmcc/t/05-header.t Tue Jun 9 08:22:59 2009 (r39466)
+++ branches/pmc_pct/compilers/pmcc/t/05-header.t Tue Jun 9 08:40:49 2009 (r39467)
@@ -8,7 +8,7 @@
load_bytecode 'pmcc.pbc'
.local int total
- plan(6)
+ plan(5)
$P0 = new ['ResizableStringArray']
$P0 = split ',', 't/data'
@@ -21,10 +21,6 @@
check_one_header(filename, $S0, "'PARROT_PMC_FOO_H_GUARD'", "Guard generated")
- filename = 't/data/class07.pmc'
- $S0 = _slurp(filename)
- check_one_header(filename, $S0, "'PMC * Parrot_Integer_instantiate(PARROT_INTERP, PMC *sig, PMC* init)'", "VTable method generated")
-
.local string attr_struct
filename = 't/data/class10.pmc'
$S0 = _slurp(filename)
@@ -71,7 +67,7 @@
.end
-# Check genrated header.
+# Check generated header.
# Parse passed string, generate header, check against supplied pattern
.sub 'check_one_header'
.param string name
Modified: branches/pmc_pct/compilers/pmcc/t/07-default.t
==============================================================================
--- branches/pmc_pct/compilers/pmcc/t/07-default.t Tue Jun 9 08:22:59 2009 (r39466)
+++ branches/pmc_pct/compilers/pmcc/t/07-default.t Tue Jun 9 08:40:49 2009 (r39467)
@@ -18,7 +18,7 @@
say generated
- like($S0, "'Parrot_default_get_vtable'", "Parrot_default_get_vtable generated")
+ like(generated, "'Parrot_default_get_vtable'", "Parrot_default_get_vtable generated")
.end
# Don't forget to update plan!
More information about the parrot-commits
mailing list