-
Notifications
You must be signed in to change notification settings - Fork 31
/
lexical.php
32 lines (28 loc) · 858 Bytes
/
lexical.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Pharen;
class Lexical{
static $scopes = array();
public static function init_closure($ns, $id){
if(isset(self::$scopes[$ns][$id])){
self::$scopes[$ns][$id][] = array();
}else{
self::$scopes[$ns][$id] = array(array());
}
return $id;
}
public static function get_closure_id($ns, $id){
if($id === Null){
return Null;
}else{
return count(self::$scopes[$ns][$id])-1;
}
}
public static function bind_lexing($ns, $id, $var, &$val){
$closure_id = self::get_closure_id($ns, $id);
self::$scopes[$ns][$id][$closure_id][$var] =& $val;
return $val;
}
public static function get_lexical_binding($ns, $id, $var, $closure_id){
return self::$scopes[$ns][$id][$closure_id][$var];
}
}