aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-09 13:34:33 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-09 13:35:04 -0700
commit1a755ddee807fe4e1b683f32b21d710dc78600a2 (patch)
tree004709fed6704e50b099430945a9adc66ce16e01 /core
parent126f51f955351a4ce85f3f1e6da6e9219ec7e23a (diff)
Added tentative support for luajit (depends on pure-lua LPEG
implementation).
Diffstat (limited to 'core')
-rw-r--r--core/metaprogramming.nom13
-rw-r--r--core/operators.nom9
2 files changed, 8 insertions, 14 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index 6d2f764..fd70119 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -159,19 +159,6 @@ immediately
compile [nomsu] to: Lua value "nomsu"
compile [%var as lua identifier] to: Lua value "nomsu:var_to_lua_identifier(\(%var as lua expr))"
-action [action %names metadata]
- =lua "nomsu.action_metadata[ACTIONS[\%names]]"
-
-# Get the source code for a function
-action [help %action]
- lua> ".."
- local metadata = \(action %action metadata);
- if not metadata then
- print("Action not found: "..repr(\%action));
- else
- print(metadata.src or "<unknown source code>");
- end
-
# Compiler tools
immediately
compile [run %code] to
diff --git a/core/operators.nom b/core/operators.nom
index 88b0374..fca56d5 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -163,7 +163,14 @@ immediately
# Unary operators
compile [- %] to: Lua value "(- \(% as lua expr))"
compile [not %] to: Lua value "(not \(% as lua expr))"
- compile [length of %list] to: Lua value "(#\(%list as lua expr))"
+ compile [length of %list] to
+ # A bit of a hack so that luajit works properly.
+ Lua value ".."
+ (function(l)
+ local mt = getmetatable(l);
+ if mt and mt.__len then return mt.__len(l) end
+ return #l
+ end)(\(%list as lua expr))
# Update operators
immediately