Skip to content

Commit

Permalink
chore: add lua version
Browse files Browse the repository at this point in the history
  • Loading branch information
DataM0del committed Oct 5, 2024
1 parent d697839 commit 11f8dbd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions full-moon/src/ast/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const VERSION_LUA52: u8 = 1 << 1;
const VERSION_LUA53: u8 = 1 << 2;
const VERSION_LUA54: u8 = 1 << 3;
const VERSION_LUAJIT: u8 = 1 << 4;
const VERSION_PLAYDATE: u8 = 1 << 5;

/// Represents the Lua version(s) to parse as.
/// Lua 5.1 is always included.
Expand Down Expand Up @@ -103,6 +104,23 @@ impl LuaVersion {
cfg!(feature = "lua54") && (self.bitfield & VERSION_LUA54 != 0)
}

#[cfg(feature = "playdate")]
pub fn playdate() -> Self {
Self {
bitfield: VERSION_LUA52 | VERSION_LUA53 | VERSION_LUA54 | VERSION_PLAYDATE,
}
}

#[cfg(feature = "playdate")]
pub fn with_playdate(self) -> Self {
self | Self::playdate()
}

#[cfg(feature = "playdate")]
pub fn has_playdate(self) -> bool {
cfg!(feature = "playdate") && (self.bitfield & VERSION_PLAYDATE != 0)
}

/// Creates a new LuaVersion with only LuaJIT.
#[cfg(feature = "luajit")]
pub fn luajit() -> Self {
Expand Down

0 comments on commit 11f8dbd

Please sign in to comment.