[svn:parrot] r35640 - trunk/languages/pipp/src/common

[email protected]
Newsgroups perl.cvs.parrot
Message-ID <[email protected]>
Author: bernhard
Date: Fri Jan 16 10:19:22 2009
New Revision: 35640

Modified:
   trunk/languages/pipp/src/common/php_MACRO.pir
   trunk/languages/pipp/src/common/php_basic.pir
   trunk/languages/pipp/src/common/php_builtin.pir
   trunk/languages/pipp/src/common/php_info.pir

Log:
[Pipp] Use package vars for constants

Modified: trunk/languages/pipp/src/common/php_MACRO.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_MACRO.pir	(original)
+++ trunk/languages/pipp/src/common/php_MACRO.pir	Fri Jan 16 10:19:22 2009
@@ -33,15 +33,13 @@
 .macro REGISTER_LONG_CONSTANT(symb, val)
     new $P0, 'PhpInteger'
     set $P0, .val
-    $P44 = get_hll_global 'php_constants'
-    $P44[.symb] = $P0
+    set_hll_global .symb, $P0
 .endm
 
 .macro REGISTER_STRING_CONSTANT(symb, val)
     new $P0, 'PhpString'
     set $P0, .val
-    $P44 = get_hll_global 'php_constants'
-    $P44[.symb] = $P0
+    set_hll_global .symb, $P0
 .endm
 
 =item C<.RETURN_BOOL( val )>

Modified: trunk/languages/pipp/src/common/php_basic.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_basic.pir	(original)
+++ trunk/languages/pipp/src/common/php_basic.pir	Fri Jan 16 10:19:22 2009
@@ -100,15 +100,14 @@
     .RETURN_NULL()
   L1:
     $P1 = shift args
-    $S1 = $P1
-    .local pmc cst
-    cst = get_hll_global 'php_constants'
-    $I0 = exists cst[$S1]
-    unless $I0 goto L2
-    $P0 = cst[$S1]
-    .return ($P0)
+    .local string name
+    name = $P1
+    .local pmc val
+    val = get_hll_global name
+    if_null val, L2
+    .return (val)
   L2:
-    error(E_WARNING, "Couldn't find constant ", $S1)
+    error(E_WARNING, "Couldn't find constant ", name)
     .RETURN_NULL()
 .end
 

Modified: trunk/languages/pipp/src/common/php_builtin.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_builtin.pir	(original)
+++ trunk/languages/pipp/src/common/php_builtin.pir	Fri Jan 16 10:19:22 2009
@@ -112,12 +112,12 @@
     error(E_WARNING,"Constants may only evaluate to scalar values")
     .RETURN_FALSE()
   L4:
-    $S1 = $P1
-    .local pmc cst
-    cst = get_hll_global 'php_constants'
-    $I0 = exists cst[$S1]
-    if $I0 goto L6
-    cst[$S1] = $P2
+    .local string name
+    name = $P1
+    .local pmc val
+    val = get_hll_global name
+    unless null val goto L6        # don't overwrite an existing value
+    set_hll_global name, $P2
     .RETURN_TRUE()
   L6:
     .RETURN_FALSE()
@@ -139,10 +139,13 @@
     .RETURN_NULL()
   L1:
     $P1 = shift args
-    $S1 = $P1
-    .local pmc cst
-    cst = get_hll_global 'php_constants'
-    $I0 = exists cst[$S1]
+    .local string name
+    name = $P1
+    .local pmc val
+    val = get_hll_global name
+    $I0 = isnull val    # check the nullness and invert it
+    $I0 = $I0 - 1
+    $I0 = neg $I0
 
     .RETURN_BOOL($I0)
 .end

Modified: trunk/languages/pipp/src/common/php_info.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_info.pir	(original)
+++ trunk/languages/pipp/src/common/php_info.pir	Fri Jan 16 10:19:22 2009
@@ -35,10 +35,8 @@
     .REGISTER_STRING_CONSTANT('DEFAULT_INCLUDE_PATH', '.')
 
     # register NULL
-    .local pmc cst
-    cst = get_hll_global 'php_constants'
     new $P0, 'PhpNull'
-    cst['NULL'] = $P0
+    set_hll_global 'NULL', $P0
 
 .end
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.