summaryrefslogtreecommitdiff
path: root/script/vm/manager.lua
blob: c9103ff92b8085b7ab6d1a2e14175c064f544d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

local files          = require 'files'
local globalManager  = require 'vm.global-manager'
local localManager = require 'vm.local-manager'

---@alias vm.object parser.object | vm.global | vm.generic

---@class vm.state
local m = {}
for uri in files.eachFile() do
    local state = files.getState(uri)
    if state then
        globalManager.compileAst(state.ast)
    end
end

files.watch(function (ev, uri)
    if ev == 'update' then
        globalManager.dropUri(uri)
        localManager.dropUri(uri)
        local state = files.getState(uri)
        if state then
            globalManager.compileAst(state.ast)
        end
    end
    if ev == 'remove' then
        globalManager.dropUri(uri)
        localManager.dropUri(uri)
    end
end)


return m