mzte-nv will pass info about source file to fennel
This commit is contained in:
parent
7cb4f971d0
commit
3b507677e1
|
@ -1,6 +1,7 @@
|
|||
const std = @import("std");
|
||||
const ffi = @import("ffi.zig");
|
||||
const c = ffi.c;
|
||||
const ser = @import("ser.zig");
|
||||
|
||||
const log = std.log.scoped(.compiler);
|
||||
|
||||
|
@ -135,7 +136,13 @@ pub fn doCompile(path: []const u8, alloc: std.mem.Allocator) !void {
|
|||
// fennel.compile-string
|
||||
c.lua_getfield(l, -3, "compile-string");
|
||||
ffi.luaPushString(l, data);
|
||||
if (c.lua_pcall(l, 1, 1, 0) != 0) {
|
||||
// push fennel compile options
|
||||
ser.luaPushAny(l.?, .{
|
||||
.filename = luafile,
|
||||
// no need for indenting, this code will likely not be seen by anyone
|
||||
.indent = "",
|
||||
});
|
||||
if (c.lua_pcall(l, 2, 1, 0) != 0) {
|
||||
log.warn(
|
||||
"error compiling fennel object {s}: {s}",
|
||||
.{ luafile, ffi.luaToString(l, -1) },
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const c = @import("ffi.zig").c;
|
||||
const ffi = @import("ffi.zig");
|
||||
const c = ffi.c;
|
||||
|
||||
pub fn luaPushAny(l: *c.lua_State, x: anytype) void {
|
||||
const T = @TypeOf(x);
|
||||
|
@ -14,16 +15,17 @@ pub fn luaPushAny(l: *c.lua_State, x: anytype) void {
|
|||
.One => {
|
||||
if (T == c.lua_CFunction or
|
||||
T == @typeInfo(c.lua_CFunction).Optional.child)
|
||||
c.lua_pushcfunction(l, x)
|
||||
else
|
||||
{
|
||||
c.lua_pushcfunction(l, x);
|
||||
} else if (@typeInfo(P.child) == .Array) {
|
||||
luaPushAny(l, @as([]const std.meta.Elem(P.child), x));
|
||||
} else {
|
||||
luaPushAny(l, x.*);
|
||||
}
|
||||
},
|
||||
.Slice => {
|
||||
if (P.child == u8) {
|
||||
if (P.sentinel == null)
|
||||
@compileError("luaPushAny doesn't support " ++ @typeName(T));
|
||||
|
||||
c.lua_pushstring(l, x.ptr);
|
||||
ffi.luaPushString(l, x);
|
||||
} else {
|
||||
c.lua_createtable(l, x.len, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue