From 057fcfe3dfb771b2b790b236fec4afb46891eaeb Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 7 Aug 2021 17:31:01 +0800 Subject: [PATCH] default parameter value generation --- nac3core/src/codegen/expr.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index f93975ab..ccba23c9 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -88,7 +88,16 @@ impl<'ctx> CodeGenContext<'ctx> { } fn gen_symbol_val(&mut self, val: &SymbolValue) -> BasicValueEnum<'ctx> { - unimplemented!() + match val { + SymbolValue::I32(v) => self.ctx.i32_type().const_int(*v as u64, true).into(), + SymbolValue::I64(v) => self.ctx.i64_type().const_int(*v as u64, true).into(), + SymbolValue::Bool(v) => self.ctx.bool_type().const_int(*v as u64, true).into(), + SymbolValue::Double(v) => self.ctx.f64_type().const_float(*v).into(), + SymbolValue::Tuple(ls) => { + let vals = ls.iter().map(|v| self.gen_symbol_val(v)).collect_vec(); + self.ctx.const_struct(&vals, false).into() + } + } } fn gen_call(