diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-12-17 11:35:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-12-17 11:35:54 +0800 |
commit | 52f34152d4f8237382ee05790df204643f6f3864 (patch) | |
tree | ec53bb6b25517f150b829cc97b9ddaff4a48e75e /script-beta/vm/eachRef.lua | |
parent | dad5101542e0a0a84a3b66df88faa9b6179210a6 (diff) | |
download | lua-language-server-52f34152d4f8237382ee05790df204643f6f3864.zip |
加个上限,先别影响我自己使用
Diffstat (limited to 'script-beta/vm/eachRef.lua')
-rw-r--r-- | script-beta/vm/eachRef.lua | 107 |
1 files changed, 57 insertions, 50 deletions
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index dc97c04d..6348c7ef 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -421,55 +421,6 @@ local function checkSetValue(state, value, callback) end end -function vm.refOf(state, source, callback) - local stype = source.type - if stype == 'local' then - ofLocal(state, source, callback) - elseif stype == 'getlocal' - or stype == 'setlocal' then - ofLocal(state, source.node, callback) - elseif stype == 'setglobal' - or stype == 'getglobal' then - ofGlobal(state, source, callback) - elseif stype == 'field' - or stype == 'method' then - ofField(state, source, callback) - elseif stype == 'setfield' - or stype == 'getfield' - or stype == 'tablefield' then - ofField(state, source.field, callback) - elseif stype == 'setmethod' - or stype == 'getmethod' then - ofField(state, source.method, callback) - elseif stype == 'goto' then - ofGoTo(state, source, callback) - elseif stype == 'label' then - ofLabel(state, source, callback) - elseif stype == 'number' - or stype == 'boolean' - or stype == 'string' then - ofIndex(state, source, callback) - ofValue(state, source, callback) - elseif stype == 'table' - or stype == 'function' then - ofValue(state, source, callback) - elseif stype == 'select' then - ofSelect(state, source, callback) - elseif stype == 'call' then - ofCall(state, source.node, 1, callback) - ofSpecialCall(state, source, source.node, 1, callback) - elseif stype == 'main' then - ofMain(state, source, callback) - elseif stype == 'paren' then - vm.refOf(state, source.exp, callback) - end - checkValue(state, source, callback) - checkAsArg(state, source, callback) - checkAsReturn(state, source, callback) - checkAsParen(state, source, callback) - checkSetValue(state, source, callback) -end - local function applyCache(cache, callback, max) await.delay(function () return files.globalVersion @@ -512,8 +463,15 @@ local function eachRef(source, callback) } end end - while #list > 0 do + for _ = 1, 1000 do + if _ == 1000 then + warn('stack overflow!') + break + end local max = #list + if max == 0 then + break + end local src = list[max] list[max] = nil vm.refOf(state, src, found) @@ -524,6 +482,55 @@ local function eachRef(source, callback) return result end +function vm.refOf(state, source, callback) + local stype = source.type + if stype == 'local' then + ofLocal(state, source, callback) + elseif stype == 'getlocal' + or stype == 'setlocal' then + ofLocal(state, source.node, callback) + elseif stype == 'setglobal' + or stype == 'getglobal' then + ofGlobal(state, source, callback) + elseif stype == 'field' + or stype == 'method' then + ofField(state, source, callback) + elseif stype == 'setfield' + or stype == 'getfield' + or stype == 'tablefield' then + ofField(state, source.field, callback) + elseif stype == 'setmethod' + or stype == 'getmethod' then + ofField(state, source.method, callback) + elseif stype == 'goto' then + ofGoTo(state, source, callback) + elseif stype == 'label' then + ofLabel(state, source, callback) + elseif stype == 'number' + or stype == 'boolean' + or stype == 'string' then + ofIndex(state, source, callback) + ofValue(state, source, callback) + elseif stype == 'table' + or stype == 'function' then + ofValue(state, source, callback) + elseif stype == 'select' then + ofSelect(state, source, callback) + elseif stype == 'call' then + ofCall(state, source.node, 1, callback) + ofSpecialCall(state, source, source.node, 1, callback) + elseif stype == 'main' then + ofMain(state, source, callback) + elseif stype == 'paren' then + vm.refOf(state, source.exp, callback) + end + checkValue(state, source, callback) + checkAsArg(state, source, callback) + checkAsReturn(state, source, callback) + checkAsParen(state, source, callback) + checkSetValue(state, source, callback) +end + --- 判断2个对象是否拥有相同的引用 function vm.isSameRef(a, b) local cache = vm.cache.eachRef[a] |