File: aot.lua

package info (click to toggle)
fennel 1.5.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,456 kB
  • sloc: makefile: 171; sh: 4
file content (33 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (2)
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
-- Just a tiny shim to allow AOT
-- This is only used to bootstrap the main compiler.
local fennel = dofile("bootstrap/fennel.lua")

local opts = {
   ["compiler-env"]=_G,
   allowedGlobals={},
   useMetadata=false,
   filename=assert(arg[1]),
}

for k in pairs(_G) do table.insert(opts.allowedGlobals, k) end

for i=2,#arg do
   if arg[i] == "--require-as-include" then opts.requireAsInclude = true end
   if arg[i] == "--macro" then
      opts.useMetadata = "utils['fennel-module'].metadata"
      opts.scope = "_COMPILER"
      opts.allowedGlobals = false
   end
end

local f = assert(io.open(opts.filename))
local compile = function() return fennel.compileString(f:read("*a"), opts) end
local ok, val = xpcall(compile, fennel.traceback)

if(ok) then
   print(val)
else
   io.stderr:write(val)
   io.stderr:write("\n")
   os.exit(1)
end