[svn:parrot] r44686 - in branches/ops_pct/compilers/opsc: src/Ops t
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Mar 6 11:45:46 UTC 2010
Author: bacek
Date: Sat Mar 6 11:45:44 2010
New Revision: 44686
URL: https://trac.parrot.org/parrot/changeset/44686
Log:
Add stub for emitting C source
Modified:
branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm
branches/ops_pct/compilers/opsc/t/06-emitter.t
Modified: branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm Sat Mar 6 09:50:16 2010 (r44685)
+++ branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm Sat Mar 6 11:45:44 2010 (r44686)
@@ -25,6 +25,7 @@
self<include> := "parrot/oplib/$base_ops_h";
self<header> := (~%flags<dir>) ~ "include/" ~ self<include>;
+ self<source> := (~%flags<dir>) ~ "src/ops/$base_ops_stub.c";
self<sym_export> := %flags<dynamic>
?? 'PARROT_DYNEXT_EXPORT'
@@ -68,6 +69,23 @@
self._emit_coda($fh);
}
+method print_c_source_file() {
+ # Build file in memeory
+ my $fh := pir::new__Ps('StringHandle');
+ self.emit_c_source_file($fh);
+ $fh.close();
+
+ # ... and write it to disk
+ my $final := pir::open__PSs(self<source>, 'w') || die("Can't open filehandle");
+ $final.print($fh.readall());
+ $final.close();
+ return self<source>;
+}
+
+method emit_c_source_file($fh) {
+}
+
+
# given a headerfile name like "include/parrot/oplib/core_ops.h", this
# returns a string like "PARROT_OPLIB_CORE_OPS_H_GUARD"
method _generate_guard_macro_name() {
Modified: branches/ops_pct/compilers/opsc/t/06-emitter.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/06-emitter.t Sat Mar 6 09:50:16 2010 (r44685)
+++ branches/ops_pct/compilers/opsc/t/06-emitter.t Sat Mar 6 11:45:44 2010 (r44686)
@@ -40,4 +40,16 @@
ok($header ~~ /DO \s NOT \s EDIT \s THIS \s FILE/, 'Preamble generated');
ok($header ~~ /Parrot_DynOp_core_ \d+ _ \d+ _ \d+/, '... and contains init_func');
+# Testing C emitting.
+#$emitter.print_c_source_file();
+
+$fh := pir::new__Ps('StringHandle');
+$fh.open('core.c', 'w');
+$emitter.emit_c_source_file($fh);
+
+$fh.close();
+my $source := $fh.readall();
+
+say($source);
+
# vim: expandtab shiftwidth=4 ft=perl6:
More information about the parrot-commits
mailing list