cleanups in save
This commit is contained in:
parent
b4654901e4
commit
2e0924616d
|
@ -73,6 +73,19 @@ function stead.getcmd(str)
|
|||
return cmd, a
|
||||
end
|
||||
|
||||
stead.tostring = function(v)
|
||||
if isCode(v) then
|
||||
v = stead.string.format("code %q", stead.functions[v].code);
|
||||
elseif type(v) == 'string' then
|
||||
v = stead.string.format("%q", v);
|
||||
elseif v == nil or type(v) == 'boolean' or type(v) == 'number' then
|
||||
v = tostring(v);
|
||||
else
|
||||
v = nil
|
||||
end
|
||||
return v
|
||||
end
|
||||
|
||||
function cctx()
|
||||
return stead.cctx[stead.call_top];
|
||||
end
|
||||
|
@ -1017,8 +1030,11 @@ function phrase_save(self, name, h, need)
|
|||
if isDisabled(self) then
|
||||
m = " = _phr("
|
||||
end
|
||||
h:write(stead.string.format("%s%s%q,%q,%q);\n",
|
||||
name, m, tostring(self.dsc), tostring(self.ans), tostring(self.do_act)));
|
||||
h:write(stead.string.format("%s%s%s,%s,%s);\n",
|
||||
name, m,
|
||||
stead.tostring(self.dsc),
|
||||
stead.tostring(self.ans),
|
||||
stead.tostring(self.do_act)));
|
||||
end
|
||||
savemembers(h, self, name, false);
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ xact = function(n, f) -- just simple action!
|
|||
n = n[1];
|
||||
end
|
||||
|
||||
if type(n) ~= 'string' or (type(f) ~= 'string' and not isCode(f) and type(f) ~= 'boolean') then
|
||||
if type(n) ~= 'string' then
|
||||
error ("Wrong parameter to xact.", 2)
|
||||
end
|
||||
v.xaction_type = true
|
||||
|
@ -20,10 +20,9 @@ xact = function(n, f) -- just simple action!
|
|||
v.save = function(self, name, h, need)
|
||||
if need then
|
||||
local f = self.act;
|
||||
if isCode(f) then
|
||||
f = stead.string.format("code %q", stead.functions[f].code);
|
||||
else
|
||||
f = stead.string.format("%q", f);
|
||||
f = stead.tostring(f);
|
||||
if f == nil then
|
||||
error("Can not save xact: "..name);
|
||||
end
|
||||
h:write(stead.string.format("%s = xact(%q, %s);\n", name, self.nam, f))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue