summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-08 15:41:31 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-08 15:41:31 +0800
commita16676ea0ec939c6848f88247e336223d20a2378 (patch)
tree174dcabff8bf68978a6ee5ca2c6b493db8413683
parent0af858e47af3cfc71bc3294f849108b5c00d0b11 (diff)
downloadlua-language-server-a16676ea0ec939c6848f88247e336223d20a2378.zip
修正一些问题
-rw-r--r--server/src/service.lua5
-rw-r--r--server/src/vm/vm.lua4
-rw-r--r--server/test/definition/set.lua10
-rw-r--r--server/test/diagnostics/init.lua2
4 files changed, 15 insertions, 6 deletions
diff --git a/server/src/service.lua b/server/src/service.lua
index 6fa6c897..aa85fc49 100644
--- a/server/src/service.lua
+++ b/server/src/service.lua
@@ -6,7 +6,8 @@ local rpc = require 'rpc'
local parser = require 'parser'
local core = require 'core'
local lang = require 'language'
-local updateTimer = require 'timer'
+local updateTimer= require 'timer'
+local buildVM = require 'vm'
local ErrorCodes = {
-- Defined by JSON RPC
@@ -322,7 +323,7 @@ function mt:compileVM(uri)
self:_clearGlobal(uri, compiled)
local clock = os.clock()
- local vm = core.vm(ast, self, uri)
+ local vm = buildVM(ast, self, uri)
if version ~= obj.version then
return nil
end
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 9e89c6e6..57b6c1cd 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -372,9 +372,9 @@ function mt:setName(name, source, value)
if global then
return global
end
- source:bindValue(global, 'set')
local ENV = self:loadLocal('_ENV')
local ENVValue = ENV:getValue()
+ source:bindValue(value, 'set')
ENVValue:setChild(name, value)
source:set('global', true)
source:set('parentValue', ENVValue)
@@ -743,7 +743,6 @@ function mt:setOne(var, value)
self:instantSource(var)
if var.type == 'name' then
self:setName(var[1], var, value)
- var:bindValue(value, 'set')
elseif var.type == 'simple' then
local parent = self:getSimple(var, -2)
local key = var[#var]
@@ -916,7 +915,6 @@ function mt:doFunction(action)
else
local value = self:buildFunction(action)
self:setName(name[1], name, value)
- name:bindValue(value, 'set')
end
else
self:buildFunction(action)
diff --git a/server/test/definition/set.lua b/server/test/definition/set.lua
index 294a92ca..82dc4828 100644
--- a/server/test/definition/set.lua
+++ b/server/test/definition/set.lua
@@ -28,3 +28,13 @@ do
<?x?>()
end
]]
+
+TEST [[
+<!x!> = 1
+if y then
+ <!x!> = 2
+else
+ <!x!> = 3
+end
+print(<?x?>)
+]]
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index 7a38ce4a..8c2f4dba 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -72,7 +72,7 @@ print(<!X!>)
print(<!Log!>)
print(_VERSION)
print(<!y!>)
-print(<!z!>)
+print(z)
z = 1
]]