Skip to main content

luaur_compiler/methods/
compiler_get_constant.rs

1use crate::enums::type_constant_folding::Type;
2use crate::records::compiler::Compiler;
3use crate::records::constant::Constant;
4use luaur_ast::records::ast_expr::AstExpr;
5
6impl Compiler {
7    pub fn get_constant(&mut self, node: *mut AstExpr) -> Constant {
8        if let Some(cv) = self.constants.find(&node) {
9            *cv
10        } else {
11            Constant {
12                r#type: Type::Type_Unknown,
13                string_length: 0,
14                data: unsafe { core::mem::zeroed() },
15            }
16        }
17    }
18}