Lifetimes are declared, now I gotta fix the lifetime issues
This commit is contained in:
@@ -4,73 +4,73 @@ use helpers::prelude::*;
|
||||
|
||||
documented! {
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum Math {
|
||||
pub enum Math<'a> {
|
||||
/// Returns the angle in radians whose cosine is the specified number.
|
||||
/// ## IC10
|
||||
/// `acos r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = acos(number|var|expression);`
|
||||
Acos(Box<Spanned<Expression>>),
|
||||
Acos(Box<Spanned<Expression<'a>>>),
|
||||
/// Returns the angle in radians whose sine is the specified number.
|
||||
/// ## IC10
|
||||
/// `asin r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = asin(number|var|expression);`
|
||||
Asin(Box<Spanned<Expression>>),
|
||||
Asin(Box<Spanned<Expression<'a>>>),
|
||||
/// Returns the angle in radians whose tangent is the specified number.
|
||||
/// ## IC10
|
||||
/// `atan r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = atan(number|var|expression);`
|
||||
Atan(Box<Spanned<Expression>>),
|
||||
Atan(Box<Spanned<Expression<'a>>>),
|
||||
/// Returns the angle in radians whose tangent is the quotient of the specified numbers.
|
||||
/// ## IC10
|
||||
/// `atan2 r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = atan2((number|var|expression), (number|var|expression));`
|
||||
Atan2(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
Atan2(Box<Spanned<Expression<'a>>>, Box<Spanned<Expression<'a>>>),
|
||||
/// Gets the absolute value of a number.
|
||||
/// ## IC10
|
||||
/// `abs r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = abs((number|var|expression));`
|
||||
Abs(Box<Spanned<Expression>>),
|
||||
Abs(Box<Spanned<Expression<'a>>>),
|
||||
/// Rounds a number up to the nearest whole number.
|
||||
/// ## IC10
|
||||
/// `ceil r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = ceil((number|var|expression));`
|
||||
Ceil(Box<Spanned<Expression>>),
|
||||
Ceil(Box<Spanned<Expression<'a>>>),
|
||||
/// Returns the cosine of the specified angle in radians.
|
||||
/// ## IC10
|
||||
/// `cos r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = cos((number|var|expression));`
|
||||
Cos(Box<Spanned<Expression>>),
|
||||
Cos(Box<Spanned<Expression<'a>>>),
|
||||
/// Rounds a number down to the nearest whole number.
|
||||
/// ## IC10
|
||||
/// `floor r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = floor((number|var|expression));`
|
||||
Floor(Box<Spanned<Expression>>),
|
||||
Floor(Box<Spanned<Expression<'a>>>),
|
||||
/// Computes the natural logarithm of a number.
|
||||
/// ## IC10
|
||||
/// `log r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = log((number|var|expression));`
|
||||
Log(Box<Spanned<Expression>>),
|
||||
Log(Box<Spanned<Expression<'a>>>),
|
||||
/// Computes the maximum of two numbers.
|
||||
/// ## IC10
|
||||
/// `max r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = max((number|var|expression), (number|var|expression));`
|
||||
Max(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
Max(Box<Spanned<Expression<'a>>>, Box<Spanned<Expression<'a>>>),
|
||||
/// Computes the minimum of two numbers.
|
||||
/// ## IC10
|
||||
/// `min r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = min((number|var|expression), (number|var|expression));`
|
||||
Min(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
Min(Box<Spanned<Expression<'a>>>, Box<Spanned<Expression<'a>>>),
|
||||
/// Gets a random number between 0 and 1.
|
||||
/// ## IC10
|
||||
/// `rand r?`
|
||||
@@ -82,29 +82,29 @@ documented! {
|
||||
/// `sin r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = sin((number|var|expression));`
|
||||
Sin(Box<Spanned<Expression>>),
|
||||
Sin(Box<Spanned<Expression<'a>>>),
|
||||
/// Computes the square root of a number.
|
||||
/// ## IC10
|
||||
/// `sqrt r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = sqrt((number|var|expression));`
|
||||
Sqrt(Box<Spanned<Expression>>),
|
||||
Sqrt(Box<Spanned<Expression<'a>>>),
|
||||
/// Returns the tangent of the specified angle in radians.
|
||||
/// ## IC10
|
||||
/// `tan r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = tan((number|var|expression));`
|
||||
Tan(Box<Spanned<Expression>>),
|
||||
Tan(Box<Spanned<Expression<'a>>>),
|
||||
/// Truncates a number by removing the decimal portion.
|
||||
/// ## IC10
|
||||
/// `trunc r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `let item = trunc((number|var|expression));`
|
||||
Trunc(Box<Spanned<Expression>>),
|
||||
Trunc(Box<Spanned<Expression<'a>>>),
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Math {
|
||||
impl<'a> std::fmt::Display for Math<'a> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Math::Acos(a) => write!(f, "acos({})", a),
|
||||
@@ -129,7 +129,7 @@ impl std::fmt::Display for Math {
|
||||
|
||||
documented! {
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum System {
|
||||
pub enum System<'a> {
|
||||
/// Pauses execution for exactly 1 tick and then resumes.
|
||||
/// ## IC10
|
||||
/// `yield`
|
||||
@@ -141,7 +141,7 @@ documented! {
|
||||
/// `sleep a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `sleep(number|var);`
|
||||
Sleep(Box<Spanned<Expression>>),
|
||||
Sleep(Box<Spanned<Expression<'a>>>),
|
||||
/// Gets the in-game hash for a specific prefab name. NOTE! This call is COMPLETELY
|
||||
/// optimized away unless you bind it to a `let` variable. If you use a `const` variable
|
||||
/// however, the hash is correctly computed at compile time and substitued automatically.
|
||||
@@ -155,7 +155,7 @@ documented! {
|
||||
/// const compDoor = hash("StructureCompositeDoor");
|
||||
/// setOnDeviceBatched(compDoor, "Lock", true);
|
||||
/// ```
|
||||
Hash(Spanned<Literal>),
|
||||
Hash(Spanned<Literal<'a>>),
|
||||
/// Represents a function which loads a device variable into a register.
|
||||
/// ## IC10
|
||||
/// `l r? d? var`
|
||||
@@ -163,7 +163,7 @@ documented! {
|
||||
/// `let item = load(deviceHash, "LogicType");`
|
||||
/// `let item = l(deviceHash, "LogicType");`
|
||||
/// `let item = deviceAlias.LogicType;`
|
||||
LoadFromDevice(Spanned<LiteralOrVariable>, Spanned<Literal>),
|
||||
LoadFromDevice(Spanned<LiteralOrVariable<'a>>, Spanned<Literal<'a>>),
|
||||
/// Function which gets a LogicType from all connected network devices that match
|
||||
/// the provided device hash and name, aggregating them via a batchMode
|
||||
/// ## IC10
|
||||
@@ -172,10 +172,10 @@ documented! {
|
||||
/// `loadBatchedNamed(deviceHash, deviceName, "LogicType", "BatchMode");`
|
||||
/// `lbn(deviceHash, deviceName, "LogicType", "BatchMode");`
|
||||
LoadBatchNamed(
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<Literal>,
|
||||
Spanned<Literal>,
|
||||
Spanned<LiteralOrVariable<'a>>,
|
||||
Spanned<LiteralOrVariable<'a>>,
|
||||
Spanned<Literal<'a>>,
|
||||
Spanned<Literal<'a>>,
|
||||
),
|
||||
/// Loads a LogicType from all connected network devices, aggregating them via a
|
||||
/// BatchMode
|
||||
@@ -184,7 +184,7 @@ documented! {
|
||||
/// ## Slang
|
||||
/// `loadBatched(deviceHash, "Variable", "LogicType");`
|
||||
/// `lb(deviceHash, "Variable", "LogicType");`
|
||||
LoadBatch(Spanned<LiteralOrVariable>, Spanned<Literal>, Spanned<Literal>),
|
||||
LoadBatch(Spanned<LiteralOrVariable<'a>>, Spanned<Literal<'a>>, Spanned<Literal<'a>>),
|
||||
/// Represents a function which stores a setting into a specific device.
|
||||
/// ## IC10
|
||||
/// `s d? logicType r?`
|
||||
@@ -192,7 +192,7 @@ documented! {
|
||||
/// `set(deviceHash, "LogicType", (number|var));`
|
||||
/// `s(deviceHash, "LogicType", (number|var));`
|
||||
/// `deviceAlias.LogicType = (number|var);`
|
||||
SetOnDevice(Spanned<LiteralOrVariable>, Spanned<Literal>, Box<Spanned<Expression>>),
|
||||
SetOnDevice(Spanned<LiteralOrVariable<'a>>, Spanned<Literal<'a>>, Box<Spanned<Expression<'a>>>),
|
||||
/// Represents a function which stores a setting to all devices that match
|
||||
/// the given deviceHash
|
||||
/// ## IC10
|
||||
@@ -200,7 +200,7 @@ documented! {
|
||||
/// ## Slang
|
||||
/// `setBatched(deviceHash, "LogicType", (number|var));`
|
||||
/// `sb(deviceHash, "LogicType", (number|var));`
|
||||
SetOnDeviceBatched(Spanned<LiteralOrVariable>, Spanned<Literal>, Box<Spanned<Expression>>),
|
||||
SetOnDeviceBatched(Spanned<LiteralOrVariable<'a>>, Spanned<Literal<'a>>, Box<Spanned<Expression<'a>>>),
|
||||
/// Represents a function which stores a setting to all devices that match
|
||||
/// both the given deviceHash AND the given nameHash
|
||||
/// ## IC10
|
||||
@@ -209,15 +209,15 @@ documented! {
|
||||
/// `setBatchedNamed(deviceHash, nameHash, "LogicType", (number|var));`
|
||||
/// `sbn(deviceHash, nameHash, "LogicType", (number|var));`
|
||||
SetOnDeviceBatchedNamed(
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<Literal>,
|
||||
Box<Spanned<Expression>>,
|
||||
Spanned<LiteralOrVariable<'a>>,
|
||||
Spanned<LiteralOrVariable<'a>>,
|
||||
Spanned<Literal<'a>>,
|
||||
Box<Spanned<Expression<'a>>>,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for System {
|
||||
impl<'a> std::fmt::Display for System<'a> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
System::Yield => write!(f, "yield()"),
|
||||
@@ -242,13 +242,13 @@ impl std::fmt::Display for System {
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
/// This represents built in functions that cannot be overwritten, but can be invoked by the user as functions.
|
||||
pub enum SysCall {
|
||||
System(System),
|
||||
pub enum SysCall<'a> {
|
||||
System(System<'a>),
|
||||
/// Represents any mathmatical function that can be called.
|
||||
Math(Math),
|
||||
Math(Math<'a>),
|
||||
}
|
||||
|
||||
impl Documentation for SysCall {
|
||||
impl<'a> Documentation for SysCall<'a> {
|
||||
fn docs(&self) -> String {
|
||||
match self {
|
||||
Self::System(s) => s.docs(),
|
||||
@@ -264,7 +264,7 @@ impl Documentation for SysCall {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SysCall {
|
||||
impl<'a> std::fmt::Display for SysCall<'a> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
SysCall::System(s) => write!(f, "{}", s),
|
||||
@@ -273,7 +273,7 @@ impl std::fmt::Display for SysCall {
|
||||
}
|
||||
}
|
||||
|
||||
impl SysCall {
|
||||
impl<'a> SysCall<'a> {
|
||||
pub fn is_syscall(identifier: &str) -> bool {
|
||||
tokenizer::token::is_syscall(identifier)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user