9
9
#include " cpp2util.h"
10
10
11
11
12
- #line 281 "reflect.h2"
12
+ #line 283 "reflect.h2"
13
13
namespace cpp2 {
14
14
namespace meta {
15
15
16
- #line 287 "reflect.h2"
16
+ #line 289 "reflect.h2"
17
17
class object_declaration ;
18
18
19
- #line 314 "reflect.h2"
19
+ #line 316 "reflect.h2"
20
20
}
21
21
}
22
22
23
- #line 434 "reflect.h2"
23
+ #line 436 "reflect.h2"
24
24
namespace cpp2 {
25
25
26
- #line 737 "reflect.h2"
26
+ #line 739 "reflect.h2"
27
27
}
28
28
29
29
@@ -132,29 +132,31 @@ class compiler_services
132
132
}
133
133
134
134
public:
135
+ virtual auto position () const
136
+ -> source_position
137
+ {
138
+ return {};
139
+ }
140
+
135
141
auto require (
136
142
bool b,
137
- std::string_view msg,
138
- source_position pos = source_position{}
143
+ std::string_view msg
139
144
) const
140
145
-> void
141
146
{
142
147
if (!b) {
143
- error ( msg, pos );
148
+ error ( msg );
144
149
}
145
150
}
146
151
147
- auto error (
148
- std::string_view msg,
149
- source_position pos = source_position{}
150
- ) const
152
+ auto error (std::string_view msg) const
151
153
-> void
152
154
{
153
155
auto message = std::string{msg};
154
156
if (!meta_function_name.empty ()) {
155
157
message = " while applying @" + meta_function_name + " - " + message;
156
158
}
157
- errors->emplace_back ( pos , message );
159
+ errors->emplace_back ( position () , message);
158
160
}
159
161
};
160
162
@@ -183,6 +185,8 @@ class declaration_base : public compiler_services
183
185
{
184
186
assert (n && " a meta::declaration must point to a valid declaration_node, not null" );
185
187
}
188
+
189
+ auto position () const -> source_position override { return n->position (); }
186
190
};
187
191
188
192
class function_declaration ;
@@ -204,8 +208,6 @@ class declaration
204
208
: declaration_base{n_, s}
205
209
{ }
206
210
207
- auto position () const -> source_position { return n->position (); }
208
-
209
211
auto is_public () const -> bool { return n->is_public (); }
210
212
auto is_protected () const -> bool { return n->is_protected (); }
211
213
auto is_private () const -> bool { return n->is_private (); }
@@ -309,7 +311,7 @@ auto declaration::as_function() const
309
311
// Switch to Cpp2
310
312
}
311
313
}
312
- #line 281 "reflect.h2"
314
+ #line 283 "reflect.h2"
313
315
namespace cpp2 {
314
316
namespace meta {
315
317
@@ -319,14 +321,14 @@ namespace meta {
319
321
class object_declaration
320
322
: public declaration {
321
323
322
- #line 291 "reflect.h2"
324
+ #line 293 "reflect.h2"
323
325
public: object_declaration(
324
326
325
327
cpp2::in<declaration_node*> n_,
326
328
cpp2::in<compiler_services> s
327
329
);
328
330
329
- #line 301 "reflect.h2"
331
+ #line 303 "reflect.h2"
330
332
public: object_declaration(object_declaration const & that);
331
333
332
334
public: [[nodiscard]] auto is_const () const -> bool;
@@ -337,7 +339,7 @@ class object_declaration
337
339
338
340
};
339
341
340
- #line 312 "reflect.h2"
342
+ #line 314 "reflect.h2"
341
343
// =======================================================================
342
344
// Switch to Cpp1
343
345
}
@@ -476,7 +478,7 @@ namespace cpp2 {
476
478
//
477
479
auto add_virtual_destructor (meta::type_declaration& t) -> void;
478
480
479
- #line 455 "reflect.h2"
481
+ #line 457 "reflect.h2"
480
482
// -----------------------------------------------------------------------
481
483
//
482
484
// "... an abstract base class defines an interface ..."
@@ -491,7 +493,7 @@ auto add_virtual_destructor(meta::type_declaration& t) -> void;
491
493
//
492
494
auto interface (meta::type_declaration& t) -> void;
493
495
494
- #line 494 "reflect.h2"
496
+ #line 496 "reflect.h2"
495
497
// -----------------------------------------------------------------------
496
498
//
497
499
// "C.35: A base class destructor should be either public and
@@ -514,7 +516,7 @@ auto interface(meta::type_declaration& t) -> void;
514
516
//
515
517
auto polymorphic_base (meta::type_declaration& t) -> void;
516
518
517
- #line 539 "reflect.h2"
519
+ #line 541 "reflect.h2"
518
520
// -----------------------------------------------------------------------
519
521
//
520
522
// "... A totally ordered type ... requires operator<=> that
@@ -540,27 +542,27 @@ auto ordered_impl(
540
542
cpp2::in<std::string_view> ordering// must be "strong_ordering" etc.
541
543
) -> void;
542
544
543
- #line 584 "reflect.h2"
545
+ #line 586 "reflect.h2"
544
546
// -----------------------------------------------------------------------
545
547
// ordered - a totally ordered type
546
548
//
547
549
// Note: the ordering that should be encouraged as default gets the nice name
548
550
//
549
551
auto ordered (meta::type_declaration& t) -> void;
550
552
551
- #line 594 "reflect.h2"
553
+ #line 596 "reflect.h2"
552
554
// -----------------------------------------------------------------------
553
555
// weakly_ordered - a weakly ordered type
554
556
//
555
557
auto weakly_ordered (meta::type_declaration& t) -> void;
556
558
557
- #line 602 "reflect.h2"
559
+ #line 604 "reflect.h2"
558
560
// -----------------------------------------------------------------------
559
561
// partially_ordered - a partially ordered type
560
562
//
561
563
auto partially_ordered (meta::type_declaration& t) -> void;
562
564
563
- #line 611 "reflect.h2"
565
+ #line 613 "reflect.h2"
564
566
// -----------------------------------------------------------------------
565
567
//
566
568
// "A value is ... a regular type. It must have all public
@@ -580,7 +582,7 @@ auto partially_ordered(meta::type_declaration& t) -> void;
580
582
//
581
583
auto basic_value (meta::type_declaration& t) -> void;
582
584
583
- #line 664 "reflect.h2"
585
+ #line 666 "reflect.h2"
584
586
// -----------------------------------------------------------------------
585
587
//
586
588
// "A 'value' is a totally ordered basic_value..."
@@ -592,13 +594,13 @@ auto basic_value(meta::type_declaration& t) -> void;
592
594
//
593
595
auto value (meta::type_declaration& t) -> void;
594
596
595
- #line 679 "reflect.h2"
597
+ #line 681 "reflect.h2"
596
598
auto weakly_ordered_value (meta::type_declaration& t) -> void;
597
599
598
- #line 685 "reflect.h2"
600
+ #line 687 "reflect.h2"
599
601
auto partially_ordered_value (meta::type_declaration& t) -> void;
600
602
601
- #line 692 "reflect.h2"
603
+ #line 694 "reflect.h2"
602
604
// -----------------------------------------------------------------------
603
605
//
604
606
// "By definition, a `struct` is a `class` in which members
@@ -626,7 +628,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void;
626
628
//
627
629
auto cpp2_struct (meta::type_declaration& t) -> void;
628
630
629
- #line 735 "reflect.h2"
631
+ #line 737 "reflect.h2"
630
632
// =======================================================================
631
633
// Switch to Cpp1
632
634
}
@@ -696,47 +698,47 @@ auto parser::apply_type_meta_functions( declaration_node& n )
696
698
// === Cpp2 function definitions =================================================
697
699
698
700
699
- #line 281 "reflect.h2"
701
+ #line 283 "reflect.h2"
700
702
namespace cpp2 {
701
703
namespace meta {
702
704
703
- #line 291 "reflect.h2"
705
+ #line 293 "reflect.h2"
704
706
object_declaration::object_declaration (
705
707
706
708
cpp2::in<declaration_node*> n_,
707
709
cpp2::in<compiler_services> s
708
710
)
709
711
: declaration{ n_, s }
710
- #line 296 "reflect.h2"
712
+ #line 298 "reflect.h2"
711
713
{
712
714
713
715
cpp2::Default.expects (CPP2_UFCS_0 (is_object, (*cpp2::assert_not_null (n))), " " );
714
716
}
715
717
716
718
object_declaration::object_declaration (object_declaration const & that)
717
719
: declaration{ that }
718
- #line 301 "reflect.h2"
720
+ #line 303 "reflect.h2"
719
721
{}
720
722
721
723
[[nodiscard]] auto object_declaration::is_const () const -> bool { return CPP2_UFCS_0 (is_const, (*cpp2::assert_not_null (n))); }
722
724
723
725
[[nodiscard]] auto object_declaration::has_wildcard_type () const -> bool { return CPP2_UFCS_0 (has_wildcard_type, (*cpp2::assert_not_null (n))); }
724
726
725
- #line 314 "reflect.h2"
727
+ #line 316 "reflect.h2"
726
728
}
727
729
}
728
730
729
- #line 434 "reflect.h2"
731
+ #line 436 "reflect.h2"
730
732
namespace cpp2 {
731
733
732
- #line 448 "reflect.h2"
734
+ #line 450 "reflect.h2"
733
735
auto add_virtual_destructor (meta::type_declaration& t) -> void
734
736
{
735
737
CPP2_UFCS (require, t, CPP2_UFCS (add_member, t, " operator=: (virtual move this) = { }" ),
736
738
" could not add virtual destructor" );
737
739
}
738
740
739
- #line 467 "reflect.h2"
741
+ #line 469 "reflect.h2"
740
742
auto interface (meta::type_declaration& t) -> void
741
743
{
742
744
auto has_dtor {false };
@@ -758,13 +760,13 @@ auto interface(meta::type_declaration& t) -> void
758
760
}
759
761
}}
760
762
761
- #line 488 "reflect.h2"
763
+ #line 490 "reflect.h2"
762
764
if (!(std::move (has_dtor))) {
763
765
add_virtual_destructor (t);
764
766
}
765
767
}
766
768
767
- #line 514 "reflect.h2"
769
+ #line 516 "reflect.h2"
768
770
auto polymorphic_base (meta::type_declaration& t) -> void
769
771
{
770
772
auto has_dtor {false };
@@ -784,13 +786,13 @@ auto polymorphic_base(meta::type_declaration& t) -> void
784
786
}
785
787
}}
786
788
787
- #line 533 "reflect.h2"
789
+ #line 535 "reflect.h2"
788
790
if (!(std::move (has_dtor))) {
789
791
add_virtual_destructor (t);
790
792
}
791
793
}
792
794
793
- #line 559 "reflect.h2"
795
+ #line 561 "reflect.h2"
794
796
auto ordered_impl (
795
797
meta::type_declaration& t,
796
798
cpp2::in<std::string_view> ordering
@@ -810,32 +812,32 @@ auto ordered_impl(
810
812
}
811
813
}}
812
814
813
- #line 578 "reflect.h2"
815
+ #line 580 "reflect.h2"
814
816
if (!(std::move (has_spaceship))) {
815
817
CPP2_UFCS (require, t, CPP2_UFCS (add_member, t, " operator<=>: (this, that) -> std::" + (cpp2::as_<std::string>(ordering)) + " ;" ),
816
818
" could not add operator<=> with std::" + (cpp2::as_<std::string>(ordering)));
817
819
}
818
820
}
819
821
820
- #line 589 "reflect.h2"
822
+ #line 591 "reflect.h2"
821
823
auto ordered (meta::type_declaration& t) -> void
822
824
{
823
825
ordered_impl (t, " strong_ordering" );
824
826
}
825
827
826
- #line 597 "reflect.h2"
828
+ #line 599 "reflect.h2"
827
829
auto weakly_ordered (meta::type_declaration& t) -> void
828
830
{
829
831
ordered_impl (t, " weak_ordering" );
830
832
}
831
833
832
- #line 605 "reflect.h2"
834
+ #line 607 "reflect.h2"
833
835
auto partially_ordered (meta::type_declaration& t) -> void
834
836
{
835
837
ordered_impl (t, " partial_ordering" );
836
838
}
837
839
838
- #line 628 "reflect.h2"
840
+ #line 630 "reflect.h2"
839
841
auto basic_value (meta::type_declaration& t) -> void
840
842
{
841
843
// If the user explicitly wrote any of the copy/move functions,
@@ -866,14 +868,14 @@ auto basic_value(meta::type_declaration& t) -> void
866
868
" a value type may not have a non-public destructor" );
867
869
}}
868
870
869
- #line 658 "reflect.h2"
871
+ #line 660 "reflect.h2"
870
872
if (!(std::move (has_default_ctor))) {
871
873
CPP2_UFCS (require, t, CPP2_UFCS (add_member, t, " operator=: (out this) = { }" ),
872
874
" could not add default constructor" );
873
875
}
874
876
}
875
877
876
- #line 673 "reflect.h2"
878
+ #line 675 "reflect.h2"
877
879
auto value (meta::type_declaration& t) -> void
878
880
{
879
881
ordered (t);
@@ -892,7 +894,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void
892
894
basic_value (t);
893
895
}
894
896
895
- #line 717 "reflect.h2"
897
+ #line 719 "reflect.h2"
896
898
auto cpp2_struct (meta::type_declaration& t) -> void
897
899
{
898
900
{ auto && cpp2_range = CPP2_UFCS_0 (get_members, t); for ( auto & m : cpp2_range )
@@ -907,11 +909,11 @@ auto cpp2_struct(meta::type_declaration& t) -> void
907
909
" a struct may not have a user-defined operator=" );
908
910
}
909
911
}}
910
- #line 731 "reflect.h2"
912
+ #line 733 "reflect.h2"
911
913
basic_value (t); // a plain_struct is-a basic_value
912
914
}
913
915
914
- #line 737 "reflect.h2"
916
+ #line 739 "reflect.h2"
915
917
}
916
918
917
919
#endif
0 commit comments