fixed bug with class value declaring

This commit is contained in:
leaf corcoran 2011-10-01 22:33:28 -07:00
parent cb159fd020
commit 5d76a8d741
7 changed files with 30 additions and 27 deletions

View File

@ -70,12 +70,8 @@ line_compile = {
end
do
local _with_0 = self:line()
local skip_values = false
if #undeclared == #names and not has_fndef then
_with_0:append(declare)
if #values == 0 then
skip_values = true
end
else
if #undeclared > 0 then
self:add(declare)
@ -94,22 +90,20 @@ line_compile = {
return _accum_0
end)(), ", ")
end
if not skip_values then
_with_0:append(" = ")
_with_0:append_list((function()
local _accum_0 = { }
local _len_0 = 0
do
local _item_0 = values
for _index_0 = 1, #_item_0 do
local v = _item_0[_index_0]
_len_0 = _len_0 + 1
_accum_0[_len_0] = self:value(v)
end
_with_0:append(" = ")
_with_0:append_list((function()
local _accum_0 = { }
local _len_0 = 0
do
local _item_0 = values
for _index_0 = 1, #_item_0 do
local v = _item_0[_index_0]
_len_0 = _len_0 + 1
_accum_0[_len_0] = self:value(v)
end
return _accum_0
end)(), ", ")
end
end
return _accum_0
end)(), ", ")
return _with_0
end
end

View File

@ -48,17 +48,14 @@ line_compile =
i = i +1
with @line!
skip_values = false
if #undeclared == #names and not has_fndef
\append declare
skip_values = true if #values == 0
else
@add declare if #undeclared > 0
\append_list [@value name for name in *names], ", "
if not skip_values
\append " = "
\append_list [@value v for v in *values], ", "
\append " = "
\append_list [@value v for v in *values], ", "
update: (node) =>
_, name, op, exp = unpack node

View File

@ -298,7 +298,11 @@ local transformers = {
cls_name
})
value = _with_0.group({
_with_0.assign_one(name),
_with_0.declare({
names = {
name
}
}),
_with_0.assign({
names = {
name

View File

@ -148,7 +148,7 @@ transformers = {
}
value = .group {
.assign_one name
.declare names: {name}
.assign {
names: {name}
values: {value}

View File

@ -39,6 +39,12 @@ local node_types = {
t
}
},
declare = {
{
"names",
t
}
},
["if"] = {
{
"cond",

View File

@ -26,6 +26,9 @@ node_types = {
{"names", t}
{"values", t}
}
declare: {
{"names", t}
}
if: {
{"cond", t}
{"then", t}

View File

@ -113,7 +113,6 @@ Hi = (function()
_base_0.__class = _class_0
return _class_0
end)()
Simple =
Simple = (function()
local _parent_0 = Hi
local _base_0 = {