aboutsummaryrefslogtreecommitdiff
path: root/php/types.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/types.php')
-rw-r--r--php/types.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/php/types.php b/php/types.php
index fa57266..e3df3ac 100644
--- a/php/types.php
+++ b/php/types.php
@@ -59,31 +59,42 @@ class FunctionClass {
public $func = NULL;
public $type = 'native'; // 'native' or 'platform'
public $meta = NULL;
+ public $ast = NULL;
+ public $env = NULL;
+ public $params = NULL;
public $ismacro = False;
- public function __construct($func, $type, $meta=NULL, $ismacro=False) {
+ public function __construct($func, $type,
+ $ast, $env, $params, $ismacro=False) {
$this->func = $func;
$this->type = $type;
- $this->meta = $meta;
+ $this->ast = $ast;
+ #print_r($ast);
+ $this->env = $env;
+ $this->params = $params;
$this->ismacro = $ismacro;
}
public function __invoke() {
$args = func_get_args();
if ($this->type === 'native') {
- $fn_env = new Env($this->meta['env'],
- $this->meta['params'], $args);
+ $fn_env = new Env($this->env,
+ $this->params, $args);
$evalf = $this->func;
- return $evalf($this->meta['exp'], $fn_env);
+ return $evalf($this->ast, $fn_env);
} else {
return call_user_func_array($this->func, $args);
}
}
+ public function gen_env($args) {
+ return new Env($this->env, $this->params, $args);
+ }
public function apply($args) {
return call_user_func_array(array(&$this, '__invoke'),$args);
}
}
-function _function($func, $type='platform', $meta=NULL, $ismacro=False) {
- return new FunctionClass($func, $type, $meta, $ismacro);
+function _function($func, $type='platform',
+ $ast=NULL, $env=NULL, $params=NULL, $ismacro=False) {
+ return new FunctionClass($func, $type, $ast, $env, $params, $ismacro);
}
function _function_Q($obj) { return $obj instanceof FunctionClass; }