diff options
Diffstat (limited to 'script-beta')
-rw-r--r-- | script-beta/utility.lua | 20 | ||||
-rw-r--r-- | script-beta/vm/eachDef.lua | 6 | ||||
-rw-r--r-- | script-beta/vm/eachRef.lua | 10 |
3 files changed, 23 insertions, 13 deletions
diff --git a/script-beta/utility.lua b/script-beta/utility.lua index d80039d3..eb263327 100644 --- a/script-beta/utility.lua +++ b/script-beta/utility.lua @@ -78,7 +78,7 @@ function m.dump(tbl, option) local lines = {} local mark = {} lines[#lines+1] = '{' - local function unpack(tbl, tab) + local function unpack(tbl, deep) mark[tbl] = (mark[tbl] or 0) + 1 local keys = {} local keymap = {} @@ -137,22 +137,24 @@ function m.dump(tbl, option) local value = tbl[key] local tp = type(value) if option['format'] and option['format'][key] then - lines[#lines+1] = ('%s%s%s,'):format(TAB[tab+1], keyWord, option['format'][key](value, unpack, tab+1)) + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, option['format'][key](value, unpack, deep+1)) elseif tp == 'table' then if mark[value] and mark[value] > 0 then - lines[#lines+1] = ('%s%s%s,'):format(TAB[tab+1], keyWord, option['loop'] or '"<Loop>"') + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, option['loop'] or '"<Loop>"') + elseif deep > (option['deep'] or math.huge) then + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, '"<Deep>"') else - lines[#lines+1] = ('%s%s{'):format(TAB[tab+1], keyWord) - unpack(value, tab+1) - lines[#lines+1] = ('%s},'):format(TAB[tab+1]) + lines[#lines+1] = ('%s%s{'):format(TAB[deep+1], keyWord) + unpack(value, deep+1) + lines[#lines+1] = ('%s},'):format(TAB[deep+1]) end elseif tp == 'string' then - lines[#lines+1] = ('%s%s%q,'):format(TAB[tab+1], keyWord, value) + lines[#lines+1] = ('%s%s%q,'):format(TAB[deep+1], keyWord, value) elseif tp == 'number' then - lines[#lines+1] = ('%s%s%s,'):format(TAB[tab+1], keyWord, (option['number'] or formatNumber)(value)) + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, (option['number'] or formatNumber)(value)) elseif tp == 'nil' then else - lines[#lines+1] = ('%s%s%s,'):format(TAB[tab+1], keyWord, tostring(value)) + lines[#lines+1] = ('%s%s%s,'):format(TAB[deep+1], keyWord, tostring(value)) end end mark[tbl] = mark[tbl] - 1 diff --git a/script-beta/vm/eachDef.lua b/script-beta/vm/eachDef.lua index fd34bed3..dfd6ce1a 100644 --- a/script-beta/vm/eachDef.lua +++ b/script-beta/vm/eachDef.lua @@ -2,6 +2,7 @@ local vm = require 'vm.vm' local guide = require 'parser.guide' local ws = require 'workspace' local files = require 'files' +local util = require 'utility' local m = {} @@ -23,7 +24,10 @@ function m.eachDef(source, results) return results end - local myResults = guide.requestDefinition(source, vm.interface) + local myResults, count = guide.requestDefinition(source, vm.interface) + if DEVELOP and count > 10 then + log.warn('requestDefinition', count, util.dump(source, { deep = 0 })) + end vm.mergeResults(results, myResults) m.searchLibrary(source, results) m.searchLibrary(guide.getObjectValue(source), results) diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua index 232cb237..d86bba0a 100644 --- a/script-beta/vm/eachRef.lua +++ b/script-beta/vm/eachRef.lua @@ -1,5 +1,6 @@ -local vm = require 'vm.vm' -local guide = require 'parser.guide' +local vm = require 'vm.vm' +local guide = require 'parser.guide' +local util = require 'utility' local function eachRef(source, results) results = results or {} @@ -8,7 +9,10 @@ local function eachRef(source, results) return results end - local myResults = guide.requestReference(source, vm.interface) + local myResults, count = guide.requestReference(source, vm.interface) + if DEVELOP and count > 10 then + log.warn('requestReference', count, util.dump(source, { deep = 0 })) + end vm.mergeResults(results, myResults) lock() |