Re: YANP (Yet Another Namespace Proposal)
| From: | Jessie Hernandez | Date: | Thu, 07 Jul 2005 14:40:40 +0000 |
| Subject: | Re: YANP (Yet Another Namespace Proposal) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-17165@lists.php.net to get a copy of this message | ||
Actually, this will work! In the "class_name_reference" rule, the
"zend_do_fetch_class" function is called. Inside this function, class_name
is a znode, and what is assigned to the opcode is "opline->op2 =
*class_name". This function is changed to check the import hashtable, and if
a match is found, then the znode string value is updated to contain the full
class name! Here's some pseudocode:
<?php
include('Object.php');
// include opcode is generated here
import lang:Object;
// "Object" => "lang:Object" added to import hashtable
$o = new Object();
// zend_do_fetch_class checks for "Object" in the import hashtable.
// A match is found, so "class_name->u.constant.value.str" is modified from
"Object" to "lang:Object".
// At runtime, the lang:Object class will be created and added to
class_table,
// and since all opcodes are using lang:Object instead of simply Object,
then everything will work.
?>
--
Jessie
""Timm Friebe"" <thekid@thekid.de> wrote in message
news:0MKwh2-1DqTBy43Wu-0004sH@mrelayeu.kundenserver.de...
> [...]
> > - All imports are done at compile time.
>
> So:
>
> == Object.php ==
> <?php
> package lang { class Object {
>
> }}
> ?>
>
> == script.php ==
> <?php
> include('Object.php');
>
> import lang:Object;
> ?>
>
> ...will not work. You'll need an opcode for this.
>
> - Timm