summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-02-26 16:11:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-02-26 16:11:31 +0800
commit20e8e3547b9a8a78570edacf33571a1e06e5adda (patch)
tree674be9499b097da68858c65ca7ae27191b8d41df
parent5afb3aed20cba832682085a545608df76c6344d6 (diff)
downloadlua-language-server-20e8e3547b9a8a78570edacf33571a1e06e5adda.zip
支持函数的self
-rw-r--r--server/src/vm/function.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index 24990448..17cc237b 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -132,10 +132,18 @@ function mt:run()
end
-- 第一次运行函数时,创建函数的参数
- if self._runed == 1 then
- self:createArgs()
+ if self._runed ~= 1 then
+ return
+ end
+
+ -- 如果是面向对象形式的函数,创建隐藏的参数self
+ if self._object then
+ self:saveLocal('self', self._object)
end
+ -- 显性声明的参数
+ self:createArgs()
+
--local index = 0
--if func.object then
-- local var = self:createArg('self', func.colon, self:getValue--(func.object, func.colon))