From 4fe643f45b15b6d2091c9582184b26f38229cd2b Mon Sep 17 00:00:00 2001 From: pca006132 Date: Wed, 22 Sep 2021 14:45:42 +0800 Subject: [PATCH] allows function ending with a number --- nac3core/src/codegen/expr.rs | 2 +- nac3core/src/toplevel/composer.rs | 9 --------- nac3core/src/toplevel/mod.rs | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index e5aa9b6e1..83547bfa1 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -150,7 +150,7 @@ impl<'ctx, 'a> CodeGenContext<'ctx, 'a> { } = &mut *definition.write() { instance_to_symbol.get(&key).cloned().unwrap_or_else(|| { - let symbol = format!("{}_{}", name, instance_to_symbol.len()); + let symbol = format!("{}.{}", name, instance_to_symbol.len()); instance_to_symbol.insert(key, symbol.clone()); let key = self.get_subst_key(obj.map(|a| a.0), fun.0, Some(var_id)); let instance = instance_to_stmt.get(&key).unwrap(); diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 5819be38b..b961ccd81 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -183,12 +183,6 @@ impl TopLevelComposer { if self.keyword_list.contains(method_name) { return Err("cannot use keyword as a method name".into()); } - if method_name.ends_with(|x: char| x.is_ascii_digit()) { - return Err(format!( - "function name `{}` must not end with numbers", - method_name - )); - } let global_class_method_name = { let mut n = mod_path.clone(); n.push_str( @@ -253,9 +247,6 @@ impl TopLevelComposer { if self.keyword_list.contains(name) { return Err("cannot use keyword as a top level function name".into()); } - if name.ends_with(|x: char| x.is_ascii_digit()) { - return Err(format!("function name `{}` must not end with numbers", name)); - } let fun_name = name.to_string(); let global_fun_name = { let mut n = mod_path; diff --git a/nac3core/src/toplevel/mod.rs b/nac3core/src/toplevel/mod.rs index 4076931fe..edc5becdb 100644 --- a/nac3core/src/toplevel/mod.rs +++ b/nac3core/src/toplevel/mod.rs @@ -57,7 +57,7 @@ pub enum TopLevelDef { constructor: Option, }, Function { - // prefix for symbol, should be unique globally, and not ending with numbers + // prefix for symbol, should be unique globally name: String, // simple name, the same as in method/function definition simple_name: String,