Disabled serializing functions until it works.
This commit is contained in:
parent
440a2f0cef
commit
7087dc5151
13
nomsu.lua
13
nomsu.lua
@ -146,7 +146,7 @@ do
|
|||||||
self:error("Attempt to call undefined function: " .. tostring(fn_name))
|
self:error("Attempt to call undefined function: " .. tostring(fn_name))
|
||||||
end
|
end
|
||||||
if fn_info.is_macro then
|
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
|
end
|
||||||
if not (self:check_permission(fn_name)) then
|
if not (self:check_permission(fn_name)) then
|
||||||
self:error("You do not have the authority to call: " .. tostring(fn_name))
|
self:error("You do not have the authority to call: " .. tostring(fn_name))
|
||||||
@ -186,7 +186,7 @@ do
|
|||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
def = function(self, spec, fn)
|
def = function(self, spec, fn, src)
|
||||||
if self.debug then
|
if self.debug then
|
||||||
self:writeln("Defining rule: " .. tostring(spec))
|
self:writeln("Defining rule: " .. tostring(spec))
|
||||||
end
|
end
|
||||||
@ -195,6 +195,7 @@ do
|
|||||||
fn = fn,
|
fn = fn,
|
||||||
arg_names = arg_names,
|
arg_names = arg_names,
|
||||||
invocations = invocations,
|
invocations = invocations,
|
||||||
|
src = src,
|
||||||
is_macro = false
|
is_macro = false
|
||||||
}
|
}
|
||||||
for _index_0 = 1, #invocations do
|
for _index_0 = 1, #invocations do
|
||||||
@ -236,12 +237,16 @@ do
|
|||||||
end
|
end
|
||||||
return invocations, arg_names
|
return invocations, arg_names
|
||||||
end,
|
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 invocations, arg_names = self:get_invocations(spec)
|
||||||
local fn_info = {
|
local fn_info = {
|
||||||
fn = lua_gen_fn,
|
fn = lua_gen_fn,
|
||||||
arg_names = arg_names,
|
arg_names = arg_names,
|
||||||
invocations = invocations,
|
invocations = invocations,
|
||||||
|
src = src,
|
||||||
is_macro = true
|
is_macro = true
|
||||||
}
|
}
|
||||||
for _index_0 = 1, #invocations do
|
for _index_0 = 1, #invocations do
|
||||||
@ -256,12 +261,14 @@ do
|
|||||||
local code, retval = self:compile(text)
|
local code, retval = self:compile(text)
|
||||||
if self.debug then
|
if self.debug then
|
||||||
self:writeln("\nGENERATED LUA CODE:\n" .. tostring(code))
|
self:writeln("\nGENERATED LUA CODE:\n" .. tostring(code))
|
||||||
|
self:writeln("\nPRODUCED RETURN VALUE:\n" .. tostring(retval))
|
||||||
end
|
end
|
||||||
return retval
|
return retval
|
||||||
end,
|
end,
|
||||||
serialize = function(self, obj)
|
serialize = function(self, obj)
|
||||||
local _exp_0 = type(obj)
|
local _exp_0 = type(obj)
|
||||||
if "function" == _exp_0 then
|
if "function" == _exp_0 then
|
||||||
|
error("Function serialization is not yet implemented.")
|
||||||
return "assert(load(" .. utils.repr(string.dump(obj), true) .. "))"
|
return "assert(load(" .. utils.repr(string.dump(obj), true) .. "))"
|
||||||
elseif "table" == _exp_0 then
|
elseif "table" == _exp_0 then
|
||||||
if utils.is_list(obj) then
|
if utils.is_list(obj) then
|
||||||
|
@ -155,6 +155,8 @@ class NomsuCompiler
|
|||||||
return invocations, arg_names
|
return invocations, arg_names
|
||||||
|
|
||||||
defmacro: (spec, lua_gen_fn, src)=>
|
defmacro: (spec, lua_gen_fn, src)=>
|
||||||
|
if @debug
|
||||||
|
@writeln("DEFINING MACRO: #{spec}#{src or ""}")
|
||||||
invocations,arg_names = @get_invocations spec
|
invocations,arg_names = @get_invocations spec
|
||||||
fn_info = {fn:lua_gen_fn, :arg_names, :invocations, :src, is_macro:true}
|
fn_info = {fn:lua_gen_fn, :arg_names, :invocations, :src, is_macro:true}
|
||||||
for invocation in *invocations
|
for invocation in *invocations
|
||||||
@ -173,6 +175,7 @@ class NomsuCompiler
|
|||||||
serialize: (obj)=>
|
serialize: (obj)=>
|
||||||
switch type(obj)
|
switch type(obj)
|
||||||
when "function"
|
when "function"
|
||||||
|
error("Function serialization is not yet implemented.")
|
||||||
"assert(load("..utils.repr(string.dump(obj), true).."))"
|
"assert(load("..utils.repr(string.dump(obj), true).."))"
|
||||||
when "table"
|
when "table"
|
||||||
if utils.is_list obj
|
if utils.is_list obj
|
||||||
|
Loading…
Reference in New Issue
Block a user