The attached patch is broken because of lack of flag space.

I coded it up this morning. It wasn't too bad except that we have run out of PObj flags in which to store sub attributes.
Ideas?

Also how do I get flex and bison to regen the grammar?
I made real clean
perl Configure.pl --maintainer

But I'm still getting this error because then new token type INIT hasn't been generated by lex and bison.

Compiling with:
xx.c
cc -I./include -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I /usr/include -g -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Winline -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings -Waggregate-return -Winline -Wno-unused -Wlarger-than-4096 -Wsign-compare -falign-functions=16 -Wformat-nonliteral -Wformat-security -Wpacked -Wdisabled-optimization -mno-accumulate-outgoing-args -Wno-shadow -DHAS_JIT -DI386 -DHAVE_COMPUTED_GOTO -fPIC -I. -o xx.o -c xx.c
compilers/imcc/main.c
compilers/imcc/main.c: In function ‘do_pre_process’:
compilers/imcc/main.c:476: error: ‘INIT’ undeclared (first use in this function) compilers/imcc/main.c:476: error: (Each undeclared identifier is reported only once
compilers/imcc/main.c:476: error: for each function it appears in.)
make: *** [compilers/imcc/main.o] Error 1

Kevin
=== compilers/imcc/imcc.l
==================================================================
--- compilers/imcc/imcc.l       (revision 290)
+++ compilers/imcc/imcc.l       (local)
@@ -276,6 +276,7 @@
 <emit,INITIAL>":multi"   return(MULTI);
 <emit,INITIAL>":main"    return(MAIN);
 <emit,INITIAL>":load"    return(LOAD);
+<emit,INITIAL>":init"    return(INIT);
 <emit,INITIAL>":immediate"    return(IMMEDIATE);
 <emit,INITIAL>":postcomp"    return(POSTCOMP);
 <emit,INITIAL>":anon"    return(ANON);
=== compilers/imcc/imcc.y
==================================================================
--- compilers/imcc/imcc.y       (revision 290)
+++ compilers/imcc/imcc.y       (local)
@@ -412,7 +412,7 @@
 %token <t> COMMA ESUB DOTDOT
 %token <t> PCC_BEGIN PCC_END PCC_CALL PCC_SUB PCC_BEGIN_RETURN PCC_END_RETURN
 %token <t> PCC_BEGIN_YIELD PCC_END_YIELD NCI_CALL METH_CALL INVOCANT
-%token <t> MAIN LOAD IMMEDIATE POSTCOMP METHOD ANON OUTER NEED_LEX
+%token <t> MAIN LOAD INIT IMMEDIATE POSTCOMP METHOD ANON OUTER NEED_LEX
 %token <t> MULTI LOADLIB
 %token <t> UNIQUE_REG
 %token <s> LABEL
@@ -804,6 +804,7 @@
 
 proto:
      LOAD           {  $$ = P_LOAD; }
+   | INIT           {  $$ = P_INIT; }
    | MAIN           {  $$ = P_MAIN; }
    | IMMEDIATE      {  $$ = P_IMMEDIATE; }
    | POSTCOMP       {  $$ = P_POSTCOMP; }
=== compilers/imcc/main.c
==================================================================
--- compilers/imcc/main.c       (revision 290)
+++ compilers/imcc/main.c       (local)
@@ -473,6 +473,7 @@
 
             case MAIN:          printf(":main");break;
             case LOAD:          printf(":load");break;
+            case INIT:          printf(":init");break;
             case IMMEDIATE:     printf(":immediate");break;
             case POSTCOMP:      printf(":postcomp");break;
             case ANON:          printf(":anon");break;
=== compilers/imcc/symreg.h
==================================================================
--- compilers/imcc/symreg.h     (revision 290)
+++ compilers/imcc/symreg.h     (local)
@@ -143,6 +143,7 @@
        P_ANON           = SUB_FLAG_PF_ANON,  /* 0x8 - private3 */
 
        P_MAIN           = SUB_FLAG_PF_MAIN,
+       P_INIT           = SUB_FLAG_PF_INIT,
        P_LOAD           = SUB_FLAG_PF_LOAD,
        P_IMMEDIATE      = SUB_FLAG_PF_IMMEDIATE,
        P_POSTCOMP       = SUB_FLAG_PF_POSTCOMP
=== ext/Parrot-Embed/Build.PL
==================================================================
--- ext/Parrot-Embed/Build.PL   (revision 290)
+++ ext/Parrot-Embed/Build.PL   (local)
@@ -9,6 +9,8 @@
 my ($cflags, $lflags) = get_compiler_flags( $in_parrot_tree );
 my $parrot            = get_parrot_path( $in_parrot_tree );
 
+print "in_parrot_tree: $in_parrot_tree clags: $cflags lflags: $lflags parrot: 
$parrot \n";
+
 my $class = Module::Build->subclass(
        code => <<"END_HERE",
        use Cwd;
=== include/parrot/packfile.h
==================================================================
--- include/parrot/packfile.h   (revision 290)
+++ include/parrot/packfile.h   (local)
@@ -254,7 +254,8 @@
     PBC_LOADED = 2,
     PBC_PBC    = 4,
     PBC_IMMEDIATE = 8,
-    PBC_POSTCOMP  = 16
+    PBC_POSTCOMP  = 16,
+    PBC_INIT  = 32
 } pbc_action_enum_t;
 
 PARROT_API void PackFile_fixup_subs(Interp *, pbc_action_enum_t, PMC 
*eval_pmc);
=== include/parrot/sub.h
==================================================================
--- include/parrot/sub.h        (revision 290)
+++ include/parrot/sub.h        (local)
@@ -33,6 +33,7 @@
     SUB_FLAG_PF_ANON      = PObj_private3_FLAG,
     SUB_FLAG_PF_MAIN      = PObj_private4_FLAG,
     SUB_FLAG_PF_LOAD      = PObj_private5_FLAG,
+    SUB_FLAG_PF_INIT      = PObj_private5_FLAG,
     SUB_FLAG_PF_IMMEDIATE = PObj_private6_FLAG,
     SUB_FLAG_PF_POSTCOMP  = PObj_private7_FLAG,
 
=== src/packfile.c
==================================================================
--- src/packfile.c      (revision 290)
+++ src/packfile.c      (local)
@@ -239,6 +239,8 @@
                  */
                 todo = 1;
             }
+            if (pragmas & SUB_FLAG_PF_INIT) /* symreg.h:P_INIT */
+                todo = 1;
             break;
         case PBC_LOADED:
             if (pragmas & SUB_FLAG_PF_LOAD) /* symreg.h:P_LOAD */
@@ -359,6 +361,12 @@
                                 ":main sub not allowed\n");
                 }
             }
+            /* run :init tagged functions */
+            if (PObj_get_FLAGS(sub_pmc) & SUB_FLAG_PF_INIT) {
+                PObj_get_FLAGS(sub_pmc) &= ~SUB_FLAG_PF_INIT;
+                run_sub(interpreter, sub_pmc);
+            }
+            break;
     }
     return NULL;
 }
@@ -425,7 +433,7 @@
    int action, PMC *eval_pmc)>
 
 B<action> is one of
-B<PBC_PBC>, B<PBC_LOADED>, or B<PBC_MAIN>. Also store the C<eval_pmc>
+B<PBC_PBC>, B<PBC_LOADED>, B<PBC_INIT>, or B<PBC_MAIN>. Also store the 
C<eval_pmc>
 in the sub structure, so that the eval PMC is kept alive be living subs.
 
 =cut
@@ -3551,7 +3559,7 @@
 /*
 
 =item C<void
-PackFile_fixup_subs(Interp *interpreter, pbc_action_enum_t, PMC *eval)>
+PackFile_fixup_subs(Interp *interpreter, pbc_action_enum_t what, PMC *eval)>
 
 Run :load or :immediate subroutines for the current code segment.
 If C<eval> is given, set this is the owner of the subroutines.

Reply via email to