aboutsummaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorMiki Tebeka <miki.tebeka@gmail.com>2015-03-01 06:12:42 +0200
committerMiki Tebeka <miki.tebeka@gmail.com>2015-03-01 06:12:42 +0200
commit9fb199e2cb2cf44cd61c2a226193a70f6013aadc (patch)
tree325a2a8e33e3e8d18217d10854152cab82ac8b61 /php
parent49916f9402e30a5277146355be878b32ec30f46d (diff)
parent2cb013877c4ed41d245ce7c5525405c4833c503d (diff)
downloadmal-9fb199e2cb2cf44cd61c2a226193a70f6013aadc.tar.gz
mal-9fb199e2cb2cf44cd61c2a226193a70f6013aadc.zip
Merge branch 'master' of https://github.com/kanaka/mal
Diffstat (limited to 'php')
-rw-r--r--php/Makefile2
-rw-r--r--php/stepA_mal.php (renamed from php/stepA_interop.php)14
-rw-r--r--php/tests/stepA_mal.mal (renamed from php/tests/stepA_interop.mal)0
3 files changed, 14 insertions, 2 deletions
diff --git a/php/Makefile b/php/Makefile
index d9fd2d4..659e89c 100644
--- a/php/Makefile
+++ b/php/Makefile
@@ -2,7 +2,7 @@
TESTS =
SOURCES_BASE = readline.php types.php reader.php printer.php
-SOURCES_LISP = env.php core.php stepA_interop.php
+SOURCES_LISP = env.php core.php stepA_mal.php
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
.PHONY: stats tests $(TESTS)
diff --git a/php/stepA_interop.php b/php/stepA_mal.php
index 8c67c66..1dc3b04 100644
--- a/php/stepA_interop.php
+++ b/php/stepA_mal.php
@@ -109,7 +109,19 @@ function MAL_EVAL($ast, $env) {
case "macroexpand":
return macroexpand($ast[1], $env);
case "php*":
- return eval($ast[1]);
+ $res = eval($ast[1]);
+ switch (gettype($res)) {
+ case "array":
+ if ($res !== array_values($res)) {
+ $new_res = _hash_map();
+ $new_res->exchangeArray($res);
+ return $new_res;
+ } else {
+ return call_user_func_array('_list', $res);
+ }
+ default:
+ return $res;
+ }
case "try*":
$a1 = $ast[1];
$a2 = $ast[2];
diff --git a/php/tests/stepA_interop.mal b/php/tests/stepA_mal.mal
index 15f8a94..15f8a94 100644
--- a/php/tests/stepA_interop.mal
+++ b/php/tests/stepA_mal.mal