From 612fb222a08ed9900fbdbcec445efe5ca991263d Mon Sep 17 00:00:00 2001 From: Ben Ruijl Date: Tue, 13 Aug 2024 16:08:06 +0200 Subject: [PATCH] Add drop_buffer to the prelude --- src/evaluate.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/evaluate.rs b/src/evaluate.rs index 78ebe19..947db48 100644 --- a/src/evaluate.rs +++ b/src/evaluate.rs @@ -1179,10 +1179,11 @@ impl ExpressionEvaluator { } pub fn export_asm_str(&self, function_name: &str, include_header: bool) -> String { - let mut res = if include_header { - "#include \n#include \n#include \n\n".to_string() - } else { - String::new() + let mut res = String::new(); + if include_header { + res += &"#include \n#include \n#include \n\n"; + res += &"extern \"C\" void drop_buffer_complex(std::complex *buffer)\n{\n\tdelete[] buffer;\n}\n\n"; + res += &"extern \"C\" void drop_buffer_double(double *buffer)\n{\n\tdelete[] buffer;\n}\n\n"; }; res += &format!( @@ -1190,7 +1191,6 @@ impl ExpressionEvaluator { function_name, self.stack.len() ); - res += &"extern \"C\" void drop_buffer_complex(std::complex *buffer)\n{\n\tdelete[] buffer;\n}\n\n"; res += &format!( "static const std::complex CONSTANTS_complex[{}] = {{{}}};\n\n", @@ -1215,8 +1215,6 @@ impl ExpressionEvaluator { function_name, self.stack.len() ); - res += - &"extern \"C\" void drop_buffer_double(double *buffer)\n{\n\tdelete[] buffer;\n}\n\n"; res += &format!( "static const double CONSTANTS_double[{}] = {{{}}};\n\n",