From 091e16124c5748942b11599287e5e0d973a475af Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 17 Mar 2023 06:28:00 +0800 Subject: [PATCH] Add isAnonymous to JSON metadata. --- CHANGELOG.md | 3 ++- src/serde/metadata.rs | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5913e007..b04490af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Bug fixes * Complex indexing/dotting chains now parse correctly, for example: `a[b][c[d]].e` * `map` and `filter` for arrays are marked `pure`. Warnings are added to the documentation of pure array methods that take `this` closures. * Syntax such as `foo.bar::baz` no longer panics, but returns a proper parse error. -* `x += y` where `x` and `y` are `char` now works correctly. +* Some op-assignment statements, such as `x += y` where `x` and `y` are `char`, now work correctly instead of failing silently. * Expressions such as `!inside` now parses correctly instead of as `!in` followed by `side`. * Custom syntax starting with symbols now works correctly and no longer raises a parse error. * Comparing different custom types now works correctly when the appropriate comparison operators are registered. @@ -32,6 +32,7 @@ Enhancements * Loading a module via `import` now gives the module access to the current scope, including variables and constants defined inside. * Some very simple operator calls (e.g. integer add) are short-circuited to avoid the overhead of a function call, resulting in a small speed improvement. * The tokenizer now uses table-driven keyword recognizers generated by GNU gperf. At least _theoretically_ it should be faster... +* The field `isAnonymous` is added to JSON functions metadata. Version 1.12.0 diff --git a/src/serde/metadata.rs b/src/serde/metadata.rs index fa41fd6b..124d8fed 100644 --- a/src/serde/metadata.rs +++ b/src/serde/metadata.rs @@ -3,6 +3,7 @@ use crate::api::formatting::format_type; use crate::module::{calc_native_fn_hash, FuncInfo, ModuleFlags}; +use crate::parser::is_anonymous_fn; use crate::{calc_fn_hash, Engine, FnAccess, SmartString, StaticVec, AST}; use serde::Serialize; #[cfg(feature = "no_std")] @@ -34,6 +35,7 @@ struct FnMetadata<'a> { pub namespace: crate::FnNamespace, pub access: FnAccess, pub name: &'a str, + pub is_anonymous: bool, #[serde(rename = "type")] pub typ: FnType, pub num_params: usize, @@ -83,6 +85,7 @@ impl<'a> From<&'a FuncInfo> for FnMetadata<'a> { namespace: info.metadata.namespace, access: info.metadata.access, name: &info.metadata.name, + is_anonymous: is_anonymous_fn(&info.metadata.name), typ, num_params: info.metadata.num_params, params: info