luau_parser/types/expression/
function.rs1use luau_lexer::prelude::Token;
2use luau_parser_derive::{Print, Range};
3
4use crate::types::{
5 Block, BracketedList, Expression, GenericDeclaration, Parameter, Pointer, PrefixExp, Table,
6 TypeValue,
7};
8
9#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
11#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
12pub enum FunctionCallInvoked {
13 Function(Pointer<PrefixExp>),
19
20 TableMethod {
27 table: Pointer<PrefixExp>,
29
30 colon: Pointer<Token>,
32
33 method: Pointer<Token>,
35 },
36}
37
38#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
44#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
45pub struct FunctionCall {
46 pub invoked: FunctionCallInvoked,
48
49 pub arguments: FunctionArguments,
51}
52
53#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
55#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
56pub enum FunctionArguments {
57 String(Token),
63
64 Table(Table),
70
71 List(BracketedList<Pointer<FunctionArgument>>),
77}
78
79#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
81#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
82pub enum FunctionArgument {
83 Expression(Expression),
85
86 VariadicValues(Token),
92}
93
94#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Range, Print)]
96#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
97pub struct Closure {
98 pub function_keyword: Token,
100
101 pub generics: Option<Pointer<GenericDeclaration>>,
103
104 pub parameters: BracketedList<Parameter>,
106
107 pub colon: Option<Pointer<Token>>,
109
110 pub return_type: Option<Pointer<TypeValue>>,
112
113 pub body: Block,
115
116 pub end_keyword: Token,
118}