[svn:parrot] r42945 - trunk/compilers/imcc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Dec 8 11:04:30 UTC 2009


Author: chromatic
Date: Tue Dec  8 11:04:28 2009
New Revision: 42945
URL: https://trac.parrot.org/parrot/changeset/42945

Log:
[PBC] Revised r42940 so that subs marked both :anon and :immediate *do* run
immediately even when emitting PBC, but subs marked :immediate do not, so that
they have the opportunity to run when *running* the PBC.  This has a faint odor
to it, but until and unless we get a better syntax or heuristic for identifying
code which has to run while emitting PBC or when starting the program, this is
the way things have to be.  Note that if you want to HLL map your own custom
Sub type (as seen in t/pmc/sub.t test #47), do the :anon and :immediate dance.

Modified:
   trunk/compilers/imcc/main.c
   trunk/compilers/imcc/pbc.c

Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c	Tue Dec  8 11:04:21 2009	(r42944)
+++ trunk/compilers/imcc/main.c	Tue Dec  8 11:04:28 2009	(r42945)
@@ -786,6 +786,7 @@
 
     /* runs :init functions */
     PackFile_fixup_subs(interp, PBC_IMMEDIATE, NULL);
+    PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
     PackFile_fixup_subs(interp, PBC_MAIN, NULL);
 
     Parrot_runcode(interp, argc, argv);
@@ -979,7 +980,7 @@
     fclose(imc_yyin_get(yyscanner));
 
     IMCC_info(interp, 1, "%ld lines compiled.\n", IMCC_INFO(interp)->line);
-    if (per_pbc)
+    if (per_pbc && !IMCC_INFO(interp)->write_pbc)
         PackFile_fixup_subs(interp, PBC_POSTCOMP, NULL);
 }
 

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	Tue Dec  8 11:04:21 2009	(r42944)
+++ trunk/compilers/imcc/pbc.c	Tue Dec  8 11:04:28 2009	(r42945)
@@ -1990,9 +1990,6 @@
     if (!unit->instructions)
         return 0;
 
-    if (IMCC_INFO(interp)->write_pbc)
-        return 0;
-
     /*
      * if the sub was marked IMMEDIATE, we run it now
      * This is *dangerous*: all possible global state can be messed
@@ -2006,7 +2003,11 @@
 
     pragma = ins->symregs[0]->pcc_sub->pragma;
 
-    if (pragma & P_IMMEDIATE) {
+    if (IMCC_INFO(interp)->write_pbc && !(pragma & P_ANON))
+        return 0;
+
+    if (pragma & P_IMMEDIATE
+    && (!IMCC_INFO(interp)->write_pbc || (pragma & P_ANON))) {
         /* clear global symbols temporarily -- TT #1324, for example */
         imcc_globals *g      = IMCC_INFO(interp)->globals;
         SymHash       ghash;


More information about the parrot-commits mailing list