From df1ec6e81258e8af6ea6ca0e1654b075f42ae781 Mon Sep 17 00:00:00 2001
From: Chris Dolan <chris@chrisdolan.net>
Date: Fri, 13 Feb 2009 23:00:57 -0600
Subject: [PATCH] Support using $? variables and implement $?PROGRAM

---
 src/builtins/guts.pir |    7 ++++++-
 src/parser/actions.pm |    6 ++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/builtins/guts.pir b/src/builtins/guts.pir
index 69cd7d0..1f737ad 100644
--- a/src/builtins/guts.pir
+++ b/src/builtins/guts.pir
@@ -312,8 +312,13 @@ first). So for now we just transform multis in user code like this.
 
   start_main:
     ## We're running as main program
-    ## Remove program argument (0) and set up @ARGS global
+
+    ## Remove program argument ($?PROGRAM) and set up @ARGS global
     $P0 = shift args
+    $P1 = get_hll_global [ "Bool" ], "True"
+    setprop $P0, "readonly", $P1
+    set_hll_global "$?PROGRAM", $P0
+
     args = args.'Array'()
     set_hll_global '@ARGS', args
     ## run unitmain
diff --git a/src/parser/actions.pm b/src/parser/actions.pm
index 7f1f339..9e0fb50 100644
--- a/src/parser/actions.pm
+++ b/src/parser/actions.pm
@@ -1972,6 +1972,12 @@ method variable($/, $key) {
             $var.viviself( container_itype($sigil) );
         }
 
+        # If it has a '?' twigil, it's a compiler hint var.
+        if $twigil eq '?' {
+            $var.namespace(@ns);
+            $var.scope('package');
+        }
+
         ## @_ and %_ add a slurpy param to the block
         if $varname eq '@_' || $varname eq '%_' {
             unless $?BLOCK.symbol($varname) {
-- 
1.6.1

