More minor Fixes in CC.pm/C.pm
Vishal Bhatia [Wed, 16 Dec 1998 03:17:03 +0000 (05:17 +0200)]
To: perl5-porters@perl.org
Message-ID: <MLIST_199812160055.QAA06272@f10.hotmail.com>

p4raw-id: //depot/cfgperl@2525

ext/B/B/C.pm
ext/B/B/CC.pm
ext/B/B/Stackobj.pm

index baf6def..95c5858 100644 (file)
@@ -1274,6 +1274,7 @@ sub descend_marked_unused {
 sub save_main {
     warn "Starting compile\n";
     warn "Walking tree\n";
+    seek(STDOUT,0,0); #exclude print statements in BEGIN{} into output
     walkoptree(main_root, "save");
     warn "done main optree, walking symtable for extras\n" if $debug_cv;
     save_unused_subs();
index 391a787..e4f8877 100644 (file)
@@ -662,11 +662,15 @@ sub numeric_binop {
            }
        } else {
            if ($force_int) {
+               my $rightruntime = new B::Pseudoreg ("IV", "riv");
+               runtime(sprintf("$$rightruntime = %s;",$right));
                runtime(sprintf("sv_setiv(TOPs, %s);",
-                               &$operator("TOPi", $right)));
+                               &$operator("TOPi", $$rightruntime)));
            } else {
+               my $rightruntime = new B::Pseudoreg ("double", "rnv");
+               runtime(sprintf("$$rightruntime = %s;",$right));
                runtime(sprintf("sv_setnv(TOPs, %s);",
-                               &$operator("TOPn", $right)));
+                               &$operator("TOPn",$$rightruntime)));
            }
        }
     } else {
@@ -1405,6 +1409,7 @@ sub cc_main {
                     );
                  
     }
+    seek(STDOUT,0,0); #prevent print statements from BEGIN{} into the output
     output_boilerplate();
     print "\n";
     output_all("perl_init");
index 3f7f0f7..09a3e90 100644 (file)
@@ -26,6 +26,7 @@ sub SVf_NOK () { 0x20000 }
 sub T_UNKNOWN () { 0 }
 sub T_DOUBLE ()  { 1 }
 sub T_INT ()     { 2 }
+sub T_SPECIAL () { 3 }
 
 # Flags
 sub VALID_INT ()       { 0x01 }
@@ -224,17 +225,21 @@ sub B::Stackobj::Const::new {
        flags => 0,
        sv => $sv    # holds the SV object until write_back happens
     }, $class;
-    my $svflags = $sv->FLAGS;
-    if ($svflags & SVf_IOK) {
-       $obj->{flags} = VALID_INT|VALID_DOUBLE;
-       $obj->{type} = T_INT;
-       $obj->{nv} = $obj->{iv} = $sv->IV;
-    } elsif ($svflags & SVf_NOK) {
-       $obj->{flags} = VALID_INT|VALID_DOUBLE;
-       $obj->{type} = T_DOUBLE;
-       $obj->{iv} = $obj->{nv} = $sv->NV;
-    } else {
-       $obj->{type} = T_UNKNOWN;
+    if ( ref($sv) eq  "B::SPECIAL" ){
+       $obj->{type}= T_SPECIAL;        
+    }else{
+       my $svflags = $sv->FLAGS;
+       if ($svflags & SVf_IOK) {
+               $obj->{flags} = VALID_INT|VALID_DOUBLE;
+               $obj->{type} = T_INT;
+               $obj->{nv} = $obj->{iv} = $sv->IV;
+       } elsif ($svflags & SVf_NOK) {
+               $obj->{flags} = VALID_INT|VALID_DOUBLE;
+               $obj->{type} = T_DOUBLE;
+               $obj->{iv} = $obj->{nv} = $sv->NV;
+       } else {
+               $obj->{type} = T_UNKNOWN;
+       }
     }
     return $obj;
 }