Skip to main content

luaur_compiler/methods/
compiler_compile_expr_temp_mult_ret.rs

1use crate::records::compiler::Compiler;
2use crate::records::reg_scope::RegScope;
3use luaur_ast::records::ast_expr::AstExpr;
4use luaur_ast::records::ast_expr_call::AstExprCall;
5use luaur_ast::records::ast_expr_varargs::AstExprVarargs;
6use luaur_ast::rtti;
7
8impl Compiler {
9    pub fn compile_expr_temp_mult_ret(&mut self, node: *mut AstExpr, target: u8) -> bool {
10        unsafe {
11            let expr = rtti::ast_node_as::<AstExprCall>(node as *mut _);
12            if !expr.is_null() {
13                if self.options.optimization_level >= 2 && !self.is_expr_mult_ret(node) {
14                    self.compile_expr_temp(node, target);
15                    return false;
16                }
17                let mut rs = self.reg_scope_compiler_i32(target as u32);
18                self.compile_expr_call(expr, target, 0, true, true);
19                return true;
20            } else {
21                let expr = rtti::ast_node_as::<AstExprVarargs>(node as *mut _);
22                if !expr.is_null() {
23                    let mut rs = self.reg_scope_compiler_i32(target as u32);
24                    self.compile_expr_varargs(expr, target, 0, true);
25                    return true;
26                } else {
27                    self.compile_expr_temp(node, target);
28                    return false;
29                }
30            }
31        }
32    }
33}