luaur_compiler/methods/
compiler_is_stat_break.rs1use crate::records::compiler::Compiler;
2use luaur_ast::records::ast_node::AstNode;
3use luaur_ast::records::ast_stat::AstStat;
4use luaur_ast::records::ast_stat_block::AstStatBlock;
5use luaur_ast::records::ast_stat_break::AstStatBreak;
6
7impl Compiler {
8 pub fn is_stat_break(&mut self, node: *mut AstStat) -> bool {
9 unsafe {
10 if node.is_null() {
11 return false;
12 }
13
14 let stat_block = luaur_ast::rtti::ast_node_as::<AstStatBlock>(node as *mut AstNode);
15 if !stat_block.is_null() {
16 let stat_block = &*stat_block;
17
18 stat_block.body.size == 1
19 && !luaur_ast::rtti::ast_node_as::<AstStatBreak>(
20 *stat_block.body.data.add(0) as *mut AstNode
21 )
22 .is_null()
23 } else {
24 !luaur_ast::rtti::ast_node_as::<AstStatBreak>(node as *mut AstNode).is_null()
25 }
26 }
27 }
28}