[svn:parrot] r46647 - branches/ops_pct/compilers/opsc

bacek at svn.parrot.org bacek at svn.parrot.org
Sat May 15 08:10:29 UTC 2010


Author: bacek
Date: Sat May 15 08:10:28 2010
New Revision: 46647
URL: https://trac.parrot.org/parrot/changeset/46647

Log:
Generate oplib/ops.h from ops2c.

Modified:
   branches/ops_pct/compilers/opsc/ops2c.nqp

Modified: branches/ops_pct/compilers/opsc/ops2c.nqp
==============================================================================
--- branches/ops_pct/compilers/opsc/ops2c.nqp	Sat May 15 05:29:04 2010	(r46646)
+++ branches/ops_pct/compilers/opsc/ops2c.nqp	Sat May 15 08:10:28 2010	(r46647)
@@ -84,6 +84,54 @@
     :flags( hash( core => $core ) ),
 );
 
+if $core {
+    # Emit oplib/ops.h
+    # TODO Move it somewhere else and test it properly.
+    my $ops_h := pir::open__Ps("include/parrot/oplib/ops.h_tmp", "w")
+                      || die("Can't open ops.h");
+
+    $ops_h.print(q|
+/* ex: set ro:
+ * !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
+ *
+ * This file is generated automatically from 'src/ops/core.ops'
+ * by ops2c.
+ *
+ * Any changes made here will be lost!
+ */
+
+#ifndef PARROT_OPS_H_GUARD
+#define PARROT_OPS_H_GUARD
+
+typedef enum {
+|);
+
+    my $sb := pir::new__Ps('StringBuilder');
+    for $f.ops -> $op {
+        $sb.append_format("    PARROT_OP_%0, %1 /* %2 */\n",
+                $op.full_name,
+                pir::repeat__SsI(' ', 30 - pir::length__Is($op.full_name)),
+                $op.code);
+    }
+
+    $ops_h.print(~$sb);
+
+    $ops_h.print(q|
+} parrot_opcode_enums;
+
+#endif /* PARROT_OPS_H_GUARD */
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
+    |);
+
+    $ops_h.close;
+}
+
 $emitter.print_c_header_file();
 $emitter.print_c_source_file();
 


More information about the parrot-commits mailing list