misc cleanups

This commit is contained in:
leaf corcoran 2022-11-04 13:29:46 -07:00
parent c7be4dcb38
commit a1265cf7a1
2 changed files with 21 additions and 16 deletions

View File

@ -296,7 +296,8 @@ return {
return self:line("not ", self:value(node[2]))
end,
self = function(self, node)
if data.lua_keywords[node[2]] then
local field_name = self:name(node[2])
if data.lua_keywords[field_name] then
return self:value({
"chain",
"self",
@ -305,16 +306,17 @@ return {
{
"string",
'"',
self:name(node[2])
field_name
}
}
})
else
return "self." .. self:name(node[2])
return "self." .. tostring(field_name)
end
end,
self_class = function(self, node)
if data.lua_keywords[node[2]] then
local field_name = self:name(node[2])
if data.lua_keywords[field_name] then
return self:value({
"chain",
"self",
@ -327,19 +329,19 @@ return {
{
"string",
'"',
self:name(node[2])
field_name
}
}
})
else
return "self.__class." .. self:name(node[2])
return "self.__class." .. tostring(field_name)
end
end,
self_colon = function(self, node)
return "self:" .. self:name(node[2])
return "self:" .. tostring(self:name(node[2]))
end,
self_class_colon = function(self, node)
return "self.__class:" .. self:name(node[2])
return "self.__class:" .. tostring(self:name(node[2]))
end,
ref = function(self, value)
do

View File

@ -183,26 +183,29 @@ string_chars = {
@line "not ", @value node[2]
self: (node) =>
if data.lua_keywords[node[2]]
field_name = @name node[2]
if data.lua_keywords[field_name]
@value {"chain", "self", {"index", {
"string", '"', @name node[2]
"string", '"', field_name
}}}
else
"self."..@name node[2]
"self.#{field_name}"
self_class: (node) =>
if data.lua_keywords[node[2]]
field_name = @name node[2]
if data.lua_keywords[field_name]
@value {"chain", "self", {"dot", "__class"}, {"index", {
"string", '"', @name node[2]
"string", '"', field_name
}}}
else
"self.__class."..@name node[2]
"self.__class.#{field_name}"
self_colon: (node) =>
"self:"..@name node[2]
"self:#{@name node[2]}"
self_class_colon: (node) =>
"self.__class:"..@name node[2]
"self.__class:#{@name node[2]}"
-- a variable reference
ref: (value) =>