From a1b559a3a269bbee1ae9a33061b08a868ea52f5c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 25 Jan 2019 15:49:29 -0800 Subject: Added metatables for bool, number, function, coroutine. Added run-time check to make sure precompiled code used the same version of Lua. Methods can now be used in (* compiles to *), etc. --- syntax_tree.moon | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'syntax_tree.moon') diff --git a/syntax_tree.moon b/syntax_tree.moon index eb9c87c..278e22b 100644 --- a/syntax_tree.moon +++ b/syntax_tree.moon @@ -72,10 +72,10 @@ class SyntaxTree assert(@type == "Action" or @type == "MethodCall", "Only actions and method calls have arguments") args = {} if @type == "MethodCall" - assert(#@ == 2, "Can't get arguments for multiple method calls at once.") args[1] = @[1] - for tok in *@[2] - if type(tok) != 'string' then args[#args+1] = tok + for i=2,#@ + for tok in *@[i] + if type(tok) != 'string' then args[#args+1] = tok else for tok in *@ if type(tok) != 'string' then args[#args+1] = tok @@ -83,8 +83,7 @@ class SyntaxTree get_stub: => if @type == "MethodCall" - assert(#@ == 2, "Can't get the stubs of multiple method calls at once.") - return @[2]\get_stub! + return "0, "..table.concat([@[i]\get_stub! for i=2,#@], "; ") stub_bits = {} arg_i = 1 for a in *@ -- cgit v1.2.3