luaur_ast/methods/
ast_expr_function_ast_expr_function.rs1use crate::records::ast_array::AstArray;
2use crate::records::ast_attr::AstAttr;
3use crate::records::ast_expr::AstExpr;
4use crate::records::ast_expr_function::AstExprFunction;
5use crate::records::ast_generic_type::AstGenericType;
6use crate::records::ast_generic_type_pack::AstGenericTypePack;
7use crate::records::ast_local::AstLocal;
8use crate::records::ast_name::AstName;
9use crate::records::ast_node::AstNode;
10use crate::records::ast_stat_block::AstStatBlock;
11use crate::records::ast_type_pack::AstTypePack;
12use crate::records::location::Location;
13use crate::rtti::AstNodeClass;
14
15impl AstExprFunction {
16 pub fn new(
17 location: Location,
18 attributes: AstArray<*mut AstAttr>,
19 generics: AstArray<*mut AstGenericType>,
20 generic_packs: AstArray<*mut AstGenericTypePack>,
21 self_: *mut AstLocal,
22 args: AstArray<*mut AstLocal>,
23 vararg: bool,
24 vararg_location: Location,
25 body: *mut AstStatBlock,
26 function_depth: usize,
27 debugname: AstName,
28 return_annotation: *mut AstTypePack,
29 vararg_annotation: *mut AstTypePack,
30 arg_location: Option<Location>,
31 ) -> Self {
32 Self {
33 base: AstExpr {
34 base: AstNode {
35 class_index: <Self as AstNodeClass>::CLASS_INDEX,
36 location,
37 },
38 },
39 attributes,
40 generics,
41 generic_packs,
42 self_,
43 args,
44 return_annotation,
45 vararg,
46 vararg_location,
47 vararg_annotation,
48 body,
49 function_depth,
50 debugname,
51 arg_location,
52 }
53 }
54}
55
56#[no_mangle]
57pub unsafe extern "C" fn ast_expr_function_ast_expr_function(
58 location: Location,
59 attributes: AstArray<*mut AstAttr>,
60 generics: AstArray<*mut AstGenericType>,
61 generic_packs: AstArray<*mut AstGenericTypePack>,
62 self_: *mut AstLocal,
63 args: AstArray<*mut AstLocal>,
64 vararg: bool,
65 vararg_location: Location,
66 body: *mut AstStatBlock,
67 function_depth: usize,
68 debugname: AstName,
69 return_annotation: *mut AstTypePack,
70 vararg_annotation: *mut AstTypePack,
71 arg_location: *const Option<Location>,
72) -> AstExprFunction {
73 AstExprFunction::new(
74 location,
75 attributes,
76 generics,
77 generic_packs,
78 self_,
79 args,
80 vararg,
81 vararg_location,
82 body,
83 function_depth,
84 debugname,
85 return_annotation,
86 vararg_annotation,
87 if arg_location.is_null() {
88 None
89 } else {
90 *arg_location
91 },
92 )
93}