Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
},

.luau = .{
.url = "https://github.com/luau-lang/luau/archive/refs/tags/0.607.tar.gz",
.hash = "122003818ff2aa912db37d4bbda314ff9ff70d03d9243af4b639490be98e2bfa7cb6",
.url = "https://github.com/luau-lang/luau/archive/refs/tags/0.653.tar.gz",
.hash = "1220c76fb74b983b0ebfdd6b3a4aa8adf0c1ff69c9b6a9e9e05f9bc6a6c57a690e23",
},
},
}
4 changes: 3 additions & 1 deletion build/luau.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
.name = "luau",
.target = target,
.optimize = optimize,
.version = std.SemanticVersion{ .major = 0, .minor = 607, .patch = 0 },
.version = std.SemanticVersion{ .major = 0, .minor = 653, .patch = 0 },
});

lib.addIncludePath(upstream.path("Common/include"));
Expand Down Expand Up @@ -84,10 +84,12 @@ const luau_source_files = [_][]const u8{
"VM/src/ltm.cpp",
"VM/src/ludata.cpp",
"VM/src/lutf8lib.cpp",
"VM/src/lveclib.cpp",
"VM/src/lvmexecute.cpp",
"VM/src/lvmload.cpp",
"VM/src/lvmutils.cpp",

"Ast/src/Allocator.cpp",
"Ast/src/Ast.cpp",
"Ast/src/Confusables.cpp",
"Ast/src/Lexer.cpp",
Expand Down
42 changes: 40 additions & 2 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4296,6 +4296,18 @@ pub const Lua = opaque {
if (lang == .lua52 or lang == .lua53 or lang == .lua54) lua.pop(1);
}

/// Open the vector standard library
///
/// Only available in Luau
///
/// * Pops: `0`
/// * Pushes: `0`
/// * Errors: `other`
pub fn openVector(lua: *Lua) void {
lua.requireF(c.LUA_VECLIBNAME, c.luaopen_vector, true);
if (lang == .lua52 or lang == .lua53 or lang == .lua54) lua.pop(1);
}

/// Returns if given typeinfo is a string type
fn isTypeString(typeinfo: std.builtin.Type.Pointer) bool {
const childinfo = @typeInfo(typeinfo.child);
Expand Down Expand Up @@ -5094,16 +5106,40 @@ pub fn wrap(comptime function: anytype) TypeOfWrap(function) {
/// Zig wrapper for Luau lua_CompileOptions that uses the same defaults as Luau if
/// no compile options is specified.
pub const CompileOptions = struct {
/// 0. no optimization
/// 1. baseline optimization level that doesn't prevent debuggability
/// 2. includes optimizations that harm debuggability such as inlining
optimization_level: i32 = 1,

/// 0. no debugging support
/// 1. line info & function names only; sufficient for backtraces
/// 2. full debug info with local & upvalue names; necessary for debugger
debug_level: i32 = 1,

/// type information is used to guide native code generation decisions
/// information includes testable types for function arguments, locals, upvalues and some temporaries
///
/// 0. generate for native modules
/// 1. generate for all modules
type_info_level: i32 = 0,

/// 0. no code coverage support
/// 1. statement coverage
/// 2. statement and expression coverage (verbose)
coverage_level: i32 = 0,
/// global builtin to construct vectors; disabled by default (<vector_lib>.<vector_ctor>)

/// alternative global builtin to construct vectors, in addition to default builtin 'vector.create'
vector_lib: ?[*:0]const u8 = null,
vector_ctor: ?[*:0]const u8 = null,
/// vector type name for type tables; disabled by default

/// alternative vector type name for type tables, in addition to default type 'vector'
vector_type: ?[*:0]const u8 = null,

/// null-terminated array of globals that are mutable; disables the import optimization for fields accessed through these
mutable_globals: ?[*:null]const ?[*:0]const u8 = null,

/// null-terminated array of userdata types that will be included in the type information
userdata_types: ?[*:null]const ?[*:0]const u8 = null,
};

/// Compile luau source into bytecode, return callee owned buffer allocated through the given allocator.
Expand All @@ -5113,10 +5149,12 @@ pub fn compile(allocator: Allocator, source: []const u8, options: CompileOptions
var opts = c.lua_CompileOptions{
.optimizationLevel = options.optimization_level,
.debugLevel = options.debug_level,
.typeInfoLevel = options.type_info_level,
.coverageLevel = options.coverage_level,
.vectorLib = options.vector_lib,
.vectorCtor = options.vector_ctor,
.mutableGlobals = options.mutable_globals,
.userdataTypes = options.userdata_types,
};
const bytecode = c.luau_compile(source.ptr, source.len, &opts, &size);
if (bytecode == null) return error.OutOfMemory;
Expand Down
Loading