add perlcompile.pod (edited content from Nathan Torkington
[p5sagit/p5-mst-13.2.git] / bytecode.pl
index 955db20..7d9b223 100644 (file)
@@ -9,7 +9,7 @@ my %alias_to = (
     U8 => [qw(char)],
 );
 
-my @optype= qw(OP UNOP BINOP LOGOP CONDOP LISTOP PMOP SVOP GVOP PVOP LOOP COP);
+my @optype= qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP GVOP PVOP LOOP COP);
 
 # Nullsv *must* come first in the following so that the condition
 # ($$sv == 0) can continue to be used to test (sv == Nullsv).
@@ -65,11 +65,23 @@ EOT
 open(BYTERUN_C, ">ext/ByteLoader/byterun.c") or die "ext/ByteLoader/byterun.c: $!";
 print BYTERUN_C $c_header, <<'EOT';
 
+#define PERL_NO_GET_CONTEXT
 #include "EXTERN.h"
 #include "perl.h"
+#define NO_XSLOCKS
+#include "XSUB.h"
+
+#ifdef PERL_OBJECT
+#undef CALL_FPTR
+#define CALL_FPTR(fptr) (pPerl->*fptr)
+#undef PL_ppaddr
+#define PL_ppaddr (*get_ppaddr())
+#endif
+
 #include "byterun.h"
 #include "bytecode.h"
 
+
 static int optype_size[] = {
 EOT
 my $i = 0;
@@ -89,7 +101,7 @@ static void **bytecode_obj_list;
 static I32 bytecode_obj_list_fill = -1;
 
 void *
-bset_obj_store(void *obj, I32 ix)
+bset_obj_store(pTHXo_ void *obj, I32 ix)
 {
     if (ix > bytecode_obj_list_fill) {
        if (bytecode_obj_list_fill == -1)
@@ -103,7 +115,7 @@ bset_obj_store(void *obj, I32 ix)
 }
 
 void
-byterun(pTHX_ struct bytestream bs)
+byterun(pTHXo_ struct bytestream bs)
 {
     dTHR;
     int insn;
@@ -196,7 +208,6 @@ struct bytestream {
 enum {
 EOT
 
-my $i = 0;
 my $add_enum_value = 0;
 my $max_insn;
 for ($i = 0; $i < @insn_name; $i++) {
@@ -221,22 +232,10 @@ for ($i = 0; $i < @optype - 1; $i++) {
     printf BYTERUN_H "    OPt_%s,\t\t/* %d */\n", $optype[$i], $i;
 }
 printf BYTERUN_H "    OPt_%s\t\t/* %d */\n};\n\n", $optype[$i], $i;
-print BYTERUN_H <<'EOT';
-EXT int PL_optype_size[]
-#ifdef DOINIT
-= {
-EOT
-for ($i = 0; $i < @optype - 1; $i++) {
-    printf BYTERUN_H "    sizeof(%s),\n", $optype[$i], $i;
-}
-printf BYTERUN_H "    sizeof(%s)\n}\n", $optype[$i], $i;
-print BYTERUN_H <<'EOT';
-#endif /* DOINIT */
-;
-
-EOT
 
 print BYTERUN_H <<'EOT';
+extern void byterun(pTHXo_ struct bytestream bs);
+
 #define INIT_SPECIALSV_LIST STMT_START { \
 EOT
 for ($i = 0; $i < @specialsv; $i++) {
@@ -314,7 +313,7 @@ xrv         SvRV(bytecode_sv)                       svindex
 xpv            bytecode_sv                             none            x
 xiv32          SvIVX(bytecode_sv)                      I32
 xiv64          SvIVX(bytecode_sv)                      IV64
-xnv            SvNVX(bytecode_sv)                      double
+xnv            SvNVX(bytecode_sv)                      NV
 xlv_targoff    LvTARGOFF(bytecode_sv)                  STRLEN
 xlv_targlen    LvTARGLEN(bytecode_sv)                  STRLEN
 xlv_targ       LvTARG(bytecode_sv)                     svindex
@@ -385,8 +384,6 @@ op_private  PL_op->op_private                       U8
 op_first       cUNOP->op_first                         opindex
 op_last                cBINOP->op_last                         opindex
 op_other       cLOGOP->op_other                        opindex
-op_true                cCONDOP->op_true                        opindex
-op_false       cCONDOP->op_false                       opindex
 op_children    cLISTOP->op_children                    U32
 op_pmreplroot  cPMOP->op_pmreplroot                    opindex
 op_pmreplrootgv        *(SV**)&cPMOP->op_pmreplroot            svindex