mirror of
https://github.com/lune-org/lune.git
synced 2025-04-16 09:53:52 +01:00
Merge branch 'main' into smol-scheduler
This commit is contained in:
commit
6f3e2a3e7d
4 changed files with 34 additions and 23 deletions
|
@ -150,6 +150,8 @@ pub async fn copy(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs::create_dir_all(target).await?;
|
||||||
|
|
||||||
// FUTURE: Write dirs / files concurrently
|
// FUTURE: Write dirs / files concurrently
|
||||||
// to potentially speed these operations up
|
// to potentially speed these operations up
|
||||||
for (_, dir) in &contents.dirs {
|
for (_, dir) in &contents.dirs {
|
||||||
|
|
|
@ -103,9 +103,9 @@ pub fn style_from_style_str<S: AsRef<str>>(s: S) -> LuaResult<Option<&'static St
|
||||||
pub fn pretty_format_value(
|
pub fn pretty_format_value(
|
||||||
buffer: &mut String,
|
buffer: &mut String,
|
||||||
value: &LuaValue,
|
value: &LuaValue,
|
||||||
|
parent_table_addr: Option<String>,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
) -> std::fmt::Result {
|
) -> std::fmt::Result {
|
||||||
// TODO: Handle tables with cyclic references
|
|
||||||
match &value {
|
match &value {
|
||||||
LuaValue::Nil => write!(buffer, "nil")?,
|
LuaValue::Nil => write!(buffer, "nil")?,
|
||||||
LuaValue::Boolean(true) => write!(buffer, "{}", COLOR_YELLOW.apply_to("true"))?,
|
LuaValue::Boolean(true) => write!(buffer, "{}", COLOR_YELLOW.apply_to("true"))?,
|
||||||
|
@ -123,10 +123,14 @@ pub fn pretty_format_value(
|
||||||
)
|
)
|
||||||
)?,
|
)?,
|
||||||
LuaValue::Table(ref tab) => {
|
LuaValue::Table(ref tab) => {
|
||||||
|
let table_addr = Some(format!("{:p}", tab.to_pointer()));
|
||||||
|
|
||||||
if depth >= MAX_FORMAT_DEPTH {
|
if depth >= MAX_FORMAT_DEPTH {
|
||||||
write!(buffer, "{}", STYLE_DIM.apply_to("{ ... }"))?;
|
write!(buffer, "{}", STYLE_DIM.apply_to("{ ... }"))?;
|
||||||
} else if let Some(s) = call_table_tostring_metamethod(tab) {
|
} else if let Some(s) = call_table_tostring_metamethod(tab) {
|
||||||
write!(buffer, "{s}")?;
|
write!(buffer, "{s}")?;
|
||||||
|
} else if depth >= 1 && parent_table_addr.eq(&table_addr) {
|
||||||
|
write!(buffer, "{}", STYLE_DIM.apply_to("<self>"))?
|
||||||
} else {
|
} else {
|
||||||
let mut is_empty = false;
|
let mut is_empty = false;
|
||||||
let depth_indent = INDENT.repeat(depth);
|
let depth_indent = INDENT.repeat(depth);
|
||||||
|
@ -144,11 +148,11 @@ pub fn pretty_format_value(
|
||||||
)?,
|
)?,
|
||||||
_ => {
|
_ => {
|
||||||
write!(buffer, "\n{depth_indent}{INDENT}[")?;
|
write!(buffer, "\n{depth_indent}{INDENT}[")?;
|
||||||
pretty_format_value(buffer, &key, depth)?;
|
pretty_format_value(buffer, &key, parent_table_addr.clone(), depth)?;
|
||||||
write!(buffer, "] {} ", STYLE_DIM.apply_to("="))?;
|
write!(buffer, "] {} ", STYLE_DIM.apply_to("="))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pretty_format_value(buffer, &value, depth + 1)?;
|
pretty_format_value(buffer, &value, parent_table_addr.clone(), depth + 1)?;
|
||||||
write!(buffer, "{}", STYLE_DIM.apply_to(","))?;
|
write!(buffer, "{}", STYLE_DIM.apply_to(","))?;
|
||||||
is_empty = false;
|
is_empty = false;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +196,9 @@ pub fn pretty_format_multi_value(multi: &LuaMultiValue) -> LuaResult<String> {
|
||||||
if let LuaValue::String(s) = value {
|
if let LuaValue::String(s) = value {
|
||||||
write!(buffer, "{}", s.to_string_lossy()).into_lua_err()?;
|
write!(buffer, "{}", s.to_string_lossy()).into_lua_err()?;
|
||||||
} else {
|
} else {
|
||||||
pretty_format_value(&mut buffer, value, 0).into_lua_err()?;
|
let addr = format!("{:p}", value.to_pointer());
|
||||||
|
|
||||||
|
pretty_format_value(&mut buffer, value, Some(addr), 0).into_lua_err()?;
|
||||||
}
|
}
|
||||||
if counter < multi.len() {
|
if counter < multi.len() {
|
||||||
write!(&mut buffer, " ").into_lua_err()?;
|
write!(&mut buffer, " ").into_lua_err()?;
|
||||||
|
|
|
@ -29,9 +29,9 @@ export type MetadataPermissions = {
|
||||||
|
|
||||||
* `kind` - If the target path is a `file`, `dir` or `symlink`
|
* `kind` - If the target path is a `file`, `dir` or `symlink`
|
||||||
* `exists` - If the target path exists
|
* `exists` - If the target path exists
|
||||||
* `createdAt` - The timestamp at which the file or directory was created
|
* `createdAt` - The timestamp represented as a `DateTime` object at which the file or directory was created
|
||||||
* `modifiedAt` - The timestamp at which the file or directory was last modified
|
* `modifiedAt` - The timestamp represented as a `DateTime` object at which the file or directory was last modified
|
||||||
* `accessedAt` - The timestamp at which the file or directory was last accessed
|
* `accessedAt` - The timestamp represented as a `DateTime` object at which the file or directory was last accessed
|
||||||
* `permissions` - Current permissions for the file or directory
|
* `permissions` - Current permissions for the file or directory
|
||||||
|
|
||||||
Note that timestamps are relative to the unix epoch, and
|
Note that timestamps are relative to the unix epoch, and
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
@interface CompileOptions
|
@interface CompileOptions
|
||||||
@within Luau
|
@within Luau
|
||||||
|
|
||||||
The Luau compiler options used in generating luau bytecode
|
The options passed to the luau compiler while compiling bytecode.
|
||||||
|
|
||||||
This is a dictionary that may contain one or more of the following values:
|
This is a dictionary that may contain one or more of the following values:
|
||||||
|
|
||||||
* `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1`
|
* `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1`.
|
||||||
* `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0`
|
* `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0`.
|
||||||
* `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1`
|
* `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1`.
|
||||||
|
|
||||||
Documentation regarding what these values represent can be found here;
|
Documentation regarding what these values represent can be found [here](https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13-L39).
|
||||||
* https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13
|
|
||||||
]=]
|
]=]
|
||||||
export type CompileOptions = {
|
export type CompileOptions = {
|
||||||
optimizationLevel: number?,
|
optimizationLevel: number?,
|
||||||
|
@ -23,11 +22,11 @@ export type CompileOptions = {
|
||||||
@interface LoadOptions
|
@interface LoadOptions
|
||||||
@within Luau
|
@within Luau
|
||||||
|
|
||||||
The Luau load options are used for generating a lua function from either bytecode or sourcecode
|
The options passed while loading a luau chunk from an arbitrary string, or bytecode.
|
||||||
|
|
||||||
This is a dictionary that may contain one or more of the following values:
|
This is a dictionary that may contain one or more of the following values:
|
||||||
|
|
||||||
* `debugName` - The debug name of the closure. Defaults to `luau.load(...)`
|
* `debugName` - The debug name of the closure. Defaults to `luau.load(...)`.
|
||||||
* `environment` - Environment values to set and/or override. Includes default globals unless overwritten.
|
* `environment` - Environment values to set and/or override. Includes default globals unless overwritten.
|
||||||
]=]
|
]=]
|
||||||
export type LoadOptions = {
|
export type LoadOptions = {
|
||||||
|
@ -53,6 +52,9 @@ export type LoadOptions = {
|
||||||
|
|
||||||
callableFn()
|
callableFn()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Since luau bytecode is highly compressible, it may also make sense to compress it using the `serde` library
|
||||||
|
while transmitting large amounts of it.
|
||||||
]=]
|
]=]
|
||||||
local luau = {}
|
local luau = {}
|
||||||
|
|
||||||
|
@ -68,15 +70,16 @@ local luau = {}
|
||||||
```lua
|
```lua
|
||||||
local luau = require("@lune/luau")
|
local luau = require("@lune/luau")
|
||||||
|
|
||||||
|
-- Compile the source to some highly optimized bytecode
|
||||||
local bytecode = luau.compile("print('Hello, World!')", {
|
local bytecode = luau.compile("print('Hello, World!')", {
|
||||||
optimizationLevel: 1,
|
optimizationLevel = 2,
|
||||||
coverageLevel: 0,
|
coverageLevel = 0,
|
||||||
debugLevel: 1,
|
debugLevel = 1,
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
@param source The string that'll be compiled into bytecode
|
@param source The string that will be compiled into bytecode
|
||||||
@param compileOptions The luau compiler options used when compiling the source string
|
@param compileOptions The options passed to the luau compiler that will output the bytecode
|
||||||
|
|
||||||
@return luau bytecode
|
@return luau bytecode
|
||||||
]=]
|
]=]
|
||||||
|
@ -104,10 +107,10 @@ end
|
||||||
callableFn()
|
callableFn()
|
||||||
```
|
```
|
||||||
|
|
||||||
@param source Either bytecode or sourcecode
|
@param source Either luau bytecode or string source code
|
||||||
@param loadOptions The load options used when creating a callbable function
|
@param loadOptions The options passed to luau for loading the chunk
|
||||||
|
|
||||||
@return luau function
|
@return luau chunk
|
||||||
]=]
|
]=]
|
||||||
function luau.load(source: string, loadOptions: LoadOptions?): (...any) -> ...any
|
function luau.load(source: string, loadOptions: LoadOptions?): (...any) -> ...any
|
||||||
return nil :: any
|
return nil :: any
|
||||||
|
|
Loading…
Add table
Reference in a new issue