diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-18 17:08:35 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-18 17:08:35 -0700 |
| commit | 7087dc5151fd08e8fc64ab2b6d3248ff0f13c271 (patch) | |
| tree | 0de912bbb6f8d41c0237ac37ca66c58f2b492093 | |
| parent | 440a2f0cef6b342fa430bd0ca42d1a2ec47324dc (diff) | |
Disabled serializing functions until it works.
| -rw-r--r-- | nomsu.lua | 13 | ||||
| -rwxr-xr-x | nomsu.moon | 3 |
2 files changed, 13 insertions, 3 deletions
@@ -146,7 +146,7 @@ do self:error("Attempt to call undefined function: " .. tostring(fn_name)) end if fn_info.is_macro then - self:error("Attempt to call macro at runtime: " .. tostring(fn_name)) + self:error("Attempt to call macro at runtime: " .. tostring(fn_name) .. "\nThis can be caused by using a macro in a function that is defined before the macro.") end if not (self:check_permission(fn_name)) then self:error("You do not have the authority to call: " .. tostring(fn_name)) @@ -186,7 +186,7 @@ do end return false end, - def = function(self, spec, fn) + def = function(self, spec, fn, src) if self.debug then self:writeln("Defining rule: " .. tostring(spec)) end @@ -195,6 +195,7 @@ do fn = fn, arg_names = arg_names, invocations = invocations, + src = src, is_macro = false } for _index_0 = 1, #invocations do @@ -236,12 +237,16 @@ do end return invocations, arg_names end, - defmacro = function(self, spec, lua_gen_fn) + defmacro = function(self, spec, lua_gen_fn, src) + if self.debug then + self:writeln("DEFINING MACRO: " .. tostring(spec) .. tostring(src or "")) + end local invocations, arg_names = self:get_invocations(spec) local fn_info = { fn = lua_gen_fn, arg_names = arg_names, invocations = invocations, + src = src, is_macro = true } for _index_0 = 1, #invocations do @@ -256,12 +261,14 @@ do local code, retval = self:compile(text) if self.debug then self:writeln("\nGENERATED LUA CODE:\n" .. tostring(code)) + self:writeln("\nPRODUCED RETURN VALUE:\n" .. tostring(retval)) end return retval end, serialize = function(self, obj) local _exp_0 = type(obj) if "function" == _exp_0 then + error("Function serialization is not yet implemented.") return "assert(load(" .. utils.repr(string.dump(obj), true) .. "))" elseif "table" == _exp_0 then if utils.is_list(obj) then @@ -155,6 +155,8 @@ class NomsuCompiler return invocations, arg_names defmacro: (spec, lua_gen_fn, src)=> + if @debug + @writeln("DEFINING MACRO: #{spec}#{src or ""}") invocations,arg_names = @get_invocations spec fn_info = {fn:lua_gen_fn, :arg_names, :invocations, :src, is_macro:true} for invocation in *invocations @@ -173,6 +175,7 @@ class NomsuCompiler serialize: (obj)=> switch type(obj) when "function" + error("Function serialization is not yet implemented.") "assert(load("..utils.repr(string.dump(obj), true).."))" when "table" if utils.is_list obj |
