diff --git a/include/cpp2util.h b/include/cpp2util.h index 57ed3c651..06206def2 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -1224,14 +1224,14 @@ constexpr auto assert_not_zero(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAUL if constexpr (std::is_signed_v) { return std::ssize(x); } \ else { return std::size(x); } \ }; \ - auto msg = "out of bounds access attempt detected - attempted access at index " + std::to_string(arg) + ", "; \ - if (max() > 0 ) { \ - msg += "[min,max] range is [0," + std::to_string(max()-1) + "]"; \ - } \ - else { \ - msg += "but container is empty"; \ - } \ if (!(0 <= arg && arg < max())) { \ + auto msg = "out of bounds access attempt detected - attempted access at index " + std::to_string(arg) + ", "; \ + if (max() > 0 ) { \ + msg += "[min,max] range is [0," + std::to_string(max()-1) + "]"; \ + } \ + else { \ + msg += "but container is empty"; \ + } \ bounds_safety.report_violation(msg.c_str() CPP2_SOURCE_LOCATION_ARG); \ } \ return CPP2_FORWARD(x) [ arg ]; \ diff --git a/source/reflect.h b/source/reflect.h index c80c4977c..456ed910c 100644 --- a/source/reflect.h +++ b/source/reflect.h @@ -102,118 +102,118 @@ class return_statement; #line 1479 "reflect.h2" class iteration_statement; -#line 1976 "reflect.h2" +#line 2148 "reflect.h2" class value_member_info; -#line 2619 "reflect.h2" +#line 2791 "reflect.h2" class simple_traverser; -#line 4111 "reflect.h2" +#line 4283 "reflect.h2" class autodiff_special_func; -#line 4155 "reflect.h2" +#line 4327 "reflect.h2" class autodiff_declared_variable; -#line 4173 "reflect.h2" +#line 4345 "reflect.h2" class autodiff_declaration_stack_item; -#line 4217 "reflect.h2" +#line 4389 "reflect.h2" class autodiff_context; -#line 4613 "reflect.h2" +#line 4785 "reflect.h2" class autodiff_diff_code; -#line 4662 "reflect.h2" +#line 4834 "reflect.h2" class autodiff_activity_check; -#line 4760 "reflect.h2" +#line 4932 "reflect.h2" class autodiff_handler_base; -#line 4778 "reflect.h2" +#line 4950 "reflect.h2" class autodiff_expression_handler; -#line 5421 "reflect.h2" +#line 5593 "reflect.h2" class autodiff_stmt_handler; -#line 5891 "reflect.h2" +#line 6063 "reflect.h2" class autodiff_declaration_handler; -#line 6243 "reflect.h2" +#line 6415 "reflect.h2" class expression_flags; -#line 6259 "reflect.h2" +#line 6431 "reflect.h2" class regex_token; -#line 6286 "reflect.h2" +#line 6458 "reflect.h2" class regex_token_check; -#line 6307 "reflect.h2" +#line 6479 "reflect.h2" class regex_token_code; -#line 6328 "reflect.h2" +#line 6500 "reflect.h2" class regex_token_empty; -#line 6346 "reflect.h2" +#line 6518 "reflect.h2" class regex_token_list; -#line 6398 "reflect.h2" +#line 6570 "reflect.h2" class parse_context_group_state; -#line 6459 "reflect.h2" +#line 6631 "reflect.h2" class parse_context_branch_reset_state; -#line 6502 "reflect.h2" +#line 6674 "reflect.h2" class parse_context; -#line 6903 "reflect.h2" +#line 7075 "reflect.h2" class generation_function_context; -#line 6921 "reflect.h2" +#line 7093 "reflect.h2" class generation_context; -#line 7120 "reflect.h2" +#line 7292 "reflect.h2" class alternative_token; -#line 7135 "reflect.h2" +#line 7307 "reflect.h2" class alternative_token_gen; -#line 7200 "reflect.h2" +#line 7372 "reflect.h2" class any_token; -#line 7217 "reflect.h2" +#line 7389 "reflect.h2" class atomic_group_token; -#line 7247 "reflect.h2" +#line 7419 "reflect.h2" class char_token; -#line 7362 "reflect.h2" +#line 7534 "reflect.h2" class class_token; -#line 7586 "reflect.h2" +#line 7758 "reflect.h2" class group_ref_token; -#line 7723 "reflect.h2" +#line 7895 "reflect.h2" class group_token; -#line 8070 "reflect.h2" +#line 8242 "reflect.h2" class lookahead_lookbehind_token; -#line 8165 "reflect.h2" +#line 8337 "reflect.h2" class range_token; -#line 8322 "reflect.h2" +#line 8494 "reflect.h2" class special_range_token; -#line 8408 "reflect.h2" +#line 8580 "reflect.h2" template class regex_generator; -#line 8671 "reflect.h2" +#line 8846 "reflect.h2" } } @@ -1346,32 +1346,35 @@ auto copy_constructible(meta::type_declaration& t) -> void; #line 1763 "reflect.h2" auto hashable(meta::type_declaration& t) -> void; -#line 1796 "reflect.h2" +#line 1799 "reflect.h2" +auto euclidean_vector(meta::type_declaration& t) -> void; + +#line 1968 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void; -#line 1824 "reflect.h2" +#line 1996 "reflect.h2" auto value(meta::type_declaration& t) -> void; -#line 1830 "reflect.h2" +#line 2002 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void; -#line 1836 "reflect.h2" +#line 2008 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void; -#line 1865 "reflect.h2" +#line 2037 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void; -#line 1907 "reflect.h2" +#line 2079 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void; -#line 1976 "reflect.h2" +#line 2148 "reflect.h2" class value_member_info { public: std::string name; public: std::string type; public: std::string value; public: value_member_info(auto const& name_, auto const& type_, auto const& value_); -#line 1980 "reflect.h2" +#line 2152 "reflect.h2" }; auto basic_enum( @@ -1380,313 +1383,313 @@ auto basic_enum( cpp2::impl::in bitwise ) -> void; -#line 2246 "reflect.h2" +#line 2418 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void; -#line 2273 "reflect.h2" +#line 2445 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void; -#line 2319 "reflect.h2" +#line 2491 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void; -#line 2470 "reflect.h2" +#line 2642 "reflect.h2" auto print(cpp2::impl::in t) -> void; -#line 2481 "reflect.h2" +#line 2653 "reflect.h2" auto noisy(cpp2::impl::in t) -> void; struct python_param_names_and_types_ret { std::string names; std::string types; }; -#line 2505 "reflect.h2" +#line 2677 "reflect.h2" [[nodiscard]] auto python_param_names_and_types(cpp2::impl::in mf) -> python_param_names_and_types_ret; -#line 2527 "reflect.h2" +#line 2699 "reflect.h2" auto python(meta::type_declaration& t) -> void; -#line 2570 "reflect.h2" +#line 2742 "reflect.h2" auto javascript(meta::type_declaration& t) -> void; -#line 2611 "reflect.h2" +#line 2783 "reflect.h2" auto sample_print(cpp2::impl::in s, cpp2::impl::in indent) -> void; -#line 2619 "reflect.h2" +#line 2791 "reflect.h2" class simple_traverser { public: virtual auto pre_traverse(cpp2::impl::in decl) -> void; -#line 2625 "reflect.h2" +#line 2797 "reflect.h2" public: virtual auto traverse(cpp2::impl::in decl) -> void; -#line 2645 "reflect.h2" +#line 2817 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in f) -> void; -#line 2649 "reflect.h2" +#line 2821 "reflect.h2" public: virtual auto traverse(cpp2::impl::in f) -> void; -#line 2670 "reflect.h2" +#line 2842 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in o) -> void; -#line 2674 "reflect.h2" +#line 2846 "reflect.h2" public: virtual auto traverse(cpp2::impl::in o) -> void; -#line 2682 "reflect.h2" +#line 2854 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in t) -> void; -#line 2686 "reflect.h2" +#line 2858 "reflect.h2" public: virtual auto traverse(cpp2::impl::in t) -> void; -#line 2694 "reflect.h2" +#line 2866 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in t) -> void; -#line 2698 "reflect.h2" +#line 2870 "reflect.h2" public: virtual auto traverse(cpp2::impl::in t) -> void; -#line 2703 "reflect.h2" +#line 2875 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in stmt) -> void; -#line 2707 "reflect.h2" +#line 2879 "reflect.h2" public: virtual auto traverse(cpp2::impl::in stmt) -> void; -#line 2742 "reflect.h2" +#line 2914 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in stmt) -> void; -#line 2746 "reflect.h2" +#line 2918 "reflect.h2" public: virtual auto traverse(cpp2::impl::in stmt) -> void; -#line 2756 "reflect.h2" +#line 2928 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in stmt) -> void; -#line 2760 "reflect.h2" +#line 2932 "reflect.h2" public: virtual auto traverse(cpp2::impl::in stmt) -> void; -#line 2768 "reflect.h2" +#line 2940 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in stmt) -> void; -#line 2772 "reflect.h2" +#line 2944 "reflect.h2" public: virtual auto traverse(cpp2::impl::in stmt) -> void; -#line 2791 "reflect.h2" +#line 2963 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in stmt) -> void; -#line 2795 "reflect.h2" +#line 2967 "reflect.h2" public: virtual auto traverse(cpp2::impl::in stmt) -> void; -#line 2806 "reflect.h2" +#line 2978 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in expr) -> void; -#line 2812 "reflect.h2" +#line 2984 "reflect.h2" public: virtual auto traverse(cpp2::impl::in expr) -> void; -#line 2826 "reflect.h2" +#line 2998 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2843 "reflect.h2" +#line 3015 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2854 "reflect.h2" +#line 3026 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2871 "reflect.h2" +#line 3043 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2883 "reflect.h2" +#line 3055 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2900 "reflect.h2" +#line 3072 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2911 "reflect.h2" +#line 3083 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2928 "reflect.h2" +#line 3100 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2939 "reflect.h2" +#line 3111 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2956 "reflect.h2" +#line 3128 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2968 "reflect.h2" +#line 3140 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 2985 "reflect.h2" +#line 3157 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 2997 "reflect.h2" +#line 3169 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3014 "reflect.h2" +#line 3186 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3025 "reflect.h2" +#line 3197 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3042 "reflect.h2" +#line 3214 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3053 "reflect.h2" +#line 3225 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3070 "reflect.h2" +#line 3242 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3081 "reflect.h2" +#line 3253 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3098 "reflect.h2" +#line 3270 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3109 "reflect.h2" +#line 3281 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3126 "reflect.h2" +#line 3298 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3138 "reflect.h2" +#line 3310 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in binexpr) -> void; -#line 3155 "reflect.h2" +#line 3327 "reflect.h2" public: virtual auto traverse(cpp2::impl::in binexpr) -> void; -#line 3166 "reflect.h2" +#line 3338 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in isas) -> void; -#line 3182 "reflect.h2" +#line 3354 "reflect.h2" public: virtual auto traverse(cpp2::impl::in isas) -> void; -#line 3193 "reflect.h2" +#line 3365 "reflect.h2" public: virtual auto traverse(cpp2::impl::in exprs) -> void; -#line 3200 "reflect.h2" +#line 3372 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in prefix) -> void; -#line 3216 "reflect.h2" +#line 3388 "reflect.h2" public: virtual auto traverse(cpp2::impl::in prefix) -> void; -#line 3221 "reflect.h2" +#line 3393 "reflect.h2" public: virtual auto pre_traverse(cpp2::impl::in postfix) -> void; -#line 3237 "reflect.h2" +#line 3409 "reflect.h2" public: virtual auto traverse(cpp2::impl::in postfix) -> void; -#line 3256 "reflect.h2" +#line 3428 "reflect.h2" public: virtual auto traverse(cpp2::impl::in uid) -> void; -#line 3262 "reflect.h2" +#line 3434 "reflect.h2" public: virtual auto traverse(cpp2::impl::in qid) -> void; -#line 3272 "reflect.h2" +#line 3444 "reflect.h2" public: virtual auto traverse(cpp2::impl::in tid) -> void; -#line 3289 "reflect.h2" +#line 3461 "reflect.h2" public: virtual auto traverse(cpp2::impl::in primary) -> void; -#line 3309 "reflect.h2" +#line 3481 "reflect.h2" public: virtual auto traverse(cpp2::impl::in idexpr) -> void; public: simple_traverser() = default; public: simple_traverser(simple_traverser const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(simple_traverser const&) -> void = delete; -#line 3324 "reflect.h2" +#line 3496 "reflect.h2" }; -#line 3337 "reflect.h2" +#line 3509 "reflect.h2" auto sample_traverser(cpp2::impl::in decl, cpp2::impl::in indent) -> void; -#line 3359 "reflect.h2" +#line 3531 "reflect.h2" auto sample_traverser(cpp2::impl::in f, cpp2::impl::in indent = 0) -> void; -#line 3389 "reflect.h2" +#line 3561 "reflect.h2" auto sample_traverser(cpp2::impl::in o, cpp2::impl::in indent) -> void; -#line 3399 "reflect.h2" +#line 3571 "reflect.h2" auto sample_traverser(cpp2::impl::in t, cpp2::impl::in indent = 0) -> void; -#line 3420 "reflect.h2" +#line 3592 "reflect.h2" auto sample_traverser(cpp2::impl::in t, cpp2::impl::in indent = 0) -> void; -#line 3439 "reflect.h2" +#line 3611 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void; -#line 3494 "reflect.h2" +#line 3666 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void; -#line 3511 "reflect.h2" +#line 3683 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void; -#line 3521 "reflect.h2" +#line 3693 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void; -#line 3553 "reflect.h2" +#line 3725 "reflect.h2" auto sample_traverser(cpp2::impl::in expr, cpp2::impl::in indent) -> void; -#line 3567 "reflect.h2" +#line 3739 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3597 "reflect.h2" +#line 3769 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3627 "reflect.h2" +#line 3799 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3657 "reflect.h2" +#line 3829 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3687 "reflect.h2" +#line 3859 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3717 "reflect.h2" +#line 3889 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3747 "reflect.h2" +#line 3919 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3777 "reflect.h2" +#line 3949 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3807 "reflect.h2" +#line 3979 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3837 "reflect.h2" +#line 4009 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3867 "reflect.h2" +#line 4039 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3897 "reflect.h2" +#line 4069 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void; -#line 3927 "reflect.h2" +#line 4099 "reflect.h2" auto sample_traverser(cpp2::impl::in isas, cpp2::impl::in indent) -> void; -#line 3953 "reflect.h2" +#line 4125 "reflect.h2" auto sample_traverser(cpp2::impl::in exprs, cpp2::impl::in indent) -> void; -#line 3968 "reflect.h2" +#line 4140 "reflect.h2" auto sample_traverser(cpp2::impl::in prefix, cpp2::impl::in indent) -> void; -#line 3992 "reflect.h2" +#line 4164 "reflect.h2" auto sample_traverser(cpp2::impl::in postfix, cpp2::impl::in indent) -> void; -#line 4025 "reflect.h2" +#line 4197 "reflect.h2" auto sample_traverser(cpp2::impl::in uid, cpp2::impl::in indent) -> void; -#line 4036 "reflect.h2" +#line 4208 "reflect.h2" auto sample_traverser(cpp2::impl::in qid, cpp2::impl::in indent) -> void; -#line 4052 "reflect.h2" +#line 4224 "reflect.h2" auto sample_traverser(cpp2::impl::in tid, cpp2::impl::in indent) -> void; -#line 4069 "reflect.h2" +#line 4241 "reflect.h2" auto sample_traverser(cpp2::impl::in primary, cpp2::impl::in indent) -> void; -#line 4089 "reflect.h2" +#line 4261 "reflect.h2" auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in indent) -> void; -#line 4111 "reflect.h2" +#line 4283 "reflect.h2" class autodiff_special_func { public: std::string name; public: int n_args; @@ -1703,18 +1706,18 @@ class autodiff_special_func { cpp2::impl::in code_rws_ = "", cpp2::impl::in code_primal_higher_order_ = "", cpp2::impl::in code_fwd_higher_order_ = "", cpp2::impl::in code_rws_higher_order_ = ""); -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" public: autodiff_special_func(autodiff_special_func const& that); -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" public: auto operator=(autodiff_special_func const& that) -> autodiff_special_func& ; -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" public: autodiff_special_func(autodiff_special_func&& that) noexcept; -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" public: auto operator=(autodiff_special_func&& that) noexcept -> autodiff_special_func& ; public: [[nodiscard]] auto is_match(cpp2::impl::in o) const& -> bool; -#line 4153 "reflect.h2" +#line 4325 "reflect.h2" }; class autodiff_declared_variable { @@ -1727,13 +1730,13 @@ class autodiff_declared_variable { public: autodiff_declared_variable(cpp2::impl::in name_, cpp2::impl::in decl_, cpp2::impl::in is_active_, cpp2::impl::in is_member_); -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" public: autodiff_declared_variable(autodiff_declared_variable const& that); -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" public: auto operator=(autodiff_declared_variable const& that) -> autodiff_declared_variable& ; -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" public: autodiff_declared_variable(autodiff_declared_variable&& that) noexcept; -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" public: auto operator=(autodiff_declared_variable&& that) noexcept -> autodiff_declared_variable& ; }; @@ -1750,25 +1753,25 @@ class autodiff_declaration_stack_item { using lookup_declaration_ret = std::vector; -#line 4187 "reflect.h2" +#line 4359 "reflect.h2" public: [[nodiscard]] auto lookup_declaration(cpp2::impl::in decl_name) const& -> lookup_declaration_ret; struct lookup_variable_declaration_ret { bool found; autodiff_declared_variable r; }; -#line 4197 "reflect.h2" +#line 4369 "reflect.h2" public: [[nodiscard]] auto lookup_variable_declaration(cpp2::impl::in decl_name) const& -> lookup_variable_declaration_ret; public: autodiff_declaration_stack_item(autodiff_declaration_stack_item const& that); public: autodiff_declaration_stack_item(autodiff_declaration_stack_item&& that) noexcept; -#line 4215 "reflect.h2" +#line 4387 "reflect.h2" }; class autodiff_context { private: int temporary_count {0}; -#line 4227 "reflect.h2" +#line 4399 "reflect.h2" public: std::vector special_funcs { autodiff_special_func("sin", 1, false, "sin(_a1_)", @@ -1808,13 +1811,13 @@ class autodiff_context { "_od_.push_back(_ad1_);", "TODO")}; -#line 4267 "reflect.h2" +#line 4439 "reflect.h2" public: std::string fwd_suffix {"_d"}; public: std::string rws_suffix {"_b"}; private: int order {1}; public: bool reverse {false}; -#line 4273 "reflect.h2" +#line 4445 "reflect.h2" public: std::string fwd_ad_type {"double"}; public: std::string rws_ad_type {"double"}; @@ -1824,94 +1827,94 @@ class autodiff_context { public: explicit autodiff_context(); public: autodiff_context(cpp2::impl::in order_, cpp2::impl::in reverse_); -#line 4296 "reflect.h2" +#line 4468 "reflect.h2" public: auto add_variable_declaration(cpp2::impl::in name, cpp2::impl::in type, cpp2::impl::in is_active, cpp2::impl::in is_member = false) & -> void; -#line 4300 "reflect.h2" +#line 4472 "reflect.h2" public: [[nodiscard]] auto is_variable_active(cpp2::impl::in name) & -> bool; -#line 4304 "reflect.h2" +#line 4476 "reflect.h2" public: auto create_namespace_stack(cpp2::impl::in t) & -> void; -#line 4321 "reflect.h2" +#line 4493 "reflect.h2" public: [[nodiscard]] auto is_forward() const& -> decltype(auto); public: [[nodiscard]] auto is_reverse() const& -> decltype(auto); public: [[nodiscard]] auto is_taylor() const& -> decltype(auto); public: [[nodiscard]] auto gen_temporary() & -> std::string; -#line 4330 "reflect.h2" +#line 4502 "reflect.h2" public: [[nodiscard]] auto is_type_active(cpp2::impl::in type) & -> bool; -#line 4351 "reflect.h2" +#line 4523 "reflect.h2" public: [[nodiscard]] auto get_fwd_ad_type(cpp2::impl::in type) & -> std::string; -#line 4369 "reflect.h2" +#line 4541 "reflect.h2" public: [[nodiscard]] auto get_rws_ad_type(cpp2::impl::in type) & -> std::string; -#line 4387 "reflect.h2" +#line 4559 "reflect.h2" public: [[nodiscard]] auto get_reverse_passing_style(cpp2::impl::in p) const& -> passing_style; using lookup_declaration_ret = std::vector; -#line 4415 "reflect.h2" +#line 4587 "reflect.h2" public: [[nodiscard]] auto lookup_declaration(cpp2::impl::in decl_name) & -> lookup_declaration_ret; -#line 4442 "reflect.h2" +#line 4614 "reflect.h2" public: [[nodiscard]] auto lookup_variable_declaration(cpp2::impl::in name) & -> autodiff_declared_variable; using lookup_function_declaration_ret = std::vector; -#line 4464 "reflect.h2" +#line 4636 "reflect.h2" public: [[nodiscard]] auto lookup_function_declaration(cpp2::impl::in decl_name) & -> lookup_function_declaration_ret; using lookup_member_function_declaration_ret = std::vector; -#line 4474 "reflect.h2" +#line 4646 "reflect.h2" public: [[nodiscard]] auto lookup_member_function_declaration(cpp2::impl::in obj_type, cpp2::impl::in decl_name) & -> lookup_member_function_declaration_ret; using lookup_type_declaration_ret = std::vector; -#line 4484 "reflect.h2" +#line 4656 "reflect.h2" public: [[nodiscard]] auto lookup_type_declaration(cpp2::impl::in decl_name) & -> lookup_type_declaration_ret; struct lookup_special_function_handling_ret { bool m; std::string code_primal; std::string code_fwd; std::string code_rws; }; -#line 4494 "reflect.h2" +#line 4666 "reflect.h2" public: [[nodiscard]] auto lookup_special_function_handling(cpp2::impl::in func_name, cpp2::impl::in n_args, cpp2::impl::in is_member) const& -> lookup_special_function_handling_ret; -#line 4519 "reflect.h2" +#line 4691 "reflect.h2" public: auto add_as_differentiated(cpp2::impl::in t) & -> void; -#line 4527 "reflect.h2" +#line 4699 "reflect.h2" public: auto add_for_differentiation(cpp2::impl::in t) & -> void; -#line 4553 "reflect.h2" +#line 4725 "reflect.h2" public: [[nodiscard]] static auto is_in_list(cpp2::impl::in v, cpp2::impl::in> list) -> bool; -#line 4563 "reflect.h2" +#line 4735 "reflect.h2" public: auto enter_function() & -> void; -#line 4568 "reflect.h2" +#line 4740 "reflect.h2" public: auto leave_function() & -> void; -#line 4572 "reflect.h2" +#line 4744 "reflect.h2" public: auto push_stack(cpp2::impl::in decl) & -> void; -#line 4585 "reflect.h2" +#line 4757 "reflect.h2" public: auto pop_stack() & -> void; -#line 4600 "reflect.h2" +#line 4772 "reflect.h2" public: auto finish() & -> void; -#line 4607 "reflect.h2" +#line 4779 "reflect.h2" public: [[nodiscard]] auto get_self() & -> autodiff_context*; public: autodiff_context(autodiff_context const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_context const&) -> void = delete; -#line 4611 "reflect.h2" +#line 4783 "reflect.h2" }; class autodiff_diff_code { @@ -1922,16 +1925,16 @@ class autodiff_diff_code { public: std::string rws_backprop {""}; public: autodiff_diff_code(cpp2::impl::in ctx_); -#line 4620 "reflect.h2" +#line 4792 "reflect.h2" public: auto operator=(cpp2::impl::in ctx_) -> autodiff_diff_code& ; -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" public: autodiff_diff_code(autodiff_diff_code const& that); -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" public: auto operator=(autodiff_diff_code const& that) -> autodiff_diff_code& ; -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" public: autodiff_diff_code(autodiff_diff_code&& that) noexcept; -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" public: auto operator=(autodiff_diff_code&& that) noexcept -> autodiff_diff_code& ; public: auto add_forward(cpp2::impl::in v) & -> void; @@ -1940,46 +1943,46 @@ class autodiff_diff_code { public: auto reset() & -> void; -#line 4636 "reflect.h2" +#line 4808 "reflect.h2" public: auto operator=(cpp2::impl::in v) -> autodiff_diff_code& ; -#line 4642 "reflect.h2" +#line 4814 "reflect.h2" public: auto operator+=(cpp2::impl::in v) & -> void; -#line 4647 "reflect.h2" +#line 4819 "reflect.h2" public: auto operator+=(cpp2::impl::in v) & -> void; -#line 4652 "reflect.h2" +#line 4824 "reflect.h2" public: [[nodiscard]] auto empty() const& -> bool; -#line 4655 "reflect.h2" +#line 4827 "reflect.h2" }; -#line 4662 "reflect.h2" +#line 4834 "reflect.h2" class autodiff_activity_check: public simple_traverser { -#line 4665 "reflect.h2" +#line 4837 "reflect.h2" public: autodiff_context* ctx; public: bool active {false}; public: autodiff_activity_check(cpp2::impl::in ctx_); -#line 4672 "reflect.h2" +#line 4844 "reflect.h2" public: auto traverse(cpp2::impl::in t) -> void override; -#line 4684 "reflect.h2" +#line 4856 "reflect.h2" public: auto traverse(cpp2::impl::in o) -> void override; -#line 4702 "reflect.h2" +#line 4874 "reflect.h2" public: auto traverse(cpp2::impl::in primary) -> void override; -#line 4726 "reflect.h2" +#line 4898 "reflect.h2" public: auto traverse(cpp2::impl::in postfix) -> void override; public: autodiff_activity_check(autodiff_activity_check const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_activity_check const&) -> void = delete; -#line 4758 "reflect.h2" +#line 4930 "reflect.h2" }; class autodiff_handler_base { @@ -1988,21 +1991,21 @@ class autodiff_handler_base { public: autodiff_diff_code diff; public: autodiff_handler_base(cpp2::impl::in ctx_); -#line 4765 "reflect.h2" +#line 4937 "reflect.h2" public: auto operator=(cpp2::impl::in ctx_) -> autodiff_handler_base& ; -#line 4771 "reflect.h2" +#line 4943 "reflect.h2" public: auto append(autodiff_handler_base const& o) & -> void; public: autodiff_handler_base(autodiff_handler_base const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_handler_base const&) -> void = delete; -#line 4776 "reflect.h2" +#line 4948 "reflect.h2" }; class autodiff_expression_handler: public simple_traverser, public autodiff_handler_base { -#line 4782 "reflect.h2" +#line 4954 "reflect.h2" public: using base = simple_traverser; public: std::string primal_expr {""}; @@ -2011,33 +2014,33 @@ class autodiff_expression_handler: public simple_traverser, public autodiff_hand public: autodiff_expression_handler(cpp2::impl::in ctx_); -#line 4792 "reflect.h2" +#line 4964 "reflect.h2" public: [[nodiscard]] auto add_suffix_if_not_wildcard(cpp2::impl::in lhs, cpp2::impl::in suffix) const& -> std::string; -#line 4801 "reflect.h2" +#line 4973 "reflect.h2" public: [[nodiscard]] auto prepare_backprop(cpp2::impl::in rhs_b, cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b) const& -> std::string; -#line 4809 "reflect.h2" +#line 4981 "reflect.h2" public: [[nodiscard]] auto prepare_backprop(cpp2::impl::in rhs_b, cpp2::impl::in lhs) const& -> std::string; public: auto gen_assignment(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b) & -> void; -#line 4822 "reflect.h2" +#line 4994 "reflect.h2" public: [[nodiscard]] auto gen_assignment(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b) & -> decltype(auto); public: [[nodiscard]] auto gen_assignment(cpp2::impl::in lhs) & -> decltype(auto); -#line 4828 "reflect.h2" +#line 5000 "reflect.h2" public: auto gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b, cpp2::impl::in type, cpp2::impl::in type_d, cpp2::impl::in type_b) & -> void; -#line 4840 "reflect.h2" +#line 5012 "reflect.h2" public: [[nodiscard]] auto gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b, cpp2::impl::in type) & -> decltype(auto); public: [[nodiscard]] auto gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in type) & -> decltype(auto); public: [[nodiscard]] auto gen_declaration(cpp2::impl::in lhs, cpp2::impl::in type) & -> decltype(auto); -#line 4849 "reflect.h2" +#line 5021 "reflect.h2" public: class primal_fwd_rws_name { public: std::string primal {""}; public: std::string fwd {""}; @@ -2046,80 +2049,80 @@ class autodiff_expression_handler: public simple_traverser, public autodiff_hand public: primal_fwd_rws_name(auto const& primal_, auto const& fwd_, auto const& rws_, auto const& active_); public: primal_fwd_rws_name(); -#line 4854 "reflect.h2" +#line 5026 "reflect.h2" }; public: [[nodiscard]] auto handle_expression_list(cpp2::impl::in list) & -> std::vector; -#line 4865 "reflect.h2" +#line 5037 "reflect.h2" public: [[nodiscard]] auto handle_expression_term(auto const& term) & -> primal_fwd_rws_name; -#line 4926 "reflect.h2" +#line 5098 "reflect.h2" public: auto handle_function_call(cpp2::impl::in postfix, cpp2::impl::in has_return) & -> void; -#line 5106 "reflect.h2" +#line 5278 "reflect.h2" public: [[nodiscard]] auto handle_special_function(cpp2::impl::in object, cpp2::impl::in object_d, cpp2::impl::in object_b, cpp2::impl::in function_name, cpp2::impl::in> args) & -> bool; -#line 5151 "reflect.h2" +#line 5323 "reflect.h2" public: auto traverse(cpp2::impl::in expr) -> void override; -#line 5155 "reflect.h2" +#line 5327 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5159 "reflect.h2" +#line 5331 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5163 "reflect.h2" +#line 5335 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5167 "reflect.h2" +#line 5339 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5171 "reflect.h2" +#line 5343 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5175 "reflect.h2" +#line 5347 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5179 "reflect.h2" +#line 5351 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5183 "reflect.h2" +#line 5355 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5187 "reflect.h2" +#line 5359 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5191 "reflect.h2" +#line 5363 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5195 "reflect.h2" +#line 5367 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5237 "reflect.h2" +#line 5409 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5324 "reflect.h2" +#line 5496 "reflect.h2" public: auto traverse(cpp2::impl::in isas) -> void override; -#line 5328 "reflect.h2" +#line 5500 "reflect.h2" public: auto traverse(cpp2::impl::in prefix) -> void override; -#line 5344 "reflect.h2" +#line 5516 "reflect.h2" public: auto traverse(cpp2::impl::in postfix) -> void override; -#line 5384 "reflect.h2" +#line 5556 "reflect.h2" public: auto traverse(cpp2::impl::in primary) -> void override; public: autodiff_expression_handler(autodiff_expression_handler const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_expression_handler const&) -> void = delete; -#line 5419 "reflect.h2" +#line 5591 "reflect.h2" }; class autodiff_stmt_handler: public simple_traverser, public autodiff_handler_base { -#line 5425 "reflect.h2" +#line 5597 "reflect.h2" public: using base = simple_traverser; private: meta::function_declaration mf; @@ -2131,102 +2134,102 @@ class autodiff_stmt_handler: public simple_traverser, public autodiff_handler_ba public: autodiff_stmt_handler(cpp2::impl::in ctx_, cpp2::impl::in mf_); -#line 5439 "reflect.h2" +#line 5611 "reflect.h2" public: [[nodiscard]] auto handle_stmt_parameters(cpp2::impl::in> params) & -> autodiff_diff_code; -#line 5481 "reflect.h2" +#line 5653 "reflect.h2" public: auto traverse(cpp2::impl::in decl) -> void override; -#line 5486 "reflect.h2" +#line 5658 "reflect.h2" public: auto traverse(cpp2::impl::in f) -> void override; -#line 5491 "reflect.h2" +#line 5663 "reflect.h2" public: auto traverse(cpp2::impl::in o) -> void override; -#line 5553 "reflect.h2" +#line 5725 "reflect.h2" public: auto traverse(cpp2::impl::in t) -> void override; -#line 5558 "reflect.h2" +#line 5730 "reflect.h2" public: auto traverse(cpp2::impl::in t) -> void override; -#line 5563 "reflect.h2" +#line 5735 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; -#line 5570 "reflect.h2" +#line 5742 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; -#line 5605 "reflect.h2" +#line 5777 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; -#line 5621 "reflect.h2" +#line 5793 "reflect.h2" public: [[nodiscard]] auto reverse_next(cpp2::impl::in expr) const& -> std::string; -#line 5636 "reflect.h2" +#line 5808 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; -#line 5734 "reflect.h2" +#line 5906 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; -#line 5745 "reflect.h2" +#line 5917 "reflect.h2" public: auto traverse(cpp2::impl::in expr) -> void override; -#line 5749 "reflect.h2" +#line 5921 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5800 "reflect.h2" +#line 5972 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5804 "reflect.h2" +#line 5976 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5808 "reflect.h2" +#line 5980 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5812 "reflect.h2" +#line 5984 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5816 "reflect.h2" +#line 5988 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5820 "reflect.h2" +#line 5992 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5824 "reflect.h2" +#line 5996 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5828 "reflect.h2" +#line 6000 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5832 "reflect.h2" +#line 6004 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5836 "reflect.h2" +#line 6008 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5840 "reflect.h2" +#line 6012 "reflect.h2" public: auto traverse(cpp2::impl::in binexpr) -> void override; -#line 5844 "reflect.h2" +#line 6016 "reflect.h2" public: auto traverse(cpp2::impl::in isas) -> void override; -#line 5848 "reflect.h2" +#line 6020 "reflect.h2" public: auto traverse(cpp2::impl::in prefix) -> void override; -#line 5853 "reflect.h2" +#line 6025 "reflect.h2" public: auto traverse(cpp2::impl::in postfix) -> void override; -#line 5885 "reflect.h2" +#line 6057 "reflect.h2" public: auto traverse(cpp2::impl::in primary) -> void override; public: autodiff_stmt_handler(autodiff_stmt_handler const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_stmt_handler const&) -> void = delete; -#line 5889 "reflect.h2" +#line 6061 "reflect.h2" }; class autodiff_declaration_handler: public simple_traverser, public autodiff_handler_base { -#line 5895 "reflect.h2" +#line 6067 "reflect.h2" public: using base = simple_traverser; private: meta::type_or_namespace_declaration decl; @@ -2236,37 +2239,37 @@ class autodiff_declaration_handler: public simple_traverser, public autodiff_han public: autodiff_declaration_handler(cpp2::impl::in ctx_, cpp2::impl::in decl_); -#line 5907 "reflect.h2" +#line 6079 "reflect.h2" public: auto traverse(cpp2::impl::in decl_) -> void override; -#line 5912 "reflect.h2" +#line 6084 "reflect.h2" public: auto traverse(cpp2::impl::in f) -> void override; -#line 6070 "reflect.h2" +#line 6242 "reflect.h2" public: auto traverse(cpp2::impl::in o) -> void override; -#line 6098 "reflect.h2" +#line 6270 "reflect.h2" public: auto traverse(cpp2::impl::in t) -> void override; -#line 6122 "reflect.h2" +#line 6294 "reflect.h2" public: auto traverse(cpp2::impl::in t) -> void override; -#line 6127 "reflect.h2" +#line 6299 "reflect.h2" public: auto traverse(cpp2::impl::in stmt) -> void override; public: autodiff_declaration_handler(autodiff_declaration_handler const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(autodiff_declaration_handler const&) -> void = delete; -#line 6130 "reflect.h2" +#line 6302 "reflect.h2" }; -#line 6133 "reflect.h2" +#line 6305 "reflect.h2" auto autodiff(meta::type_declaration& t) -> void; -#line 6239 "reflect.h2" +#line 6411 "reflect.h2" using error_func = std::function x)>; -#line 6243 "reflect.h2" +#line 6415 "reflect.h2" class expression_flags { private: cpp2::u8 _value; private: constexpr expression_flags(cpp2::impl::in _val); @@ -2301,20 +2304,20 @@ public: [[nodiscard]] auto to_code() const& -> std::string; public: [[nodiscard]] static auto from_string(cpp2::impl::in s) -> expression_flags; public: [[nodiscard]] static auto from_code(cpp2::impl::in s) -> expression_flags; -#line 6251 "reflect.h2" +#line 6423 "reflect.h2" }; -#line 6259 "reflect.h2" +#line 6431 "reflect.h2" class regex_token { public: std::string string_rep; public: regex_token(cpp2::impl::in str); -#line 6267 "reflect.h2" +#line 6439 "reflect.h2" public: explicit regex_token(); -#line 6272 "reflect.h2" +#line 6444 "reflect.h2" public: virtual auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void = 0; public: [[nodiscard]] virtual auto reverse() const -> std::shared_ptr = 0; @@ -2326,103 +2329,103 @@ class regex_token public: regex_token(regex_token const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_token const&) -> void = delete; -#line 6278 "reflect.h2" +#line 6450 "reflect.h2" }; using token_ptr = std::shared_ptr; using token_vec = std::vector; -#line 6284 "reflect.h2" +#line 6456 "reflect.h2" // Adds a check in code generation. // class regex_token_check : public regex_token { -#line 6290 "reflect.h2" +#line 6462 "reflect.h2" private: std::string check; public: regex_token_check(cpp2::impl::in str, cpp2::impl::in check_); -#line 6297 "reflect.h2" +#line 6469 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 6301 "reflect.h2" +#line 6473 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; public: virtual ~regex_token_check() noexcept; public: regex_token_check(regex_token_check const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_token_check const&) -> void = delete; -#line 6302 "reflect.h2" +#line 6474 "reflect.h2" }; -#line 6305 "reflect.h2" +#line 6477 "reflect.h2" // Adds code in code generation. // class regex_token_code : public regex_token { -#line 6311 "reflect.h2" +#line 6483 "reflect.h2" private: std::string code; public: regex_token_code(cpp2::impl::in str, cpp2::impl::in code_); -#line 6318 "reflect.h2" +#line 6490 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 6322 "reflect.h2" +#line 6494 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; public: virtual ~regex_token_code() noexcept; public: regex_token_code(regex_token_code const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_token_code const&) -> void = delete; -#line 6323 "reflect.h2" +#line 6495 "reflect.h2" }; -#line 6326 "reflect.h2" +#line 6498 "reflect.h2" // Token that does not influence the matching. E.g. comment. // class regex_token_empty : public regex_token { -#line 6332 "reflect.h2" +#line 6504 "reflect.h2" public: regex_token_empty(cpp2::impl::in str); -#line 6336 "reflect.h2" +#line 6508 "reflect.h2" public: auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void override; -#line 6340 "reflect.h2" +#line 6512 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; public: virtual ~regex_token_empty() noexcept; public: regex_token_empty(regex_token_empty const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_token_empty const&) -> void = delete; -#line 6341 "reflect.h2" +#line 6513 "reflect.h2" }; -#line 6344 "reflect.h2" +#line 6516 "reflect.h2" // Represents a list of regex tokens as one token. // class regex_token_list : public regex_token { -#line 6350 "reflect.h2" +#line 6522 "reflect.h2" public: token_vec tokens; public: regex_token_list(cpp2::impl::in t); -#line 6357 "reflect.h2" +#line 6529 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 6363 "reflect.h2" +#line 6535 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 6369 "reflect.h2" +#line 6541 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in vec) -> std::string; -#line 6377 "reflect.h2" +#line 6549 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; public: virtual ~regex_token_list() noexcept; @@ -2430,10 +2433,10 @@ class regex_token_list public: auto operator=(regex_token_list const&) -> void = delete; -#line 6389 "reflect.h2" +#line 6561 "reflect.h2" }; -#line 6392 "reflect.h2" +#line 6564 "reflect.h2" // // Parse and generation context. // @@ -2449,33 +2452,33 @@ class parse_context_group_state // Start a new alternative. public: auto next_alternative() & -> void; -#line 6412 "reflect.h2" +#line 6584 "reflect.h2" // Swap this state with the other one. NOLINTNEXTLINE(performance-noexcept-swap) public: auto swap(parse_context_group_state& t) & -> void; -#line 6419 "reflect.h2" +#line 6591 "reflect.h2" // Convert this state into a regex token. public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 6431 "reflect.h2" +#line 6603 "reflect.h2" // Add a token to the current matcher list. public: auto add(cpp2::impl::in token) & -> void; -#line 6436 "reflect.h2" +#line 6608 "reflect.h2" // True if current matcher list is empty. public: [[nodiscard]] auto empty() const& -> bool; -#line 6440 "reflect.h2" +#line 6612 "reflect.h2" // Apply optimizations to the matcher list. public: static auto post_process_list(token_vec& list) -> void; public: parse_context_group_state(auto const& cur_match_list_, auto const& alternate_match_lists_, auto const& modifiers_); public: parse_context_group_state(); -#line 6454 "reflect.h2" +#line 6626 "reflect.h2" }; -#line 6457 "reflect.h2" +#line 6629 "reflect.h2" // State for the branch reset. Takes care of the group numbering. See '(|)'. // class parse_context_branch_reset_state @@ -2488,25 +2491,25 @@ class parse_context_branch_reset_state // Next group identifier. public: [[nodiscard]] auto next() & -> int; -#line 6475 "reflect.h2" +#line 6647 "reflect.h2" // Set next group identifier. public: auto set_next(cpp2::impl::in g) & -> void; -#line 6481 "reflect.h2" +#line 6653 "reflect.h2" // Start a new alternative branch. public: auto next_alternative() & -> void; -#line 6488 "reflect.h2" +#line 6660 "reflect.h2" // Initialize for a branch reset group. public: auto set_active_reset(cpp2::impl::in restart) & -> void; public: parse_context_branch_reset_state(auto const& is_active_, auto const& cur_group_, auto const& max_group_, auto const& from_); public: parse_context_branch_reset_state(); -#line 6495 "reflect.h2" +#line 6667 "reflect.h2" }; -#line 6498 "reflect.h2" +#line 6670 "reflect.h2" // Context during parsing of the regular expressions. // // Keeps track of the distributed group identifiers, current parsed group and branch resets. @@ -2522,7 +2525,7 @@ class parse_context private: parse_context_group_state cur_group_state {}; private: parse_context_branch_reset_state cur_branch_reset_state {}; -#line 6514 "reflect.h2" +#line 6686 "reflect.h2" public: std::map named_groups {}; private: error_func error_out; // TODO: Declaring std::function fails for cpp2. @@ -2530,64 +2533,64 @@ class parse_context public: parse_context(cpp2::impl::in r, auto const& e); -#line 6525 "reflect.h2" +#line 6697 "reflect.h2" // State management functions // // Returned group state needs to be stored and provided in `end_group`. public: [[nodiscard]] auto start_group() & -> parse_context_group_state; -#line 6538 "reflect.h2" +#line 6710 "reflect.h2" // `old_state` argument needs to be from start group. public: [[nodiscard]] auto end_group(cpp2::impl::in old_state) & -> token_ptr; -#line 6546 "reflect.h2" +#line 6718 "reflect.h2" public: [[nodiscard]] auto get_modifiers() const& -> expression_flags; -#line 6550 "reflect.h2" +#line 6722 "reflect.h2" public: auto set_modifiers(cpp2::impl::in mod) & -> void; -#line 6554 "reflect.h2" +#line 6726 "reflect.h2" // Branch reset management functions // public: [[nodiscard]] auto branch_reset_new_state() & -> parse_context_branch_reset_state; -#line 6566 "reflect.h2" +#line 6738 "reflect.h2" public: auto branch_reset_restore_state(cpp2::impl::in old_state) & -> void; -#line 6573 "reflect.h2" +#line 6745 "reflect.h2" public: auto next_alternative() & -> void; -#line 6579 "reflect.h2" +#line 6751 "reflect.h2" // Regex token management // public: auto add_token(cpp2::impl::in token) & -> void; -#line 6585 "reflect.h2" +#line 6757 "reflect.h2" public: [[nodiscard]] auto has_token() const& -> bool; -#line 6589 "reflect.h2" +#line 6761 "reflect.h2" public: [[nodiscard]] auto pop_token() & -> token_ptr; -#line 6600 "reflect.h2" +#line 6772 "reflect.h2" public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 6604 "reflect.h2" +#line 6776 "reflect.h2" // Group management // public: [[nodiscard]] auto get_cur_group() const& -> int; -#line 6610 "reflect.h2" +#line 6782 "reflect.h2" public: [[nodiscard]] auto next_group() & -> int; -#line 6614 "reflect.h2" +#line 6786 "reflect.h2" public: auto set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void; -#line 6621 "reflect.h2" +#line 6793 "reflect.h2" public: [[nodiscard]] auto get_named_group(cpp2::impl::in name) const& -> int; -#line 6632 "reflect.h2" +#line 6804 "reflect.h2" // Position management functions // public: [[nodiscard]] auto current() const& -> char; @@ -2595,51 +2598,51 @@ class parse_context // Get the next token in the regex, skipping spaces according to the parameters. See `x` and `xx` modifiers. private: [[nodiscard]] auto get_next_position(cpp2::impl::in in_class, cpp2::impl::in no_skip) const& -> size_t; -#line 6676 "reflect.h2" +#line 6848 "reflect.h2" // Return true if next token is available. private: [[nodiscard]] auto next_impl(cpp2::impl::in in_class, cpp2::impl::in no_skip) & -> bool; -#line 6688 "reflect.h2" +#line 6860 "reflect.h2" public: [[nodiscard]] auto next() & -> decltype(auto); public: [[nodiscard]] auto next_in_class() & -> decltype(auto); public: [[nodiscard]] auto next_no_skip() & -> decltype(auto); public: [[nodiscard]] auto next_n(cpp2::impl::in n) & -> bool; -#line 6701 "reflect.h2" +#line 6873 "reflect.h2" public: [[nodiscard]] auto has_next() const& -> bool; private: [[nodiscard]] auto grab_until_impl(cpp2::impl::in e, cpp2::impl::out r, cpp2::impl::in any) & -> bool; -#line 6724 "reflect.h2" +#line 6896 "reflect.h2" public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_n(cpp2::impl::in n, cpp2::impl::out r) & -> bool; -#line 6741 "reflect.h2" +#line 6913 "reflect.h2" public: [[nodiscard]] auto grab_number() & -> std::string; -#line 6762 "reflect.h2" +#line 6934 "reflect.h2" private: [[nodiscard]] auto peek_impl(cpp2::impl::in in_class) const& -> char; -#line 6772 "reflect.h2" +#line 6944 "reflect.h2" public: [[nodiscard]] auto peek() const& -> decltype(auto); public: [[nodiscard]] auto peek_in_class() const& -> decltype(auto); -#line 6776 "reflect.h2" +#line 6948 "reflect.h2" // Parsing functions // public: [[nodiscard]] auto parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool; -#line 6832 "reflect.h2" +#line 7004 "reflect.h2" public: [[nodiscard]] auto parse_until(cpp2::impl::in term) & -> bool; -#line 6871 "reflect.h2" +#line 7043 "reflect.h2" public: [[nodiscard]] auto parse(cpp2::impl::in modifiers) & -> bool; -#line 6886 "reflect.h2" +#line 7058 "reflect.h2" // Misc functions public: [[nodiscard]] auto get_pos() const& -> decltype(auto); @@ -2651,10 +2654,10 @@ class parse_context public: auto operator=(parse_context const&) -> void = delete; -#line 6897 "reflect.h2" +#line 7069 "reflect.h2" }; -#line 6900 "reflect.h2" +#line 7072 "reflect.h2" // Context for one function generation. Generation of functions can be interleaved, // therefore we buffer the code for one function here. // @@ -2664,16 +2667,16 @@ class generation_function_context { public: auto add_tabs(cpp2::impl::in c) & -> void; -#line 6914 "reflect.h2" +#line 7086 "reflect.h2" public: auto remove_tabs(cpp2::impl::in c) & -> void; public: generation_function_context(auto const& code_, auto const& tabs_); public: generation_function_context(); -#line 6917 "reflect.h2" +#line 7089 "reflect.h2" }; -#line 6920 "reflect.h2" +#line 7092 "reflect.h2" // Context for generating the state machine. class generation_context { @@ -2693,68 +2696,68 @@ class generation_context // Add code line. public: auto add(cpp2::impl::in s) & -> void; -#line 6942 "reflect.h2" +#line 7114 "reflect.h2" // Add check for token. The check needs to be a function call that returns a boolean. public: auto add_check(cpp2::impl::in check) & -> void; -#line 6948 "reflect.h2" +#line 7120 "reflect.h2" // Add a stateful check. The check needs to return a `match_return`. public: auto add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void; -#line 6957 "reflect.h2" +#line 7129 "reflect.h2" protected: auto start_func_named(cpp2::impl::in name) & -> void; -#line 6968 "reflect.h2" +#line 7140 "reflect.h2" protected: [[nodiscard]] auto start_func() & -> std::string; -#line 6975 "reflect.h2" +#line 7147 "reflect.h2" protected: auto end_func_statefull(cpp2::impl::in s) & -> void; -#line 6995 "reflect.h2" +#line 7167 "reflect.h2" // Generate the function for a token. public: [[nodiscard]] auto generate_func(cpp2::impl::in token) & -> std::string; -#line 7005 "reflect.h2" +#line 7177 "reflect.h2" // Generate the reset for a list of group identifiers. public: [[nodiscard]] auto generate_reset(cpp2::impl::in> groups) & -> std::string; -#line 7028 "reflect.h2" +#line 7200 "reflect.h2" // Name generation // protected: [[nodiscard]] auto gen_func_name() & -> std::string; -#line 7036 "reflect.h2" +#line 7208 "reflect.h2" public: [[nodiscard]] auto next_func_name() & -> std::string; -#line 7040 "reflect.h2" +#line 7212 "reflect.h2" protected: [[nodiscard]] auto gen_reset_func_name() & -> std::string; -#line 7046 "reflect.h2" +#line 7218 "reflect.h2" public: [[nodiscard]] auto gen_temp() & -> std::string; -#line 7052 "reflect.h2" +#line 7224 "reflect.h2" // Context management // public: [[nodiscard]] auto new_context() & -> generation_function_context*; -#line 7062 "reflect.h2" +#line 7234 "reflect.h2" public: auto finish_context() & -> void; -#line 7070 "reflect.h2" +#line 7242 "reflect.h2" // Misc functions // private: [[nodiscard]] auto get_current() & -> generation_function_context*; -#line 7076 "reflect.h2" +#line 7248 "reflect.h2" private: [[nodiscard]] auto get_base() & -> generation_function_context*; -#line 7080 "reflect.h2" +#line 7252 "reflect.h2" public: [[nodiscard]] auto get_entry_func() const& -> std::string; -#line 7084 "reflect.h2" +#line 7256 "reflect.h2" public: [[nodiscard]] auto create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string; -#line 7108 "reflect.h2" +#line 7280 "reflect.h2" // Run the generation for the token. public: [[nodiscard]] auto run(cpp2::impl::in token) & -> std::string; public: generation_context() = default; @@ -2762,7 +2765,7 @@ class generation_context public: auto operator=(generation_context const&) -> void = delete; -#line 7114 "reflect.h2" +#line 7286 "reflect.h2" }; // Regex syntax: | Example: ab|ba @@ -2782,27 +2785,27 @@ class alternative_token public: auto operator=(alternative_token const&) -> void = delete; -#line 7133 "reflect.h2" +#line 7305 "reflect.h2" }; class alternative_token_gen : public regex_token { -#line 7139 "reflect.h2" +#line 7311 "reflect.h2" private: token_vec alternatives; public: alternative_token_gen(cpp2::impl::in a); -#line 7146 "reflect.h2" +#line 7318 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 7163 "reflect.h2" +#line 7335 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 7170 "reflect.h2" +#line 7342 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in a) -> std::string; -#line 7183 "reflect.h2" +#line 7355 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; public: virtual ~alternative_token_gen() noexcept; @@ -2810,19 +2813,19 @@ class alternative_token_gen public: auto operator=(alternative_token_gen const&) -> void = delete; -#line 7195 "reflect.h2" +#line 7367 "reflect.h2" }; -#line 7198 "reflect.h2" +#line 7370 "reflect.h2" // Regex syntax: . // class any_token : public regex_token_check { -#line 7204 "reflect.h2" +#line 7376 "reflect.h2" public: any_token(cpp2::impl::in single_line); -#line 7208 "reflect.h2" +#line 7380 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~any_token() noexcept; @@ -2830,7 +2833,7 @@ class any_token public: auto operator=(any_token const&) -> void = delete; -#line 7213 "reflect.h2" +#line 7385 "reflect.h2" }; // Regex syntax: (?>) Example: a(?>bc|c)c @@ -2838,17 +2841,17 @@ class any_token class atomic_group_token : public regex_token { -#line 7221 "reflect.h2" +#line 7393 "reflect.h2" public: token_ptr inner_token {nullptr}; public: explicit atomic_group_token(); public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 7232 "reflect.h2" +#line 7404 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 7240 "reflect.h2" +#line 7412 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~atomic_group_token() noexcept; @@ -2856,7 +2859,7 @@ class atomic_group_token public: auto operator=(atomic_group_token const&) -> void = delete; -#line 7243 "reflect.h2" +#line 7415 "reflect.h2" }; // Regex syntax: a @@ -2864,34 +2867,34 @@ class atomic_group_token class char_token : public regex_token { -#line 7251 "reflect.h2" +#line 7423 "reflect.h2" private: std::string token; private: bool ignore_case; public: char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); -#line 7260 "reflect.h2" +#line 7432 "reflect.h2" public: char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); -#line 7266 "reflect.h2" +#line 7438 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 7270 "reflect.h2" +#line 7442 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 7293 "reflect.h2" +#line 7465 "reflect.h2" public: auto gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void; -#line 7314 "reflect.h2" +#line 7486 "reflect.h2" public: auto gen_case_sensitive(generation_context& ctx) const& -> void; -#line 7332 "reflect.h2" +#line 7504 "reflect.h2" public: [[nodiscard]] auto add_escapes(std::string str) const& -> std::string; -#line 7347 "reflect.h2" +#line 7519 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 7353 "reflect.h2" +#line 7525 "reflect.h2" public: auto append(char_token const& that) & -> void; public: virtual ~char_token() noexcept; @@ -2899,33 +2902,33 @@ class char_token public: auto operator=(char_token const&) -> void = delete; -#line 7357 "reflect.h2" +#line 7529 "reflect.h2" }; -#line 7360 "reflect.h2" +#line 7532 "reflect.h2" // Regex syntax: [] Example: [abcx-y[:digits:]] // class class_token : public regex_token { -#line 7366 "reflect.h2" +#line 7538 "reflect.h2" private: bool negate; private: bool case_insensitive; private: std::string class_str; public: class_token(cpp2::impl::in negate_, cpp2::impl::in case_insensitive_, cpp2::impl::in class_str_, cpp2::impl::in str); -#line 7378 "reflect.h2" +#line 7550 "reflect.h2" // TODO: Rework class generation: Generate check functions for classes. public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 7504 "reflect.h2" +#line 7676 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 7513 "reflect.h2" +#line 7685 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 7518 "reflect.h2" +#line 7690 "reflect.h2" private: [[nodiscard]] static auto create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string; public: virtual ~class_token() noexcept; @@ -2933,20 +2936,20 @@ class class_token public: auto operator=(class_token const&) -> void = delete; -#line 7525 "reflect.h2" +#line 7697 "reflect.h2" }; -#line 7528 "reflect.h2" +#line 7700 "reflect.h2" // Regex syntax: \a or \n or \[ // [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr; -#line 7569 "reflect.h2" +#line 7741 "reflect.h2" // Regex syntax: \K Example: ab\Kcd // [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr; -#line 7580 "reflect.h2" +#line 7752 "reflect.h2" // Regex syntax: \ Example: \1 // \g{name_or_number} // \k{name_or_number} @@ -2956,20 +2959,20 @@ class class_token class group_ref_token : public regex_token { -#line 7590 "reflect.h2" +#line 7762 "reflect.h2" private: int id; private: bool case_insensitive; private: bool reverse_eval; public: group_ref_token(cpp2::impl::in id_, cpp2::impl::in case_insensitive_, cpp2::impl::in reverse_, cpp2::impl::in str); -#line 7602 "reflect.h2" +#line 7774 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 7703 "reflect.h2" +#line 7875 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 7707 "reflect.h2" +#line 7879 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~group_ref_token() noexcept; @@ -2977,10 +2980,10 @@ class group_ref_token public: auto operator=(group_ref_token const&) -> void = delete; -#line 7710 "reflect.h2" +#line 7882 "reflect.h2" }; -#line 7713 "reflect.h2" +#line 7885 "reflect.h2" // Regex syntax: () Example: (abc) // (?:) (?i:abc) @@ -2994,29 +2997,29 @@ class group_ref_token class group_token : public regex_token { -#line 7727 "reflect.h2" +#line 7899 "reflect.h2" private: int number {-1}; private: bool reverse_eval {false}; private: token_ptr inner {nullptr}; public: [[nodiscard]] static auto parse_lookahead_lookbehind(parse_context& ctx, cpp2::impl::in syntax, cpp2::impl::in lookahead, cpp2::impl::in positive) -> token_ptr; -#line 7749 "reflect.h2" +#line 7921 "reflect.h2" public: [[nodiscard]] static auto parse_atomic_pattern(parse_context& ctx, cpp2::impl::in syntax) -> token_ptr; -#line 7763 "reflect.h2" +#line 7935 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 7922 "reflect.h2" +#line 8094 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 7930 "reflect.h2" +#line 8102 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in name, cpp2::impl::in name_brackets, cpp2::impl::in has_modifier, cpp2::impl::in modifiers, cpp2::impl::in inner_) -> std::string; -#line 7948 "reflect.h2" +#line 8120 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 7979 "reflect.h2" +#line 8151 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~group_token() noexcept; @@ -3025,25 +3028,25 @@ class group_token public: auto operator=(group_token const&) -> void = delete; -#line 7986 "reflect.h2" +#line 8158 "reflect.h2" }; -#line 7989 "reflect.h2" +#line 8161 "reflect.h2" // Regex syntax: \x or \x{} Example: \x{62} // [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr; -#line 8030 "reflect.h2" +#line 8202 "reflect.h2" // Regex syntax: $ Example: aa$ // [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr; -#line 8050 "reflect.h2" +#line 8222 "reflect.h2" // Regex syntax: ^ Example: ^aa // [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr; -#line 8066 "reflect.h2" +#line 8238 "reflect.h2" // Regex syntax: (?=) or (?!) or (*pla), etc. Example: (?=AA) // // Parsed in group_token. @@ -3051,20 +3054,20 @@ class group_token class lookahead_lookbehind_token : public regex_token { -#line 8074 "reflect.h2" +#line 8246 "reflect.h2" protected: bool lookahead; protected: bool positive; public: token_ptr inner {nullptr}; public: lookahead_lookbehind_token(cpp2::impl::in lookahead_, cpp2::impl::in positive_); -#line 8083 "reflect.h2" +#line 8255 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 8094 "reflect.h2" +#line 8266 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 8101 "reflect.h2" +#line 8273 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~lookahead_lookbehind_token() noexcept; @@ -3072,26 +3075,26 @@ class lookahead_lookbehind_token public: auto operator=(lookahead_lookbehind_token const&) -> void = delete; -#line 8104 "reflect.h2" +#line 8276 "reflect.h2" }; -#line 8107 "reflect.h2" +#line 8279 "reflect.h2" // Named character classes // [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr; -#line 8135 "reflect.h2" +#line 8307 "reflect.h2" // Regex syntax: \o{} Example: \o{142} // [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr; -#line 8163 "reflect.h2" +#line 8335 "reflect.h2" // Regex syntax: {min, max} Example: a{2,4} // class range_token : public regex_token { -#line 8169 "reflect.h2" +#line 8341 "reflect.h2" protected: int min_count {-1}; protected: int max_count {-1}; protected: int kind {range_flags::greedy}; @@ -3101,22 +3104,22 @@ class range_token public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 8249 "reflect.h2" +#line 8421 "reflect.h2" public: auto parse_modifier(parse_context& ctx) & -> void; -#line 8261 "reflect.h2" +#line 8433 "reflect.h2" public: [[nodiscard]] auto gen_mod_string() const& -> std::string; -#line 8274 "reflect.h2" +#line 8446 "reflect.h2" public: [[nodiscard]] auto gen_range_string() const& -> std::string; -#line 8293 "reflect.h2" +#line 8465 "reflect.h2" public: [[nodiscard]] auto reverse() const -> token_ptr override; -#line 8303 "reflect.h2" +#line 8475 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 8314 "reflect.h2" +#line 8486 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~range_token() noexcept; @@ -3124,16 +3127,16 @@ class range_token public: auto operator=(range_token const&) -> void = delete; -#line 8317 "reflect.h2" +#line 8489 "reflect.h2" }; -#line 8320 "reflect.h2" +#line 8492 "reflect.h2" // Regex syntax: *, +, or ? Example: aa* // class special_range_token : public range_token { -#line 8326 "reflect.h2" +#line 8498 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~special_range_token() noexcept; @@ -3142,7 +3145,7 @@ class special_range_token public: auto operator=(special_range_token const&) -> void = delete; -#line 8356 "reflect.h2" +#line 8528 "reflect.h2" }; // Regex syntax: \G Example: \Gaa @@ -3151,14 +3154,14 @@ class special_range_token // [[nodiscard]] auto start_match_parse(parse_context& ctx) -> token_ptr; -#line 8378 "reflect.h2" +#line 8550 "reflect.h2" // Regex syntax: \b or \B Example: \bword\b // // Matches the start end end of word boundaries. // [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr; -#line 8400 "reflect.h2" +#line 8572 "reflect.h2" //----------------------------------------------------------------------- // // Parser for regular expression. @@ -3179,24 +3182,24 @@ template class regex_generator public: regex_generator(cpp2::impl::in r, Error_out const& e); -#line 8423 "reflect.h2" +#line 8595 "reflect.h2" public: [[nodiscard]] auto parse() & -> std::string; -#line 8458 "reflect.h2" +#line 8630 "reflect.h2" private: auto extract_modifiers() & -> void; public: regex_generator(regex_generator const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_generator const&) -> void = delete; -#line 8472 "reflect.h2" +#line 8644 "reflect.h2" }; template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string; -#line 8484 "reflect.h2" +#line 8656 "reflect.h2" auto regex_gen(meta::type_declaration& t) -> void; -#line 8539 "reflect.h2" +#line 8711 "reflect.h2" //----------------------------------------------------------------------- // // apply_metafunctions @@ -3207,7 +3210,7 @@ auto regex_gen(meta::type_declaration& t) -> void; auto const& error ) -> bool; -#line 8671 "reflect.h2" +#line 8846 "reflect.h2" } } @@ -5469,12 +5472,185 @@ auto hashable(meta::type_declaration& t) -> void #line 1789 "reflect.h2" //----------------------------------------------------------------------- // +// euclidean_vector +// (a little metafunction experiment) +// +// Automatically generate +, -, * and / operators across all member variables, optionally with +// a single numeric type argument (eg. vector3 * float) if given a template argument. +// +// Additionally creates functions For getting the magnitude/length, normalisation, dot product. +// +#line 1799 "reflect.h2" +auto euclidean_vector(meta::type_declaration& t) -> void +{ + auto single_arg_type {CPP2_UFCS(get_argument)(t, 0)}; + bool add_single_arg_fns {CPP2_UFCS(size)(single_arg_type) != 0}; + + std::string op_add {"operator+: (this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_sub {"operator-: (this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_mul {"operator*: (this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_div {"operator/: (this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + + std::string op_negate {"operator-: (this) -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + + std::string op_assign_add {"operator+=: (inout this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") = { "}; + std::string op_assign_sub {"operator-=: (inout this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") = { "}; + std::string op_assign_mul {"operator*=: (inout this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") = { "}; + std::string op_assign_div {"operator/=: (inout this, in_ref other: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") = { "}; + + std::string op_add_sc {"operator+: (this, other: " + cpp2::to_string(single_arg_type) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_sub_sc {"operator-: (this, other: " + cpp2::to_string(single_arg_type) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_mul_sc {"operator*: (this, other: " + cpp2::to_string(single_arg_type) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + std::string op_div_sc {"operator/: (this, other: " + cpp2::to_string(single_arg_type) + ") -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = " + cpp2::to_string(CPP2_UFCS(name)(t)) + "( "}; + + std::string op_assign_add_sc {"operator+=: (inout this, other: " + cpp2::to_string(single_arg_type) + ") = { "}; + std::string op_assign_sub_sc {"operator-=: (inout this, other: " + cpp2::to_string(single_arg_type) + ") = { "}; + std::string op_assign_mul_sc {"operator*=: (inout this, other: " + cpp2::to_string(single_arg_type) + ") = { "}; + std::string op_assign_div_sc {"operator/=: (inout this, other: " + cpp2::to_string(cpp2::move(single_arg_type)) + ") = { "}; + + std::string fn_lengthSq {"lengthSquared: (this) -> _ = "}; + + std::string fn_normalise {"normalise: (inout this) = {\n len: _ = length();\n"}; + std::string fn_normalised {"normalised: (this) -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = {\n len: _ = length();\n return " + cpp2::to_string(CPP2_UFCS(name)(t)) + "(\n"}; + + std::string fn_dot {"dot: (in_ref lhs: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ", in_ref rhs: " + cpp2::to_string(CPP2_UFCS(name)(t)) + ") -> _ = "}; + + bool after_first_value_added {false}; + for ( + auto const& o : CPP2_UFCS(get_member_objects)(t) ) + { + if (after_first_value_added) { + op_add += ", "; + op_sub += ", "; + op_mul += ", "; + op_div += ", "; + + op_negate += ", "; + + if (add_single_arg_fns) { + op_add_sc += ", "; + op_sub_sc += ", "; + op_mul_sc += ", "; + op_div_sc += ", "; + } + + fn_lengthSq += " + "; + fn_dot += " + "; + + fn_normalised += ",\n"; + }else { + fn_normalised += "\n"; + } + + op_add += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " + other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ""; + op_sub += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " - other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ""; + op_mul += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " * other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ""; + op_div += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " / other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ""; + + op_negate += "-" + cpp2::to_string(CPP2_UFCS(name)(o)) + ""; + + fn_normalise += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " /= len;\n"; + fn_normalised += " " + cpp2::to_string(CPP2_UFCS(name)(o)) + " / len"; + + if (add_single_arg_fns) { + op_add_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " + other"; + op_sub_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " - other"; + op_mul_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " * other"; + op_div_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " / other"; + } + + op_assign_add += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " += other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ";"; + op_assign_sub += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " -= other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ";"; + op_assign_mul += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " *= other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ";"; + op_assign_div += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " /= other." + cpp2::to_string(CPP2_UFCS(name)(o)) + ";"; + + if (add_single_arg_fns) { + op_assign_add_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " += other;"; + op_assign_sub_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " -= other;"; + op_assign_mul_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " *= other;"; + op_assign_div_sc += "" + cpp2::to_string(CPP2_UFCS(name)(o)) + " /= other;"; + } + + fn_lengthSq += "( " + cpp2::to_string(CPP2_UFCS(name)(o)) + " * " + cpp2::to_string(CPP2_UFCS(name)(o)) + " )"; + fn_dot += "( lhs." + cpp2::to_string(CPP2_UFCS(name)(o)) + " * rhs." + cpp2::to_string(CPP2_UFCS(name)(o)) + " )"; + + after_first_value_added = true; + } + + op_assign_add += " }"; + op_assign_sub += " }"; + op_assign_mul += " }"; + op_assign_div += " }"; + + if (add_single_arg_fns) { + op_assign_add_sc += " }"; + op_assign_sub_sc += " }"; + op_assign_mul_sc += " }"; + op_assign_div_sc += " }"; + } + + op_add += " );"; + op_sub += " );"; + op_mul += " );"; + op_div += " );"; + + op_negate += " );"; + + if (add_single_arg_fns) { + op_add_sc += " );"; + op_sub_sc += " );"; + op_mul_sc += " );"; + op_div_sc += " );"; + } + + fn_lengthSq += ";"; + fn_dot += ";"; + + fn_normalise += "}"; + fn_normalised += ");\n}"; + + CPP2_UFCS(add_member)(t, cpp2::move(fn_lengthSq)); + CPP2_UFCS(add_member)(t, "length: (this) -> _ = std::sqrt( lengthSquared() );"); + + CPP2_UFCS(add_member)(t, cpp2::move(fn_normalise)); + CPP2_UFCS(add_member)(t, cpp2::move(fn_normalised)); + + CPP2_UFCS(add_member)(t, cpp2::move(fn_dot)); + + CPP2_UFCS(add_member)(t, cpp2::move(op_add)); + CPP2_UFCS(add_member)(t, cpp2::move(op_sub)); + CPP2_UFCS(add_member)(t, cpp2::move(op_mul)); + CPP2_UFCS(add_member)(t, cpp2::move(op_div)); + + CPP2_UFCS(add_member)(t, cpp2::move(op_negate)); + + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_add)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_sub)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_mul)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_div)); + + if (cpp2::move(add_single_arg_fns)) { + CPP2_UFCS(add_member)(t, cpp2::move(op_add_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_sub_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_mul_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_div_sc)); + + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_add_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_sub_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_mul_sc)); + CPP2_UFCS(add_member)(t, cpp2::move(op_assign_div_sc)); + } +} + +#line 1961 "reflect.h2" +//----------------------------------------------------------------------- +// // basic_value // // A regular type: copyable, plus has public default construction // and no protected or virtual functions // -#line 1796 "reflect.h2" +#line 1968 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void { CPP2_UFCS(copyable)(t); @@ -5503,28 +5679,28 @@ auto basic_value(meta::type_declaration& t) -> void // // Note: the ordering that should be encouraged as default gets the nice name // -#line 1824 "reflect.h2" +#line 1996 "reflect.h2" auto value(meta::type_declaration& t) -> void { CPP2_UFCS(ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 1830 "reflect.h2" +#line 2002 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(weakly_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 1836 "reflect.h2" +#line 2008 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(partially_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 1843 "reflect.h2" +#line 2015 "reflect.h2" //----------------------------------------------------------------------- // // C.20: If you can avoid defining default operations, do @@ -5547,7 +5723,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void // // a type without declared copy/move/destructor functions // -#line 1865 "reflect.h2" +#line 2037 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void { for ( auto& mf : CPP2_UFCS(get_member_functions)(t) ) @@ -5590,7 +5766,7 @@ auto cpp1_rule_of_zero(meta::type_declaration& t) -> void // parameters instead of concrete forwarding parameters (mainly used // for cppfront internal use, so cppfront builds under GCC 10) // -#line 1907 "reflect.h2" +#line 2079 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void { std::string ctor_params {}; @@ -5647,7 +5823,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto , type{ type_ } , value{ value_ }{} -#line 1959 "reflect.h2" +#line 2131 "reflect.h2" //----------------------------------------------------------------------- // // "C enumerations constitute a curiously half-baked concept. ... @@ -5666,7 +5842,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto // a type together with named constants that are its possible values // -#line 1982 "reflect.h2" +#line 2154 "reflect.h2" auto basic_enum( meta::type_declaration& t, auto const& nextval, @@ -5691,7 +5867,7 @@ auto basic_enum( { std::string value{"-1"}; -#line 2005 "reflect.h2" +#line 2177 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) if ( CPP2_UFCS(is_member_object)(m)) @@ -5733,7 +5909,7 @@ std::string value{"-1"}; } } -#line 2045 "reflect.h2" +#line 2217 "reflect.h2" if ((CPP2_UFCS(empty)(enumerators))) { CPP2_UFCS(error)(t, "an enumeration must contain at least one enumerator value"); return ; @@ -5784,7 +5960,7 @@ std::string value{"-1"}; } } -#line 2096 "reflect.h2" +#line 2268 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents // // Note that most values and functions are declared as '==' compile-time values, i.e. Cpp1 'constexpr' @@ -5834,7 +6010,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" // Provide 'to_string' and 'to_code' functions to print enumerator // name(s) as human-readable strings or as code expressions -#line 2143 "reflect.h2" +#line 2315 "reflect.h2" { if (bitwise) { to_string_impl += ", separator: std::string_view ) -> std::string = { \n" @@ -5875,7 +6051,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" } } -#line 2182 "reflect.h2" +#line 2354 "reflect.h2" if (bitwise) { CPP2_UFCS(add_member)(t, " to_string: (this) -> std::string = to_string_impl( \"\", \", \" );"); CPP2_UFCS(add_member)(t, " to_code : (this) -> std::string = to_string_impl( \"" + cpp2::to_string(CPP2_UFCS(name)(t)) + "::\", \" | \" );"); @@ -5889,7 +6065,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ // Provide a 'from_string' function to parse strings into enumerators -#line 2193 "reflect.h2" +#line 2365 "reflect.h2" { std::string_view prefix {""}; std::string_view combine_op {"return"}; @@ -5911,7 +6087,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ { std::string_view else_{""}; -#line 2213 "reflect.h2" +#line 2385 "reflect.h2" for ( auto const& e : cpp2::move(enumerators) ) { from_string += " " + cpp2::to_string(else_) + "if \"" + cpp2::to_string(e.name) + "\" == x { " + cpp2::to_string(combine_op) + " " + cpp2::to_string(CPP2_UFCS(name)(t)) + "::" + cpp2::to_string(e.name) + "; }\n"; @@ -5919,7 +6095,7 @@ std::string_view else_{""}; } } -#line 2219 "reflect.h2" +#line 2391 "reflect.h2" if (bitwise) { from_string += " else { break outer; }\n" " }\n" @@ -5935,11 +6111,11 @@ std::string_view else_{""}; } } -#line 2233 "reflect.h2" +#line 2405 "reflect.h2" CPP2_UFCS(add_member)(t, " from_code: (s: std::string_view) -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = { str: std::string = s; return from_string( cpp2::string_util::replace_all(str, \"" + cpp2::to_string(CPP2_UFCS(name)(t)) + "::\", \"\" ) ); }"); } -#line 2237 "reflect.h2" +#line 2409 "reflect.h2" //----------------------------------------------------------------------- // // "An enum[...] is a totally ordered value type that stores a @@ -5949,7 +6125,7 @@ std::string_view else_{""}; // // -- P0707R4, section 3 // -#line 2246 "reflect.h2" +#line 2418 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with an incrementing value generator @@ -5966,7 +6142,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void ); } -#line 2263 "reflect.h2" +#line 2435 "reflect.h2" //----------------------------------------------------------------------- // // "flag_enum expresses an enumeration that stores values @@ -5977,7 +6153,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void // // -- P0707R4, section 3 // -#line 2273 "reflect.h2" +#line 2445 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with a power-of-two value generator @@ -5999,7 +6175,7 @@ auto flag_enum(meta::type_declaration& t) -> void ); } -#line 2295 "reflect.h2" +#line 2467 "reflect.h2" //----------------------------------------------------------------------- // // "As with void*, programmers should know that unions [...] are @@ -6024,7 +6200,7 @@ auto flag_enum(meta::type_declaration& t) -> void // a type that contains exactly one of a fixed set of values at a time // -#line 2319 "reflect.h2" +#line 2491 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void { std::vector alternatives {}; @@ -6033,7 +6209,7 @@ auto value{0}; // 1. Gather: All the user-written members, and find/compute the max size -#line 2326 "reflect.h2" +#line 2498 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) { do @@ -6063,7 +6239,7 @@ auto value{0}; } while (false); ++value; } } -#line 2354 "reflect.h2" +#line 2526 "reflect.h2" std::string discriminator_type {}; if (cpp2::impl::cmp_less(CPP2_UFCS(ssize)(alternatives),std::numeric_limits::max())) { discriminator_type = "i8"; @@ -6078,7 +6254,7 @@ auto value{0}; discriminator_type = "i64"; }}} -#line 2369 "reflect.h2" +#line 2541 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents CPP2_UFCS(remove_marked_members)(t); @@ -6087,7 +6263,7 @@ std::string storage{" _storage: cpp2::aligned_storage t) -> void { std::cout << CPP2_UFCS(print)(t) << "\n"; } -#line 2476 "reflect.h2" +#line 2648 "reflect.h2" //----------------------------------------------------------------------- // // noisy - make each function print its name and signature, // so the programmer can see what's called // -#line 2481 "reflect.h2" +#line 2653 "reflect.h2" auto noisy(cpp2::impl::in t) -> void { for ( @@ -6224,7 +6400,7 @@ auto noisy(cpp2::impl::in t) -> void } } -#line 2498 "reflect.h2" +#line 2670 "reflect.h2" //----------------------------------------------------------------------- // // python - expose the type using pybind11 @@ -6232,14 +6408,14 @@ auto noisy(cpp2::impl::in t) -> void // *** Basic proof of concept only, limited and not well tested // Hardcoded for pybind11 and g++10 and my local cppfront include path // -#line 2505 "reflect.h2" +#line 2677 "reflect.h2" [[nodiscard]] auto python_param_names_and_types(cpp2::impl::in mf) -> python_param_names_and_types_ret -#line 2511 "reflect.h2" +#line 2683 "reflect.h2" { std::string names {}; std::string types {}; -#line 2512 "reflect.h2" +#line 2684 "reflect.h2" for ( auto const& param : CPP2_UFCS(get_parameters)(mf) ) if ( CPP2_UFCS(name)(CPP2_UFCS(get_declaration)(param)) != "this") @@ -6255,7 +6431,7 @@ auto noisy(cpp2::impl::in t) -> void static_cast(names); return { std::move(names), std::move(types) }; } -#line 2527 "reflect.h2" +#line 2699 "reflect.h2" auto python(meta::type_declaration& t) -> void { std::string bind {}; @@ -6292,14 +6468,14 @@ auto python(meta::type_declaration& t) -> void CPP2_UFCS(add_extra_build_step)(t, cpp2::move(build)); } -#line 2564 "reflect.h2" +#line 2736 "reflect.h2" //----------------------------------------------------------------------- // // javascript - expose the type using emscripten // // *** Basic proof of concept only, limited and not well tested // -#line 2570 "reflect.h2" +#line 2742 "reflect.h2" auto javascript(meta::type_declaration& t) -> void { std::string bind {}; @@ -6336,12 +6512,12 @@ auto javascript(meta::type_declaration& t) -> void CPP2_UFCS(disable_ref_qualifier_generation)(t); } -#line 2607 "reflect.h2" +#line 2779 "reflect.h2" //----------------------------------------------------------------------- // // For reflection test cases // -#line 2611 "reflect.h2" +#line 2783 "reflect.h2" auto sample_print(cpp2::impl::in s, cpp2::impl::in indent) -> void { std::cout @@ -6350,12 +6526,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in << "\n"; } -#line 2621 "reflect.h2" +#line 2793 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in decl) -> void{ traverse(decl); } -#line 2625 "reflect.h2" +#line 2797 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in decl) -> void { if (CPP2_UFCS(is_function)(decl)) { @@ -6375,12 +6551,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in // ... } -#line 2645 "reflect.h2" +#line 2817 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in f) -> void{ traverse(f); } -#line 2649 "reflect.h2" +#line 2821 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in f) -> void { auto parameters {CPP2_UFCS(get_parameters)(f)}; @@ -6401,12 +6577,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2670 "reflect.h2" +#line 2842 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in o) -> void{ traverse(o); } -#line 2674 "reflect.h2" +#line 2846 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in o) -> void { if (CPP2_UFCS(has_initializer)(o)) { @@ -6414,12 +6590,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2682 "reflect.h2" +#line 2854 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in t) -> void{ traverse(t); } -#line 2686 "reflect.h2" +#line 2858 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in t) -> void { for ( auto const& m : CPP2_UFCS(get_members)(t) ) { @@ -6427,23 +6603,23 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2694 "reflect.h2" +#line 2866 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in t) -> void{ traverse(t); } -#line 2698 "reflect.h2" +#line 2870 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in t) -> void { pre_traverse(CPP2_UFCS(get_declaration)(t)); } -#line 2703 "reflect.h2" +#line 2875 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in stmt) -> void{ traverse(stmt); } -#line 2707 "reflect.h2" +#line 2879 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in stmt) -> void { if (CPP2_UFCS(is_expression_statement)(stmt)) { @@ -6478,12 +6654,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in // jump } -#line 2742 "reflect.h2" +#line 2914 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in stmt) -> void{ traverse(stmt); } -#line 2746 "reflect.h2" +#line 2918 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in stmt) -> void { auto stmts {CPP2_UFCS(get_statements)(stmt)}; @@ -6493,12 +6669,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2756 "reflect.h2" +#line 2928 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in stmt) -> void{ traverse(stmt); } -#line 2760 "reflect.h2" +#line 2932 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in stmt) -> void { if (CPP2_UFCS(has_expression)(stmt)) { @@ -6506,12 +6682,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2768 "reflect.h2" +#line 2940 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in stmt) -> void{ traverse(stmt); } -#line 2772 "reflect.h2" +#line 2944 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in stmt) -> void { if (CPP2_UFCS(is_do)(stmt) || CPP2_UFCS(is_while)(stmt)) { @@ -6530,12 +6706,12 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2791 "reflect.h2" +#line 2963 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in stmt) -> void{ traverse(stmt); } -#line 2795 "reflect.h2" +#line 2967 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in stmt) -> void { pre_traverse(CPP2_UFCS(get_expression)(stmt)); @@ -6546,14 +6722,14 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2806 "reflect.h2" +#line 2978 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in expr) -> void { // Nothing to select here. traverse(expr); } -#line 2812 "reflect.h2" +#line 2984 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in expr) -> void { // An expression has other shortcuts to query deeper properties, @@ -6567,7 +6743,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in pre_traverse(CPP2_UFCS(as_assignment_expression)(expr)); } -#line 2826 "reflect.h2" +#line 2998 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6585,7 +6761,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2843 "reflect.h2" +#line 3015 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6597,7 +6773,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2854 "reflect.h2" +#line 3026 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6615,7 +6791,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2871 "reflect.h2" +#line 3043 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6627,7 +6803,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2883 "reflect.h2" +#line 3055 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6645,7 +6821,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2900 "reflect.h2" +#line 3072 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6657,7 +6833,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2911 "reflect.h2" +#line 3083 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6675,7 +6851,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2928 "reflect.h2" +#line 3100 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6687,7 +6863,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2939 "reflect.h2" +#line 3111 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6705,7 +6881,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2956 "reflect.h2" +#line 3128 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6717,7 +6893,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2968 "reflect.h2" +#line 3140 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6735,7 +6911,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2985 "reflect.h2" +#line 3157 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6747,7 +6923,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 2997 "reflect.h2" +#line 3169 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6765,7 +6941,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3014 "reflect.h2" +#line 3186 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6777,7 +6953,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3025 "reflect.h2" +#line 3197 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6795,7 +6971,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3042 "reflect.h2" +#line 3214 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6807,7 +6983,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3053 "reflect.h2" +#line 3225 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6825,7 +7001,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3070 "reflect.h2" +#line 3242 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6837,7 +7013,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3081 "reflect.h2" +#line 3253 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6855,7 +7031,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3098 "reflect.h2" +#line 3270 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6867,7 +7043,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3109 "reflect.h2" +#line 3281 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6885,7 +7061,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3126 "reflect.h2" +#line 3298 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6897,7 +7073,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3138 "reflect.h2" +#line 3310 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6915,7 +7091,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3155 "reflect.h2" +#line 3327 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in binexpr) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -6927,7 +7103,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3166 "reflect.h2" +#line 3338 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in isas) -> void { auto terms {CPP2_UFCS(get_terms)(isas)}; @@ -6944,7 +7120,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3182 "reflect.h2" +#line 3354 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in isas) -> void { auto terms {CPP2_UFCS(get_terms)(isas)}; @@ -6956,7 +7132,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3193 "reflect.h2" +#line 3365 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in exprs) -> void { for ( auto const& expr : CPP2_UFCS(get_expressions)(exprs) ) { @@ -6964,7 +7140,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3200 "reflect.h2" +#line 3372 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in prefix) -> void { auto ops {CPP2_UFCS(get_ops)(prefix)}; @@ -6981,13 +7157,13 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3216 "reflect.h2" +#line 3388 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in prefix) -> void { pre_traverse(CPP2_UFCS(get_postfix_expression)(prefix)); } -#line 3221 "reflect.h2" +#line 3393 "reflect.h2" auto simple_traverser::pre_traverse(cpp2::impl::in postfix) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -7004,7 +7180,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3237 "reflect.h2" +#line 3409 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in postfix) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -7024,13 +7200,13 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3256 "reflect.h2" +#line 3428 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in uid) -> void { static_cast(uid); } -#line 3262 "reflect.h2" +#line 3434 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in qid) -> void { for ( @@ -7040,7 +7216,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in } } -#line 3272 "reflect.h2" +#line 3444 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in tid) -> void { if (CPP2_UFCS(is_postfix_expression)(tid)) { @@ -7057,7 +7233,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in }}} } -#line 3289 "reflect.h2" +#line 3461 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in primary) -> void { if (CPP2_UFCS(is_identifier)(primary)) { @@ -7077,7 +7253,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in }}}} } -#line 3309 "reflect.h2" +#line 3481 "reflect.h2" auto simple_traverser::traverse(cpp2::impl::in idexpr) -> void { if (CPP2_UFCS(is_identifier)(idexpr)) { @@ -7094,7 +7270,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in }}} } -#line 3327 "reflect.h2" +#line 3499 "reflect.h2" //----------------------------------------------------------------------- // // sample_traverser serves two purposes: @@ -7105,7 +7281,7 @@ auto sample_print(cpp2::impl::in s, cpp2::impl::in // for reflecting on function bodies (statements, expressions) // -#line 3337 "reflect.h2" +#line 3509 "reflect.h2" auto sample_traverser(cpp2::impl::in decl, cpp2::impl::in indent) -> void { sample_print("Declaration: " + cpp2::to_string(CPP2_UFCS(name)(decl)) + "", indent); @@ -7127,7 +7303,7 @@ auto sample_traverser(cpp2::impl::in decl, cpp2::impl::in f, cpp2::impl::in indent) -> void { sample_print("Function: " + cpp2::to_string(CPP2_UFCS(name)(f)) + "", indent + 1); @@ -7157,7 +7333,7 @@ auto sample_traverser(cpp2::impl::in f, cpp2::impl:: } } -#line 3389 "reflect.h2" +#line 3561 "reflect.h2" auto sample_traverser(cpp2::impl::in o, cpp2::impl::in indent) -> void { sample_print("Object: name " + cpp2::to_string(CPP2_UFCS(name)(o)) + ", type " + cpp2::to_string(CPP2_UFCS(type)(o)) + "", indent); @@ -7167,7 +7343,7 @@ auto sample_traverser(cpp2::impl::in o, cpp2::impl::in } } -#line 3399 "reflect.h2" +#line 3571 "reflect.h2" auto sample_traverser(cpp2::impl::in t, cpp2::impl::in indent) -> void { sample_print("Type: " + cpp2::to_string(CPP2_UFCS(name)(t)) + "", indent); @@ -7188,7 +7364,7 @@ auto sample_traverser(cpp2::impl::in t, cpp2::impl::in t, cpp2::impl::in indent) -> void { sample_print("parameter:", indent); @@ -7207,7 +7383,7 @@ auto sample_traverser(cpp2::impl::in t, cpp2::impl: sample_traverser(CPP2_UFCS(get_declaration)(t), indent + 2); } -#line 3439 "reflect.h2" +#line 3611 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void { auto params {CPP2_UFCS(get_parameters)(stmt)}; @@ -7262,7 +7438,7 @@ auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in stmt, cpp2::impl::in indent) -> void { auto stmts {CPP2_UFCS(get_statements)(stmt)}; @@ -7279,7 +7455,7 @@ auto sample_traverser(cpp2::impl::in stmt, cpp2::impl: } } -#line 3511 "reflect.h2" +#line 3683 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void { sample_print("return statement", indent); @@ -7289,7 +7465,7 @@ auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::i } } -#line 3521 "reflect.h2" +#line 3693 "reflect.h2" auto sample_traverser(cpp2::impl::in stmt, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_do)(stmt) || CPP2_UFCS(is_while)(stmt)) { @@ -7321,7 +7497,7 @@ auto sample_traverser(cpp2::impl::in stmt, cpp2::impl } } -#line 3553 "reflect.h2" +#line 3725 "reflect.h2" auto sample_traverser(cpp2::impl::in expr, cpp2::impl::in indent) -> void { // An expression has other shortcuts to query deeper properties, @@ -7335,7 +7511,7 @@ auto sample_traverser(cpp2::impl::in expr, cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7353,7 +7529,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2: { auto first{true}; -#line 3583 "reflect.h2" +#line 3755 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7365,11 +7541,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3593 "reflect.h2" +#line 3765 "reflect.h2" } } -#line 3597 "reflect.h2" +#line 3769 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7387,7 +7563,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2: { auto first{true}; -#line 3613 "reflect.h2" +#line 3785 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7399,11 +7575,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3623 "reflect.h2" +#line 3795 "reflect.h2" } } -#line 3627 "reflect.h2" +#line 3799 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7421,7 +7597,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2 { auto first{true}; -#line 3643 "reflect.h2" +#line 3815 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7433,11 +7609,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3653 "reflect.h2" +#line 3825 "reflect.h2" } } -#line 3657 "reflect.h2" +#line 3829 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7455,7 +7631,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::imp { auto first{true}; -#line 3673 "reflect.h2" +#line 3845 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7467,11 +7643,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3683 "reflect.h2" +#line 3855 "reflect.h2" } } -#line 3687 "reflect.h2" +#line 3859 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7489,7 +7665,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::im { auto first{true}; -#line 3703 "reflect.h2" +#line 3875 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7501,11 +7677,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3713 "reflect.h2" +#line 3885 "reflect.h2" } } -#line 3717 "reflect.h2" +#line 3889 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7523,7 +7699,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::im { auto first{true}; -#line 3733 "reflect.h2" +#line 3905 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7535,11 +7711,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3743 "reflect.h2" +#line 3915 "reflect.h2" } } -#line 3747 "reflect.h2" +#line 3919 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7557,7 +7733,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::i { auto first{true}; -#line 3763 "reflect.h2" +#line 3935 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7569,11 +7745,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3773 "reflect.h2" +#line 3945 "reflect.h2" } } -#line 3777 "reflect.h2" +#line 3949 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7591,7 +7767,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2: { auto first{true}; -#line 3793 "reflect.h2" +#line 3965 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7603,11 +7779,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3803 "reflect.h2" +#line 3975 "reflect.h2" } } -#line 3807 "reflect.h2" +#line 3979 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7625,7 +7801,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::im { auto first{true}; -#line 3823 "reflect.h2" +#line 3995 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7637,11 +7813,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3833 "reflect.h2" +#line 4005 "reflect.h2" } } -#line 3837 "reflect.h2" +#line 4009 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7659,7 +7835,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl { auto first{true}; -#line 3853 "reflect.h2" +#line 4025 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7671,11 +7847,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3863 "reflect.h2" +#line 4035 "reflect.h2" } } -#line 3867 "reflect.h2" +#line 4039 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7693,7 +7869,7 @@ auto sample_traverser(cpp2::impl::in binexpr, cpp2::i { auto first{true}; -#line 3883 "reflect.h2" +#line 4055 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7705,11 +7881,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3893 "reflect.h2" +#line 4065 "reflect.h2" } } -#line 3897 "reflect.h2" +#line 4069 "reflect.h2" auto sample_traverser(cpp2::impl::in binexpr, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -7727,7 +7903,7 @@ auto sample_traverser(cpp2::impl::in binexpr, c { auto first{true}; -#line 3913 "reflect.h2" +#line 4085 "reflect.h2" for ( auto const& term : cpp2::move(terms) ) { @@ -7739,11 +7915,11 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_term)(term), indent + 2); } } -#line 3923 "reflect.h2" +#line 4095 "reflect.h2" } } -#line 3927 "reflect.h2" +#line 4099 "reflect.h2" auto sample_traverser(cpp2::impl::in isas, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(isas)}; @@ -7769,7 +7945,7 @@ auto sample_traverser(cpp2::impl::in isas, cpp2::impl::i } } -#line 3953 "reflect.h2" +#line 4125 "reflect.h2" auto sample_traverser(cpp2::impl::in exprs, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_empty)(exprs)) { @@ -7784,7 +7960,7 @@ auto sample_traverser(cpp2::impl::in exprs, cpp2::impl::i } } -#line 3968 "reflect.h2" +#line 4140 "reflect.h2" auto sample_traverser(cpp2::impl::in prefix, cpp2::impl::in indent) -> void { auto ops {CPP2_UFCS(get_ops)(prefix)}; @@ -7808,7 +7984,7 @@ auto sample_traverser(cpp2::impl::in prefix, cpp2::impl } } -#line 3992 "reflect.h2" +#line 4164 "reflect.h2" auto sample_traverser(cpp2::impl::in postfix, cpp2::impl::in indent) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -7841,7 +8017,7 @@ auto sample_traverser(cpp2::impl::in postfix, cpp2::im } } -#line 4025 "reflect.h2" +#line 4197 "reflect.h2" auto sample_traverser(cpp2::impl::in uid, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_identifier)(uid)) { @@ -7852,13 +8028,13 @@ auto sample_traverser(cpp2::impl::in uid, cpp2::impl::in qid, cpp2::impl::in indent) -> void { { auto first{true}; -#line 4039 "reflect.h2" +#line 4211 "reflect.h2" for ( auto const& term : CPP2_UFCS(get_terms)(qid) ) { @@ -7870,10 +8046,10 @@ auto first{true}; sample_traverser(CPP2_UFCS(get_unqualified)(term), indent + 2); } } -#line 4049 "reflect.h2" +#line 4221 "reflect.h2" } -#line 4052 "reflect.h2" +#line 4224 "reflect.h2" auto sample_traverser(cpp2::impl::in tid, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_postfix_expression)(tid)) { @@ -7890,7 +8066,7 @@ auto sample_traverser(cpp2::impl::in tid, cpp2::impl::in primary, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_identifier)(primary)) { @@ -7910,7 +8086,7 @@ auto sample_traverser(cpp2::impl::in primary, cpp2::im }}}} } -#line 4089 "reflect.h2" +#line 4261 "reflect.h2" auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in indent) -> void { if (CPP2_UFCS(is_identifier)(idexpr)) { @@ -7927,13 +8103,13 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in }}} } -#line 4106 "reflect.h2" +#line 4278 "reflect.h2" //----------------------------------------------------------------------- // // autodiff // -#line 4123 "reflect.h2" +#line 4295 "reflect.h2" autodiff_special_func::autodiff_special_func(cpp2::impl::in name_, cpp2::impl::in n_args_, cpp2::impl::in is_member_, cpp2::impl::in code_primal_, cpp2::impl::in code_fwd_, cpp2::impl::in code_rws_, cpp2::impl::in code_primal_higher_order_, cpp2::impl::in code_fwd_higher_order_, cpp2::impl::in code_rws_higher_order_) @@ -7947,7 +8123,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in , code_fwd_higher_order{ code_fwd_higher_order_ } , code_rws_higher_order{ code_rws_higher_order_ }{ -#line 4137 "reflect.h2" +#line 4309 "reflect.h2" if (CPP2_UFCS(empty)(code_primal_higher_order)) { code_primal_higher_order = code_primal; } @@ -7959,7 +8135,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in } } -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" autodiff_special_func::autodiff_special_func(autodiff_special_func const& that) : name{ that.name } , n_args{ that.n_args } @@ -7970,7 +8146,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in , code_primal_higher_order{ that.code_primal_higher_order } , code_fwd_higher_order{ that.code_fwd_higher_order } , code_rws_higher_order{ that.code_rws_higher_order }{} -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" auto autodiff_special_func::operator=(autodiff_special_func const& that) -> autodiff_special_func& { name = that.name; n_args = that.n_args; @@ -7982,7 +8158,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in code_fwd_higher_order = that.code_fwd_higher_order; code_rws_higher_order = that.code_rws_higher_order; return *this; } -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" autodiff_special_func::autodiff_special_func(autodiff_special_func&& that) noexcept : name{ std::move(that).name } , n_args{ std::move(that).n_args } @@ -7993,7 +8169,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in , code_primal_higher_order{ std::move(that).code_primal_higher_order } , code_fwd_higher_order{ std::move(that).code_fwd_higher_order } , code_rws_higher_order{ std::move(that).code_rws_higher_order }{} -#line 4148 "reflect.h2" +#line 4320 "reflect.h2" auto autodiff_special_func::operator=(autodiff_special_func&& that) noexcept -> autodiff_special_func& { name = std::move(that).name; n_args = std::move(that).n_args; @@ -8006,47 +8182,47 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in code_rws_higher_order = std::move(that).code_rws_higher_order; return *this; }// Default copy. -#line 4150 "reflect.h2" +#line 4322 "reflect.h2" [[nodiscard]] auto autodiff_special_func::is_match(cpp2::impl::in o) const& -> bool{ return name == o.name && n_args == o.n_args && is_member == o.is_member; } -#line 4157 "reflect.h2" +#line 4329 "reflect.h2" // TODO: Maybe use variant here. -#line 4161 "reflect.h2" +#line 4333 "reflect.h2" autodiff_declared_variable::autodiff_declared_variable(){} -#line 4163 "reflect.h2" +#line 4335 "reflect.h2" autodiff_declared_variable::autodiff_declared_variable(cpp2::impl::in name_, cpp2::impl::in decl_, cpp2::impl::in is_active_, cpp2::impl::in is_member_) : name{ name_ } , decl{ decl_ } , is_active{ is_active_ } , is_member{ is_member_ }{ -#line 4168 "reflect.h2" +#line 4340 "reflect.h2" } -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" autodiff_declared_variable::autodiff_declared_variable(autodiff_declared_variable const& that) : name{ that.name } , decl{ that.decl } , is_active{ that.is_active } , is_member{ that.is_member }{} -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" auto autodiff_declared_variable::operator=(autodiff_declared_variable const& that) -> autodiff_declared_variable& { name = that.name; decl = that.decl; is_active = that.is_active; is_member = that.is_member; return *this; } -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" autodiff_declared_variable::autodiff_declared_variable(autodiff_declared_variable&& that) noexcept : name{ std::move(that).name } , decl{ std::move(that).decl } , is_active{ std::move(that).is_active } , is_member{ std::move(that).is_member }{} -#line 4170 "reflect.h2" +#line 4342 "reflect.h2" auto autodiff_declared_variable::operator=(autodiff_declared_variable&& that) noexcept -> autodiff_declared_variable& { name = std::move(that).name; decl = std::move(that).decl; @@ -8054,21 +8230,21 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in is_member = std::move(that).is_member; return *this; } -#line 4174 "reflect.h2" +#line 4346 "reflect.h2" // namespace + type name -#line 4182 "reflect.h2" +#line 4354 "reflect.h2" autodiff_declaration_stack_item::autodiff_declaration_stack_item(cpp2::impl::in full_name_, cpp2::impl::in decl_) : full_name{ full_name_ } , decl{ decl_ }{ -#line 4185 "reflect.h2" +#line 4357 "reflect.h2" } -#line 4187 "reflect.h2" +#line 4359 "reflect.h2" [[nodiscard]] auto autodiff_declaration_stack_item::lookup_declaration(cpp2::impl::in decl_name) const& -> lookup_declaration_ret{ std::vector r {}; -#line 4188 "reflect.h2" +#line 4360 "reflect.h2" for ( auto const& cur : CPP2_UFCS(get_members)(decl) ) { if (CPP2_UFCS(has_name)(cur) && decl_name == CPP2_UFCS(name)(cur)) { CPP2_UFCS(push_back)(r, cur); @@ -8078,7 +8254,7 @@ auto sample_traverser(cpp2::impl::in idexpr, cpp2::impl::in }return r; } -#line 4197 "reflect.h2" +#line 4369 "reflect.h2" [[nodiscard]] auto autodiff_declaration_stack_item::lookup_variable_declaration(cpp2::impl::in decl_name) const& -> lookup_variable_declaration_ret{ bool found {false}; autodiff_declared_variable r {}; @@ -8087,7 +8263,7 @@ auto cur_context{CPP2_UFCS(rbegin)(declared_variables_stack)}; // Note: Not using "for std::ranges::views::reverse(...)" because // that does not work correctly in Clang 12 + older libstdc++ -#line 4201 "reflect.h2" +#line 4373 "reflect.h2" for( ; cur_context != CPP2_UFCS(rend)(declared_variables_stack); ++cur_context ) { @@ -8100,10 +8276,10 @@ auto cur_context{CPP2_UFCS(rbegin)(declared_variables_stack)}; } } } -#line 4202 "reflect.h2" +#line 4374 "reflect.h2" return { std::move(found), std::move(r) }; -#line 4212 "reflect.h2" +#line 4384 "reflect.h2" } autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declaration_stack_item const& that) @@ -8119,7 +8295,7 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar , diff_done{ std::move(that).diff_done } , declared_variables_stack{ std::move(that).declared_variables_stack }{} -#line 4220 "reflect.h2" +#line 4392 "reflect.h2" // Code in special function is replaced. Placeholders are: // _o_ : name of object for member functions. // _o_ : name of derivative object for member functions. @@ -8130,29 +8306,29 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar /* is_member = */ -#line 4237 "reflect.h2" +#line 4409 "reflect.h2" /* is_member = */ -#line 4245 "reflect.h2" +#line 4417 "reflect.h2" /* is_member = */ -#line 4253 "reflect.h2" +#line 4425 "reflect.h2" /* is_member = */ -#line 4261 "reflect.h2" +#line 4433 "reflect.h2" /* is_member = */ -#line 4272 "reflect.h2" +#line 4444 "reflect.h2" // Members depending on order -#line 4279 "reflect.h2" +#line 4451 "reflect.h2" autodiff_context::autodiff_context(){} -#line 4280 "reflect.h2" +#line 4452 "reflect.h2" autodiff_context::autodiff_context(cpp2::impl::in order_, cpp2::impl::in reverse_) : order{ order_ } , reverse{ reverse_ }{ -#line 4284 "reflect.h2" +#line 4456 "reflect.h2" if (1 != order) { if (reverse) { fwd_ad_type = "cpp2::taylor"; @@ -8165,17 +8341,17 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar } -#line 4296 "reflect.h2" +#line 4468 "reflect.h2" auto autodiff_context::add_variable_declaration(cpp2::impl::in name, cpp2::impl::in type, cpp2::impl::in is_active, cpp2::impl::in is_member) & -> void{ CPP2_UFCS(push_back)(CPP2_UFCS(back)(CPP2_UFCS(back)(declaration_stack).declared_variables_stack), autodiff_declared_variable(name, type, is_active, is_member)); } -#line 4300 "reflect.h2" +#line 4472 "reflect.h2" [[nodiscard]] auto autodiff_context::is_variable_active(cpp2::impl::in name) & -> bool{ return lookup_variable_declaration(name).is_active; } -#line 4304 "reflect.h2" +#line 4476 "reflect.h2" auto autodiff_context::create_namespace_stack(cpp2::impl::in t) & -> void{ if (CPP2_UFCS(parent_is_nonglobal_namespace)(t)) { create_namespace_stack(CPP2_UFCS(as_nonglobal_namespace)(CPP2_UFCS(get_parent)(t))); @@ -8193,20 +8369,20 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar static_cast(CPP2_UFCS(push_back)(declaration_stack, autodiff_declaration_stack_item(cpp2::move(full_name), t))); } -#line 4321 "reflect.h2" +#line 4493 "reflect.h2" [[nodiscard]] auto autodiff_context::is_forward() const& -> decltype(auto) { return !(reverse) || (reverse && order != 1); } -#line 4322 "reflect.h2" +#line 4494 "reflect.h2" [[nodiscard]] auto autodiff_context::is_reverse() const& -> decltype(auto) { return reverse; } -#line 4323 "reflect.h2" +#line 4495 "reflect.h2" [[nodiscard]] auto autodiff_context::is_taylor() const& -> decltype(auto) { return order != 1; } -#line 4325 "reflect.h2" +#line 4497 "reflect.h2" [[nodiscard]] auto autodiff_context::gen_temporary() & -> std::string{ temporary_count += 1; return "temp_" + cpp2::to_string(temporary_count) + ""; } -#line 4330 "reflect.h2" +#line 4502 "reflect.h2" [[nodiscard]] auto autodiff_context::is_type_active(cpp2::impl::in type) & -> bool{ auto decls {lookup_type_declaration(type)}; auto r {false}; @@ -8228,7 +8404,7 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar return r; } -#line 4351 "reflect.h2" +#line 4523 "reflect.h2" [[nodiscard]] auto autodiff_context::get_fwd_ad_type(cpp2::impl::in type) & -> std::string{ auto type_d {type}; @@ -8247,7 +8423,7 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar return string_util::replace_all(cpp2::move(type_d), "double", fwd_ad_type); } -#line 4369 "reflect.h2" +#line 4541 "reflect.h2" [[nodiscard]] auto autodiff_context::get_rws_ad_type(cpp2::impl::in type) & -> std::string{ auto type_d {type}; @@ -8266,7 +8442,7 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar return string_util::replace_all(cpp2::move(type_d), "double", rws_ad_type); } -#line 4387 "reflect.h2" +#line 4559 "reflect.h2" [[nodiscard]] auto autodiff_context::get_reverse_passing_style(cpp2::impl::in p) const& -> passing_style{ // TODO: inspect does not work here: error: error: no matching function for call to ‘is(const cpp2::passing_style&)’ // return inspect p -> passing_style { @@ -8289,13 +8465,13 @@ autodiff_declaration_stack_item::autodiff_declaration_stack_item(autodiff_declar if (p == passing_style::forward) { return passing_style::inout; } if (p == passing_style::forward_ref) { return passing_style::inout; } -#line 4410 "reflect.h2" +#line 4582 "reflect.h2" CPP2_UFCS(error)(CPP2_UFCS(back)(declaration_stack).decl, "AD: Do not know how to handle passing style:" + cpp2::to_string(p) + ""); return passing_style::inout; } -#line 4415 "reflect.h2" +#line 4587 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_declaration(cpp2::impl::in decl_name) & -> lookup_declaration_ret{ std::vector r {}; { @@ -8303,7 +8479,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; // Note: Not using "for std::ranges::views::reverse(...)" because // that does not work correctly in Clang 12 + older libstdc++ -#line 4419 "reflect.h2" +#line 4591 "reflect.h2" for( ; cur != CPP2_UFCS(rend)(declaration_stack); ++cur ) { @@ -8325,11 +8501,11 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } } -#line 4439 "reflect.h2" +#line 4611 "reflect.h2" return r; } -#line 4442 "reflect.h2" +#line 4614 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_variable_declaration(cpp2::impl::in name) & -> autodiff_declared_variable{ if (name == "_") { return autodiff_declared_variable(name, "_", false, false); @@ -8340,7 +8516,7 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; // Note: Not using "for std::ranges::views::reverse(...)" because // that does not work correctly in Clang 12 + older libstdc++ -#line 4450 "reflect.h2" +#line 4622 "reflect.h2" for( ; cur_context != CPP2_UFCS(rend)(declaration_stack); ++cur_context ) { @@ -8351,16 +8527,16 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; } } -#line 4459 "reflect.h2" +#line 4631 "reflect.h2" CPP2_UFCS(error)(CPP2_UFCS(back)(declaration_stack).decl, "AD: Could not find declaration of variable with name `" + cpp2::to_string(name) + "`."); return autodiff_declared_variable(); } -#line 4464 "reflect.h2" +#line 4636 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_function_declaration(cpp2::impl::in decl_name) & -> lookup_function_declaration_ret{ std::vector r {}; -#line 4465 "reflect.h2" +#line 4637 "reflect.h2" auto r_all {lookup_declaration(decl_name)}; for ( auto const& cur : cpp2::move(r_all) ) { @@ -8370,10 +8546,10 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; }return r; } -#line 4474 "reflect.h2" +#line 4646 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_member_function_declaration(cpp2::impl::in obj_type, cpp2::impl::in decl_name) & -> lookup_member_function_declaration_ret{ std::vector r {}; -#line 4475 "reflect.h2" +#line 4647 "reflect.h2" for ( auto const& cur : CPP2_UFCS(get_members)(obj_type) ) { if (CPP2_UFCS(is_function)(cur) && CPP2_UFCS(has_name)(cur) && decl_name == CPP2_UFCS(name)(cur)) { CPP2_UFCS(push_back)(r, CPP2_UFCS(as_function)(cur)); @@ -8383,10 +8559,10 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; }return r; } -#line 4484 "reflect.h2" +#line 4656 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_type_declaration(cpp2::impl::in decl_name) & -> lookup_type_declaration_ret{ std::vector r {}; -#line 4485 "reflect.h2" +#line 4657 "reflect.h2" auto r_all {lookup_declaration(decl_name)}; for ( auto const& cur : cpp2::move(r_all) ) { @@ -8396,13 +8572,13 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; }return r; } -#line 4494 "reflect.h2" +#line 4666 "reflect.h2" [[nodiscard]] auto autodiff_context::lookup_special_function_handling(cpp2::impl::in func_name, cpp2::impl::in n_args, cpp2::impl::in is_member) const& -> lookup_special_function_handling_ret{ cpp2::impl::deferred_init m; cpp2::impl::deferred_init code_primal; cpp2::impl::deferred_init code_fwd; cpp2::impl::deferred_init code_rws; -#line 4495 "reflect.h2" +#line 4667 "reflect.h2" autodiff_special_func lookup {func_name, n_args, is_member}; m.construct(false); @@ -8427,7 +8603,7 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; }return { std::move(m.value()), std::move(code_primal.value()), std::move(code_fwd.value()), std::move(code_rws.value()) }; } -#line 4519 "reflect.h2" +#line 4691 "reflect.h2" auto autodiff_context::add_as_differentiated(cpp2::impl::in t) & -> void{ auto top {&CPP2_UFCS(back)(declaration_stack)}; @@ -8436,7 +8612,7 @@ auto cur_context{CPP2_UFCS(rbegin)(declaration_stack)}; CPP2_UFCS(push_back)((*cpp2::impl::assert_not_null(cpp2::move(top))).diff_done, t); } -#line 4527 "reflect.h2" +#line 4699 "reflect.h2" auto autodiff_context::add_for_differentiation(cpp2::impl::in t) & -> void{ auto t_parent {CPP2_UFCS(get_parent)(t)}; @@ -8447,7 +8623,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; // Note: Not using "for std::ranges::views::reverse(...)" because // that does not work correctly in Clang 12 + older libstdc++ -#line 4535 "reflect.h2" +#line 4707 "reflect.h2" for( ; cur != CPP2_UFCS(rend)(declaration_stack); ++cur ) { @@ -8462,13 +8638,13 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } } -#line 4548 "reflect.h2" +#line 4720 "reflect.h2" if (!(cpp2::move(found))) { CPP2_UFCS(error)(t, "AD: Could not find parent type/namespace for: " + cpp2::to_string(t) + ""); } } -#line 4553 "reflect.h2" +#line 4725 "reflect.h2" [[nodiscard]] auto autodiff_context::is_in_list(cpp2::impl::in v, cpp2::impl::in> list) -> bool{ for ( auto const& cur : list ) { if (CPP2_UFCS(is_same)(cur, v)) { @@ -8479,18 +8655,18 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; return false; } -#line 4563 "reflect.h2" +#line 4735 "reflect.h2" auto autodiff_context::enter_function() & -> void{ temporary_count = 0; CPP2_UFCS(push_back)(CPP2_UFCS(back)(declaration_stack).declared_variables_stack, std::vector()); } -#line 4568 "reflect.h2" +#line 4740 "reflect.h2" auto autodiff_context::leave_function() & -> void{ CPP2_UFCS(pop_back)(CPP2_UFCS(back)(declaration_stack).declared_variables_stack); } -#line 4572 "reflect.h2" +#line 4744 "reflect.h2" auto autodiff_context::push_stack(cpp2::impl::in decl) & -> void{ std::string full_name {""}; @@ -8504,7 +8680,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; CPP2_UFCS(push_back)(declaration_stack, autodiff_declaration_stack_item(cpp2::move(full_name), decl)); } -#line 4585 "reflect.h2" +#line 4757 "reflect.h2" auto autodiff_context::pop_stack() & -> void{ if (cpp2::cpp2_default.is_active() && !(!(CPP2_UFCS(empty)(declaration_stack))) ) { cpp2::cpp2_default.report_violation(""); } @@ -8520,7 +8696,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; CPP2_UFCS(pop_back)(declaration_stack); } -#line 4600 "reflect.h2" +#line 4772 "reflect.h2" auto autodiff_context::finish() & -> void{ while( !(CPP2_UFCS(empty)(declaration_stack)) ) { pop_stack(); @@ -8528,18 +8704,18 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } //TODO: Remove when autodiff_diff_code is updated -#line 4607 "reflect.h2" +#line 4779 "reflect.h2" [[nodiscard]] auto autodiff_context::get_self() & -> autodiff_context*{ return &(*this); } -#line 4620 "reflect.h2" +#line 4792 "reflect.h2" autodiff_diff_code::autodiff_diff_code(cpp2::impl::in ctx_) : ctx{ ctx_ }{ -#line 4622 "reflect.h2" +#line 4794 "reflect.h2" } -#line 4620 "reflect.h2" +#line 4792 "reflect.h2" auto autodiff_diff_code::operator=(cpp2::impl::in ctx_) -> autodiff_diff_code& { ctx = ctx_; fwd = ""; @@ -8547,28 +8723,28 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; rws_backprop = ""; return *this; -#line 4622 "reflect.h2" +#line 4794 "reflect.h2" } -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" autodiff_diff_code::autodiff_diff_code(autodiff_diff_code const& that) : ctx{ that.ctx } , fwd{ that.fwd } , rws_primal{ that.rws_primal } , rws_backprop{ that.rws_backprop }{} -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" auto autodiff_diff_code::operator=(autodiff_diff_code const& that) -> autodiff_diff_code& { ctx = that.ctx; fwd = that.fwd; rws_primal = that.rws_primal; rws_backprop = that.rws_backprop; return *this; } -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" autodiff_diff_code::autodiff_diff_code(autodiff_diff_code&& that) noexcept : ctx{ std::move(that).ctx } , fwd{ std::move(that).fwd } , rws_primal{ std::move(that).rws_primal } , rws_backprop{ std::move(that).rws_backprop }{} -#line 4623 "reflect.h2" +#line 4795 "reflect.h2" auto autodiff_diff_code::operator=(autodiff_diff_code&& that) noexcept -> autodiff_diff_code& { ctx = std::move(that).ctx; fwd = std::move(that).fwd; @@ -8576,14 +8752,14 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; rws_backprop = std::move(that).rws_backprop; return *this; } -#line 4625 "reflect.h2" +#line 4797 "reflect.h2" auto autodiff_diff_code::add_forward(cpp2::impl::in v) & -> void{if (CPP2_UFCS(is_forward)((*cpp2::impl::assert_not_null(ctx)))) {fwd += v;}} -#line 4626 "reflect.h2" +#line 4798 "reflect.h2" auto autodiff_diff_code::add_reverse_primal(cpp2::impl::in v) & -> void{if (CPP2_UFCS(is_reverse)((*cpp2::impl::assert_not_null(ctx)))) {rws_primal += v;}} -#line 4627 "reflect.h2" +#line 4799 "reflect.h2" auto autodiff_diff_code::add_reverse_backprop(cpp2::impl::in v) & -> void{if (CPP2_UFCS(is_reverse)((*cpp2::impl::assert_not_null(ctx)))) {rws_backprop = v + rws_backprop; }} -#line 4629 "reflect.h2" +#line 4801 "reflect.h2" auto autodiff_diff_code::reset() & -> void{ fwd = ""; rws_primal = ""; @@ -8591,7 +8767,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. -#line 4636 "reflect.h2" +#line 4808 "reflect.h2" auto autodiff_diff_code::operator=(cpp2::impl::in v) -> autodiff_diff_code& { ctx = CPP2_UFCS_NONLOCAL(get_self)((*cpp2::impl::assert_not_null(ctx))); fwd = v; @@ -8599,42 +8775,42 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; rws_backprop = ""; return *this; -#line 4639 "reflect.h2" +#line 4811 "reflect.h2" } // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. -#line 4642 "reflect.h2" +#line 4814 "reflect.h2" auto autodiff_diff_code::operator+=(cpp2::impl::in v) & -> void{ fwd += v; } // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. -#line 4647 "reflect.h2" +#line 4819 "reflect.h2" auto autodiff_diff_code::operator+=(cpp2::impl::in v) & -> void{ fwd += v.fwd; } // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. -#line 4652 "reflect.h2" +#line 4824 "reflect.h2" [[nodiscard]] auto autodiff_diff_code::empty() const& -> bool{ return CPP2_UFCS(empty)(fwd); } -#line 4657 "reflect.h2" +#line 4829 "reflect.h2" // // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. // to_string: (v: autodiff_diff_code) -> std::string = { // return v.fwd; // } -#line 4668 "reflect.h2" +#line 4840 "reflect.h2" autodiff_activity_check::autodiff_activity_check(cpp2::impl::in ctx_) : simple_traverser{ } , ctx{ ctx_ }{ -#line 4670 "reflect.h2" +#line 4842 "reflect.h2" } -#line 4672 "reflect.h2" +#line 4844 "reflect.h2" auto autodiff_activity_check::traverse(cpp2::impl::in t) -> void{ for ( auto const& m : CPP2_UFCS(get_members)(t) ) @@ -8647,7 +8823,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } } -#line 4684 "reflect.h2" +#line 4856 "reflect.h2" auto autodiff_activity_check::traverse(cpp2::impl::in o) -> void{ auto type {o.type()}; @@ -8666,7 +8842,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; } } -#line 4702 "reflect.h2" +#line 4874 "reflect.h2" auto autodiff_activity_check::traverse(cpp2::impl::in primary) -> void { if (CPP2_UFCS(is_identifier)(primary)) { @@ -8691,7 +8867,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; }}}} } -#line 4726 "reflect.h2" +#line 4898 "reflect.h2" auto autodiff_activity_check::traverse(cpp2::impl::in postfix) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -8700,7 +8876,7 @@ auto cur{CPP2_UFCS(rbegin)(declaration_stack)}; { auto i{0}; -#line 4733 "reflect.h2" +#line 4905 "reflect.h2" for ( auto const& term : terms ) { do { if (CPP2_UFCS(get_op)(term) == ".") { continue; @@ -8716,7 +8892,7 @@ auto i{0}; } // TODO: Really check for members -#line 4747 "reflect.h2" +#line 4919 "reflect.h2" if (!(is_func) || CPP2_UFCS(ssize)(terms) != 1) { active |= CPP2_UFCS(is_variable_active)((*cpp2::impl::assert_not_null(ctx)), CPP2_UFCS(to_string)(CPP2_UFCS(get_primary_expression)(postfix))); } @@ -8729,39 +8905,39 @@ auto i{0}; } } -#line 4765 "reflect.h2" +#line 4937 "reflect.h2" autodiff_handler_base::autodiff_handler_base(cpp2::impl::in ctx_) : ctx{ ctx_ } , diff{ ctx }{ -#line 4768 "reflect.h2" +#line 4940 "reflect.h2" } -#line 4765 "reflect.h2" +#line 4937 "reflect.h2" auto autodiff_handler_base::operator=(cpp2::impl::in ctx_) -> autodiff_handler_base& { ctx = ctx_; diff = ctx; return *this; -#line 4768 "reflect.h2" +#line 4940 "reflect.h2" } // Temporary: TODO: remove when everything has been adapted to primal, fwd, rws pushes. -#line 4771 "reflect.h2" +#line 4943 "reflect.h2" auto autodiff_handler_base::append(autodiff_handler_base const& o) & -> void{ diff.fwd += o.diff.fwd; diff.rws_primal += o.diff.rws_primal; diff.rws_backprop = o.diff.rws_backprop + diff.rws_backprop; } -#line 4788 "reflect.h2" +#line 4960 "reflect.h2" autodiff_expression_handler::autodiff_expression_handler(cpp2::impl::in ctx_) : simple_traverser{ } , autodiff_handler_base{ ctx_ }{ -#line 4790 "reflect.h2" +#line 4962 "reflect.h2" } -#line 4792 "reflect.h2" +#line 4964 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::add_suffix_if_not_wildcard(cpp2::impl::in lhs, cpp2::impl::in suffix) const& -> std::string{ if ("_" == lhs) { return lhs; @@ -8771,7 +8947,7 @@ auto i{0}; } } -#line 4801 "reflect.h2" +#line 4973 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::prepare_backprop(cpp2::impl::in rhs_b, cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b) const& -> std::string{ auto r {rhs_b}; r = string_util::replace_all(r, "_r_", lhs); @@ -8780,10 +8956,10 @@ auto i{0}; return r; } -#line 4809 "reflect.h2" +#line 4981 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::prepare_backprop(cpp2::impl::in rhs_b, cpp2::impl::in lhs) const& -> std::string { return prepare_backprop(rhs_b, lhs, lhs + (*cpp2::impl::assert_not_null(ctx)).fwd_suffix, lhs + (*cpp2::impl::assert_not_null(ctx)).rws_suffix); } -#line 4811 "reflect.h2" +#line 4983 "reflect.h2" auto autodiff_expression_handler::gen_assignment(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b) & -> void{ CPP2_UFCS(add_forward)(diff, "" + cpp2::to_string(lhs_d) + " = " + cpp2::to_string(rhs_d) + ";\n"); CPP2_UFCS(add_forward)(diff, "" + cpp2::to_string(lhs) + " = " + cpp2::to_string(rhs) + ";\n"); @@ -8795,14 +8971,14 @@ auto i{0}; CPP2_UFCS(add_reverse_backprop)(diff, "" + cpp2::to_string(lhs_b) + " = 0.0;\n"); CPP2_UFCS(add_reverse_backprop)(diff, prepare_backprop(rhs_b, lhs, lhs_d, lhs_b)); } -#line 4822 "reflect.h2" +#line 4994 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::gen_assignment(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b) & -> decltype(auto) { return gen_assignment(lhs, lhs_d, lhs_b, primal_expr, fwd_expr, rws_expr); } -#line 4824 "reflect.h2" +#line 4996 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::gen_assignment(cpp2::impl::in lhs) & -> decltype(auto) { return gen_assignment(lhs, add_suffix_if_not_wildcard(lhs, (*cpp2::impl::assert_not_null(ctx)).fwd_suffix), add_suffix_if_not_wildcard(lhs, (*cpp2::impl::assert_not_null(ctx)).rws_suffix), primal_expr, fwd_expr, rws_expr); } -#line 4828 "reflect.h2" +#line 5000 "reflect.h2" auto autodiff_expression_handler::gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b, cpp2::impl::in type, cpp2::impl::in type_d, cpp2::impl::in type_b) & -> void{ CPP2_UFCS(add_forward)(diff, "" + cpp2::to_string(lhs_d) + ": " + cpp2::to_string(type_d) + " = " + cpp2::to_string(rhs_d) + ";\n"); CPP2_UFCS(add_forward)(diff, "" + cpp2::to_string(lhs) + " : " + cpp2::to_string(type) + " = " + cpp2::to_string(rhs) + ";\n"); @@ -8815,13 +8991,13 @@ auto i{0}; CPP2_UFCS(add_reverse_backprop)(diff, "" + cpp2::to_string(lhs_b) + " = 0.0;\n"); CPP2_UFCS(add_reverse_backprop)(diff, prepare_backprop(rhs_b, lhs, lhs_d, lhs_b)); } -#line 4840 "reflect.h2" +#line 5012 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in rhs, cpp2::impl::in rhs_d, cpp2::impl::in rhs_b, cpp2::impl::in type) & -> decltype(auto) { return gen_declaration(lhs, lhs_d, lhs_b, rhs, rhs_d, rhs_b, type, CPP2_UFCS(get_fwd_ad_type)((*cpp2::impl::assert_not_null(ctx)), type), CPP2_UFCS(get_rws_ad_type)((*cpp2::impl::assert_not_null(ctx)), type)); } -#line 4842 "reflect.h2" +#line 5014 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::gen_declaration(cpp2::impl::in lhs, cpp2::impl::in lhs_d, cpp2::impl::in lhs_b, cpp2::impl::in type) & -> decltype(auto) { return gen_declaration(lhs, lhs_d, lhs_b, primal_expr, fwd_expr, rws_expr, type); } -#line 4844 "reflect.h2" +#line 5016 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::gen_declaration(cpp2::impl::in lhs, cpp2::impl::in type) & -> decltype(auto) { return gen_declaration(lhs, lhs + (*cpp2::impl::assert_not_null(ctx)).fwd_suffix, lhs + (*cpp2::impl::assert_not_null(ctx)).rws_suffix, type); } @@ -8832,7 +9008,7 @@ auto i{0}; , active{ active_ }{} autodiff_expression_handler::primal_fwd_rws_name::primal_fwd_rws_name(){} -#line 4856 "reflect.h2" +#line 5028 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::handle_expression_list(cpp2::impl::in list) & -> std::vector{ std::vector args {}; for ( auto const& expr : CPP2_UFCS(get_expressions)(list) ) { @@ -8842,7 +9018,7 @@ autodiff_expression_handler::primal_fwd_rws_name::primal_fwd_rws_name(){} return args; } -#line 4865 "reflect.h2" +#line 5037 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::handle_expression_term(auto const& term) & -> primal_fwd_rws_name{ if (CPP2_UFCS(is_identifier)(term)) { auto primal {CPP2_UFCS(to_string)(term)}; @@ -8904,7 +9080,7 @@ autodiff_expression_handler::primal_fwd_rws_name::primal_fwd_rws_name(){} }} } -#line 4926 "reflect.h2" +#line 5098 "reflect.h2" auto autodiff_expression_handler::handle_function_call(cpp2::impl::in postfix, cpp2::impl::in has_return) & -> void{ auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -8912,7 +9088,7 @@ autodiff_expression_handler::primal_fwd_rws_name::primal_fwd_rws_name(){} { auto i{0}; -#line 4932 "reflect.h2" +#line 5104 "reflect.h2" for ( auto const& term : terms ) { do { if (CPP2_UFCS(get_op)(term) == ".") { continue; @@ -8926,7 +9102,7 @@ auto i{0}; } // Check for function call, everything else is not handled. -#line 4944 "reflect.h2" +#line 5116 "reflect.h2" if (!((cpp2::move(is_func)))) { CPP2_UFCS(error)(postfix, "AD: Postfix expressions are only handled for function calls, or member function calls. Do not know how to handle: " + cpp2::to_string(CPP2_UFCS(to_string)(postfix)) + ""); return ; @@ -8951,7 +9127,7 @@ auto i{0}; { auto i{0}; -#line 4967 "reflect.h2" +#line 5139 "reflect.h2" for ( auto const& term : terms ) { do { if (CPP2_UFCS(get_op)(term) == ".") { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_id_expression)(term)) ) { cpp2::cpp2_default.report_violation(""); } @@ -8976,7 +9152,7 @@ auto i{0}; } while (false); i += 1; } } -#line 4990 "reflect.h2" +#line 5162 "reflect.h2" if (handle_special_function(object, object_d, object_b, function_name, args)) { return ; } @@ -9093,7 +9269,7 @@ auto i{0}; // TODO: Add function to list of functions/objects for differentiation for the no return case. } -#line 5106 "reflect.h2" +#line 5278 "reflect.h2" [[nodiscard]] auto autodiff_expression_handler::handle_special_function(cpp2::impl::in object, cpp2::impl::in object_d, cpp2::impl::in object_b, cpp2::impl::in function_name, cpp2::impl::in> args) & -> bool{ auto r {CPP2_UFCS(lookup_special_function_handling)((*cpp2::impl::assert_not_null(ctx)), function_name, cpp2::unchecked_narrow(CPP2_UFCS(ssize)(args)), !(CPP2_UFCS(empty)(object)))}; @@ -9121,7 +9297,7 @@ auto i{0}; { auto i{1}; -#line 5132 "reflect.h2" +#line 5304 "reflect.h2" for ( auto const& arg : args ) { code_primal = string_util::replace_all(code_primal, "_a" + cpp2::to_string(i) + "_", arg.primal); code_primal = string_util::replace_all(code_primal, "_ad" + cpp2::to_string(i) + "_", arg.fwd); @@ -9135,7 +9311,7 @@ auto i{1}; } } -#line 5144 "reflect.h2" +#line 5316 "reflect.h2" primal_expr = cpp2::move(code_primal); fwd_expr = cpp2::move(code_fwd); rws_expr = cpp2::move(code_rws); @@ -9143,62 +9319,62 @@ auto i{1}; return true; } -#line 5151 "reflect.h2" +#line 5323 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in expr) -> void{ base::traverse(expr); } -#line 5155 "reflect.h2" +#line 5327 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Assign expressions are not yet handled."); } -#line 5159 "reflect.h2" +#line 5331 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Logical or expressions are not yet handled."); } -#line 5163 "reflect.h2" +#line 5335 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Logical and expressions are not yet handled."); } -#line 5167 "reflect.h2" +#line 5339 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit or expressions are not yet handled."); } -#line 5171 "reflect.h2" +#line 5343 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit xor expressions are not yet handled."); } -#line 5175 "reflect.h2" +#line 5347 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit and expressions are not yet handled."); } -#line 5179 "reflect.h2" +#line 5351 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Equality or expressions are not yet handled."); } -#line 5183 "reflect.h2" +#line 5355 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Relational expressions are not yet handled."); } -#line 5187 "reflect.h2" +#line 5359 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Compare or expressions are not yet handled."); } -#line 5191 "reflect.h2" +#line 5363 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Shift or expressions are not yet handled."); } -#line 5195 "reflect.h2" +#line 5367 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -9241,7 +9417,7 @@ auto i{1}; rws_expr = cpp2::move(rws); } -#line 5237 "reflect.h2" +#line 5409 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in binexpr) -> void{ auto terms {CPP2_UFCS(get_terms)(binexpr)}; @@ -9312,7 +9488,7 @@ auto i{1}; CPP2_UFCS(error)(binexpr, "unkown multiplicative operator '" + cpp2::to_string(cpp2::move(op)) + "'"); }} -#line 5308 "reflect.h2" +#line 5480 "reflect.h2" if (i + 1 == CPP2_UFCS(ssize)(terms)) { primal_expr = cpp2::move(primal); fwd_expr = cpp2::move(fwd); @@ -9329,12 +9505,12 @@ auto i{1}; } } -#line 5324 "reflect.h2" +#line 5496 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in isas) -> void{ CPP2_UFCS(error)(isas, "AD: Is as expressions are not yet handled."); } -#line 5328 "reflect.h2" +#line 5500 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in prefix) -> void { auto ops {CPP2_UFCS(get_ops)(prefix)}; @@ -9351,7 +9527,7 @@ auto i{1}; fwd_expr = CPP2_ASSERT_IN_BOUNDS_LITERAL(cpp2::move(ops), 0) + cpp2::move(ad).fwd_expr; } -#line 5344 "reflect.h2" +#line 5516 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in postfix) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -9360,7 +9536,7 @@ auto i{1}; { auto i{0}; -#line 5351 "reflect.h2" +#line 5523 "reflect.h2" for ( auto const& term : terms ) { do { if (CPP2_UFCS(get_op)(term) == ".") { continue; @@ -9375,7 +9551,7 @@ auto i{0}; } while (false); i += 1; } } -#line 5364 "reflect.h2" +#line 5536 "reflect.h2" if (cpp2::move(is_func)) { handle_function_call(postfix, true); } @@ -9396,7 +9572,7 @@ auto i{0}; } } -#line 5384 "reflect.h2" +#line 5556 "reflect.h2" auto autodiff_expression_handler::traverse(cpp2::impl::in primary) -> void { if (CPP2_UFCS(is_identifier)(primary)) { @@ -9433,16 +9609,16 @@ auto i{0}; }}}} } -#line 5434 "reflect.h2" +#line 5606 "reflect.h2" autodiff_stmt_handler::autodiff_stmt_handler(cpp2::impl::in ctx_, cpp2::impl::in mf_) : simple_traverser{ } , autodiff_handler_base{ ctx_ } , mf{ mf_ }{ -#line 5437 "reflect.h2" +#line 5609 "reflect.h2" } -#line 5439 "reflect.h2" +#line 5611 "reflect.h2" [[nodiscard]] auto autodiff_stmt_handler::handle_stmt_parameters(cpp2::impl::in> params) & -> autodiff_diff_code{ autodiff_diff_code r {ctx}; if (CPP2_UFCS(empty)(params)) { @@ -9472,7 +9648,7 @@ auto i{0}; } } -#line 5469 "reflect.h2" +#line 5641 "reflect.h2" CPP2_UFCS(add_forward)(r, "" + cpp2::to_string(fwd_pass_style) + " " + cpp2::to_string(name) + " : " + cpp2::to_string(type) + cpp2::to_string(init) + ", "); CPP2_UFCS(add_reverse_primal)(r, "" + cpp2::to_string(fwd_pass_style) + " " + cpp2::to_string(name) + " : " + cpp2::to_string(type) + cpp2::to_string(cpp2::move(init)) + ", "); if (ada.active) { @@ -9485,17 +9661,17 @@ auto i{0}; return r; } -#line 5481 "reflect.h2" +#line 5653 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in decl) -> void{ base::traverse(decl); } -#line 5486 "reflect.h2" +#line 5658 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in f) -> void{ CPP2_UFCS(error)(f, "AD: Do not know how to handle function_declaration: " + cpp2::to_string(CPP2_UFCS(to_string)(f)) + ""); } -#line 5491 "reflect.h2" +#line 5663 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in o) -> void{ std::string lhs {CPP2_UFCS(name)(o)}; auto type {o.type()}; @@ -9557,24 +9733,24 @@ auto i{0}; CPP2_UFCS(add_variable_declaration)((*cpp2::impl::assert_not_null(ctx)), cpp2::move(lhs), cpp2::move(type), cpp2::move(active)); } -#line 5553 "reflect.h2" +#line 5725 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in t) -> void{ CPP2_UFCS(error)(t, "AD: Do not know how to handle type_declaration: " + cpp2::to_string(CPP2_UFCS(to_string)(t)) + ""); } -#line 5558 "reflect.h2" +#line 5730 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in t) -> void{ CPP2_UFCS(error)(t, "AD: Do not know how to handle parameter_declaration: " + cpp2::to_string(CPP2_UFCS(to_string)(t)) + ""); } -#line 5563 "reflect.h2" +#line 5735 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in stmt) -> void{ // TODO: Remove this hack when statements like compound_statement can access their root statement. last_params = CPP2_UFCS(get_parameters)(stmt); base::traverse(stmt); } -#line 5570 "reflect.h2" +#line 5742 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in stmt) -> void{ autodiff_stmt_handler ad {ctx, mf}; autodiff_stmt_handler ad_push_pop {ctx, mf}; @@ -9609,7 +9785,7 @@ auto i{0}; CPP2_UFCS(add_reverse_backprop)(diff, "{\n"); } -#line 5605 "reflect.h2" +#line 5777 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in stmt) -> void{ if (CPP2_UFCS(has_expression)(stmt)) { // Return with expression. @@ -9626,7 +9802,7 @@ auto i{0}; } } -#line 5621 "reflect.h2" +#line 5793 "reflect.h2" [[nodiscard]] auto autodiff_stmt_handler::reverse_next(cpp2::impl::in expr) const& -> std::string{ if (CPP2_UFCS(contains)(expr, "+=")) { return string_util::replace_all(expr, "+=", "-="); @@ -9641,7 +9817,7 @@ auto i{0}; } -#line 5636 "reflect.h2" +#line 5808 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in stmt) -> void{ auto diff_params {handle_stmt_parameters(last_params)}; @@ -9739,7 +9915,7 @@ auto i{0}; }} } -#line 5734 "reflect.h2" +#line 5906 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in stmt) -> void{ // TODO: Currently assuming that nothing bad happens in the condition diff += "if " + cpp2::to_string(CPP2_UFCS(to_string)(CPP2_UFCS(get_expression)(stmt))) + ""; @@ -9751,12 +9927,12 @@ auto i{0}; } } -#line 5745 "reflect.h2" +#line 5917 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in expr) -> void{ base::traverse(expr); } -#line 5749 "reflect.h2" +#line 5921 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ autodiff_activity_check ada {ctx}; CPP2_UFCS(pre_traverse)(ada, CPP2_UFCS(get_lhs_postfix_expression)(binexpr)); @@ -9808,73 +9984,73 @@ auto i{0}; } } -#line 5800 "reflect.h2" +#line 5972 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Logical or expressions are not yet handled as standalone statements."); } -#line 5804 "reflect.h2" +#line 5976 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Logical and expressions are not yet handled as standalone statements."); } -#line 5808 "reflect.h2" +#line 5980 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit or expressions are not yet handled as standalone statements."); } -#line 5812 "reflect.h2" +#line 5984 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit xor expressions are not yet handled as standalone statements."); } -#line 5816 "reflect.h2" +#line 5988 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Bit and expressions are not yet handled as standalone statements."); } -#line 5820 "reflect.h2" +#line 5992 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Equality or expressions are not yet handled as standalone statements."); } -#line 5824 "reflect.h2" +#line 5996 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Relational expressions are not yet handled as standalone statements."); } -#line 5828 "reflect.h2" +#line 6000 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Compare or expressions are not yet handled as standalone statements."); } -#line 5832 "reflect.h2" +#line 6004 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Shift or expressions are not yet handled as standalone statements."); } -#line 5836 "reflect.h2" +#line 6008 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Additive expressions are not yet handled as standalone statements."); } -#line 5840 "reflect.h2" +#line 6012 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in binexpr) -> void{ CPP2_UFCS(error)(binexpr, "AD: Multiplicative expressions are not yet handled as standalone statements."); } -#line 5844 "reflect.h2" +#line 6016 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in isas) -> void{ CPP2_UFCS(error)(isas, "AD: Is as expressions are not yet handled as standalone statements."); } -#line 5848 "reflect.h2" +#line 6020 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in prefix) -> void { CPP2_UFCS(error)(prefix, "AD: Prefix expressions are not yet handled as standalone statements."); } -#line 5853 "reflect.h2" +#line 6025 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in postfix) -> void { auto terms {CPP2_UFCS(get_terms)(postfix)}; @@ -9883,7 +10059,7 @@ auto i{0}; { auto i{0}; -#line 5860 "reflect.h2" +#line 6032 "reflect.h2" for ( auto const& term : terms ) { do { if (CPP2_UFCS(get_op)(term) == ".") { continue; @@ -9898,7 +10074,7 @@ auto i{0}; } // Check for function call, everything else is not handled. -#line 5873 "reflect.h2" +#line 6045 "reflect.h2" if (!((cpp2::move(is_func)))) { CPP2_UFCS(error)(postfix, "AD: Postfix expressions are only handled for function calls, or member function calls. Do not know how to handle: " + cpp2::to_string(CPP2_UFCS(to_string)(postfix)) + ""); return ; @@ -9911,27 +10087,27 @@ auto i{0}; append(cpp2::move(ad)); } -#line 5885 "reflect.h2" +#line 6057 "reflect.h2" auto autodiff_stmt_handler::traverse(cpp2::impl::in primary) -> void { CPP2_UFCS(error)(primary, "AD: Primary expressions are not yet handled as standalone statements."); } -#line 5902 "reflect.h2" +#line 6074 "reflect.h2" autodiff_declaration_handler::autodiff_declaration_handler(cpp2::impl::in ctx_, cpp2::impl::in decl_) : simple_traverser{ } , autodiff_handler_base{ ctx_ } , decl{ decl_ }{ -#line 5905 "reflect.h2" +#line 6077 "reflect.h2" } -#line 5907 "reflect.h2" +#line 6079 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in decl_) -> void{ base::traverse(decl_); } -#line 5912 "reflect.h2" +#line 6084 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in f) -> void{ CPP2_UFCS(enter_function)((*cpp2::impl::assert_not_null(ctx))); @@ -10061,10 +10237,10 @@ auto i{0}; return ; } -#line 6042 "reflect.h2" +#line 6214 "reflect.h2" autodiff_stmt_handler ad_impl {&*cpp2::impl::assert_not_null(ctx), f}; -#line 6045 "reflect.h2" +#line 6217 "reflect.h2" for ( auto const& stmt : CPP2_UFCS(get_statements)(CPP2_UFCS(get_compound_body)(f)) ) { ad_impl.pre_traverse(stmt); @@ -10089,7 +10265,7 @@ auto i{0}; CPP2_UFCS(add_as_differentiated)((*cpp2::impl::assert_not_null(ctx)), f); } -#line 6070 "reflect.h2" +#line 6242 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in o) -> void{ std::string ad_name {"" + cpp2::to_string(CPP2_UFCS(name)(o)) + cpp2::to_string((*cpp2::impl::assert_not_null(ctx)).fwd_suffix) + ""}; std::string fwd_ad_type {CPP2_UFCS(get_fwd_ad_type)((*cpp2::impl::assert_not_null(ctx)), CPP2_UFCS(type)(o))}; @@ -10117,7 +10293,7 @@ auto i{0}; CPP2_UFCS(add_variable_declaration)((*cpp2::impl::assert_not_null(ctx)), "" + cpp2::to_string(CPP2_UFCS(name)(o)) + "", "" + cpp2::to_string(CPP2_UFCS(type)(o)) + "", true, true);// TODO_a: Add acitivty check } -#line 6098 "reflect.h2" +#line 6270 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in t) -> void{ CPP2_UFCS(push_stack)((*cpp2::impl::assert_not_null(ctx)), t); autodiff_declaration_handler ad {ctx, t}; @@ -10141,17 +10317,17 @@ auto i{0}; } } -#line 6122 "reflect.h2" +#line 6294 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in t) -> void{ CPP2_UFCS(error)(t, "AD: Do not know how to handle parameter_declaration: " + cpp2::to_string(CPP2_UFCS(to_string)(t)) + ""); } -#line 6127 "reflect.h2" +#line 6299 "reflect.h2" auto autodiff_declaration_handler::traverse(cpp2::impl::in stmt) -> void{ CPP2_UFCS(error)(stmt, "AD: Do not know how to handle statement in declaration context: " + cpp2::to_string(CPP2_UFCS(to_string)(stmt)) + ""); } -#line 6133 "reflect.h2" +#line 6305 "reflect.h2" auto autodiff(meta::type_declaration& t) -> void { @@ -10334,7 +10510,7 @@ return expression_flags::none; [[nodiscard]] auto expression_flags::from_code(cpp2::impl::in s) -> expression_flags{ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::move(str), "expression_flags::", "")); } -#line 6225 "reflect.h2" +#line 6397 "reflect.h2" //----------------------------------------------------------------------- // // regex - creates regular expressions from members @@ -10350,11 +10526,11 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // ``` // -#line 6241 "reflect.h2" +#line 6413 "reflect.h2" // Possible modifiers for a regular expression. // -#line 6245 "reflect.h2" +#line 6417 "reflect.h2" // mod: i // mod: m // mod: s @@ -10362,116 +10538,116 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // mod: x // mod: xx -#line 6254 "reflect.h2" +#line 6426 "reflect.h2" // Tokens for regular expressions. // // Basic class for a regex token. // -#line 6263 "reflect.h2" +#line 6435 "reflect.h2" regex_token::regex_token(cpp2::impl::in str) : string_rep{ str }{ -#line 6265 "reflect.h2" +#line 6437 "reflect.h2" } -#line 6267 "reflect.h2" +#line 6439 "reflect.h2" regex_token::regex_token() : string_rep{ "" }{ -#line 6269 "reflect.h2" +#line 6441 "reflect.h2" } //parse: (inout ctx: parse_context) -> token_ptr; // Generate the matching code. // Create a reverse token for look behind expressions. -#line 6275 "reflect.h2" +#line 6447 "reflect.h2" auto regex_token::add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void{}// Adds all group indices to the set. -#line 6276 "reflect.h2" +#line 6448 "reflect.h2" [[nodiscard]] auto regex_token::to_string() const& -> std::string{return string_rep; }// Create a string representation. -#line 6277 "reflect.h2" +#line 6449 "reflect.h2" auto regex_token::set_string(cpp2::impl::in s) & -> void{string_rep = s; } regex_token::~regex_token() noexcept{}// Set the string representation. -#line 6292 "reflect.h2" +#line 6464 "reflect.h2" regex_token_check::regex_token_check(cpp2::impl::in str, cpp2::impl::in check_) : regex_token{ str } , check{ check_ }{ -#line 6295 "reflect.h2" +#line 6467 "reflect.h2" } -#line 6297 "reflect.h2" +#line 6469 "reflect.h2" auto regex_token_check::generate_code(generation_context& ctx) const -> void{ ctx.add_check(check + "(" + ctx.match_parameters() + ")"); } -#line 6301 "reflect.h2" +#line 6473 "reflect.h2" [[nodiscard]] auto regex_token_check::reverse() const -> token_ptr { return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, CPP2_UFCS(to_string)((*this)), (*this).check); } regex_token_check::~regex_token_check() noexcept{} -#line 6313 "reflect.h2" +#line 6485 "reflect.h2" regex_token_code::regex_token_code(cpp2::impl::in str, cpp2::impl::in code_) : regex_token{ str } , code{ code_ }{ -#line 6316 "reflect.h2" +#line 6488 "reflect.h2" } -#line 6318 "reflect.h2" +#line 6490 "reflect.h2" auto regex_token_code::generate_code(generation_context& ctx) const -> void{ ctx.add(code); } -#line 6322 "reflect.h2" +#line 6494 "reflect.h2" [[nodiscard]] auto regex_token_code::reverse() const -> token_ptr { return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, CPP2_UFCS(to_string)((*this)), (*this).code); } regex_token_code::~regex_token_code() noexcept{} -#line 6332 "reflect.h2" +#line 6504 "reflect.h2" regex_token_empty::regex_token_empty(cpp2::impl::in str) : regex_token{ str }{ -#line 6334 "reflect.h2" +#line 6506 "reflect.h2" } -#line 6336 "reflect.h2" +#line 6508 "reflect.h2" auto regex_token_empty::generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void{ // Nothing. } -#line 6340 "reflect.h2" +#line 6512 "reflect.h2" [[nodiscard]] auto regex_token_empty::reverse() const -> token_ptr { return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, CPP2_UFCS(to_string)((*this))); } regex_token_empty::~regex_token_empty() noexcept{} -#line 6352 "reflect.h2" +#line 6524 "reflect.h2" regex_token_list::regex_token_list(cpp2::impl::in t) : regex_token{ gen_string(t) } , tokens{ t }{ -#line 6355 "reflect.h2" +#line 6527 "reflect.h2" } -#line 6357 "reflect.h2" +#line 6529 "reflect.h2" auto regex_token_list::generate_code(generation_context& ctx) const -> void{ for ( auto const& token : tokens ) { (*cpp2::impl::assert_not_null(token)).generate_code(ctx); } } -#line 6363 "reflect.h2" +#line 6535 "reflect.h2" auto regex_token_list::add_groups(std::set& groups) const -> void{ for ( auto const& token : tokens ) { (*cpp2::impl::assert_not_null(token)).add_groups(groups); } } -#line 6369 "reflect.h2" +#line 6541 "reflect.h2" [[nodiscard]] auto regex_token_list::gen_string(cpp2::impl::in vec) -> std::string{ std::string r {""}; for ( auto const& token : vec ) { @@ -10480,7 +10656,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov return r; } -#line 6377 "reflect.h2" +#line 6549 "reflect.h2" [[nodiscard]] auto regex_token_list::reverse() const -> token_ptr{ int s {cpp2::unchecked_narrow(tokens.size())}; @@ -10496,7 +10672,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov regex_token_list::~regex_token_list() noexcept{} -#line 6405 "reflect.h2" +#line 6577 "reflect.h2" auto parse_context_group_state::next_alternative() & -> void{ token_vec new_list {}; std::swap(new_list, cur_match_list); @@ -10504,14 +10680,14 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov static_cast(alternate_match_lists.insert(alternate_match_lists.end(), CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, cpp2::move(new_list)))); } -#line 6413 "reflect.h2" +#line 6585 "reflect.h2" auto parse_context_group_state::swap(parse_context_group_state& t) & -> void{// NOLINT(performance-noexcept-swap) std::swap(cur_match_list, t.cur_match_list); std::swap(alternate_match_lists, t.alternate_match_lists); std::swap(modifiers, t.modifiers); } -#line 6420 "reflect.h2" +#line 6592 "reflect.h2" [[nodiscard]] auto parse_context_group_state::get_as_token() & -> token_ptr{ if (alternate_match_lists.empty()) { post_process_list(cur_match_list); @@ -10523,15 +10699,15 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov } } -#line 6432 "reflect.h2" +#line 6604 "reflect.h2" auto parse_context_group_state::add(cpp2::impl::in token) & -> void{ cur_match_list.push_back(token); } -#line 6437 "reflect.h2" +#line 6609 "reflect.h2" [[nodiscard]] auto parse_context_group_state::empty() const& -> bool { return cur_match_list.empty(); } -#line 6441 "reflect.h2" +#line 6613 "reflect.h2" auto parse_context_group_state::post_process_list(token_vec& list) -> void{ // Merge all characters auto merge_pos {list.begin()}; @@ -10552,7 +10728,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov , modifiers{ modifiers_ }{} parse_context_group_state::parse_context_group_state(){} -#line 6467 "reflect.h2" +#line 6639 "reflect.h2" [[nodiscard]] auto parse_context_branch_reset_state::next() & -> int{ auto g {cur_group}; cur_group += 1; @@ -10561,20 +10737,20 @@ parse_context_group_state::parse_context_group_state(){} return g; } -#line 6476 "reflect.h2" +#line 6648 "reflect.h2" auto parse_context_branch_reset_state::set_next(cpp2::impl::in g) & -> void{ cur_group = g; max_group = max(max_group, g); } -#line 6482 "reflect.h2" +#line 6654 "reflect.h2" auto parse_context_branch_reset_state::next_alternative() & -> void{ if (is_active) { cur_group = from; } } -#line 6489 "reflect.h2" +#line 6661 "reflect.h2" auto parse_context_branch_reset_state::set_active_reset(cpp2::impl::in restart) & -> void{ is_active = true; cur_group = restart; @@ -10589,16 +10765,16 @@ parse_context_group_state::parse_context_group_state(){} , from{ from_ }{} parse_context_branch_reset_state::parse_context_branch_reset_state(){} -#line 6519 "reflect.h2" +#line 6691 "reflect.h2" parse_context::parse_context(cpp2::impl::in r, auto const& e) : regex{ r } , root{ CPP2_UFCS_TEMPLATE_NONLOCAL(cpp2_new)(cpp2::shared, "") } , error_out{ e }{ -#line 6523 "reflect.h2" +#line 6695 "reflect.h2" } -#line 6529 "reflect.h2" +#line 6701 "reflect.h2" [[nodiscard]] auto parse_context::start_group() & -> parse_context_group_state { parse_context_group_state old_state {}; @@ -10608,7 +10784,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 6539 "reflect.h2" +#line 6711 "reflect.h2" [[nodiscard]] auto parse_context::end_group(cpp2::impl::in old_state) & -> token_ptr { auto inner {cur_group_state.get_as_token()}; @@ -10616,17 +10792,17 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return inner; } -#line 6546 "reflect.h2" +#line 6718 "reflect.h2" [[nodiscard]] auto parse_context::get_modifiers() const& -> expression_flags{ return cur_group_state.modifiers; } -#line 6550 "reflect.h2" +#line 6722 "reflect.h2" auto parse_context::set_modifiers(cpp2::impl::in mod) & -> void{ cur_group_state.modifiers = mod; } -#line 6557 "reflect.h2" +#line 6729 "reflect.h2" [[nodiscard]] auto parse_context::branch_reset_new_state() & -> parse_context_branch_reset_state { parse_context_branch_reset_state old_state {}; @@ -10636,7 +10812,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 6566 "reflect.h2" +#line 6738 "reflect.h2" auto parse_context::branch_reset_restore_state(cpp2::impl::in old_state) & -> void { auto max_group {cur_branch_reset_state.max_group}; @@ -10644,24 +10820,24 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} cur_branch_reset_state.set_next(cpp2::move(max_group)); } -#line 6573 "reflect.h2" +#line 6745 "reflect.h2" auto parse_context::next_alternative() & -> void { cur_group_state.next_alternative(); cur_branch_reset_state.next_alternative(); } -#line 6581 "reflect.h2" +#line 6753 "reflect.h2" auto parse_context::add_token(cpp2::impl::in token) & -> void{ cur_group_state.add(token); } -#line 6585 "reflect.h2" +#line 6757 "reflect.h2" [[nodiscard]] auto parse_context::has_token() const& -> bool{ return !(cur_group_state.empty()); } -#line 6589 "reflect.h2" +#line 6761 "reflect.h2" [[nodiscard]] auto parse_context::pop_token() & -> token_ptr { token_ptr r {nullptr}; @@ -10673,22 +10849,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 6600 "reflect.h2" +#line 6772 "reflect.h2" [[nodiscard]] auto parse_context::get_as_token() & -> token_ptr{ return root; } -#line 6606 "reflect.h2" +#line 6778 "reflect.h2" [[nodiscard]] auto parse_context::get_cur_group() const& -> int{ return cur_branch_reset_state.cur_group; } -#line 6610 "reflect.h2" +#line 6782 "reflect.h2" [[nodiscard]] auto parse_context::next_group() & -> int{ return cur_branch_reset_state.next(); } -#line 6614 "reflect.h2" +#line 6786 "reflect.h2" auto parse_context::set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void { if (!(named_groups.contains(name))) {// Redefinition of group name is not an error. The left most one is retained. @@ -10696,7 +10872,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6621 "reflect.h2" +#line 6793 "reflect.h2" [[nodiscard]] auto parse_context::get_named_group(cpp2::impl::in name) const& -> int { auto iter {named_groups.find(name)}; @@ -10708,10 +10884,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6634 "reflect.h2" +#line 6806 "reflect.h2" [[nodiscard]] auto parse_context::current() const& -> char{return CPP2_ASSERT_IN_BOUNDS(regex, pos); } -#line 6637 "reflect.h2" +#line 6809 "reflect.h2" [[nodiscard]] auto parse_context::get_next_position(cpp2::impl::in in_class, cpp2::impl::in no_skip) const& -> size_t { auto perl_syntax {false}; @@ -10751,7 +10927,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cur; } -#line 6677 "reflect.h2" +#line 6849 "reflect.h2" [[nodiscard]] auto parse_context::next_impl(cpp2::impl::in in_class, cpp2::impl::in no_skip) & -> bool { pos = get_next_position(in_class, no_skip); @@ -10763,14 +10939,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6688 "reflect.h2" +#line 6860 "reflect.h2" [[nodiscard]] auto parse_context::next() & -> decltype(auto) { return next_impl(false, false); } -#line 6689 "reflect.h2" +#line 6861 "reflect.h2" [[nodiscard]] auto parse_context::next_in_class() & -> decltype(auto) { return next_impl(true, false); } -#line 6690 "reflect.h2" +#line 6862 "reflect.h2" [[nodiscard]] auto parse_context::next_no_skip() & -> decltype(auto) { return next_impl(false, true); } -#line 6692 "reflect.h2" +#line 6864 "reflect.h2" [[nodiscard]] auto parse_context::next_n(cpp2::impl::in n) & -> bool{ auto r {true}; auto cur {0}; @@ -10780,10 +10956,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 6701 "reflect.h2" +#line 6873 "reflect.h2" [[nodiscard]] auto parse_context::has_next() const& -> bool{return cpp2::impl::cmp_less(pos,regex.size()); } -#line 6703 "reflect.h2" +#line 6875 "reflect.h2" [[nodiscard]] auto parse_context::grab_until_impl(cpp2::impl::in e, cpp2::impl::out r, cpp2::impl::in any) & -> bool { auto end {pos}; // NOLINT(clang-analyzer-deadcode.DeadStores) @@ -10805,14 +10981,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6724 "reflect.h2" +#line 6896 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(e, cpp2::impl::out(&r), false); } -#line 6725 "reflect.h2" +#line 6897 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(std::string(1, e), cpp2::impl::out(&r), false); } -#line 6726 "reflect.h2" +#line 6898 "reflect.h2" [[nodiscard]] auto parse_context::grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(e, cpp2::impl::out(&r), true); } -#line 6728 "reflect.h2" +#line 6900 "reflect.h2" [[nodiscard]] auto parse_context::grab_n(cpp2::impl::in n, cpp2::impl::out r) & -> bool { if (cpp2::impl::cmp_less_eq(pos + cpp2::impl::as_(n),regex.size())) { @@ -10826,7 +11002,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6741 "reflect.h2" +#line 6913 "reflect.h2" [[nodiscard]] auto parse_context::grab_number() & -> std::string { auto start {pos}; @@ -10848,7 +11024,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cpp2::move(r.value()); } -#line 6762 "reflect.h2" +#line 6934 "reflect.h2" [[nodiscard]] auto parse_context::peek_impl(cpp2::impl::in in_class) const& -> char{ auto next_pos {get_next_position(in_class, false)}; if (cpp2::impl::cmp_less(next_pos,regex.size())) { @@ -10859,12 +11035,12 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6772 "reflect.h2" +#line 6944 "reflect.h2" [[nodiscard]] auto parse_context::peek() const& -> decltype(auto) { return peek_impl(false); } -#line 6773 "reflect.h2" +#line 6945 "reflect.h2" [[nodiscard]] auto parse_context::peek_in_class() const& -> decltype(auto) { return peek_impl(true); } -#line 6778 "reflect.h2" +#line 6950 "reflect.h2" [[nodiscard]] auto parse_context::parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool { auto is_negative {false}; @@ -10919,7 +11095,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 6832 "reflect.h2" +#line 7004 "reflect.h2" [[nodiscard]] auto parse_context::parse_until(cpp2::impl::in term) & -> bool{ token_ptr cur_token {}; @@ -10959,7 +11135,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 6871 "reflect.h2" +#line 7043 "reflect.h2" [[nodiscard]] auto parse_context::parse(cpp2::impl::in modifiers) & -> bool { @@ -10975,21 +11151,21 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 6888 "reflect.h2" +#line 7060 "reflect.h2" [[nodiscard]] auto parse_context::get_pos() const& -> decltype(auto) { return pos; } -#line 6889 "reflect.h2" +#line 7061 "reflect.h2" [[nodiscard]] auto parse_context::get_range(cpp2::impl::in start, cpp2::impl::in end) const& -> decltype(auto) { return std::string(regex.substr(start, end - start + 1)); } -#line 6890 "reflect.h2" +#line 7062 "reflect.h2" [[nodiscard]] auto parse_context::valid() const& -> bool{return has_next() && !(has_error); } -#line 6892 "reflect.h2" +#line 7064 "reflect.h2" [[nodiscard]] auto parse_context::error(cpp2::impl::in err) & -> token_ptr{ has_error = true; error_out("Error during parsing of regex '" + cpp2::to_string(regex) + "' at position '" + cpp2::to_string(pos) + "': " + cpp2::to_string(err) + ""); return nullptr; } -#line 6907 "reflect.h2" +#line 7079 "reflect.h2" auto generation_function_context::add_tabs(cpp2::impl::in c) & -> void{ int i {0}; for( ; cpp2::impl::cmp_less(i,c); i += 1 ) { @@ -10997,7 +11173,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 6914 "reflect.h2" +#line 7086 "reflect.h2" auto generation_function_context::remove_tabs(cpp2::impl::in c) & -> void{ tabs = tabs.substr(0, (cpp2::impl::as_(c)) * 2); } @@ -11007,22 +11183,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} , tabs{ tabs_ }{} generation_function_context::generation_function_context(){} -#line 6932 "reflect.h2" +#line 7104 "reflect.h2" [[nodiscard]] auto generation_context::match_parameters() const& -> std::string{return "r.pos, ctx"; } -#line 6937 "reflect.h2" +#line 7109 "reflect.h2" auto generation_context::add(cpp2::impl::in s) & -> void{ auto cur {get_current()}; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(s) + "\n"; } -#line 6943 "reflect.h2" +#line 7115 "reflect.h2" auto generation_context::add_check(cpp2::impl::in check) & -> void{ auto cur {get_current()}; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + "if !cpp2::regex::" + cpp2::to_string(check) + " { r.matched = false; break; }\n"; } -#line 6949 "reflect.h2" +#line 7121 "reflect.h2" auto generation_context::add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void { end_func_statefull(check); @@ -11031,7 +11207,7 @@ generation_function_context::generation_function_context(){} start_func_named(cpp2::move(name)); } -#line 6957 "reflect.h2" +#line 7129 "reflect.h2" auto generation_context::start_func_named(cpp2::impl::in name) & -> void { auto cur {new_context()}; @@ -11043,7 +11219,7 @@ generation_function_context::generation_function_context(){} (*cpp2::impl::assert_not_null(cpp2::move(cur))).add_tabs(3); } -#line 6968 "reflect.h2" +#line 7140 "reflect.h2" [[nodiscard]] auto generation_context::start_func() & -> std::string { auto name {gen_func_name()}; @@ -11051,7 +11227,7 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 6975 "reflect.h2" +#line 7147 "reflect.h2" auto generation_context::end_func_statefull(cpp2::impl::in s) & -> void { auto cur {get_current()}; @@ -11072,7 +11248,7 @@ generation_function_context::generation_function_context(){} finish_context(); } -#line 6996 "reflect.h2" +#line 7168 "reflect.h2" [[nodiscard]] auto generation_context::generate_func(cpp2::impl::in token) & -> std::string { auto name {start_func()}; @@ -11082,7 +11258,7 @@ generation_function_context::generation_function_context(){} return name; } -#line 7006 "reflect.h2" +#line 7178 "reflect.h2" [[nodiscard]] auto generation_context::generate_reset(cpp2::impl::in> groups) & -> std::string { if (groups.empty()) { @@ -11105,33 +11281,33 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 7030 "reflect.h2" +#line 7202 "reflect.h2" [[nodiscard]] auto generation_context::gen_func_name() & -> std::string{ auto cur_id {matcher_func}; matcher_func += 1; return "func_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 7036 "reflect.h2" +#line 7208 "reflect.h2" [[nodiscard]] auto generation_context::next_func_name() & -> std::string{ return gen_func_name() + "()"; } -#line 7040 "reflect.h2" +#line 7212 "reflect.h2" [[nodiscard]] auto generation_context::gen_reset_func_name() & -> std::string{ auto cur_id {reset_func}; reset_func += 1; return "reset_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 7046 "reflect.h2" +#line 7218 "reflect.h2" [[nodiscard]] auto generation_context::gen_temp() & -> std::string{ auto cur_id {temp_name}; temp_name += 1; return "tmp_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 7054 "reflect.h2" +#line 7226 "reflect.h2" [[nodiscard]] auto generation_context::new_context() & -> generation_function_context*{ gen_stack.push_back(generation_function_context()); auto cur {get_current()}; @@ -11140,7 +11316,7 @@ generation_function_context::generation_function_context(){} return cur; } -#line 7062 "reflect.h2" +#line 7234 "reflect.h2" auto generation_context::finish_context() & -> void{ auto cur {get_current()}; auto base {get_base()}; @@ -11149,22 +11325,22 @@ generation_function_context::generation_function_context(){} gen_stack.pop_back(); } -#line 7072 "reflect.h2" +#line 7244 "reflect.h2" [[nodiscard]] auto generation_context::get_current() & -> generation_function_context*{ return &gen_stack.back(); } -#line 7076 "reflect.h2" +#line 7248 "reflect.h2" [[nodiscard]] auto generation_context::get_base() & -> generation_function_context*{ return &CPP2_ASSERT_IN_BOUNDS_LITERAL(gen_stack, 0); } -#line 7080 "reflect.h2" +#line 7252 "reflect.h2" [[nodiscard]] auto generation_context::get_entry_func() const& -> std::string{ return entry_func; } -#line 7084 "reflect.h2" +#line 7256 "reflect.h2" [[nodiscard]] auto generation_context::create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string { std::string res {"get_named_group_index: (name) -> int = {\n"}; @@ -11188,18 +11364,18 @@ generation_function_context::generation_function_context(){} return res; } -#line 7109 "reflect.h2" +#line 7281 "reflect.h2" [[nodiscard]] auto generation_context::run(cpp2::impl::in token) & -> std::string{ entry_func = generate_func(token); return (*cpp2::impl::assert_not_null(get_base())).code; } -#line 7124 "reflect.h2" +#line 7296 "reflect.h2" alternative_token::alternative_token() : regex_token_empty{ "" }{} -#line 7126 "reflect.h2" +#line 7298 "reflect.h2" [[nodiscard]] auto alternative_token::parse(parse_context& ctx) -> token_ptr{ if (ctx.current() != '|') {return nullptr; } @@ -11210,15 +11386,15 @@ generation_function_context::generation_function_context(){} alternative_token::~alternative_token() noexcept{} -#line 7141 "reflect.h2" +#line 7313 "reflect.h2" alternative_token_gen::alternative_token_gen(cpp2::impl::in a) : regex_token{ gen_string(a) } , alternatives{ a }{ -#line 7144 "reflect.h2" +#line 7316 "reflect.h2" } -#line 7146 "reflect.h2" +#line 7318 "reflect.h2" auto alternative_token_gen::generate_code(generation_context& ctx) const -> void { std::string functions {""}; @@ -11236,7 +11412,7 @@ generation_function_context::generation_function_context(){} ctx.add_statefull(next_name, "cpp2::regex::alternative_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ", other, " + cpp2::to_string(next_name) + " " + cpp2::to_string(cpp2::move(functions)) + ")"); } -#line 7163 "reflect.h2" +#line 7335 "reflect.h2" auto alternative_token_gen::add_groups(std::set& groups) const -> void { for ( auto const& cur : alternatives ) { @@ -11244,7 +11420,7 @@ generation_function_context::generation_function_context(){} } } -#line 7170 "reflect.h2" +#line 7342 "reflect.h2" [[nodiscard]] auto alternative_token_gen::gen_string(cpp2::impl::in a) -> std::string { std::string r {""}; @@ -11258,7 +11434,7 @@ generation_function_context::generation_function_context(){} return r; } -#line 7183 "reflect.h2" +#line 7355 "reflect.h2" [[nodiscard]] auto alternative_token_gen::reverse() const -> token_ptr{ int s {cpp2::unchecked_narrow(alternatives.size())}; @@ -11274,14 +11450,14 @@ generation_function_context::generation_function_context(){} alternative_token_gen::~alternative_token_gen() noexcept{} -#line 7204 "reflect.h2" +#line 7376 "reflect.h2" any_token::any_token(cpp2::impl::in single_line) : regex_token_check{ ".", "any_token_matcher" }{ -#line 7206 "reflect.h2" +#line 7378 "reflect.h2" } -#line 7208 "reflect.h2" +#line 7380 "reflect.h2" [[nodiscard]] auto any_token::parse(parse_context& ctx) -> token_ptr{ if ('.' != ctx.current()) {return nullptr; } @@ -11290,11 +11466,11 @@ generation_function_context::generation_function_context(){} any_token::~any_token() noexcept{} -#line 7223 "reflect.h2" +#line 7395 "reflect.h2" atomic_group_token::atomic_group_token() : regex_token{ "" }{} -#line 7225 "reflect.h2" +#line 7397 "reflect.h2" [[nodiscard]] auto atomic_group_token::reverse() const -> token_ptr{ auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; (*cpp2::impl::assert_not_null(r)).inner_token = CPP2_UFCS(reverse)((*cpp2::impl::assert_not_null(inner_token))); @@ -11302,7 +11478,7 @@ generation_function_context::generation_function_context(){} return r; } -#line 7232 "reflect.h2" +#line 7404 "reflect.h2" auto atomic_group_token::generate_code(generation_context& ctx) const -> void { auto inner_name {ctx.generate_func(inner_token)}; @@ -11311,37 +11487,37 @@ generation_function_context::generation_function_context(){} ctx.add_statefull(next_name, "cpp2::regex::atomic_group_matcher(" + cpp2::to_string(ctx.match_parameters()) + ", " + cpp2::to_string(cpp2::move(inner_name)) + ", other, " + cpp2::to_string(next_name) + ")"); } -#line 7240 "reflect.h2" +#line 7412 "reflect.h2" auto atomic_group_token::add_groups(std::set& groups) const -> void{ (*cpp2::impl::assert_not_null(inner_token)).add_groups(groups); } atomic_group_token::~atomic_group_token() noexcept{} -#line 7254 "reflect.h2" +#line 7426 "reflect.h2" char_token::char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_) : regex_token{ std::string(1, t) } , token{ t } , ignore_case{ ignore_case_ }{ -#line 7258 "reflect.h2" +#line 7430 "reflect.h2" } -#line 7260 "reflect.h2" +#line 7432 "reflect.h2" char_token::char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_) : regex_token{ t } , token{ t } , ignore_case{ ignore_case_ }{ -#line 7264 "reflect.h2" +#line 7436 "reflect.h2" } -#line 7266 "reflect.h2" +#line 7438 "reflect.h2" [[nodiscard]] auto char_token::parse(parse_context& ctx) -> token_ptr{ return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, ctx.current(), ctx.get_modifiers().has(expression_flags::case_insensitive)); } -#line 7270 "reflect.h2" +#line 7442 "reflect.h2" auto char_token::generate_code(generation_context& ctx) const -> void { if (ignore_case) { @@ -11350,14 +11526,14 @@ generation_function_context::generation_function_context(){} { size_t i{0}; -#line 7276 "reflect.h2" +#line 7448 "reflect.h2" for( ; cpp2::impl::cmp_less(i,token.size()); i += 1 ) { CPP2_ASSERT_IN_BOUNDS(lower, i) = string_util::safe_tolower(CPP2_ASSERT_IN_BOUNDS(token, i)); CPP2_ASSERT_IN_BOUNDS(upper, i) = string_util::safe_toupper(CPP2_ASSERT_IN_BOUNDS(token, i)); } } -#line 7281 "reflect.h2" +#line 7453 "reflect.h2" if (upper != lower) { gen_case_insensitive(cpp2::move(lower), cpp2::move(upper), ctx); } @@ -11370,7 +11546,7 @@ size_t i{0}; } } -#line 7293 "reflect.h2" +#line 7465 "reflect.h2" auto char_token::gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -11392,7 +11568,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 7314 "reflect.h2" +#line 7486 "reflect.h2" auto char_token::gen_case_sensitive(generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -11411,7 +11587,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 7332 "reflect.h2" +#line 7504 "reflect.h2" [[nodiscard]] auto char_token::add_escapes(std::string str) const& -> std::string { str = string_util::replace_all(str, "\\", "\\\\"); @@ -11427,14 +11603,14 @@ size_t i{0}; return cpp2::move(str); } -#line 7347 "reflect.h2" +#line 7519 "reflect.h2" [[nodiscard]] auto char_token::reverse() const -> token_ptr{ std::string reverse_str {token}; std::reverse(reverse_str.begin(), reverse_str.end()); return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, cpp2::move(reverse_str), ignore_case); } -#line 7353 "reflect.h2" +#line 7525 "reflect.h2" auto char_token::append(char_token const& that) & -> void{ (*this).token += that.token; (*this).string_rep += that.string_rep; @@ -11442,19 +11618,19 @@ size_t i{0}; char_token::~char_token() noexcept{} -#line 7370 "reflect.h2" +#line 7542 "reflect.h2" class_token::class_token(cpp2::impl::in negate_, cpp2::impl::in case_insensitive_, cpp2::impl::in class_str_, cpp2::impl::in str) : regex_token{ str } , negate{ negate_ } , case_insensitive{ case_insensitive_ } , class_str{ class_str_ } -#line 7371 "reflect.h2" +#line 7543 "reflect.h2" { -#line 7376 "reflect.h2" +#line 7548 "reflect.h2" } -#line 7379 "reflect.h2" +#line 7551 "reflect.h2" [[nodiscard]] auto class_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '[') {return nullptr; } @@ -11580,7 +11756,7 @@ size_t i{0}; ); } -#line 7504 "reflect.h2" +#line 7676 "reflect.h2" [[nodiscard]] auto class_token::reverse() const -> token_ptr{ return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, negate, @@ -11590,13 +11766,13 @@ size_t i{0}; ); } -#line 7513 "reflect.h2" +#line 7685 "reflect.h2" auto class_token::generate_code(generation_context& ctx) const -> void { ctx.add_check("class_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ")"); } -#line 7518 "reflect.h2" +#line 7690 "reflect.h2" [[nodiscard]] auto class_token::create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string { auto sep {", "}; @@ -11607,12 +11783,12 @@ size_t i{0}; class_token::~class_token() noexcept{} -#line 7530 "reflect.h2" +#line 7702 "reflect.h2" [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } -#line 7535 "reflect.h2" +#line 7707 "reflect.h2" if (std::string::npos == std::string("afenrt^.[]()*{}?+|\\").find(ctx.peek())) { return nullptr; } @@ -11646,7 +11822,7 @@ size_t i{0}; } -#line 7571 "reflect.h2" +#line 7743 "reflect.h2" [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'K'))) {return nullptr; } @@ -11655,19 +11831,19 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\K", "ctx..set_group_start(0, r.pos);"); } -#line 7594 "reflect.h2" +#line 7766 "reflect.h2" group_ref_token::group_ref_token(cpp2::impl::in id_, cpp2::impl::in case_insensitive_, cpp2::impl::in reverse_, cpp2::impl::in str) : regex_token{ str } , id{ id_ } , case_insensitive{ case_insensitive_ } , reverse_eval{ reverse_ } -#line 7595 "reflect.h2" +#line 7767 "reflect.h2" { -#line 7600 "reflect.h2" +#line 7772 "reflect.h2" } -#line 7602 "reflect.h2" +#line 7774 "reflect.h2" [[nodiscard]] auto group_ref_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -11769,19 +11945,19 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, cpp2::move(group_id), ctx.get_modifiers().has(expression_flags::case_insensitive), false, cpp2::move(str)); } -#line 7703 "reflect.h2" +#line 7875 "reflect.h2" [[nodiscard]] auto group_ref_token::reverse() const -> token_ptr{ return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, id, case_insensitive, !(reverse_eval), to_string()); } -#line 7707 "reflect.h2" +#line 7879 "reflect.h2" auto group_ref_token::generate_code(generation_context& ctx) const -> void{ ctx.add_check("group_ref_token_matcher(" + cpp2::to_string(ctx.match_parameters()) + ")"); } group_ref_token::~group_ref_token() noexcept{} -#line 7731 "reflect.h2" +#line 7903 "reflect.h2" [[nodiscard]] auto group_token::parse_lookahead_lookbehind(parse_context& ctx, cpp2::impl::in syntax, cpp2::impl::in lookahead, cpp2::impl::in positive) -> token_ptr { static_cast(ctx.next());// Skip last token defining the syntax @@ -11800,7 +11976,7 @@ size_t i{0}; return r; } -#line 7749 "reflect.h2" +#line 7921 "reflect.h2" [[nodiscard]] auto group_token::parse_atomic_pattern(parse_context& ctx, cpp2::impl::in syntax) -> token_ptr { static_cast(ctx.next());// Skip last token defining the syntax @@ -11815,7 +11991,7 @@ size_t i{0}; return r; } -#line 7763 "reflect.h2" +#line 7935 "reflect.h2" [[nodiscard]] auto group_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '(') {return nullptr; } @@ -11975,7 +12151,7 @@ size_t i{0}; } } -#line 7922 "reflect.h2" +#line 8094 "reflect.h2" [[nodiscard]] auto group_token::reverse() const -> token_ptr{ auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; (*cpp2::impl::assert_not_null(r)).number = number; @@ -11984,7 +12160,7 @@ size_t i{0}; return r; } -#line 7930 "reflect.h2" +#line 8102 "reflect.h2" [[nodiscard]] auto group_token::gen_string(cpp2::impl::in name, cpp2::impl::in name_brackets, cpp2::impl::in has_modifier, cpp2::impl::in modifiers, cpp2::impl::in inner_) -> std::string { std::string start {"("}; @@ -12003,7 +12179,7 @@ size_t i{0}; return cpp2::move(start) + (*cpp2::impl::assert_not_null(inner_)).to_string() + ")"; } -#line 7948 "reflect.h2" +#line 8120 "reflect.h2" auto group_token::generate_code(generation_context& ctx) const -> void { if (-1 != number) { @@ -12035,7 +12211,7 @@ size_t i{0}; } } -#line 7979 "reflect.h2" +#line 8151 "reflect.h2" auto group_token::add_groups(std::set& groups) const -> void { (*cpp2::impl::assert_not_null(inner)).add_groups(groups); @@ -12046,7 +12222,7 @@ size_t i{0}; group_token::~group_token() noexcept{} -#line 7991 "reflect.h2" +#line 8163 "reflect.h2" [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'x'))) {return nullptr; } @@ -12085,7 +12261,7 @@ size_t i{0}; return r; } -#line 8032 "reflect.h2" +#line 8204 "reflect.h2" [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() == '$' || (ctx.current() == '\\' && ctx.peek() == '$')) { @@ -12103,7 +12279,7 @@ size_t i{0}; }} } -#line 8052 "reflect.h2" +#line 8224 "reflect.h2" [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '^' && !((ctx.current() == '\\' && ctx.peek() == 'A'))) {return nullptr; } @@ -12117,16 +12293,16 @@ size_t i{0}; } } -#line 8078 "reflect.h2" +#line 8250 "reflect.h2" lookahead_lookbehind_token::lookahead_lookbehind_token(cpp2::impl::in lookahead_, cpp2::impl::in positive_) : regex_token{ "" } , lookahead{ lookahead_ } , positive{ positive_ }{ -#line 8081 "reflect.h2" +#line 8253 "reflect.h2" } -#line 8083 "reflect.h2" +#line 8255 "reflect.h2" auto lookahead_lookbehind_token::generate_code(generation_context& ctx) const -> void{ auto inner_name {ctx.generate_func(inner)}; @@ -12138,7 +12314,7 @@ size_t i{0}; } } -#line 8094 "reflect.h2" +#line 8266 "reflect.h2" [[nodiscard]] auto lookahead_lookbehind_token::reverse() const -> token_ptr{ auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, lookahead, positive)}; (*cpp2::impl::assert_not_null(r)).inner = inner;// We do not reverse here. Nested lookahead and lookbehind stay as they are. @@ -12146,14 +12322,14 @@ size_t i{0}; return r; } -#line 8101 "reflect.h2" +#line 8273 "reflect.h2" auto lookahead_lookbehind_token::add_groups(std::set& groups) const -> void{ (*cpp2::impl::assert_not_null(inner)).add_groups(groups); } lookahead_lookbehind_token::~lookahead_lookbehind_token() noexcept{} -#line 8109 "reflect.h2" +#line 8281 "reflect.h2" [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -12179,7 +12355,7 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\" + cpp2::to_string(ctx.current()) + "", "" + cpp2::to_string(cpp2::move(name)) + "::match"); } -#line 8137 "reflect.h2" +#line 8309 "reflect.h2" [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'o'))) {return nullptr; } @@ -12205,11 +12381,11 @@ size_t i{0}; return r; } -#line 8174 "reflect.h2" +#line 8346 "reflect.h2" range_token::range_token() : regex_token{ "" }{} -#line 8176 "reflect.h2" +#line 8348 "reflect.h2" [[nodiscard]] auto range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -12283,7 +12459,7 @@ size_t i{0}; return nullptr; } -#line 8249 "reflect.h2" +#line 8421 "reflect.h2" auto range_token::parse_modifier(parse_context& ctx) & -> void { if (ctx.peek() == '?') { @@ -12296,7 +12472,7 @@ size_t i{0}; }} } -#line 8261 "reflect.h2" +#line 8433 "reflect.h2" [[nodiscard]] auto range_token::gen_mod_string() const& -> std::string { if (kind == range_flags::not_greedy) { @@ -12310,7 +12486,7 @@ size_t i{0}; }} } -#line 8274 "reflect.h2" +#line 8446 "reflect.h2" [[nodiscard]] auto range_token::gen_range_string() const& -> std::string { std::string r {""}; @@ -12330,7 +12506,7 @@ size_t i{0}; return r; } -#line 8293 "reflect.h2" +#line 8465 "reflect.h2" [[nodiscard]] auto range_token::reverse() const -> token_ptr{ auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; (*cpp2::impl::assert_not_null(r)).min_count = min_count; @@ -12341,7 +12517,7 @@ size_t i{0}; return r; } -#line 8303 "reflect.h2" +#line 8475 "reflect.h2" auto range_token::generate_code(generation_context& ctx) const -> void { auto inner_name {ctx.generate_func(inner_token)}; @@ -12353,14 +12529,14 @@ size_t i{0}; ctx.add_statefull(next_name, "cpp2::regex::range_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ", " + cpp2::to_string(cpp2::move(inner_name)) + ", " + cpp2::to_string(cpp2::move(reset_name)) + ", other, " + cpp2::to_string(next_name) + ")"); } -#line 8314 "reflect.h2" +#line 8486 "reflect.h2" auto range_token::add_groups(std::set& groups) const -> void{ (*cpp2::impl::assert_not_null(inner_token)).add_groups(groups); } range_token::~range_token() noexcept{} -#line 8326 "reflect.h2" +#line 8498 "reflect.h2" [[nodiscard]] auto special_range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -12384,7 +12560,7 @@ size_t i{0}; if (!(ctx.has_token())) {return ctx.error("'" + cpp2::to_string(ctx.current()) + "' without previous element."); } -#line 8350 "reflect.h2" +#line 8522 "reflect.h2" (*cpp2::impl::assert_not_null(r)).parse_modifier(ctx); (*cpp2::impl::assert_not_null(r)).inner_token = ctx.pop_token(); @@ -12394,7 +12570,7 @@ size_t i{0}; special_range_token::~special_range_token() noexcept{} -#line 8362 "reflect.h2" +#line 8534 "reflect.h2" [[nodiscard]] auto start_match_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -12410,7 +12586,7 @@ size_t i{0}; } } -#line 8382 "reflect.h2" +#line 8554 "reflect.h2" [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -12428,15 +12604,15 @@ size_t i{0}; }} } -#line 8418 "reflect.h2" +#line 8590 "reflect.h2" template regex_generator::regex_generator(cpp2::impl::in r, Error_out const& e) : regex{ r } , error_out{ e }{ -#line 8421 "reflect.h2" +#line 8593 "reflect.h2" } -#line 8423 "reflect.h2" +#line 8595 "reflect.h2" template [[nodiscard]] auto regex_generator::parse() & -> std::string { // Extract modifiers and adapt regex. @@ -12472,7 +12648,7 @@ size_t i{0}; return source; } -#line 8458 "reflect.h2" +#line 8630 "reflect.h2" template auto regex_generator::extract_modifiers() & -> void { if (regex.find_first_of("'/") == 0) { @@ -12488,7 +12664,7 @@ size_t i{0}; } } -#line 8474 "reflect.h2" +#line 8646 "reflect.h2" template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string { regex_generator parser {regex, err}; @@ -12497,7 +12673,7 @@ template [[nodiscard]] auto generate_regex(cpp2::impl::in void { auto has_default {false}; @@ -12552,7 +12728,7 @@ auto regex_gen(meta::type_declaration& t) -> void CPP2_UFCS(add_runtime_support_include)(t, "cpp2regex.h"); } -#line 8543 "reflect.h2" +#line 8715 "reflect.h2" [[nodiscard]] auto apply_metafunctions( declaration_node& n, type_declaration& rtype, @@ -12619,6 +12795,9 @@ auto regex_gen(meta::type_declaration& t) -> void else {if (name == "hashable") { hashable(rtype); } + else {if (name == "euclidean_vector") { + euclidean_vector(rtype); + } else {if (name == "basic_value") { basic_value(rtype); } @@ -12674,13 +12853,13 @@ auto regex_gen(meta::type_declaration& t) -> void "https://hsutter.github.io/cppfront/cpp2/metafunctions/#built-in-metafunctions" ); return false; - }}}}}}}}}}}}}}}}}}}}}}}} + }}}}}}}}}}}}}}}}}}}}}}}}} } return true; } -#line 8671 "reflect.h2" +#line 8846 "reflect.h2" } } diff --git a/source/reflect.h2 b/source/reflect.h2 index d228d8aac..1cc0361be 100644 --- a/source/reflect.h2 +++ b/source/reflect.h2 @@ -1786,6 +1786,178 @@ hashable: (inout t: meta::type_declaration) = } +//----------------------------------------------------------------------- +// +// euclidean_vector +// (a little metafunction experiment) +// +// Automatically generate +, -, * and / operators across all member variables, optionally with +// a single numeric type argument (eg. vector3 * float) if given a template argument. +// +// Additionally creates functions For getting the magnitude/length, normalisation, dot product. +// +euclidean_vector: (inout t: meta::type_declaration) = +{ + single_arg_type: _ = t.get_argument(0); + add_single_arg_fns: bool = ( single_arg_type.size() != 0 ); + + op_add: std::string = "operator+: (this, in_ref other: (t.name())$) -> (t.name())$ = (t.name())$( "; + op_sub: std::string = "operator-: (this, in_ref other: (t.name())$) -> (t.name())$ = (t.name())$( "; + op_mul: std::string = "operator*: (this, in_ref other: (t.name())$) -> (t.name())$ = (t.name())$( "; + op_div: std::string = "operator/: (this, in_ref other: (t.name())$) -> (t.name())$ = (t.name())$( "; + + op_negate: std::string = "operator-: (this) -> (t.name())$ = (t.name())$( "; + + op_assign_add: std::string = "operator+=: (inout this, in_ref other: (t.name())$) = { "; + op_assign_sub: std::string = "operator-=: (inout this, in_ref other: (t.name())$) = { "; + op_assign_mul: std::string = "operator*=: (inout this, in_ref other: (t.name())$) = { "; + op_assign_div: std::string = "operator/=: (inout this, in_ref other: (t.name())$) = { "; + + op_add_sc: std::string = "operator+: (this, other: (single_arg_type)$) -> (t.name())$ = (t.name())$( "; + op_sub_sc: std::string = "operator-: (this, other: (single_arg_type)$) -> (t.name())$ = (t.name())$( "; + op_mul_sc: std::string = "operator*: (this, other: (single_arg_type)$) -> (t.name())$ = (t.name())$( "; + op_div_sc: std::string = "operator/: (this, other: (single_arg_type)$) -> (t.name())$ = (t.name())$( "; + + op_assign_add_sc: std::string = "operator+=: (inout this, other: (single_arg_type)$) = { "; + op_assign_sub_sc: std::string = "operator-=: (inout this, other: (single_arg_type)$) = { "; + op_assign_mul_sc: std::string = "operator*=: (inout this, other: (single_arg_type)$) = { "; + op_assign_div_sc: std::string = "operator/=: (inout this, other: (single_arg_type)$) = { "; + + fn_lengthSq: std::string = "lengthSquared: (this) -> _ = "; + + fn_normalise: std::string = "normalise: (inout this) = {\n len: _ = length();\n"; + fn_normalised: std::string = "normalised: (this) -> (t.name())$ = {\n len: _ = length();\n return (t.name())$(\n"; + + fn_dot: std::string = "dot: (in_ref lhs: (t.name())$, in_ref rhs: (t.name())$) -> _ = "; + + after_first_value_added: bool = false; + for t.get_member_objects() + do (o) + { + if after_first_value_added { + op_add += ", "; + op_sub += ", "; + op_mul += ", "; + op_div += ", "; + + op_negate += ", "; + + if add_single_arg_fns { + op_add_sc += ", "; + op_sub_sc += ", "; + op_mul_sc += ", "; + op_div_sc += ", "; + } + + fn_lengthSq += " + "; + fn_dot += " + "; + + fn_normalised += ",\n"; + } else { + fn_normalised += "\n"; + } + + op_add += "(o.name())$ + other.(o.name())$"; + op_sub += "(o.name())$ - other.(o.name())$"; + op_mul += "(o.name())$ * other.(o.name())$"; + op_div += "(o.name())$ / other.(o.name())$"; + + op_negate += "-(o.name())$"; + + fn_normalise += "(o.name())$ /= len;\n"; + fn_normalised += " (o.name())$ / len"; + + if add_single_arg_fns { + op_add_sc += "(o.name())$ + other"; + op_sub_sc += "(o.name())$ - other"; + op_mul_sc += "(o.name())$ * other"; + op_div_sc += "(o.name())$ / other"; + } + + op_assign_add += "(o.name())$ += other.(o.name())$;"; + op_assign_sub += "(o.name())$ -= other.(o.name())$;"; + op_assign_mul += "(o.name())$ *= other.(o.name())$;"; + op_assign_div += "(o.name())$ /= other.(o.name())$;"; + + if add_single_arg_fns { + op_assign_add_sc += "(o.name())$ += other;"; + op_assign_sub_sc += "(o.name())$ -= other;"; + op_assign_mul_sc += "(o.name())$ *= other;"; + op_assign_div_sc += "(o.name())$ /= other;"; + } + + fn_lengthSq += "( (o.name())$ * (o.name())$ )"; + fn_dot += "( lhs.(o.name())$ * rhs.(o.name())$ )"; + + after_first_value_added = true; + } + + op_assign_add += " }"; + op_assign_sub += " }"; + op_assign_mul += " }"; + op_assign_div += " }"; + + if add_single_arg_fns { + op_assign_add_sc += " }"; + op_assign_sub_sc += " }"; + op_assign_mul_sc += " }"; + op_assign_div_sc += " }"; + } + + op_add += " );"; + op_sub += " );"; + op_mul += " );"; + op_div += " );"; + + op_negate += " );"; + + if add_single_arg_fns { + op_add_sc += " );"; + op_sub_sc += " );"; + op_mul_sc += " );"; + op_div_sc += " );"; + } + + fn_lengthSq += ";"; + fn_dot += ";"; + + fn_normalise += "}"; + fn_normalised += ");\n}"; + + t.add_member( fn_lengthSq ); + t.add_member( "length: (this) -> _ = std::sqrt( lengthSquared() );" ); + + t.add_member( fn_normalise ); + t.add_member( fn_normalised ); + + t.add_member( fn_dot ); + + t.add_member( op_add ); + t.add_member( op_sub ); + t.add_member( op_mul ); + t.add_member( op_div ); + + t.add_member( op_negate ); + + t.add_member( op_assign_add ); + t.add_member( op_assign_sub ); + t.add_member( op_assign_mul ); + t.add_member( op_assign_div ); + + if add_single_arg_fns { + t.add_member( op_add_sc ); + t.add_member( op_sub_sc ); + t.add_member( op_mul_sc ); + t.add_member( op_div_sc ); + + t.add_member( op_assign_add_sc ); + t.add_member( op_assign_sub_sc ); + t.add_member( op_assign_mul_sc ); + t.add_member( op_assign_div_sc ); + } +} + + //----------------------------------------------------------------------- // // basic_value @@ -8606,6 +8778,9 @@ apply_metafunctions: ( else if name == "hashable" { hashable( rtype ); } + else if name == "euclidean_vector" { + euclidean_vector( rtype ); + } else if name == "basic_value" { basic_value( rtype ); }