summaryrefslogtreecommitdiff
path: root/script/vm/node/init.lua
blob: 524dab4edb99cbf8bef03599e108207057634c09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local files    = require 'files'
local compiler = require 'vm.node.compiler'
local vmState  = require 'vm.state'

for uri in files.eachFile() do
    local state = files.getState(uri)
    if state then
        compiler.compileGlobals(state.ast)
    end
end

files.watch(function (ev, uri)
    if ev == 'update' then
        local state = files.getState(uri)
        if state then
            compiler.compileGlobals(state.ast)
        end
    end
    if ev == 'remove' then
        vmState.dropUri(uri)
    end
end)