aboutsummaryrefslogtreecommitdiff
path: root/lib/object.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-06 15:13:55 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-06 15:15:14 -0800
commitc8ccbe5f42b5a197010b5ee95491dce5b9bbcbf4 (patch)
treedb2259bad177e558067a7cc2ea09836749242009 /lib/object.nom
parent0f17c5eb9ac4660f2f969bd1e67af42713e45eac (diff)
Removed utils.lua, simplified some metaprogramming stuff, added native support
for calling functions with (%a %b %c) instead of (call %a with [%b, %c]), renamed _List -> List, _Dict -> Dict, improved example code.
Diffstat (limited to 'lib/object.nom')
-rw-r--r--lib/object.nom16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/object.nom b/lib/object.nom
index d5555df..6f6fc20 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -54,25 +54,21 @@ test:
(my action %actions %body) compiles to:
lua> "\
..local fn_name = \%actions[1].stub:as_lua_id()
- local \%args = table.map(\%actions[1]:get_args(), function(a) return tostring(nomsu:compile(a)) end)
- table.insert(\%args, 1, \(\%me as lua id))
+ local \%args = List(\%actions[1]:get_args())
+ table.insert(\%args, 1, \(\%me))
local lua = LuaCode(tree.source, "class.", fn_name, " = ", \(..)
what (%args -> %body) compiles to
..)
for i=2,#\%actions do
local alias = \%actions[i]
local alias_name = alias.stub:as_lua_id()
- local \%alias_args = table.map(alias:get_args(), function(a) return tostring(nomsu:compile(a)) end)
- table.insert(\%alias_args, 1, \(\%me as lua id))
+ local \%alias_args = List(alias:get_args())
+ table.insert(\%alias_args, 1, \(\%me))
lua:append("\\nclass.", alias_name, " = ")
- if utils.equivalent(\%args, \%alias_args) then
+ if \%args == \%alias_args then
lua:append("class.", fn_name)
else
- lua:append("function(")
- lua:concat_append(\%alias_args, ", ")
- lua:append(")\\n return class.", fn_name, "(")
- lua:concat_append(\%args, ", ")
- lua:append(")\\nend")
+ lua:append(\(what (%alias_args -> %actions.1) compiles to))
end
end
return lua"