aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-12 18:04:18 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-12 18:04:41 -0700
commit3c510e4ee5027aa5191e994bdf0a080a32a4b082 (patch)
treeb8d740f6ce0e263faa92967a63d16af07f3d45e7 /core
parentb5fb8933af283d2b873a03ded085e8b69f374e81 (diff)
Lots of optimizations and simplifications, especially towards getting
better performance on luajit.
Diffstat (limited to 'core')
-rw-r--r--core/control_flow.nom12
-rw-r--r--core/metaprogramming.nom10
-rw-r--r--core/operators.nom3
3 files changed, 11 insertions, 14 deletions
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 73a0f43..f0238a4 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -188,14 +188,14 @@ immediately
%body has subtree % where
(%.type = "Action") and
(%.stub is "do next %") and
- %.3.value = %var.value
+ %.3.(1) = %var.(1)
..: to %lua write (Lua "\n ::continue_\(%var as lua identifier)::")
to %lua write "\nend --foreach-loop"
if
%body has subtree % where
(%.type = "Action") and
(%.stub is "stop %") and
- %.2.value = %var.value
+ %.2.(1) = %var.(1)
..
%lua <-
Lua ".."
@@ -222,14 +222,14 @@ immediately
%body has subtree % where
(%.type = "Action") and
(%.stub is "do next %") and
- %.3.value = %key.value
+ %.3.(1) = %key.(1)
..: to %lua write (Lua "\n ::continue_\(%key as lua identifier)::")
if
%body has subtree % where
(%.type = "Action") and
(%.stub is "do next %") and
- %.3.value = %value.value
+ %.3.(1) = %value.(1)
..: to %lua write (Lua "\n ::continue_\(%value as lua identifier)::")
to %lua write "\nend --foreach-loop"
@@ -238,14 +238,14 @@ immediately
%body has subtree % where
(%.type = "Action") and
(%.stub is "stop %") and
- %.2.value = %key.value
+ %.2.(1) = %key.(1)
..: to %stop_labels write "\n::stop_\(%key as lua identifier)::"
if
%body has subtree % where
(%.type = "Action") and
(%.stub is "stop %") and
- %.2.value = %value.value
+ %.2.(1) = %value.(1)
..: to %stop_labels write "\n::stop_\(%value as lua identifier)::"
if: (length of %stop_labels) > 0
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index ec65f3e..e413191 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -82,7 +82,7 @@ immediately
for i,tok in ipairs(\%shorthand[1]) do
if tok.type == "Var" then
local lua_var = tostring(nomsu:tree_to_lua(tok))
- replacements[tok.value] = lua_var
+ replacements[tok[1]] = lua_var
lua:append(", ", lua_var)
end
end
@@ -90,12 +90,10 @@ immediately
local function make_tree(t)
if type(t) ~= 'table' and type(t) ~= 'userdata' then
return repr(t)
- elseif t.type == 'Var' and replacements[t.value] then
- return replacements[t.value]
+ elseif t.type == 'Var' and replacements[t[1]] then
+ return replacements[t[1]]
elseif t.type == 'Var' then
- return t.type.."("..repr(tostring(t.source))..", "..repr(t.value.."#"..tostring(MANGLE_INDEX))..")"
- elseif t.value then
- return t.type.."("..repr(tostring(t.source))..", "..repr(t.value)..")"
+ return t.type.."("..repr(tostring(t.source))..", "..repr(t[1].."#"..tostring(MANGLE_INDEX))..")"
else
local bits = {repr(tostring(t.source))}
for i, entry in ipairs(t) do
diff --git a/core/operators.nom b/core/operators.nom
index 4ec8ff1..555a636 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -160,8 +160,7 @@ immediately
# Unary operators
compile [- %] to: Lua value "(- \(% as lua expr))"
compile [not %] to: Lua value "(not \(% as lua expr))"
- # Using custom "len()" instead of Lua's "#" operator for compatibility with luajit.
- compile [length of %list] to: Lua value "len(\(%list as lua expr))"
+ compile [length of %list] to: Lua value "(#\(%list as lua expr))"
# Update operators
immediately