summaryrefslogtreecommitdiff
path: root/script/vm/precompile.lua
blob: 47c630260dccf43623610f68cb0b0ee64a1c3a52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local files    = require 'files'
local global   = require 'vm.global'
local variable = require 'vm.variable'

---@async
files.watch(function (ev, uri)
    if ev == 'update' then
        global.dropUri(uri)
    end
    if ev == 'remove' then
        global.dropUri(uri)
    end
    if ev == 'compile' then
        local state = files.getLastState(uri)
        if state then
            global.compileAst(state.ast)
            variable.compileAst(state.ast)
        end
    end
end)