mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
allow lua keyword property access on self #410
This commit is contained in:
parent
0af9a8df8c
commit
1ba34563f9
@ -76,7 +76,8 @@ do
|
||||
_continue_0 = true
|
||||
break
|
||||
end
|
||||
names_by_position[pos] = names_by_position[pos] or { }
|
||||
local _update_0 = pos
|
||||
names_by_position[_update_0] = names_by_position[_update_0] or { }
|
||||
insert(names_by_position[pos], name)
|
||||
_continue_0 = true
|
||||
until true
|
||||
|
@ -296,10 +296,44 @@ return {
|
||||
return self:line("not ", self:value(node[2]))
|
||||
end,
|
||||
self = function(self, node)
|
||||
if data.lua_keywords[node[2]] then
|
||||
return self:value({
|
||||
"chain",
|
||||
"self",
|
||||
{
|
||||
"index",
|
||||
{
|
||||
"string",
|
||||
'"',
|
||||
node[2]
|
||||
}
|
||||
}
|
||||
})
|
||||
else
|
||||
return "self." .. self:name(node[2])
|
||||
end
|
||||
end,
|
||||
self_class = function(self, node)
|
||||
if data.lua_keywords[node[2]] then
|
||||
return self:value({
|
||||
"chain",
|
||||
"self",
|
||||
{
|
||||
"dot",
|
||||
"__class"
|
||||
},
|
||||
{
|
||||
"index",
|
||||
{
|
||||
"string",
|
||||
'"',
|
||||
node[2]
|
||||
}
|
||||
}
|
||||
})
|
||||
else
|
||||
return "self.__class." .. self:name(node[2])
|
||||
end
|
||||
end,
|
||||
self_colon = function(self, node)
|
||||
return "self:" .. self:name(node[2])
|
||||
|
@ -183,9 +183,19 @@ string_chars = {
|
||||
@line "not ", @value node[2]
|
||||
|
||||
self: (node) =>
|
||||
if data.lua_keywords[node[2]]
|
||||
@value {"chain", "self", {"index", {
|
||||
"string", '"', node[2]
|
||||
}}}
|
||||
else
|
||||
"self."..@name node[2]
|
||||
|
||||
self_class: (node) =>
|
||||
if data.lua_keywords[node[2]]
|
||||
@value {"chain", "self", {"dot", "__class"}, {"index", {
|
||||
"string", '"', node[2]
|
||||
}}}
|
||||
else
|
||||
"self.__class."..@name node[2]
|
||||
|
||||
self_colon: (node) =>
|
||||
|
@ -158,6 +158,9 @@ hello ..= "world"
|
||||
@@something += 10
|
||||
@something += 10
|
||||
|
||||
@@then += 10
|
||||
@then += 10
|
||||
|
||||
a["hello"] += 10
|
||||
a["hello#{tostring ff}"] += 10
|
||||
a[four].x += 10
|
||||
|
@ -162,6 +162,8 @@ local m = m % 2
|
||||
local hello = hello .. "world"
|
||||
self.__class.something = self.__class.something + 10
|
||||
self.something = self.something + 10
|
||||
self.__class["then"] = self.__class["then"] + 10
|
||||
self["then"] = self["then"] + 10
|
||||
local _update_0 = "hello"
|
||||
a[_update_0] = a[_update_0] + 10
|
||||
local _update_1 = "hello" .. tostring(tostring(ff))
|
||||
|
Loading…
Reference in New Issue
Block a user