Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f61824f

Browse files
committed
optimize
1 parent 5f2d0c7 commit f61824f

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

‎script/vm/compiler.lua‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function vm.bindDocs(source)
7474
end
7575

7676
---@param source parser.object | vm.variable
77-
---@param key string|vm.global|vm.ANY
77+
---@param key string|vm.global|vm.ANY|vm.ANYDOC
7878
---@param pushResult fun(res: parser.object, markDoc?: boolean)
7979
local function searchFieldByLocalID(source, key, pushResult)
8080
local fields
@@ -142,15 +142,15 @@ end
142142

143143
---@param suri uri
144144
---@param source parser.object
145-
---@param key string|vm.global|vm.ANY
145+
---@param key string|vm.global|vm.ANY|vm.ANYDOC
146146
---@param pushResult fun(res: parser.object, markDoc?: boolean)
147147
local function searchFieldByGlobalID(suri, source, key, pushResult)
148148
local node = vm.getGlobalNode(source)
149149
if not node then
150150
return
151151
end
152152
if node.cate == 'variable' then
153-
if key ~= vm.ANY then
153+
if key ~= vm.ANY andkey~=vm.ANYDOCthen
154154
if type(key) ~= 'string' then
155155
return
156156
end
@@ -272,6 +272,7 @@ local searchFieldSwitch = util.switch()
272272
end
273273
local fieldKey = guide.getKeyName(field)
274274
if key == vm.ANY
275+
or key == vm.ANYDOC
275276
or key == fieldKey then
276277
pushResult(field)
277278
end
@@ -320,6 +321,7 @@ local searchFieldSwitch = util.switch()
320321
for fn in fieldNode:eachObject() do
321322
if fn.type == 'global' and fn.cate == 'type' then
322323
if key == vm.ANY
324+
or key == vm.ANYDOC
323325
or fn.name == 'any'
324326
or (fn.name == 'boolean' and type(key) == 'boolean')
325327
or (fn.name == 'number' and type(key) == 'number')
@@ -331,14 +333,15 @@ local searchFieldSwitch = util.switch()
331333
or fn.type == 'doc.type.integer'
332334
or fn.type == 'doc.type.boolean' then
333335
if key == vm.ANY
336+
or key == vm.ANYDOC
334337
or fn[1] == key then
335338
pushResult(field, true)
336339
end
337340
end
338341
end
339342
end
340343
if fieldKey.type == 'doc.field.name' then
341-
if key == vm.ANY or fieldKey[1] == key then
344+
if key == vm.ANY or key==vm.ANYDOCorfieldKey[1] == key then
342345
pushResult(field, true)
343346
end
344347
end
@@ -358,7 +361,7 @@ local searchFieldSwitch = util.switch()
358361
: case 'global'
359362
: call(function (suri, node, key, pushResult)
360363
if node.cate == 'variable' then
361-
if key ~= vm.ANY then
364+
if key ~= vm.ANY andkey~=vm.ANYDOCthen
362365
if type(key) ~= 'string' then
363366
return
364367
end
@@ -388,7 +391,7 @@ local searchFieldSwitch = util.switch()
388391

389392
---@param suri uri
390393
---@param object vm.global
391-
---@param key string|number|integer|boolean|vm.global|vm.ANY
394+
---@param key string|number|integer|boolean|vm.global|vm.ANY|vm.ANYDOC
392395
---@param pushResult fun(field: vm.object, isMark?: boolean)
393396
function vm.getClassFields(suri, object, key, pushResult)
394397
local mark = {}
@@ -418,6 +421,7 @@ function vm.getClassFields(suri, object, key, pushResult)
418421
if fieldKey then
419422
-- ---@field x boolean -> class.x
420423
if key == vm.ANY
424+
or key == vm.ANYDOC
421425
or fieldKey == key then
422426
if not searchedFields[fieldKey] then
423427
pushResult(field, true)
@@ -426,7 +430,7 @@ function vm.getClassFields(suri, object, key, pushResult)
426430
end
427431
goto CONTINUE
428432
end
429-
if key == vm.ANY then
433+
if key == vm.ANY orkey==vm.ANYDOCthen
430434
pushResult(field, true)
431435
goto CONTINUE
432436
end
@@ -771,7 +775,7 @@ function vm.bindAs(source)
771775
end
772776

773777
---@param source parser.object | vm.variable
774-
---@param key string|vm.global|vm.ANY
778+
---@param key string|vm.global|vm.ANY|vm.ANYDOC
775779
---@return parser.object[] docedResults
776780
---@return parser.object[] commonResults
777781
function vm.getNodesOfParentNode(source, key)
@@ -832,7 +836,7 @@ end
832836

833837
-- 遍历所有字段(按照优先级)
834838
---@param source parser.object | vm.variable
835-
---@param key string|vm.global|vm.ANY
839+
---@param key string|vm.global|vm.ANY|vm.ANYDOC
836840
---@param pushResult fun(source: parser.object)
837841
function vm.compileByParentNode(source, key, pushResult)
838842
local docedResults, commonResults = vm.getNodesOfParentNode(source, key)
@@ -851,7 +855,7 @@ end
851855

852856
-- 遍历所有字段(无视优先级)
853857
---@param source parser.object | vm.variable
854-
---@param key string|vm.global|vm.ANY
858+
---@param key string|vm.global|vm.ANY|vm.ANYDOC
855859
---@param pushResult fun(source: parser.object)
856860
function vm.compileByParentNodeAll(source, key, pushResult)
857861
local docedResults, commonResults = vm.getNodesOfParentNode(source, key)
@@ -1724,7 +1728,7 @@ local compilerSwitch = util.switch()
17241728
end
17251729

17261730
if not hasMarkDoc and source.type == 'tableindex' then
1727-
vm.compileByParentNode(source.node, vm.ANY, function (src)
1731+
vm.compileByParentNode(source.node, vm.ANYDOC, function (src)
17281732
if src.type == 'doc.field'
17291733
or src.type == 'doc.type.field' then
17301734
if vm.isSubType(guide.getUri(source), vm.compileNode(source.index), vm.compileNode(src.field or src.name)) then

‎script/vm/type.lua‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ local util = require 'utility'
66
local lang = require 'language'
77

88
---@class vm.ANY
9-
---@diagnostic disable-next-line: assign-type-mismatch
10-
vm.ANY = debug.upvalueid(require, 1)
9+
vm.ANY = {'<VM.ANY>'}
10+
---@class vm.ANYDOC
11+
vm.ANYDOC = {'<VM.ANYDOC>'}
1112

1213
---@alias typecheck.err vm.node.object|string|vm.node
1314

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /