11local util = require ' utility'
22local scope = require ' workspace.scope'
33local guide = require ' parser.guide'
4- local files = require ' files'
54--- @class vm
65local vm = require ' vm.vm'
76
@@ -569,43 +568,6 @@ function vm.getGlobalBase(source)
569568 return source ._globalBase
570569end
571570
572- --- @param source parser.object
573- local function compileSelf (source )
574- if source .parent .type ~= ' funcargs' then
575- return
576- end
577- --- @type parser.object
578- local node = source .parent .parent and source .parent .parent .parent and source .parent .parent .parent .node
579- if not node then
580- return
581- end
582- local fields = vm .getVariableFields (source , false )
583- if not fields then
584- return
585- end
586- local nodeLocalID = vm .getVariableID (node )
587- local globalNode = node ._globalNode
588- if not nodeLocalID and not globalNode then
589- return
590- end
591- for _ , field in ipairs (fields ) do
592- if field .type == ' setfield' then
593- local key = guide .getKeyName (field )
594- if key then
595- if nodeLocalID then
596- local myID = nodeLocalID .. vm .ID_SPLITE .. key
597- vm .insertVariableID (myID , field )
598- end
599- if globalNode then
600- local myID = globalNode :getName () .. vm .ID_SPLITE .. key
601- local myGlobal = vm .declareGlobal (' variable' , myID , guide .getUri (node ))
602- myGlobal :addSet (guide .getUri (node ), field )
603- end
604- end
605- end
606- end
607- end
608-
609571--- @param source parser.object
610572local function compileAst (source )
611573 local env = guide .getENV (source )
@@ -628,18 +590,6 @@ local function compileAst(source)
628590 }, function (src )
629591 compileObject (src )
630592 end )
631-
632- --[[
633- local mt
634- function mt:xxx()
635- self.a = 1
636- end
637-
638- mt.a --> find this definition
639- ]]
640- guide .eachSourceType (source , ' self' , function (src )
641- compileSelf (src )
642- end )
643593end
644594
645595--- @param uri uri
@@ -657,18 +607,7 @@ local function dropUri(uri)
657607 end
658608end
659609
660- --- @async
661- files .watch (function (ev , uri )
662- if ev == ' update' then
663- dropUri (uri )
664- end
665- if ev == ' remove' then
666- dropUri (uri )
667- end
668- if ev == ' compile' then
669- local state = files .getLastState (uri )
670- if state then
671- compileAst (state .ast )
672- end
673- end
674- end )
610+ return {
611+ compileAst = compileAst ,
612+ dropUri = dropUri ,
613+ }
0 commit comments