aboutsummaryrefslogtreecommitdiff
path: root/lib
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 /lib
parent126f51f955351a4ce85f3f1e6da6e9219ec7e23a (diff)
Added tentative support for luajit (depends on pure-lua LPEG
implementation).
Diffstat (limited to 'lib')
-rw-r--r--lib/object2.nom54
1 files changed, 28 insertions, 26 deletions
diff --git a/lib/object2.nom b/lib/object2.nom
index 863ee2a..3916fa2 100644
--- a/lib/object2.nom
+++ b/lib/object2.nom
@@ -83,34 +83,36 @@ compile [define object %classname %class_body] to
%actions <- %line.value.2
%body <- %line.value.3
lua> ".."
- local stubs = {};
- for i, action in ipairs(\%actions.value) do
- stubs[i] = nomsu:tree_to_named_stub(action);
- end
- local args = {};
- for i,tok in ipairs(\%actions.value[1].value) do
- if tok.type == "Var" then args[#args+1] = nomsu:var_to_lua_identifier(tok.value); end
- end
- local arg_set = {};
- for i, arg in ipairs(args) do arg_set[arg] = true; end
- local body_lua = nomsu:tree_to_lua(\%body);
- body_lua:convert_to_statements();
- body_lua:declare_locals();
- local lua_fn_args = table.concat({"self", unpack(args)}, ", ");
- local def_tree = nomsu.compilestack[#nomsu.compilestack];
+ do
+ local stubs = {};
+ for i, action in ipairs(\%actions.value) do
+ stubs[i] = nomsu:tree_to_named_stub(action);
+ end
+ local args = {};
+ for i,tok in ipairs(\%actions.value[1].value) do
+ if tok.type == "Var" then args[#args+1] = nomsu:var_to_lua_identifier(tok.value); end
+ end
+ local arg_set = {};
+ for i, arg in ipairs(args) do arg_set[arg] = true; end
+ local body_lua = nomsu:tree_to_lua(\%body);
+ body_lua:convert_to_statements();
+ body_lua:declare_locals();
+ local lua_fn_args = table.concat({"self", unpack(args)}, ", ");
+ local def_tree = nomsu.compilestack[#nomsu.compilestack];
- local compiled_args = {};
- for i, arg in ipairs(args) do
- compiled_args[i] = "nomsu:tree_to_lua("..arg..")";
- end
- compiled_args = table.concat(compiled_args, "..', '..");
- table.insert(\%methods, ([==[
- %s[ %s] = function(%s)
- %s
+ local compiled_args = {};
+ for i, arg in ipairs(args) do
+ compiled_args[i] = "nomsu:tree_to_lua("..arg..")";
end
- ]==]):format(
- \%class_identifier, repr(stubs[1]), lua_fn_args,
- body_lua));
+ compiled_args = table.concat(compiled_args, "..', '..");
+ table.insert(\%methods, ([==[
+ %s[ %s] = function(%s)
+ %s
+ end
+ ]==]):format(
+ \%class_identifier, repr(stubs[1]), lua_fn_args,
+ body_lua));
+ end
return
Lua ".."