1
2
3
4
5
6 #include <cmajor/symbols/SymbolCreatorVisitor.hpp>
7 #include <cmajor/symbols/Exception.hpp>
8 #include <cmajor/symbols/SymbolTable.hpp>
9 #include <cmajor/symbols/GlobalFlags.hpp>
10 #include <cmajor/symbols/Module.hpp>
11 #include <cmajor/symbols/Sources.hpp>
12 #include <cmajor/symbols/InterfaceTypeSymbol.hpp>
13 #include <cmajor/symbols/TypedefSymbol.hpp>
14 #include <cmajor/symbols/ConstantSymbol.hpp>
15 #include <sngcm/ast/CompileUnit.hpp>
16 #include <sngcm/ast/Class.hpp>
17 #include <sngcm/ast/Interface.hpp>
18 #include <sngcm/ast/Expression.hpp>
19 #include <sngcm/ast/Literal.hpp>
20
21 namespace cmajor { namespace symbols {
22
23 SymbolCreatorVisitor::SymbolCreatorVisitor(SymbolTable& symbolTable_) :
24 symbolTable(symbolTable_), classInstanceNode(nullptr), classTemplateSpecialization(nullptr), functionIndex(0), leaveFunction(false), editMode(false), level(0), source(nullptr)
25 {
26 symbolTable.ResetCursorContainer();
27 symbolTable.ResetAxiomNumber();
28 symbolTable.ResetAliasNodesAndNamespaceImports();
29 }
30
31 void SymbolCreatorVisitor::SetClassInstanceNode(ClassNode* classInstanceNode_)
32 {
33 classInstanceNode = classInstanceNode_;
34 }
35
36 void SymbolCreatorVisitor::SetClassTemplateSpecialization(ClassTemplateSpecializationSymbol* classTemplateSpecialization_)
37 {
38 classTemplateSpecialization = classTemplateSpecialization_;
39 }
40
41 void SymbolCreatorVisitor::Visit(CompileUnitNode& compileUnitNode)
42 {
43 try
44 {
45 compileUnitNode.GlobalNs()->Accept(*this);
46 }
47 catch (const Exception& ex;)
48 {
49 if (editMode)
50 {
51 errors.push_back(ex.Message());
52 }
53 else
54 {
55 throw ;
56 }
57 }
58 catch (const std::exception& ex;)
59 {
60 if (editMode)
61 {
62 errors.push_back(ex.what());
63 }
64 else
65 {
66 throw ;
67 }
68 }
69 }
70
71 void SymbolCreatorVisitor::Visit(NamespaceNode& namespaceNode)
72 {
73 bool namespaceAdded = false;
74 try
75 {
76 symbolTable.BeginNamespace(namespaceNode);
77 namespaceAdded = true;
78 if (namespaceNode.Id())
79 {
80 namespaceNode.Id()->Accept(*this);
81 }
82 NodeList<Node>& members = namespaceNode.Members();
83 int n = members.Count();
84 for (int i = 0; i < n; ++i)
85 {
86 Node* member = members[i];
87 member->Accept(*this);
88 }
89 symbolTable.SetCursorContainer(namespaceNode);
90 symbolTable.EndNamespace();
91 }
92 catch (const Exception& ex;)
93 {
94 if (editMode)
95 {
96 if (namespaceAdded)
97 {
98 symbolTable.EndNamespace();
99 }
100 errors.push_back(ex.Message());
101 }
102 else
103 {
104 throw ;
105 }
106 }
107 catch (const std::exception& ex;)
108 {
109 if (editMode)
110 {
111 if (namespaceAdded)
112 {
113 symbolTable.EndNamespace();
114 }
115 errors.push_back(ex.what());
116 }
117 else
118 {
119 throw ;
120 }
121 }
122 }
123
124 void SymbolCreatorVisitor::Visit(AliasNode& aliasNode)
125 {
126 try
127 {
128 aliasNode.Id()->Accept(*this);
129 aliasNode.Qid()->Accept(*this);
130 if (editMode)
131 {
132 symbolTable.AddAliasNode(&aliasNode);
133 }
134 symbolTable.SetCursorContainer(aliasNode);
135 }
136 catch (const Exception& ex;)
137 {
138 if (editMode)
139 {
140 errors.push_back(ex.Message());
141 }
142 else
143 {
144 throw ;
145 }
146 }
147 catch (const std::exception& ex;)
148 {
149 if (editMode)
150 {
151 errors.push_back(ex.what());
152 }
153 else
154 {
155 throw ;
156 }
157 }
158 }
159
160 void SymbolCreatorVisitor::Visit(NamespaceImportNode& namespaceImportNode)
161 {
162 try
163 {
164 namespaceImportNode.Ns()->Accept(*this);
165 if (editMode)
166 {
167 symbolTable.AddNamespaceImport(&namespaceImportNode);
168 }
169 symbolTable.SetCursorContainer(namespaceImportNode);
170 }
171 catch (const Exception& ex;)
172 {
173 if (editMode)
174 {
175 errors.push_back(ex.Message());
176 }
177 else
178 {
179 throw ;
180 }
181 }
182 catch (const std::exception& ex;)
183 {
184 if (editMode)
185 {
186 errors.push_back(ex.what());
187 }
188 else
189 {
190 throw ;
191 }
192 }
193 }
194
195 void SymbolCreatorVisitor::Visit(IdentifierNode& identifierNode)
196 {
197 symbolTable.SetCursorContainer(identifierNode);
198 }
199
200 void SymbolCreatorVisitor::Visit(CursorIdNode& cursorIdNode)
201 {
202 symbolTable.SetCursorContainer(cursorIdNode);
203 }
204
205 void SymbolCreatorVisitor::Visit(TemplateIdNode& templateIdNode)
206 {
207 try
208 {
209 templateIdNode.Primary()->Accept(*this);
210 const NodeList<Node>& args = templateIdNode.TemplateArguments();
211 int n = args.Count();
212 for (int i = 0; i < n; ++i)
213 {
214 Node* arg = args[i];
215 arg->Accept(*this);
216 }
217 symbolTable.SetCursorContainer(templateIdNode);
218 }
219 catch (const Exception& ex;)
220 {
221 if (editMode)
222 {
223 errors.push_back(ex.Message());
224 }
225 else
226 {
227 throw ;
228 }
229 }
230 catch (const std::exception& ex;)
231 {
232 if (editMode)
233 {
234 errors.push_back(ex.what());
235 }
236 else
237 {
238 throw ;
239 }
240 }
241 }
242
243 void SymbolCreatorVisitor::Visit(FunctionNode& functionNode)
244 {
245 bool functionAdded = false;
246 try
247 {
248 symbolTable.BeginFunction(functionNode, functionIndex++);
249 ++level;
250 functionAdded = true;
251 if (functionNode.ReturnTypeExpr())
252 {
253 functionNode.ReturnTypeExpr()->Accept(*this);
254 }
255 int nt = functionNode.TemplateParameters().Count();
256 for (int i = 0; i < nt; ++i)
257 {
258 symbolTable.AddTemplateParameter(*functionNode.TemplateParameters()[i]);
259 }
260 int n = functionNode.Parameters().Count();
261 for (int i = 0; i < n; ++i)
262 {
263 ParameterNode* parameterNode = functionNode.Parameters()[i];
264 parameterNode->Accept(*this);
265 }
266 if (functionNode.WhereConstraint())
267 {
268 functionNode.WhereConstraint()->Accept(*this);
269 }
270 if (nt == 0 || editMode)
271 {
272 if (functionNode.Body())
273 {
274 functionNode.Body()->Accept(*this);
275 }
276 }
277 --level;
278 symbolTable.SetCursorContainer(functionNode);
279 if (level == 0 && source)
280 {
281 source->AddSymbol(symbolTable.Container());
282 }
283 symbolTable.EndFunction(!leaveFunction);
284 }
285 catch (const Exception& ex;)
286 {
287 if (editMode)
288 {
289 if (functionAdded)
290 {
291 --level;
292 symbolTable.EndFunction(!leaveFunction);
293 }
294 errors.push_back(ex.Message());
295 }
296 else
297 {
298 throw ;
299 }
300 }
301 catch (const std::exception& ex;)
302 {
303 if (editMode)
304 {
305 if (functionAdded)
306 {
307 --level;
308 symbolTable.EndFunction(!leaveFunction);
309 }
310 errors.push_back(ex.what());
311 }
312 else
313 {
314 throw ;
315 }
316 }
317 }
318
319 void SymbolCreatorVisitor::Visit(FunctionPtrNode& functionPtrNode)
320 {
321 symbolTable.SetCursorContainer(functionPtrNode);
322 }
323
324 void SymbolCreatorVisitor::Visit(ClassNode& classNode)
325 {
326 bool classAdded = false;
327 try
328 {
329 if (&classNode == classInstanceNode)
330 {
331 symbolTable.BeginClassTemplateSpecialization(*classInstanceNode, classTemplateSpecialization);
332 }
333 else
334 {
335 symbolTable.BeginClass(classNode);
336 }
337 ++level;
338 classAdded = true;
339 classNode.Id()->Accept(*this);
340 int nt = classNode.TemplateParameters().Count();
341 for (int i = 0; i < nt; ++i)
342 {
343 symbolTable.AddTemplateParameter(*classNode.TemplateParameters()[i]);
344 }
345 int nb = classNode.BaseClassOrInterfaces().Count();
346 for (int i = 0; i < nb; ++i)
347 {
348 classNode.BaseClassOrInterfaces()[i]->Accept(*this);
349 }
350 if (nt == 0 || editMode)
351 {
352 int n = classNode.Members().Count();
353 for (int i = 0; i < n; ++i)
354 {
355 Node* member = classNode.Members()[i];
356 member->Accept(*this);
357 }
358 }
359 --level;
360 symbolTable.SetCursorContainer(classNode);
361 if (level == 0 && source)
362 {
363 source->AddSymbol(symbolTable.CurrentClass());
364 }
365 if (&classNode == classInstanceNode)
366 {
367 symbolTable.EndClassTemplateSpecialization();
368 }
369 else
370 {
371 symbolTable.EndClass();
372 }
373 }
374 catch (const Exception& ex;)
375 {
376 if (editMode)
377 {
378 if (classAdded)
379 {
380 --level;
381 if (&classNode == classInstanceNode)
382 {
383 symbolTable.EndClassTemplateSpecialization();
384 }
385 else
386 {
387 symbolTable.EndClass();
388 }
389 }
390 errors.push_back(ex.Message());
391 }
392 else
393 {
394 throw ;
395 }
396 }
397 catch (const std::exception& ex;)
398 {
399 if (editMode)
400 {
401 if (classAdded)
402 {
403 --level;
404 if (&classNode == classInstanceNode)
405 {
406 symbolTable.EndClassTemplateSpecialization();
407 }
408 else
409 {
410 symbolTable.EndClass();
411 }
412 }
413 errors.push_back(ex.what());
414 }
415 else
416 {
417 throw ;
418 }
419 }
420 }
421
422 void SymbolCreatorVisitor::Visit(ThisInitializerNode& thisInitializerNode)
423 {
424 try
425 {
426 int n = thisInitializerNode.Arguments().Count();
427 for (int i = 0; i < n; ++i)
428 {
429 thisInitializerNode.Arguments()[i]->Accept(*this);
430 }
431 symbolTable.SetCursorContainer(thisInitializerNode);
432 }
433 catch (const Exception& ex;)
434 {
435 if (editMode)
436 {
437 errors.push_back(ex.Message());
438 }
439 else
440 {
441 throw ;
442 }
443 }
444 catch (const std::exception& ex;)
445 {
446 if (editMode)
447 {
448 errors.push_back(ex.what());
449 }
450 else
451 {
452 throw ;
453 }
454 }
455 }
456
457 void SymbolCreatorVisitor::Visit(BaseInitializerNode& baseInitializerNode)
458 {
459 try
460 {
461 int n = baseInitializerNode.Arguments().Count();
462 for (int i = 0; i < n; ++i)
463 {
464 baseInitializerNode.Arguments()[i]->Accept(*this);
465 }
466 symbolTable.SetCursorContainer(baseInitializerNode);
467 }
468 catch (const Exception& ex;)
469 {
470 if (editMode)
471 {
472 errors.push_back(ex.Message());
473 }
474 else
475 {
476 throw ;
477 }
478 }
479 catch (const std::exception& ex;)
480 {
481 if (editMode)
482 {
483 errors.push_back(ex.what());
484 }
485 else
486 {
487 throw ;
488 }
489 }
490 }
491
492 void SymbolCreatorVisitor::Visit(MemberInitializerNode& memberInitializerNode)
493 {
494 try
495 {
496 memberInitializerNode.MemberId()->Accept(*this);
497 int n = memberInitializerNode.Arguments().Count();
498 for (int i = 0; i < n; ++i)
499 {
500 memberInitializerNode.Arguments()[i]->Accept(*this);
501 }
502 symbolTable.SetCursorContainer(memberInitializerNode);
503 }
504 catch (const Exception& ex;)
505 {
506 if (editMode)
507 {
508 errors.push_back(ex.Message());
509 }
510 else
511 {
512 throw ;
513 }
514 }
515 catch (const std::exception& ex;)
516 {
517 if (editMode)
518 {
519 errors.push_back(ex.what());
520 }
521 else
522 {
523 throw ;
524 }
525 }
526 }
527
528 void SymbolCreatorVisitor::Visit(StaticConstructorNode& staticConstructorNode)
529 {
530 bool staticConstructorAdded = false;
531 try
532 {
533 symbolTable.BeginStaticConstructor(staticConstructorNode, functionIndex++);
534 ++level;
535 staticConstructorAdded = true;
536 int ni = staticConstructorNode.Initializers().Count();
537 for (int i = 0; i < ni; ++i)
538 {
539 staticConstructorNode.Initializers()[i]->Accept(*this);
540 }
541 if (staticConstructorNode.WhereConstraint())
542 {
543 staticConstructorNode.WhereConstraint()->Accept(*this);
544 }
545 if (staticConstructorNode.Body())
546 {
547 InsertTracer(staticConstructorNode.Body());
548 staticConstructorNode.Body()->Accept(*this);
549 }
550 --level;
551 symbolTable.SetCursorContainer(staticConstructorNode);
552 symbolTable.EndStaticConstructor(!leaveFunction);
553 }
554 catch (const Exception& ex;)
555 {
556 if (editMode)
557 {
558 if (staticConstructorAdded)
559 {
560 --level;
561 symbolTable.EndStaticConstructor(!leaveFunction);
562 }
563 errors.push_back(ex.Message());
564 }
565 else
566 {
567 throw ;
568 }
569 }
570 catch (const std::exception& ex;)
571 {
572 if (editMode)
573 {
574 if (staticConstructorAdded)
575 {
576 --level;
577 symbolTable.EndStaticConstructor(!leaveFunction);
578 }
579 errors.push_back(ex.what());
580 }
581 else
582 {
583 throw ;
584 }
585 }
586 }
587
588 void SymbolCreatorVisitor::Visit(ConstructorNode& constructorNode)
589 {
590 bool constructorAdded = false;
591 try
592 {
593 symbolTable.BeginConstructor(constructorNode, functionIndex++);
594 ++level;
595 constructorAdded = true;
596 int ni = constructorNode.Initializers().Count();
597 for (int i = 0; i < ni; ++i)
598 {
599 constructorNode.Initializers()[i]->Accept(*this);
600 }
601 if (constructorNode.WhereConstraint())
602 {
603 constructorNode.WhereConstraint()->Accept(*this);
604 }
605 int n = constructorNode.Parameters().Count();
606 for (int i = 0; i < n; ++i)
607 {
608 ParameterNode* parameterNode = constructorNode.Parameters()[i];
609 parameterNode->Accept(*this);
610 }
611 if (constructorNode.Body())
612 {
613 InsertTracer(constructorNode.Body());
614 constructorNode.Body()->Accept(*this);
615 }
616 symbolTable.SetCursorContainer(constructorNode);
617 --level;
618 symbolTable.EndConstructor(!leaveFunction);
619 }
620 catch (const Exception& ex;)
621 {
622 if (editMode)
623 {
624 if (constructorAdded)
625 {
626 --level;
627 symbolTable.EndConstructor(!leaveFunction);
628 }
629 errors.push_back(ex.Message());
630 }
631 else
632 {
633 throw ;
634 }
635 }
636 catch (const std::exception& ex;)
637 {
638 if (editMode)
639 {
640 if (constructorAdded)
641 {
642 --level;
643 symbolTable.EndConstructor(!leaveFunction);
644 }
645 errors.push_back(ex.what());
646 }
647 else
648 {
649 throw ;
650 }
651 }
652 }
653
654 void SymbolCreatorVisitor::Visit(DestructorNode& destructorNode)
655 {
656 bool destructorAdded = false;
657 try
658 {
659 symbolTable.BeginDestructor(destructorNode, functionIndex++);
660 ++level;
661 destructorAdded = true;
662 if (destructorNode.Body())
663 {
664 InsertTracer(destructorNode.Body());
665 destructorNode.Body()->Accept(*this);
666 }
667 --level;
668 symbolTable.SetCursorContainer(destructorNode);
669 symbolTable.EndDestructor(!leaveFunction);
670 }
671 catch (const Exception& ex;)
672 {
673 if (editMode)
674 {
675 if (destructorAdded)
676 {
677 --level;
678 symbolTable.EndDestructor(!leaveFunction);
679 }
680 errors.push_back(ex.Message());
681 }
682 else
683 {
684 throw ;
685 }
686 }
687 catch (const std::exception& ex;)
688 {
689 if (editMode)
690 {
691 if (destructorAdded)
692 {
693 --level;
694 symbolTable.EndDestructor(!leaveFunction);
695 }
696 errors.push_back(ex.what());
697 }
698 else
699 {
700 throw ;
701 }
702 }
703 }
704
705 void SymbolCreatorVisitor::Visit(MemberFunctionNode& memberFunctionNode)
706 {
707 bool memberFunctionAdded = false;
708 try
709 {
710 symbolTable.BeginMemberFunction(memberFunctionNode, functionIndex++);
711 ++level;
712 memberFunctionAdded = true;
713 if (memberFunctionNode.WhereConstraint())
714 {
715 memberFunctionNode.WhereConstraint()->Accept(*this);
716 }
717 if (memberFunctionNode.ReturnTypeExpr())
718 {
719 memberFunctionNode.ReturnTypeExpr()->Accept(*this);
720 }
721 int n = memberFunctionNode.Parameters().Count();
722 for (int i = 0; i < n; ++i)
723 {
724 ParameterNode* parameterNode = memberFunctionNode.Parameters()[i];
725 parameterNode->Accept(*this);
726 }
727 if (memberFunctionNode.Body())
728 {
729 InsertTracer(memberFunctionNode.Body());
730 memberFunctionNode.Body()->Accept(*this);
731 }
732 --level;
733 symbolTable.SetCursorContainer(memberFunctionNode);
734 symbolTable.EndMemberFunction(!leaveFunction);
735 }
736 catch (const Exception& ex;)
737 {
738 if (editMode)
739 {
740 if (memberFunctionAdded)
741 {
742 --level;
743 symbolTable.EndMemberFunction(!leaveFunction);
744 }
745 errors.push_back(ex.Message());
746 }
747 else
748 {
749 throw ;
750 }
751 }
752 catch (const std::exception& ex;)
753 {
754 if (editMode)
755 {
756 if (memberFunctionAdded)
757 {
758 --level;
759 symbolTable.EndMemberFunction(!leaveFunction);
760 }
761 errors.push_back(ex.what());
762 }
763 else
764 {
765 throw ;
766 }
767 }
768 }
769
770 void SymbolCreatorVisitor::Visit(ConversionFunctionNode& conversionFunctionNode)
771 {
772 bool conversionFunctionAdded = false;
773 try
774 {
775 symbolTable.BeginConversionFunction(conversionFunctionNode, functionIndex++);
776 ++level;
777 conversionFunctionAdded = true;
778 if (conversionFunctionNode.WhereConstraint())
779 {
780 conversionFunctionNode.WhereConstraint()->Accept(*this);
781 }
782 if (conversionFunctionNode.ReturnTypeExpr())
783 {
784 conversionFunctionNode.ReturnTypeExpr()->Accept(*this);
785 }
786 if (conversionFunctionNode.Body())
787 {
788 InsertTracer(conversionFunctionNode.Body());
789 conversionFunctionNode.Body()->Accept(*this);
790 }
791 symbolTable.SetCursorContainer(conversionFunctionNode);
792 --level;
793 symbolTable.EndConversionFunction(!leaveFunction);
794 }
795 catch (const Exception& ex;)
796 {
797 if (editMode)
798 {
799 if (conversionFunctionAdded)
800 {
801 --level;
802 symbolTable.EndConversionFunction(!leaveFunction);
803 }
804 errors.push_back(ex.Message());
805 }
806 else
807 {
808 throw ;
809 }
810 }
811 catch (const std::exception& ex;)
812 {
813 if (editMode)
814 {
815 if (conversionFunctionAdded)
816 {
817 --level;
818 symbolTable.EndConversionFunction(!leaveFunction);
819 }
820 errors.push_back(ex.what());
821 }
822 else
823 {
824 throw ;
825 }
826 }
827 }
828
829 void SymbolCreatorVisitor::Visit(MemberVariableNode& memberVariableNode)
830 {
831 try
832 {
833 symbolTable.AddMemberVariable(memberVariableNode);
834 memberVariableNode.TypeExpr()->Accept(*this);
835 memberVariableNode.Id()->Accept(*this);
836 symbolTable.SetCursorContainer(memberVariableNode);
837 }
838 catch (const Exception& ex;)
839 {
840 if (editMode)
841 {
842 errors.push_back(ex.Message());
843 }
844 else
845 {
846 throw ;
847 }
848 }
849 catch (const std::exception& ex;)
850 {
851 if (editMode)
852 {
853 errors.push_back(ex.what());
854 }
855 else
856 {
857 throw ;
858 }
859 }
860 }
861
862 void SymbolCreatorVisitor::Visit(InterfaceNode& interfaceNode)
863 {
864 bool interfaceAdded = false;
865 try
866 {
867 symbolTable.BeginInterface(interfaceNode);
868 ++level;
869 interfaceAdded = true;
870 interfaceNode.Id()->Accept(*this);
871 int n = interfaceNode.Members().Count();
872 for (int i = 0; i < n; ++i)
873 {
874 Node* member = interfaceNode.Members()[i];
875 member->Accept(*this);
876 }
877 --level;
878 symbolTable.SetCursorContainer(interfaceNode);
879 if (level == 0 && source)
880 {
881 source->AddSymbol(symbolTable.CurrentInterface());
882 }
883 symbolTable.EndInterface();
884 }
885 catch (const Exception& ex;)
886 {
887 if (editMode)
888 {
889 if (interfaceAdded)
890 {
891 --level;
892 symbolTable.EndInterface();
893 }
894 errors.push_back(ex.Message());
895 }
896 else
897 {
898 throw ;
899 }
900 }
901 catch (const std::exception& ex;)
902 {
903 if (editMode)
904 {
905 if (interfaceAdded)
906 {
907 --level;
908 symbolTable.EndInterface();
909 }
910 errors.push_back(ex.what());
911 }
912 else
913 {
914 throw ;
915 }
916 }
917 }
918
919 void SymbolCreatorVisitor::Visit(DelegateNode& delegateNode)
920 {
921 bool delegateAdded = false;
922 try
923 {
924 symbolTable.BeginDelegate(delegateNode);
925 ++level;
926 delegateAdded = true;
927 delegateNode.ReturnTypeExpr()->Accept(*this);
928 delegateNode.Id()->Accept(*this);
929 int n = delegateNode.Parameters().Count();
930 for (int i = 0; i < n; ++i)
931 {
932 ParameterNode* parameterNode = delegateNode.Parameters()[i];
933 parameterNode->Accept(*this);
934 }
935 --level;
936 symbolTable.SetCursorContainer(delegateNode);
937 if (level == 0 && source)
938 {
939 source->AddSymbol(symbolTable.Container());
940 }
941 symbolTable.EndDelegate();
942 }
943 catch (const Exception& ex;)
944 {
945 if (editMode)
946 {
947 if (delegateAdded)
948 {
949 --level;
950 symbolTable.EndDelegate();
951 }
952 errors.push_back(ex.Message());
953 }
954 else
955 {
956 throw ;
957 }
958 }
959 catch (const std::exception& ex;)
960 {
961 if (editMode)
962 {
963 if (delegateAdded)
964 {
965 --level;
966 symbolTable.EndDelegate();
967 }
968 errors.push_back(ex.what());
969 }
970 else
971 {
972 throw ;
973 }
974 }
975 }
976
977 void SymbolCreatorVisitor::Visit(ClassDelegateNode& classDelegateNode)
978 {
979 bool classDelegateAdded = false;
980 try
981 {
982 symbolTable.BeginClassDelegate(classDelegateNode);
983 ++level;
984 classDelegateAdded = true;
985 classDelegateNode.ReturnTypeExpr()->Accept(*this);
986 classDelegateNode.Id()->Accept(*this);
987 int n = classDelegateNode.Parameters().Count();
988 for (int i = 0; i < n; ++i)
989 {
990 ParameterNode* parameterNode = classDelegateNode.Parameters()[i];
991 parameterNode->Accept(*this);
992 }
993 --level;
994 symbolTable.SetCursorContainer(classDelegateNode);
995 if (level == 0 && source)
996 {
997 source->AddSymbol(symbolTable.Container());
998 }
999 symbolTable.EndClassDelegate();
1000 }
1001 catch (const Exception& ex;)
1002 {
1003 if (editMode)
1004 {
1005 if (classDelegateAdded)
1006 {
1007 --level;
1008 symbolTable.EndClassDelegate();
1009 }
1010 errors.push_back(ex.Message());
1011 }
1012 else
1013 {
1014 throw ;
1015 }
1016 }
1017 catch (const std::exception& ex;)
1018 {
1019 if (editMode)
1020 {
1021 if (classDelegateAdded)
1022 {
1023 --level;
1024 symbolTable.EndClassDelegate();
1025 }
1026 errors.push_back(ex.what());
1027 }
1028 else
1029 {
1030 throw ;
1031 }
1032 }
1033 }
1034
1035 void SymbolCreatorVisitor::Visit(ParenthesizedConstraintNode& parenthesizedConstraintNode)
1036 {
1037 try
1038 {
1039 parenthesizedConstraintNode.Constraint()->Accept(*this);
1040 symbolTable.SetCursorContainer(parenthesizedConstraintNode);
1041 }
1042 catch (const Exception& ex;)
1043 {
1044 if (editMode)
1045 {
1046 errors.push_back(ex.Message());
1047 }
1048 else
1049 {
1050 throw ;
1051 }
1052 }
1053 catch (const std::exception& ex;)
1054 {
1055 if (editMode)
1056 {
1057 errors.push_back(ex.what());
1058 }
1059 else
1060 {
1061 throw ;
1062 }
1063 }
1064 }
1065
1066 void SymbolCreatorVisitor::Visit(DisjunctiveConstraintNode& disjunctiveConstraintNode)
1067 {
1068 try
1069 {
1070 disjunctiveConstraintNode.Left()->Accept(*this);
1071 disjunctiveConstraintNode.Right()->Accept(*this);
1072 symbolTable.SetCursorContainer(disjunctiveConstraintNode);
1073 }
1074 catch (const Exception& ex;)
1075 {
1076 if (editMode)
1077 {
1078 errors.push_back(ex.Message());
1079 }
1080 else
1081 {
1082 throw ;
1083 }
1084 }
1085 catch (const std::exception& ex;)
1086 {
1087 if (editMode)
1088 {
1089 errors.push_back(ex.what());
1090 }
1091 else
1092 {
1093 throw ;
1094 }
1095 }
1096 }
1097
1098 void SymbolCreatorVisitor::Visit(ConjunctiveConstraintNode& conjunctiveConstraintNode)
1099 {
1100 try
1101 {
1102 conjunctiveConstraintNode.Left()->Accept(*this);
1103 conjunctiveConstraintNode.Right()->Accept(*this);
1104 symbolTable.SetCursorContainer(conjunctiveConstraintNode);
1105 }
1106 catch (const Exception& ex;)
1107 {
1108 if (editMode)
1109 {
1110 errors.push_back(ex.Message());
1111 }
1112 else
1113 {
1114 throw ;
1115 }
1116 }
1117 catch (const std::exception& ex;)
1118 {
1119 if (editMode)
1120 {
1121 errors.push_back(ex.what());
1122 }
1123 else
1124 {
1125 throw ;
1126 }
1127 }
1128 }
1129
1130 void SymbolCreatorVisitor::Visit(WhereConstraintNode& whereConstraintNode)
1131 {
1132 try
1133 {
1134 whereConstraintNode.Constraint()->Accept(*this);
1135 symbolTable.SetCursorContainer(whereConstraintNode);
1136 }
1137 catch (const Exception& ex;)
1138 {
1139 if (editMode)
1140 {
1141 errors.push_back(ex.Message());
1142 }
1143 else
1144 {
1145 throw ;
1146 }
1147 }
1148 catch (const std::exception& ex;)
1149 {
1150 if (editMode)
1151 {
1152 errors.push_back(ex.what());
1153 }
1154 else
1155 {
1156 throw ;
1157 }
1158 }
1159 }
1160
1161 void SymbolCreatorVisitor::Visit(PredicateConstraintNode& predicateConstraintNode)
1162 {
1163 try
1164 {
1165 predicateConstraintNode.InvokeExpr()->Accept(*this);
1166 symbolTable.SetCursorContainer(predicateConstraintNode);
1167 }
1168 catch (const Exception& ex;)
1169 {
1170 if (editMode)
1171 {
1172 errors.push_back(ex.Message());
1173 }
1174 else
1175 {
1176 throw ;
1177 }
1178 }
1179 catch (const std::exception& ex;)
1180 {
1181 if (editMode)
1182 {
1183 errors.push_back(ex.what());
1184 }
1185 else
1186 {
1187 throw ;
1188 }
1189 }
1190 }
1191
1192 void SymbolCreatorVisitor::Visit(IsConstraintNode& isConstraintNode)
1193 {
1194 try
1195 {
1196 isConstraintNode.TypeExpr()->Accept(*this);
1197 isConstraintNode.ConceptOrTypeName()->Accept(*this);
1198 symbolTable.SetCursorContainer(isConstraintNode);
1199 }
1200 catch (const Exception& ex;)
1201 {
1202 if (editMode)
1203 {
1204 errors.push_back(ex.Message());
1205 }
1206 else
1207 {
1208 throw ;
1209 }
1210 }
1211 catch (const std::exception& ex;)
1212 {
1213 if (editMode)
1214 {
1215 errors.push_back(ex.what());
1216 }
1217 else
1218 {
1219 throw ;
1220 }
1221 }
1222 }
1223
1224 void SymbolCreatorVisitor::Visit(MultiParamConstraintNode& multiParamConstraintNode)
1225 {
1226 try
1227 {
1228 multiParamConstraintNode.ConceptId()->Accept(*this);
1229 int n = multiParamConstraintNode.TypeExprs().Count();
1230 for (int i = 0; i < n; ++i)
1231 {
1232 multiParamConstraintNode.TypeExprs()[i]->Accept(*this);
1233 }
1234 symbolTable.SetCursorContainer(multiParamConstraintNode);
1235 }
1236 catch (const Exception& ex;)
1237 {
1238 if (editMode)
1239 {
1240 errors.push_back(ex.Message());
1241 }
1242 else
1243 {
1244 throw ;
1245 }
1246 }
1247 catch (const std::exception& ex;)
1248 {
1249 if (editMode)
1250 {
1251 errors.push_back(ex.what());
1252 }
1253 else
1254 {
1255 throw ;
1256 }
1257 }
1258 }
1259
1260 void SymbolCreatorVisitor::Visit(TypeNameConstraintNode& typeNameConstraintNode)
1261 {
1262 try
1263 {
1264 typeNameConstraintNode.TypeId()->Accept(*this);
1265 symbolTable.SetCursorContainer(typeNameConstraintNode);
1266 }
1267 catch (const Exception& ex;)
1268 {
1269 if (editMode)
1270 {
1271 errors.push_back(ex.Message());
1272 }
1273 else
1274 {
1275 throw ;
1276 }
1277 }
1278 catch (const std::exception& ex;)
1279 {
1280 if (editMode)
1281 {
1282 errors.push_back(ex.what());
1283 }
1284 else
1285 {
1286 throw ;
1287 }
1288 }
1289 }
1290
1291 void SymbolCreatorVisitor::Visit(ConstructorConstraintNode& constructorConstraintNode)
1292 {
1293 try
1294 {
1295 constructorConstraintNode.TypeParamId()->Accept(*this);
1296 int n = constructorConstraintNode.Parameters().Count();
1297 for (int i = 0; i < n; ++i)
1298 {
1299 constructorConstraintNode.Parameters()[i]->Accept(*this);
1300 }
1301 symbolTable.SetCursorContainer(constructorConstraintNode);
1302 }
1303 catch (const Exception& ex;)
1304 {
1305 if (editMode)
1306 {
1307 errors.push_back(ex.Message());
1308 }
1309 else
1310 {
1311 throw ;
1312 }
1313 }
1314 catch (const std::exception& ex;)
1315 {
1316 if (editMode)
1317 {
1318 errors.push_back(ex.what());
1319 }
1320 else
1321 {
1322 throw ;
1323 }
1324 }
1325 }
1326
1327 void SymbolCreatorVisitor::Visit(DestructorConstraintNode& destructorConstraintNode)
1328 {
1329 try
1330 {
1331 destructorConstraintNode.TypeParamId()->Accept(*this);
1332 symbolTable.SetCursorContainer(destructorConstraintNode);
1333 }
1334 catch (const Exception& ex;)
1335 {
1336 if (editMode)
1337 {
1338 errors.push_back(ex.Message());
1339 }
1340 else
1341 {
1342 throw ;
1343 }
1344 }
1345 catch (const std::exception& ex;)
1346 {
1347 if (editMode)
1348 {
1349 errors.push_back(ex.what());
1350 }
1351 else
1352 {
1353 throw ;
1354 }
1355 }
1356 }
1357
1358 void SymbolCreatorVisitor::Visit(MemberFunctionConstraintNode& memberFunctionConstraintNode)
1359 {
1360 try
1361 {
1362 memberFunctionConstraintNode.ReturnTypeExpr()->Accept(*this);
1363 memberFunctionConstraintNode.TypeParamId()->Accept(*this);
1364 int n = memberFunctionConstraintNode.Parameters().Count();
1365 for (int i = 0; i < n; ++i)
1366 {
1367 memberFunctionConstraintNode.Parameters()[i]->Accept(*this);
1368 }
1369 symbolTable.SetCursorContainer(memberFunctionConstraintNode);
1370 }
1371 catch (const Exception& ex;)
1372 {
1373 if (editMode)
1374 {
1375 errors.push_back(ex.Message());
1376 }
1377 else
1378 {
1379 throw ;
1380 }
1381 }
1382 catch (const std::exception& ex;)
1383 {
1384 if (editMode)
1385 {
1386 errors.push_back(ex.what());
1387 }
1388 else
1389 {
1390 throw ;
1391 }
1392 }
1393 }
1394
1395 void SymbolCreatorVisitor::Visit(FunctionConstraintNode& functionConstraintNode)
1396 {
1397 try
1398 {
1399 functionConstraintNode.ReturnTypeExpr()->Accept(*this);
1400 int n = functionConstraintNode.Parameters().Count();
1401 for (int i = 0; i < n; ++i)
1402 {
1403 functionConstraintNode.Parameters()[i]->Accept(*this);
1404 }
1405 symbolTable.SetCursorContainer(functionConstraintNode);
1406 }
1407 catch (const Exception& ex;)
1408 {
1409 if (editMode)
1410 {
1411 errors.push_back(ex.Message());
1412 }
1413 else
1414 {
1415 throw ;
1416 }
1417 }
1418 catch (const std::exception& ex;)
1419 {
1420 if (editMode)
1421 {
1422 errors.push_back(ex.what());
1423 }
1424 else
1425 {
1426 throw ;
1427 }
1428 }
1429 }
1430
1431 void SymbolCreatorVisitor::Visit(AxiomStatementNode& axiomStatementNode)
1432 {
1433 try
1434 {
1435 axiomStatementNode.Expression()->Accept(*this);
1436 symbolTable.SetCursorContainer(axiomStatementNode);
1437 }
1438 catch (const Exception& ex;)
1439 {
1440 if (editMode)
1441 {
1442 errors.push_back(ex.Message());
1443 }
1444 else
1445 {
1446 throw ;
1447 }
1448 }
1449 catch (const std::exception& ex;)
1450 {
1451 if (editMode)
1452 {
1453 errors.push_back(ex.what());
1454 }
1455 else
1456 {
1457 throw ;
1458 }
1459 }
1460 }
1461
1462 void SymbolCreatorVisitor::Visit(AxiomNode& axiomNode)
1463 {
1464 bool axiomAdded = false;
1465 try
1466 {
1467 symbolTable.BeginAxiom(axiomNode);
1468 ++level;
1469 axiomAdded = true;
1470 if (axiomNode.Id())
1471 {
1472 axiomNode.Id()->Accept(*this);
1473 }
1474 int n = axiomNode.Parameters().Count();
1475 for (int i = 0; i < n; ++i)
1476 {
1477 axiomNode.Parameters()[i]->Accept(*this);
1478 }
1479 int ns = axiomNode.Statements().Count();
1480 for (int i = 0; i < ns; ++i)
1481 {
1482 axiomNode.Statements()[i]->Accept(*this);
1483 }
1484 --level;
1485 symbolTable.SetCursorContainer(axiomNode);
1486 symbolTable.EndAxiom();
1487 }
1488 catch (const Exception& ex;)
1489 {
1490 if (editMode)
1491 {
1492 if (axiomAdded)
1493 {
1494 --level;
1495 symbolTable.EndAxiom();
1496 }
1497 errors.push_back(ex.Message());
1498 }
1499 else
1500 {
1501 throw ;
1502 }
1503 }
1504 catch (const std::exception& ex;)
1505 {
1506 if (editMode)
1507 {
1508 if (axiomAdded)
1509 {
1510 --level;
1511 symbolTable.EndAxiom();
1512 }
1513 errors.push_back(ex.what());
1514 }
1515 else
1516 {
1517 throw ;
1518 }
1519 }
1520 }
1521
1522 void SymbolCreatorVisitor::Visit(ConceptIdNode& conceptIdNode)
1523 {
1524 try
1525 {
1526 conceptIdNode.Id()->Accept(*this);
1527 int n = conceptIdNode.TypeParameters().Count();
1528 for (int i = 0; i < n; ++i)
1529 {
1530 conceptIdNode.TypeParameters()[i]->Accept(*this);
1531 }
1532 symbolTable.SetCursorContainer(conceptIdNode);
1533 }
1534 catch (const Exception& ex;)
1535 {
1536 if (editMode)
1537 {
1538 errors.push_back(ex.Message());
1539 }
1540 else
1541 {
1542 throw ;
1543 }
1544 }
1545 catch (const std::exception& ex;)
1546 {
1547 if (editMode)
1548 {
1549 errors.push_back(ex.what());
1550 }
1551 else
1552 {
1553 throw ;
1554 }
1555 }
1556 }
1557
1558 void SymbolCreatorVisitor::Visit(SameConstraintNode& sameConstraintNode)
1559 {
1560 symbolTable.SetCursorContainer(sameConstraintNode);
1561 }
1562
1563 void SymbolCreatorVisitor::Visit(DerivedConstraintNode& derivedConstraintNode)
1564 {
1565 symbolTable.SetCursorContainer(derivedConstraintNode);
1566 }
1567
1568 void SymbolCreatorVisitor::Visit(ConvertibleConstraintNode& convertibleConstraintNode)
1569 {
1570 symbolTable.SetCursorContainer(convertibleConstraintNode);
1571 }
1572
1573 void SymbolCreatorVisitor::Visit(ExplicitlyConvertibleConstraintNode& explicitlyConvertibleConstraintNode)
1574 {
1575 symbolTable.SetCursorContainer(explicitlyConvertibleConstraintNode);
1576 }
1577
1578 void SymbolCreatorVisitor::Visit(CommonConstraintNode& commonConstraintNode)
1579 {
1580 symbolTable.SetCursorContainer(commonConstraintNode);
1581 }
1582
1583 void SymbolCreatorVisitor::Visit(NonreferenceTypeConstraintNode& nonreferenceTypeConstraintNode)
1584 {
1585 symbolTable.SetCursorContainer(nonreferenceTypeConstraintNode);
1586 }
1587
1588 void SymbolCreatorVisitor::Visit(ConceptNode& conceptNode)
1589 {
1590 bool conceptAdded = false;
1591 try
1592 {
1593 symbolTable.BeginConcept(conceptNode, true);
1594 ++level;
1595 conceptAdded = true;
1596 conceptNode.Id()->Accept(*this);
1597 int n = conceptNode.TypeParameters().Count();
1598 for (int i = 0; i < n; ++i)
1599 {
1600 IdentifierNode* identifierNode = conceptNode.TypeParameters()[i];
1601 symbolTable.AddTemplateParameter(*identifierNode);
1602 }
1603 if (conceptNode.Refinement())
1604 {
1605 conceptNode.Refinement()->Accept(*this);
1606 }
1607 int nc = conceptNode.Constraints().Count();
1608 for (int i = 0; i < nc; ++i)
1609 {
1610 conceptNode.Constraints()[i]->Accept(*this);
1611 }
1612 int na = conceptNode.Axioms().Count();
1613 for (int i = 0; i < na; ++i)
1614 {
1615 conceptNode.Axioms()[i]->Accept(*this);
1616 }
1617 --level;
1618 symbolTable.SetCursorContainer(conceptNode);
1619 if (level == 0 && source)
1620 {
1621 source->AddSymbol(symbolTable.Container());
1622 }
1623 symbolTable.EndConcept();
1624 }
1625 catch (const Exception& ex;)
1626 {
1627 if (editMode)
1628 {
1629 if (conceptAdded)
1630 {
1631 --level;
1632 symbolTable.EndConcept();
1633 }
1634 errors.push_back(ex.Message());
1635 }
1636 else
1637 {
1638 throw ;
1639 }
1640 }
1641 catch (const std::exception& ex;)
1642 {
1643 if (editMode)
1644 {
1645 if (conceptAdded)
1646 {
1647 --level;
1648 symbolTable.EndConcept();
1649 }
1650 errors.push_back(ex.what());
1651 }
1652 else
1653 {
1654 throw ;
1655 }
1656 }
1657 }
1658
1659 void SymbolCreatorVisitor::Visit(LabelNode& labelNode)
1660 {
1661 symbolTable.SetCursorContainer(labelNode);
1662 }
1663
1664 void SymbolCreatorVisitor::Visit(LabeledStatementNode& labeledStatementNode)
1665 {
1666 labeledStatementNode.Label()->Accept(*this);
1667 symbolTable.SetCursorContainer(labeledStatementNode);
1668 }
1669
1670 void SymbolCreatorVisitor::Visit(CompoundStatementNode& compoundStatementNode)
1671 {
1672 bool declarationBlockAdded = false;
1673 try
1674 {
1675 symbolTable.BeginDeclarationBlock(compoundStatementNode);
1676 ++level;
1677 declarationBlockAdded = true;
1678 int n = compoundStatementNode.Statements().Count();
1679 for (int i = 0; i < n; ++i)
1680 {
1681 StatementNode* statement = compoundStatementNode.Statements()[i];
1682 statement->Accept(*this);
1683 }
1684 --level;
1685 symbolTable.SetCursorContainer(compoundStatementNode);
1686 symbolTable.EndDeclarationBlock();
1687 }
1688 catch (const Exception& ex;)
1689 {
1690 if (editMode)
1691 {
1692 if (declarationBlockAdded)
1693 {
1694 --level;
1695 symbolTable.EndDeclarationBlock();
1696 }
1697 errors.push_back(ex.Message());
1698 }
1699 else
1700 {
1701 throw ;
1702 }
1703 }
1704 catch (const std::exception& ex;)
1705 {
1706 if (editMode)
1707 {
1708 if (declarationBlockAdded)
1709 {
1710 --level;
1711 symbolTable.EndDeclarationBlock();
1712 }
1713 errors.push_back(ex.what());
1714 }
1715 else
1716 {
1717 throw ;
1718 }
1719 }
1720 }
1721
1722 void SymbolCreatorVisitor::Visit(ReturnStatementNode& returnStatementNode)
1723 {
1724 try
1725 {
1726 if (returnStatementNode.Expression())
1727 {
1728 returnStatementNode.Expression()->Accept(*this);
1729 }
1730 symbolTable.SetCursorContainer(returnStatementNode);
1731 }
1732 catch (const Exception& ex;)
1733 {
1734 if (editMode)
1735 {
1736 errors.push_back(ex.Message());
1737 }
1738 else
1739 {
1740 throw ;
1741 }
1742 }
1743 catch (const std::exception& ex;)
1744 {
1745 if (editMode)
1746 {
1747 errors.push_back(ex.what());
1748 }
1749 else
1750 {
1751 throw ;
1752 }
1753 }
1754 }
1755
1756 void SymbolCreatorVisitor::Visit(IfStatementNode& ifStatementNode)
1757 {
1758 try
1759 {
1760 ifStatementNode.Condition()->Accept(*this);
1761 ifStatementNode.ThenS()->Accept(*this);
1762 if (ifStatementNode.ElseS())
1763 {
1764 ifStatementNode.ElseS()->Accept(*this);
1765 }
1766 }
1767 catch (const Exception& ex;)
1768 {
1769 if (editMode)
1770 {
1771 errors.push_back(ex.Message());
1772 }
1773 else
1774 {
1775 throw ;
1776 }
1777 }
1778 catch (const std::exception& ex;)
1779 {
1780 if (editMode)
1781 {
1782 errors.push_back(ex.what());
1783 }
1784 else
1785 {
1786 throw ;
1787 }
1788 }
1789 }
1790
1791 void SymbolCreatorVisitor::Visit(WhileStatementNode& whileStatementNode)
1792 {
1793 try
1794 {
1795 whileStatementNode.Condition()->Accept(*this);
1796 whileStatementNode.Statement()->Accept(*this);
1797 }
1798 catch (const Exception& ex;)
1799 {
1800 if (editMode)
1801 {
1802 errors.push_back(ex.Message());
1803 }
1804 else
1805 {
1806 throw ;
1807 }
1808 }
1809 catch (const std::exception& ex;)
1810 {
1811 if (editMode)
1812 {
1813 errors.push_back(ex.what());
1814 }
1815 else
1816 {
1817 throw ;
1818 }
1819 }
1820 }
1821
1822 void SymbolCreatorVisitor::Visit(DoStatementNode& doStatementNode)
1823 {
1824 try
1825 {
1826 doStatementNode.Statement()->Accept(*this);
1827 if (doStatementNode.Condition())
1828 {
1829 doStatementNode.Condition()->Accept(*this);
1830 }
1831 else
1832 {
1833 throw Exception("condition expected", doStatementNode.GetSpan(), doStatementNode.ModuleId());
1834 }
1835 }
1836 catch (const Exception& ex;)
1837 {
1838 if (editMode)
1839 {
1840 errors.push_back(ex.Message());
1841 }
1842 else
1843 {
1844 throw ;
1845 }
1846 }
1847 catch (const std::exception& ex;)
1848 {
1849 if (editMode)
1850 {
1851 errors.push_back(ex.what());
1852 }
1853 else
1854 {
1855 throw ;
1856 }
1857 }
1858 }
1859
1860 void SymbolCreatorVisitor::Visit(ForStatementNode& forStatementNode)
1861 {
1862 bool declarationBlockAdded = false;
1863 try
1864 {
1865 symbolTable.BeginDeclarationBlock(forStatementNode);
1866 ++level;
1867 declarationBlockAdded = true;
1868 forStatementNode.InitS()->Accept(*this);
1869 if (forStatementNode.Condition())
1870 {
1871 forStatementNode.Condition()->Accept(*this);
1872 }
1873 else
1874 {
1875 throw Exception("condition expected", forStatementNode.GetSpan(), forStatementNode.ModuleId());
1876 }
1877 if (forStatementNode.LoopS())
1878 {
1879 forStatementNode.LoopS()->Accept(*this);
1880 }
1881 else
1882 {
1883 throw Exception("loop expression expected", forStatementNode.GetSpan(), forStatementNode.ModuleId());
1884 }
1885 if (forStatementNode.ActionS())
1886 {
1887 forStatementNode.ActionS()->Accept(*this);
1888 }
1889 else
1890 {
1891 throw Exception("action expected", forStatementNode.GetSpan(), forStatementNode.ModuleId());
1892 }
1893 --level;
1894 symbolTable.EndDeclarationBlock();
1895 }
1896 catch (const Exception& ex;)
1897 {
1898 if (editMode)
1899 {
1900 if (declarationBlockAdded)
1901 {
1902 --level;
1903 symbolTable.EndDeclarationBlock();
1904 }
1905 errors.push_back(ex.Message());
1906 }
1907 else
1908 {
1909 throw ;
1910 }
1911 }
1912 catch (const std::exception& ex;)
1913 {
1914 if (editMode)
1915 {
1916 if (declarationBlockAdded)
1917 {
1918 --level;
1919 symbolTable.EndDeclarationBlock();
1920 }
1921 errors.push_back(ex.what());
1922 }
1923 else
1924 {
1925 throw ;
1926 }
1927 }
1928 }
1929
1930 void SymbolCreatorVisitor::Visit(BreakStatementNode& breakStatementNode)
1931 {
1932 symbolTable.SetCursorContainer(breakStatementNode);
1933 }
1934
1935 void SymbolCreatorVisitor::Visit(ContinueStatementNode& continueStatementNode)
1936 {
1937 symbolTable.SetCursorContainer(continueStatementNode);
1938 }
1939
1940 void SymbolCreatorVisitor::Visit(GotoStatementNode& gotoStatementNode)
1941 {
1942 symbolTable.SetCursorContainer(gotoStatementNode);
1943 }
1944
1945 void SymbolCreatorVisitor::Visit(ConstructionStatementNode& constructionStatementNode)
1946 {
1947 try
1948 {
1949 symbolTable.AddLocalVariable(constructionStatementNode);
1950 constructionStatementNode.TypeExpr()->Accept(*this);
1951 if (constructionStatementNode.Id())
1952 {
1953 constructionStatementNode.Id()->Accept(*this);
1954 }
1955 else
1956 {
1957 throw Exception("identifier expected", constructionStatementNode.GetSpan(), constructionStatementNode.ModuleId());
1958 }
1959 int n = constructionStatementNode.Arguments().Count();
1960 for (int i = 0; i < n; ++i)
1961 {
1962 constructionStatementNode.Arguments()[i]->Accept(*this);
1963 }
1964 symbolTable.SetCursorContainer(constructionStatementNode);
1965 }
1966 catch (const Exception& ex;)
1967 {
1968 if (editMode)
1969 {
1970 errors.push_back(ex.Message());
1971 }
1972 else
1973 {
1974 throw ;
1975 }
1976 }
1977 catch (const std::exception& ex;)
1978 {
1979 if (editMode)
1980 {
1981 errors.push_back(ex.what());
1982 }
1983 else
1984 {
1985 throw ;
1986 }
1987 }
1988
1989 }
1990
1991 void SymbolCreatorVisitor::Visit(DeleteStatementNode& deleteStatementNode)
1992 {
1993 try
1994 {
1995 deleteStatementNode.Expression()->Accept(*this);
1996 symbolTable.SetCursorContainer(deleteStatementNode);
1997 }
1998 catch (const Exception& ex;)
1999 {
2000 if (editMode)
2001 {
2002 errors.push_back(ex.Message());
2003 }
2004 else
2005 {
2006 throw ;
2007 }
2008 }
2009 catch (const std::exception& ex;)
2010 {
2011 if (editMode)
2012 {
2013 errors.push_back(ex.what());
2014 }
2015 else
2016 {
2017 throw ;
2018 }
2019 }
2020 }
2021
2022 void SymbolCreatorVisitor::Visit(DestroyStatementNode& destroyStatementNode)
2023 {
2024 try
2025 {
2026 destroyStatementNode.Expression()->Accept(*this);
2027 symbolTable.SetCursorContainer(destroyStatementNode);
2028 }
2029 catch (const Exception& ex;)
2030 {
2031 if (editMode)
2032 {
2033 errors.push_back(ex.Message());
2034 }
2035 else
2036 {
2037 throw ;
2038 }
2039 }
2040 catch (const std::exception& ex;)
2041 {
2042 if (editMode)
2043 {
2044 errors.push_back(ex.what());
2045 }
2046 else
2047 {
2048 throw ;
2049 }
2050 }
2051 }
2052
2053 void SymbolCreatorVisitor::Visit(AssignmentStatementNode& assignmentStatementNode)
2054 {
2055 try
2056 {
2057 assignmentStatementNode.TargetExpr()->Accept(*this);
2058 assignmentStatementNode.SourceExpr()->Accept(*this);
2059 symbolTable.SetCursorContainer(assignmentStatementNode);
2060 }
2061 catch (const Exception& ex;)
2062 {
2063 if (editMode)
2064 {
2065 errors.push_back(ex.Message());
2066 }
2067 else
2068 {
2069 throw ;
2070 }
2071 }
2072 catch (const std::exception& ex;)
2073 {
2074 if (editMode)
2075 {
2076 errors.push_back(ex.what());
2077 }
2078 else
2079 {
2080 throw ;
2081 }
2082 }
2083 }
2084
2085 void SymbolCreatorVisitor::Visit(ExpressionStatementNode& expressionStatementNode)
2086 {
2087 try
2088 {
2089 expressionStatementNode.Expression()->Accept(*this);
2090 symbolTable.SetCursorContainer(expressionStatementNode);
2091 }
2092 catch (const Exception& ex;)
2093 {
2094 if (editMode)
2095 {
2096 errors.push_back(ex.Message());
2097 }
2098 else
2099 {
2100 throw ;
2101 }
2102 }
2103 catch (const std::exception& ex;)
2104 {
2105 if (editMode)
2106 {
2107 errors.push_back(ex.what());
2108 }
2109 else
2110 {
2111 throw ;
2112 }
2113 }
2114 }
2115
2116 void SymbolCreatorVisitor::Visit(EmptyStatementNode& emptyStatementNode)
2117 {
2118 symbolTable.SetCursorContainer(emptyStatementNode);
2119 }
2120
2121 void SymbolCreatorVisitor::Visit(RangeForStatementNode& rangeForStatementNode)
2122 {
2123 try
2124 {
2125 if (editMode)
2126 {
2127 rangeForStatementNode.TypeExpr()->Accept(*this);
2128 rangeForStatementNode.Id()->Accept(*this);
2129 rangeForStatementNode.Container()->Accept(*this);
2130 rangeForStatementNode.Action()->Accept(*this);
2131 symbolTable.SetCursorContainer(rangeForStatementNode);
2132 }
2133 }
2134 catch (const Exception& ex;)
2135 {
2136 if (editMode)
2137 {
2138 errors.push_back(ex.Message());
2139 }
2140 else
2141 {
2142 throw ;
2143 }
2144 }
2145 catch (const std::exception& ex;)
2146 {
2147 if (editMode)
2148 {
2149 errors.push_back(ex.what());
2150 }
2151 else
2152 {
2153 throw ;
2154 }
2155 }
2156 }
2157
2158 void SymbolCreatorVisitor::Visit(SwitchStatementNode& switchStatementNode)
2159 {
2160 try
2161 {
2162 switchStatementNode.Condition()->Accept(*this);
2163 int n = switchStatementNode.Cases().Count();
2164 for (int i = 0; i < n; ++i)
2165 {
2166 CaseStatementNode* caseStatementNode = switchStatementNode.Cases()[i];
2167 caseStatementNode->Accept(*this);
2168 }
2169 if (switchStatementNode.Default())
2170 {
2171 switchStatementNode.Default()->Accept(*this);
2172 }
2173 symbolTable.SetCursorContainer(switchStatementNode);
2174 }
2175 catch (const Exception& ex;)
2176 {
2177 if (editMode)
2178 {
2179 errors.push_back(ex.Message());
2180 }
2181 else
2182 {
2183 throw ;
2184 }
2185 }
2186 catch (const std::exception& ex;)
2187 {
2188 if (editMode)
2189 {
2190 errors.push_back(ex.what());
2191 }
2192 else
2193 {
2194 throw ;
2195 }
2196 }
2197 }
2198
2199 void SymbolCreatorVisitor::Visit(CaseStatementNode& caseStatementNode)
2200 {
2201 try
2202 {
2203 int nc = caseStatementNode.CaseExprs().Count();
2204 for (int i = 0; i < nc; ++i)
2205 {
2206 caseStatementNode.CaseExprs()[i]->Accept(*this);
2207 }
2208 int n = caseStatementNode.Statements().Count();
2209 for (int i = 0; i < n; ++i)
2210 {
2211 StatementNode* statementNode = caseStatementNode.Statements()[i];
2212 statementNode->Accept(*this);
2213 }
2214 symbolTable.SetCursorContainer(caseStatementNode);
2215 }
2216 catch (const Exception& ex;)
2217 {
2218 if (editMode)
2219 {
2220 errors.push_back(ex.Message());
2221 }
2222 else
2223 {
2224 throw ;
2225 }
2226 }
2227 catch (const std::exception& ex;)
2228 {
2229 if (editMode)
2230 {
2231 errors.push_back(ex.what());
2232 }
2233 else
2234 {
2235 throw ;
2236 }
2237 }
2238 }
2239
2240 void SymbolCreatorVisitor::Visit(DefaultStatementNode& defaultStatementNode)
2241 {
2242 try
2243 {
2244 int n = defaultStatementNode.Statements().Count();
2245 for (int i = 0; i < n; ++i)
2246 {
2247 StatementNode* statementNode = defaultStatementNode.Statements()[i];
2248 statementNode->Accept(*this);
2249 }
2250 symbolTable.SetCursorContainer(defaultStatementNode);
2251 }
2252 catch (const Exception& ex;)
2253 {
2254 if (editMode)
2255 {
2256 errors.push_back(ex.Message());
2257 }
2258 else
2259 {
2260 throw ;
2261 }
2262 }
2263 catch (const std::exception& ex;)
2264 {
2265 if (editMode)
2266 {
2267 errors.push_back(ex.what());
2268 }
2269 else
2270 {
2271 throw ;
2272 }
2273 }
2274 }
2275
2276 void SymbolCreatorVisitor::Visit(GotoCaseStatementNode& gotoCaseStatementNode)
2277 {
2278 symbolTable.SetCursorContainer(gotoCaseStatementNode);
2279 }
2280
2281 void SymbolCreatorVisitor::Visit(GotoDefaultStatementNode& gotoDefaultStatementNode)
2282 {
2283 symbolTable.SetCursorContainer(gotoDefaultStatementNode);
2284 }
2285
2286 void SymbolCreatorVisitor::Visit(ThrowStatementNode& throwStatementNode)
2287 {
2288 symbolTable.SetCursorContainer(throwStatementNode);
2289 }
2290
2291 void SymbolCreatorVisitor::Visit(TryStatementNode& tryStatementNode)
2292 {
2293 try
2294 {
2295 tryStatementNode.TryBlock()->Accept(*this);
2296 int n = tryStatementNode.Catches().Count();
2297 for (int i = 0; i < n; ++i)
2298 {
2299 CatchNode* catchNode = tryStatementNode.Catches()[i];
2300 catchNode->Accept(*this);
2301 }
2302 symbolTable.SetCursorContainer(tryStatementNode);
2303 }
2304 catch (const Exception& ex;)
2305 {
2306 if (editMode)
2307 {
2308 errors.push_back(ex.Message());
2309 }
2310 else
2311 {
2312 throw ;
2313 }
2314 }
2315 catch (const std::exception& ex;)
2316 {
2317 if (editMode)
2318 {
2319 errors.push_back(ex.what());
2320 }
2321 else
2322 {
2323 throw ;
2324 }
2325 }
2326 }
2327
2328 void SymbolCreatorVisitor::Visit(CatchNode& catchNode)
2329 {
2330 try
2331 {
2332 symbolTable.BeginDeclarationBlock(catchNode);
2333 if (catchNode.Id())
2334 {
2335 symbolTable.AddLocalVariable(*catchNode.Id());
2336 }
2337 catchNode.CatchBlock()->Accept(*this);
2338 symbolTable.EndDeclarationBlock();
2339 }
2340 catch (const Exception& ex;)
2341 {
2342 if (editMode)
2343 {
2344 symbolTable.EndDeclarationBlock();
2345 errors.push_back(ex.Message());
2346 }
2347 else
2348 {
2349 throw ;
2350 }
2351 }
2352 catch (const std::exception& ex;)
2353 {
2354 if (editMode)
2355 {
2356 errors.push_back(ex.what());
2357 }
2358 else
2359 {
2360 throw ;
2361 }
2362 }
2363 }
2364
2365 void SymbolCreatorVisitor::Visit(AssertStatementNode& assertStatementNode)
2366 {
2367 try
2368 {
2369 assertStatementNode.AssertExpr()->Accept(*this);
2370 symbolTable.SetCursorContainer(assertStatementNode);
2371 }
2372 catch (const Exception& ex;)
2373 {
2374 if (editMode)
2375 {
2376 errors.push_back(ex.Message());
2377 }
2378 else
2379 {
2380 throw ;
2381 }
2382 }
2383 catch (const std::exception& ex;)
2384 {
2385 if (editMode)
2386 {
2387 errors.push_back(ex.what());
2388 }
2389 else
2390 {
2391 throw ;
2392 }
2393 }
2394 }
2395
2396 void SymbolCreatorVisitor::Visit(ConditionalCompilationPartNode& conditionalCompilationPartNode)
2397 {
2398 try
2399 {
2400 conditionalCompilationPartNode.Expr()->Accept(*this);
2401 symbolTable.SetCursorContainer(conditionalCompilationPartNode);
2402 }
2403 catch (const Exception& ex;)
2404 {
2405 if (editMode)
2406 {
2407 errors.push_back(ex.Message());
2408 }
2409 else
2410 {
2411 throw ;
2412 }
2413 }
2414 catch (const std::exception& ex;)
2415 {
2416 if (editMode)
2417 {
2418 errors.push_back(ex.what());
2419 }
2420 else
2421 {
2422 throw ;
2423 }
2424 }
2425 }
2426
2427 void SymbolCreatorVisitor::Visit(ConditionalCompilationDisjunctionNode& conditionalCompilationDisjunctionNode)
2428 {
2429 try
2430 {
2431 conditionalCompilationDisjunctionNode.Left()->Accept(*this);
2432 bool left = conditionalCompilationStack.top();
2433 conditionalCompilationStack.pop();
2434 conditionalCompilationDisjunctionNode.Right()->Accept(*this);
2435 bool right = conditionalCompilationStack.top();
2436 conditionalCompilationStack.pop();
2437 conditionalCompilationStack.push(left || right);
2438 symbolTable.SetCursorContainer(conditionalCompilationDisjunctionNode);
2439 }
2440 catch (const Exception& ex;)
2441 {
2442 if (editMode)
2443 {
2444 errors.push_back(ex.Message());
2445 }
2446 else
2447 {
2448 throw ;
2449 }
2450 }
2451 catch (const std::exception& ex;)
2452 {
2453 if (editMode)
2454 {
2455 errors.push_back(ex.what());
2456 }
2457 else
2458 {
2459 throw ;
2460 }
2461 }
2462 }
2463
2464 void SymbolCreatorVisitor::Visit(ConditionalCompilationConjunctionNode& conditionalCompilationConjunctionNode)
2465 {
2466 try
2467 {
2468 conditionalCompilationConjunctionNode.Left()->Accept(*this);
2469 bool left = conditionalCompilationStack.top();
2470 conditionalCompilationStack.pop();
2471 conditionalCompilationConjunctionNode.Right()->Accept(*this);
2472 bool right = conditionalCompilationStack.top();
2473 conditionalCompilationStack.pop();
2474 conditionalCompilationStack.push(left && right);
2475 symbolTable.SetCursorContainer(conditionalCompilationConjunctionNode);
2476 }
2477 catch (const Exception& ex;)
2478 {
2479 if (editMode)
2480 {
2481 errors.push_back(ex.Message());
2482 }
2483 else
2484 {
2485 throw ;
2486 }
2487 }
2488 catch (const std::exception& ex;)
2489 {
2490 if (editMode)
2491 {
2492 errors.push_back(ex.what());
2493 }
2494 else
2495 {
2496 throw ;
2497 }
2498 }
2499 }
2500
2501 void SymbolCreatorVisitor::Visit(ConditionalCompilationNotNode& conditionalCompilationNotNode)
2502 {
2503 try
2504 {
2505 conditionalCompilationNotNode.Expr()->Accept(*this);
2506 bool operand = conditionalCompilationStack.top();
2507 conditionalCompilationStack.pop();
2508 conditionalCompilationStack.push(!operand);
2509 symbolTable.SetCursorContainer(conditionalCompilationNotNode);
2510 }
2511 catch (const Exception& ex;)
2512 {
2513 if (editMode)
2514 {
2515 errors.push_back(ex.Message());
2516 }
2517 else
2518 {
2519 throw ;
2520 }
2521 }
2522 catch (const std::exception& ex;)
2523 {
2524 if (editMode)
2525 {
2526 errors.push_back(ex.what());
2527 }
2528 else
2529 {
2530 throw ;
2531 }
2532 }
2533 }
2534
2535 void SymbolCreatorVisitor::Visit(ConditionalCompilationPrimaryNode& conditionalCompilationPrimaryNode)
2536 {
2537 try
2538 {
2539 bool defined = symbolTable.GetModule()->IsSymbolDefined(conditionalCompilationPrimaryNode.Symbol());
2540 conditionalCompilationStack.push(defined);
2541 symbolTable.SetCursorContainer(conditionalCompilationPrimaryNode);
2542 }
2543 catch (const Exception& ex;)
2544 {
2545 if (editMode)
2546 {
2547 errors.push_back(ex.Message());
2548 }
2549 else
2550 {
2551 throw ;
2552 }
2553 }
2554 catch (const std::exception& ex;)
2555 {
2556 if (editMode)
2557 {
2558 errors.push_back(ex.what());
2559 }
2560 else
2561 {
2562 throw ;
2563 }
2564 }
2565 }
2566
2567 void SymbolCreatorVisitor::Visit(ConditionalCompilationStatementNode& conditionalCompilationStatementNode)
2568 {
2569 try
2570 {
2571 conditionalCompilationStatementNode.IfPart()->Accept(*this);
2572 bool defined = conditionalCompilationStack.top();
2573 conditionalCompilationStack.pop();
2574 if (defined)
2575 {
2576 int n = conditionalCompilationStatementNode.IfPart()->Statements().Count();
2577 for (int i = 0; i < n; ++i)
2578 {
2579 StatementNode* statement = conditionalCompilationStatementNode.IfPart()->Statements()[i];
2580 statement->Accept(*this);
2581 }
2582 }
2583 else
2584 {
2585 bool executed = false;
2586 int n = conditionalCompilationStatementNode.ElifParts().Count();
2587 for (int i = 0; i < n; ++i)
2588 {
2589 ConditionalCompilationPartNode* elifPart = conditionalCompilationStatementNode.ElifParts()[i];
2590 elifPart->Accept(*this);
2591 bool defined = conditionalCompilationStack.top();
2592 conditionalCompilationStack.pop();
2593 if (defined)
2594 {
2595 int n = elifPart->Statements().Count();
2596 for (int i = 0; i < n; ++i)
2597 {
2598 StatementNode* statement = elifPart->Statements()[i];
2599 statement->Accept(*this);
2600 }
2601 executed = true;
2602 break;
2603 }
2604 }
2605 if (!executed)
2606 {
2607 ConditionalCompilationPartNode* elsePart = conditionalCompilationStatementNode.ElsePart();
2608 if (elsePart)
2609 {
2610 int n = elsePart->Statements().Count();
2611 for (int i = 0; i < n; ++i)
2612 {
2613 StatementNode* statement = elsePart->Statements()[i];
2614 statement->Accept(*this);
2615 }
2616 }
2617 }
2618 }
2619 symbolTable.SetCursorContainer(conditionalCompilationStatementNode);
2620 }
2621 catch (const Exception& ex;)
2622 {
2623 if (editMode)
2624 {
2625 errors.push_back(ex.Message());
2626 }
2627 else
2628 {
2629 throw ;
2630 }
2631 }
2632 catch (const std::exception& ex;)
2633 {
2634 if (editMode)
2635 {
2636 errors.push_back(ex.what());
2637 }
2638 else
2639 {
2640 throw ;
2641 }
2642 }
2643 }
2644
2645 void SymbolCreatorVisitor::Visit(TypedefNode& typedefNode)
2646 {
2647 TypedefSymbol* symbol = symbolTable.AddTypedef(typedefNode);
2648 symbolTable.SetCursorContainer(typedefNode);
2649 if (level == 0 && source)
2650 {
2651 source->AddSymbol(symbol);
2652 }
2653 }
2654
2655 void SymbolCreatorVisitor::Visit(ConstantNode& constantNode)
2656 {
2657 ConstantSymbol* symbol = symbolTable.AddConstant(constantNode);
2658 if (level == 0 && source)
2659 {
2660 source->AddSymbol(symbol);
2661 }
2662 symbolTable.SetCursorContainer(constantNode);
2663 }
2664
2665 void SymbolCreatorVisitor::Visit(EnumTypeNode& enumTypeNode)
2666 {
2667 bool enumTypeAdded = false;
2668 try
2669 {
2670 symbolTable.BeginEnumType(enumTypeNode);
2671 ++level;
2672 enumTypeAdded = true;
2673 enumTypeNode.Id()->Accept(*this);
2674 if (enumTypeNode.GetUnderlyingType())
2675 {
2676 enumTypeNode.GetUnderlyingType()->Accept(*this);
2677 }
2678 int n = enumTypeNode.Constants().Count();
2679 for (int i = 0; i < n; ++i)
2680 {
2681 enumTypeNode.Constants()[i]->Accept(*this);
2682 }
2683 --level;
2684 symbolTable.SetCursorContainer(enumTypeNode);
2685 if (level == 0 && source)
2686 {
2687 source->AddSymbol(symbolTable.Container());
2688 }
2689 symbolTable.EndEnumType();
2690 }
2691 catch (const Exception& ex;)
2692 {
2693 if (editMode)
2694 {
2695 if (enumTypeAdded)
2696 {
2697 --level;
2698 symbolTable.EndEnumType();
2699 }
2700 errors.push_back(ex.Message());
2701 }
2702 else
2703 {
2704 throw ;
2705 }
2706 }
2707 catch (const std::exception& ex;)
2708 {
2709 if (editMode)
2710 {
2711 if (enumTypeAdded)
2712 {
2713 --level;
2714 symbolTable.EndEnumType();
2715 }
2716 errors.push_back(ex.what());
2717 }
2718 else
2719 {
2720 throw ;
2721 }
2722 }
2723 }
2724
2725 void SymbolCreatorVisitor::Visit(EnumConstantNode& enumConstantNode)
2726 {
2727 try
2728 {
2729 symbolTable.AddEnumConstant(enumConstantNode);
2730 enumConstantNode.Id()->Accept(*this);
2731 if (enumConstantNode.GetValue())
2732 {
2733 enumConstantNode.GetValue()->Accept(*this);
2734 }
2735 symbolTable.SetCursorContainer(enumConstantNode);
2736 }
2737 catch (const Exception& ex;)
2738 {
2739 if (editMode)
2740 {
2741 errors.push_back(ex.Message());
2742 }
2743 else
2744 {
2745 throw ;
2746 }
2747 }
2748 catch (const std::exception& ex;)
2749 {
2750 if (editMode)
2751 {
2752 errors.push_back(ex.what());
2753 }
2754 else
2755 {
2756 throw ;
2757 }
2758 }
2759 }
2760
2761 void SymbolCreatorVisitor::Visit(GlobalVariableNode& globalVariableNode)
2762 {
2763 try
2764 {
2765 GlobalVariableSymbol* symbol = symbolTable.AddGlobalVariable(globalVariableNode);
2766 if (level == 0 && source)
2767 {
2768 source->AddSymbol(symbol);
2769 }
2770 globalVariableNode.TypeExpr()->Accept(*this);
2771 globalVariableNode.Id()->Accept(*this);
2772 if (globalVariableNode.Initializer())
2773 {
2774 globalVariableNode.Initializer()->Accept(*this);
2775 }
2776 symbolTable.SetCursorContainer(globalVariableNode);
2777 }
2778 catch (const Exception& ex;)
2779 {
2780 if (editMode)
2781 {
2782 errors.push_back(ex.Message());
2783 }
2784 else
2785 {
2786 throw ;
2787 }
2788 }
2789 catch (const std::exception& ex;)
2790 {
2791 if (editMode)
2792 {
2793 errors.push_back(ex.what());
2794 }
2795 else
2796 {
2797 throw ;
2798 }
2799 }
2800 }
2801
2802 void SymbolCreatorVisitor::Visit(ParameterNode& parameterNode)
2803 {
2804 try
2805 {
2806 switch (parameterNode.Parent()->GetNodeType())
2807 {
2808 case NodeType::functionNode:
2809 case NodeType::constructorNode:
2810 case NodeType::memberFunctionNode:
2811 case NodeType::delegateNode:
2812 case NodeType::classDelegateNode:
2813 {
2814 symbolTable.AddParameter(parameterNode);
2815 break;
2816 }
2817 }
2818 parameterNode.TypeExpr()->Accept(*this);
2819 if (parameterNode.Id())
2820 {
2821 parameterNode.Id()->Accept(*this);
2822 }
2823 symbolTable.SetCursorContainer(parameterNode);
2824 }
2825 catch (const Exception& ex;)
2826 {
2827 if (editMode)
2828 {
2829 errors.push_back(ex.Message());
2830 }
2831 else
2832 {
2833 throw ;
2834 }
2835 }
2836 catch (const std::exception& ex;)
2837 {
2838 if (editMode)
2839 {
2840 errors.push_back(ex.what());
2841 }
2842 else
2843 {
2844 throw ;
2845 }
2846 }
2847 }
2848
2849 void SymbolCreatorVisitor::Visit(TemplateParameterNode& templateParameterNode)
2850 {
2851 try
2852 {
2853 templateParameterNode.Id()->Accept(*this);
2854 if (templateParameterNode.DefaultTemplateArgument())
2855 {
2856 templateParameterNode.DefaultTemplateArgument()->Accept(*this);
2857 }
2858 symbolTable.SetCursorContainer(templateParameterNode);
2859 }
2860 catch (const Exception& ex;)
2861 {
2862 if (editMode)
2863 {
2864 errors.push_back(ex.Message());
2865 }
2866 else
2867 {
2868 throw ;
2869 }
2870 }
2871 catch (const std::exception& ex;)
2872 {
2873 if (editMode)
2874 {
2875 errors.push_back(ex.what());
2876 }
2877 else
2878 {
2879 throw ;
2880 }
2881 }
2882 }
2883
2884 void SymbolCreatorVisitor::Visit(ConstNode& constNode)
2885 {
2886 try
2887 {
2888 constNode.Subject()->Accept(*this);
2889 symbolTable.SetCursorContainer(constNode);
2890 }
2891 catch (const Exception& ex;)
2892 {
2893 if (editMode)
2894 {
2895 errors.push_back(ex.Message());
2896 }
2897 else
2898 {
2899 throw ;
2900 }
2901 }
2902 catch (const std::exception& ex;)
2903 {
2904 if (editMode)
2905 {
2906 errors.push_back(ex.what());
2907 }
2908 else
2909 {
2910 throw ;
2911 }
2912 }
2913 }
2914
2915 void SymbolCreatorVisitor::Visit(LValueRefNode& lvalueRefNode)
2916 {
2917 try
2918 {
2919 lvalueRefNode.Subject()->Accept(*this);
2920 symbolTable.SetCursorContainer(lvalueRefNode);
2921 }
2922 catch (const Exception& ex;)
2923 {
2924 if (editMode)
2925 {
2926 errors.push_back(ex.Message());
2927 }
2928 else
2929 {
2930 throw ;
2931 }
2932 }
2933 catch (const std::exception& ex;)
2934 {
2935 if (editMode)
2936 {
2937 errors.push_back(ex.what());
2938 }
2939 else
2940 {
2941 throw ;
2942 }
2943 }
2944 }
2945
2946 void SymbolCreatorVisitor::Visit(RValueRefNode& rvalueRefNode)
2947 {
2948 try
2949 {
2950 rvalueRefNode.Subject()->Accept(*this);
2951 symbolTable.SetCursorContainer(rvalueRefNode);
2952 }
2953 catch (const Exception& ex;)
2954 {
2955 if (editMode)
2956 {
2957 errors.push_back(ex.Message());
2958 }
2959 else
2960 {
2961 throw ;
2962 }
2963 }
2964 catch (const std::exception& ex;)
2965 {
2966 if (editMode)
2967 {
2968 errors.push_back(ex.what());
2969 }
2970 else
2971 {
2972 throw ;
2973 }
2974 }
2975 }
2976
2977 void SymbolCreatorVisitor::Visit(PointerNode& pointerNode)
2978 {
2979 try
2980 {
2981 pointerNode.Subject()->Accept(*this);
2982 symbolTable.SetCursorContainer(pointerNode);
2983 }
2984 catch (const Exception& ex;)
2985 {
2986 if (editMode)
2987 {
2988 errors.push_back(ex.Message());
2989 }
2990 else
2991 {
2992 throw ;
2993 }
2994 }
2995 catch (const std::exception& ex;)
2996 {
2997 if (editMode)
2998 {
2999 errors.push_back(ex.what());
3000 }
3001 else
3002 {
3003 throw ;
3004 }
3005 }
3006 }
3007
3008 void SymbolCreatorVisitor::Visit(ArrayNode& arrayNode)
3009 {
3010 try
3011 {
3012 arrayNode.Subject()->Accept(*this);
3013 if (arrayNode.Size())
3014 {
3015 arrayNode.Size()->Accept(*this);
3016 }
3017 symbolTable.SetCursorContainer(arrayNode);
3018 }
3019 catch (const Exception& ex;)
3020 {
3021 if (editMode)
3022 {
3023 errors.push_back(ex.Message());
3024 }
3025 else
3026 {
3027 throw ;
3028 }
3029 }
3030 catch (const std::exception& ex;)
3031 {
3032 if (editMode)
3033 {
3034 errors.push_back(ex.what());
3035 }
3036 else
3037 {
3038 throw ;
3039 }
3040 }
3041 }
3042
3043 void SymbolCreatorVisitor::Visit(DotNode& dotNode)
3044 {
3045 try
3046 {
3047 dotNode.Subject()->Accept(*this);
3048 dotNode.MemberId()->Accept(*this);
3049 symbolTable.SetCursorContainer(dotNode);
3050 }
3051 catch (const Exception& ex;)
3052 {
3053 if (editMode)
3054 {
3055 errors.push_back(ex.Message());
3056 }
3057 else
3058 {
3059 throw ;
3060 }
3061 }
3062 catch (const std::exception& ex;)
3063 {
3064 if (editMode)
3065 {
3066 errors.push_back(ex.what());
3067 }
3068 else
3069 {
3070 throw ;
3071 }
3072 }
3073 }
3074
3075 void SymbolCreatorVisitor::Visit(ArrowNode& arrowNode)
3076 {
3077 try
3078 {
3079 arrowNode.Subject()->Accept(*this);
3080 arrowNode.MemberId()->Accept(*this);
3081 symbolTable.SetCursorContainer(arrowNode);
3082 }
3083 catch (const Exception& ex;)
3084 {
3085 if (editMode)
3086 {
3087 errors.push_back(ex.Message());
3088 }
3089 else
3090 {
3091 throw ;
3092 }
3093 }
3094 catch (const std::exception& ex;)
3095 {
3096 if (editMode)
3097 {
3098 errors.push_back(ex.what());
3099 }
3100 else
3101 {
3102 throw ;
3103 }
3104 }
3105 }
3106
3107 void SymbolCreatorVisitor::Visit(EquivalenceNode& equivalenceNode)
3108 {
3109 try
3110 {
3111 equivalenceNode.Left()->Accept(*this);
3112 equivalenceNode.Right()->Accept(*this);
3113 symbolTable.SetCursorContainer(equivalenceNode);
3114 }
3115 catch (const Exception& ex;)
3116 {
3117 if (editMode)
3118 {
3119 errors.push_back(ex.Message());
3120 }
3121 else
3122 {
3123 throw ;
3124 }
3125 }
3126 catch (const std::exception& ex;)
3127 {
3128 if (editMode)
3129 {
3130 errors.push_back(ex.what());
3131 }
3132 else
3133 {
3134 throw ;
3135 }
3136 }
3137 }
3138
3139 void SymbolCreatorVisitor::Visit(ImplicationNode& implicationNode)
3140 {
3141 try
3142 {
3143 implicationNode.Left()->Accept(*this);
3144 implicationNode.Right()->Accept(*this);
3145 symbolTable.SetCursorContainer(implicationNode);
3146 }
3147 catch (const Exception& ex;)
3148 {
3149 if (editMode)
3150 {
3151 errors.push_back(ex.Message());
3152 }
3153 else
3154 {
3155 throw ;
3156 }
3157 }
3158 catch (const std::exception& ex;)
3159 {
3160 if (editMode)
3161 {
3162 errors.push_back(ex.what());
3163 }
3164 else
3165 {
3166 throw ;
3167 }
3168 }
3169 }
3170
3171 void SymbolCreatorVisitor::Visit(DisjunctionNode& disjunctionNode)
3172 {
3173 try
3174 {
3175 disjunctionNode.Left()->Accept(*this);
3176 disjunctionNode.Right()->Accept(*this);
3177 symbolTable.SetCursorContainer(disjunctionNode);
3178 }
3179 catch (const Exception& ex;)
3180 {
3181 if (editMode)
3182 {
3183 errors.push_back(ex.Message());
3184 }
3185 else
3186 {
3187 throw ;
3188 }
3189 }
3190 catch (const std::exception& ex;)
3191 {
3192 if (editMode)
3193 {
3194 errors.push_back(ex.what());
3195 }
3196 else
3197 {
3198 throw ;
3199 }
3200 }
3201 }
3202
3203 void SymbolCreatorVisitor::Visit(ConjunctionNode& conjunctionNode)
3204 {
3205 try
3206 {
3207 conjunctionNode.Left()->Accept(*this);
3208 conjunctionNode.Right()->Accept(*this);
3209 symbolTable.SetCursorContainer(conjunctionNode);
3210 }
3211 catch (const Exception& ex;)
3212 {
3213 if (editMode)
3214 {
3215 errors.push_back(ex.Message());
3216 }
3217 else
3218 {
3219 throw ;
3220 }
3221 }
3222 catch (const std::exception& ex;)
3223 {
3224 if (editMode)
3225 {
3226 errors.push_back(ex.what());
3227 }
3228 else
3229 {
3230 throw ;
3231 }
3232 }
3233 }
3234
3235 void SymbolCreatorVisitor::Visit(BitOrNode& bitOrNode)
3236 {
3237 try
3238 {
3239 bitOrNode.Left()->Accept(*this);
3240 bitOrNode.Right()->Accept(*this);
3241 symbolTable.SetCursorContainer(bitOrNode);
3242 }
3243 catch (const Exception& ex;)
3244 {
3245 if (editMode)
3246 {
3247 errors.push_back(ex.Message());
3248 }
3249 else
3250 {
3251 throw ;
3252 }
3253 }
3254 catch (const std::exception& ex;)
3255 {
3256 if (editMode)
3257 {
3258 errors.push_back(ex.what());
3259 }
3260 else
3261 {
3262 throw ;
3263 }
3264 }
3265 }
3266
3267 void SymbolCreatorVisitor::Visit(BitXorNode& bitXorNode)
3268 {
3269 try
3270 {
3271 bitXorNode.Left()->Accept(*this);
3272 bitXorNode.Right()->Accept(*this);
3273 symbolTable.SetCursorContainer(bitXorNode);
3274 }
3275 catch (const Exception& ex;)
3276 {
3277 if (editMode)
3278 {
3279 errors.push_back(ex.Message());
3280 }
3281 else
3282 {
3283 throw ;
3284 }
3285 }
3286 catch (const std::exception& ex;)
3287 {
3288 if (editMode)
3289 {
3290 errors.push_back(ex.what());
3291 }
3292 else
3293 {
3294 throw ;
3295 }
3296 }
3297 }
3298
3299 void SymbolCreatorVisitor::Visit(BitAndNode& bitAndNode)
3300 {
3301 try
3302 {
3303 bitAndNode.Left()->Accept(*this);
3304 bitAndNode.Right()->Accept(*this);
3305 symbolTable.SetCursorContainer(bitAndNode);
3306 }
3307 catch (const Exception& ex;)
3308 {
3309 if (editMode)
3310 {
3311 errors.push_back(ex.Message());
3312 }
3313 else
3314 {
3315 throw ;
3316 }
3317 }
3318 catch (const std::exception& ex;)
3319 {
3320 if (editMode)
3321 {
3322 errors.push_back(ex.what());
3323 }
3324 else
3325 {
3326 throw ;
3327 }
3328 }
3329 }
3330
3331 void SymbolCreatorVisitor::Visit(EqualNode& equalNode)
3332 {
3333 try
3334 {
3335 equalNode.Left()->Accept(*this);
3336 equalNode.Right()->Accept(*this);
3337 symbolTable.SetCursorContainer(equalNode);
3338 }
3339 catch (const Exception& ex;)
3340 {
3341 if (editMode)
3342 {
3343 errors.push_back(ex.Message());
3344 }
3345 else
3346 {
3347 throw ;
3348 }
3349 }
3350 catch (const std::exception& ex;)
3351 {
3352 if (editMode)
3353 {
3354 errors.push_back(ex.what());
3355 }
3356 else
3357 {
3358 throw ;
3359 }
3360 }
3361 }
3362
3363 void SymbolCreatorVisitor::Visit(NotEqualNode& notEqualNode)
3364 {
3365 try
3366 {
3367 notEqualNode.Left()->Accept(*this);
3368 notEqualNode.Right()->Accept(*this);
3369 symbolTable.SetCursorContainer(notEqualNode);
3370 }
3371 catch (const Exception& ex;)
3372 {
3373 if (editMode)
3374 {
3375 errors.push_back(ex.Message());
3376 }
3377 else
3378 {
3379 throw ;
3380 }
3381 }
3382 catch (const std::exception& ex;)
3383 {
3384 if (editMode)
3385 {
3386 errors.push_back(ex.what());
3387 }
3388 else
3389 {
3390 throw ;
3391 }
3392 }
3393 }
3394
3395 void SymbolCreatorVisitor::Visit(LessNode& lessNode)
3396 {
3397 try
3398 {
3399 lessNode.Left()->Accept(*this);
3400 lessNode.Right()->Accept(*this);
3401 symbolTable.SetCursorContainer(lessNode);
3402 }
3403 catch (const Exception& ex;)
3404 {
3405 if (editMode)
3406 {
3407 errors.push_back(ex.Message());
3408 }
3409 else
3410 {
3411 throw ;
3412 }
3413 }
3414 catch (const std::exception& ex;)
3415 {
3416 if (editMode)
3417 {
3418 errors.push_back(ex.what());
3419 }
3420 else
3421 {
3422 throw ;
3423 }
3424 }
3425 }
3426
3427 void SymbolCreatorVisitor::Visit(GreaterNode& greaterNode)
3428 {
3429 try
3430 {
3431 greaterNode.Left()->Accept(*this);
3432 greaterNode.Right()->Accept(*this);
3433 symbolTable.SetCursorContainer(greaterNode);
3434 }
3435 catch (const Exception& ex;)
3436 {
3437 if (editMode)
3438 {
3439 errors.push_back(ex.Message());
3440 }
3441 else
3442 {
3443 throw ;
3444 }
3445 }
3446 catch (const std::exception& ex;)
3447 {
3448 if (editMode)
3449 {
3450 errors.push_back(ex.what());
3451 }
3452 else
3453 {
3454 throw ;
3455 }
3456 }
3457 }
3458
3459 void SymbolCreatorVisitor::Visit(LessOrEqualNode& lessOrEqualNode)
3460 {
3461 try
3462 {
3463 lessOrEqualNode.Left()->Accept(*this);
3464 lessOrEqualNode.Right()->Accept(*this);
3465 symbolTable.SetCursorContainer(lessOrEqualNode);
3466 }
3467 catch (const Exception& ex;)
3468 {
3469 if (editMode)
3470 {
3471 errors.push_back(ex.Message());
3472 }
3473 else
3474 {
3475 throw ;
3476 }
3477 }
3478 catch (const std::exception& ex;)
3479 {
3480 if (editMode)
3481 {
3482 errors.push_back(ex.what());
3483 }
3484 else
3485 {
3486 throw ;
3487 }
3488 }
3489 }
3490
3491 void SymbolCreatorVisitor::Visit(GreaterOrEqualNode& greaterOrEqualNode)
3492 {
3493 try
3494 {
3495 greaterOrEqualNode.Left()->Accept(*this);
3496 greaterOrEqualNode.Right()->Accept(*this);
3497 symbolTable.SetCursorContainer(greaterOrEqualNode);
3498 }
3499 catch (const Exception& ex;)
3500 {
3501 if (editMode)
3502 {
3503 errors.push_back(ex.Message());
3504 }
3505 else
3506 {
3507 throw ;
3508 }
3509 }
3510 catch (const std::exception& ex;)
3511 {
3512 if (editMode)
3513 {
3514 errors.push_back(ex.what());
3515 }
3516 else
3517 {
3518 throw ;
3519 }
3520 }
3521 }
3522
3523 void SymbolCreatorVisitor::Visit(ShiftLeftNode& shiftLeftNode)
3524 {
3525 try
3526 {
3527 shiftLeftNode.Left()->Accept(*this);
3528 shiftLeftNode.Right()->Accept(*this);
3529 symbolTable.SetCursorContainer(shiftLeftNode);
3530 }
3531 catch (const Exception& ex;)
3532 {
3533 if (editMode)
3534 {
3535 errors.push_back(ex.Message());
3536 }
3537 else
3538 {
3539 throw ;
3540 }
3541 }
3542 catch (const std::exception& ex;)
3543 {
3544 if (editMode)
3545 {
3546 errors.push_back(ex.what());
3547 }
3548 else
3549 {
3550 throw ;
3551 }
3552 }
3553 }
3554
3555 void SymbolCreatorVisitor::Visit(ShiftRightNode& shiftRightNode)
3556 {
3557 try
3558 {
3559 shiftRightNode.Left()->Accept(*this);
3560 shiftRightNode.Right()->Accept(*this);
3561 symbolTable.SetCursorContainer(shiftRightNode);
3562 }
3563 catch (const Exception& ex;)
3564 {
3565 if (editMode)
3566 {
3567 errors.push_back(ex.Message());
3568 }
3569 else
3570 {
3571 throw ;
3572 }
3573 }
3574 catch (const std::exception& ex;)
3575 {
3576 if (editMode)
3577 {
3578 errors.push_back(ex.what());
3579 }
3580 else
3581 {
3582 throw ;
3583 }
3584 }
3585 }
3586
3587 void SymbolCreatorVisitor::Visit(AddNode& addNode)
3588 {
3589 try
3590 {
3591 addNode.Left()->Accept(*this);
3592 addNode.Right()->Accept(*this);
3593 symbolTable.SetCursorContainer(addNode);
3594 }
3595 catch (const Exception& ex;)
3596 {
3597 if (editMode)
3598 {
3599 errors.push_back(ex.Message());
3600 }
3601 else
3602 {
3603 throw ;
3604 }
3605 }
3606 catch (const std::exception& ex;)
3607 {
3608 if (editMode)
3609 {
3610 errors.push_back(ex.what());
3611 }
3612 else
3613 {
3614 throw ;
3615 }
3616 }
3617 }
3618
3619 void SymbolCreatorVisitor::Visit(SubNode& subNode)
3620 {
3621 try
3622 {
3623 subNode.Left()->Accept(*this);
3624 subNode.Right()->Accept(*this);
3625 symbolTable.SetCursorContainer(subNode);
3626 }
3627 catch (const Exception& ex;)
3628 {
3629 if (editMode)
3630 {
3631 errors.push_back(ex.Message());
3632 }
3633 else
3634 {
3635 throw ;
3636 }
3637 }
3638 catch (const std::exception& ex;)
3639 {
3640 if (editMode)
3641 {
3642 errors.push_back(ex.what());
3643 }
3644 else
3645 {
3646 throw ;
3647 }
3648 }
3649 }
3650
3651 void SymbolCreatorVisitor::Visit(MulNode& mulNode)
3652 {
3653 try
3654 {
3655 mulNode.Left()->Accept(*this);
3656 mulNode.Right()->Accept(*this);
3657 symbolTable.SetCursorContainer(mulNode);
3658 }
3659 catch (const Exception& ex;)
3660 {
3661 if (editMode)
3662 {
3663 errors.push_back(ex.Message());
3664 }
3665 else
3666 {
3667 throw ;
3668 }
3669 }
3670 catch (const std::exception& ex;)
3671 {
3672 if (editMode)
3673 {
3674 errors.push_back(ex.what());
3675 }
3676 else
3677 {
3678 throw ;
3679 }
3680 }
3681 }
3682
3683 void SymbolCreatorVisitor::Visit(DivNode& divNode)
3684 {
3685 try
3686 {
3687 divNode.Left()->Accept(*this);
3688 divNode.Right()->Accept(*this);
3689 symbolTable.SetCursorContainer(divNode);
3690 }
3691 catch (const Exception& ex;)
3692 {
3693 if (editMode)
3694 {
3695 errors.push_back(ex.Message());
3696 }
3697 else
3698 {
3699 throw ;
3700 }
3701 }
3702 catch (const std::exception& ex;)
3703 {
3704 if (editMode)
3705 {
3706 errors.push_back(ex.what());
3707 }
3708 else
3709 {
3710 throw ;
3711 }
3712 }
3713 }
3714
3715 void SymbolCreatorVisitor::Visit(RemNode& remNode)
3716 {
3717 try
3718 {
3719 remNode.Left()->Accept(*this);
3720 remNode.Right()->Accept(*this);
3721 symbolTable.SetCursorContainer(remNode);
3722 }
3723 catch (const Exception& ex;)
3724 {
3725 if (editMode)
3726 {
3727 errors.push_back(ex.Message());
3728 }
3729 else
3730 {
3731 throw ;
3732 }
3733 }
3734 catch (const std::exception& ex;)
3735 {
3736 if (editMode)
3737 {
3738 errors.push_back(ex.what());
3739 }
3740 else
3741 {
3742 throw ;
3743 }
3744 }
3745 }
3746
3747 void SymbolCreatorVisitor::Visit(NotNode& notNode)
3748 {
3749 try
3750 {
3751 notNode.Subject()->Accept(*this);
3752 symbolTable.SetCursorContainer(notNode);
3753 }
3754 catch (const Exception& ex;)
3755 {
3756 if (editMode)
3757 {
3758 errors.push_back(ex.Message());
3759 }
3760 else
3761 {
3762 throw ;
3763 }
3764 }
3765 catch (const std::exception& ex;)
3766 {
3767 if (editMode)
3768 {
3769 errors.push_back(ex.what());
3770 }
3771 else
3772 {
3773 throw ;
3774 }
3775 }
3776 }
3777
3778 void SymbolCreatorVisitor::Visit(UnaryPlusNode& unaryPlusNode)
3779 {
3780 try
3781 {
3782 unaryPlusNode.Subject()->Accept(*this);
3783 symbolTable.SetCursorContainer(unaryPlusNode);
3784 }
3785 catch (const Exception& ex;)
3786 {
3787 if (editMode)
3788 {
3789 errors.push_back(ex.Message());
3790 }
3791 else
3792 {
3793 throw ;
3794 }
3795 }
3796 catch (const std::exception& ex;)
3797 {
3798 if (editMode)
3799 {
3800 errors.push_back(ex.what());
3801 }
3802 else
3803 {
3804 throw ;
3805 }
3806 }
3807 }
3808
3809 void SymbolCreatorVisitor::Visit(UnaryMinusNode& unaryMinusNode)
3810 {
3811 try
3812 {
3813 unaryMinusNode.Subject()->Accept(*this);
3814 symbolTable.SetCursorContainer(unaryMinusNode);
3815 }
3816 catch (const Exception& ex;)
3817 {
3818 if (editMode)
3819 {
3820 errors.push_back(ex.Message());
3821 }
3822 else
3823 {
3824 throw ;
3825 }
3826 }
3827 catch (const std::exception& ex;)
3828 {
3829 if (editMode)
3830 {
3831 errors.push_back(ex.what());
3832 }
3833 else
3834 {
3835 throw ;
3836 }
3837 }
3838 }
3839
3840 void SymbolCreatorVisitor::Visit(PrefixIncrementNode& prefixIncrementNode)
3841 {
3842 try
3843 {
3844 prefixIncrementNode.Subject()->Accept(*this);
3845 symbolTable.SetCursorContainer(prefixIncrementNode);
3846 }
3847 catch (const Exception& ex;)
3848 {
3849 if (editMode)
3850 {
3851 errors.push_back(ex.Message());
3852 }
3853 else
3854 {
3855 throw ;
3856 }
3857 }
3858 catch (const std::exception& ex;)
3859 {
3860 if (editMode)
3861 {
3862 errors.push_back(ex.what());
3863 }
3864 else
3865 {
3866 throw ;
3867 }
3868 }
3869 }
3870
3871 void SymbolCreatorVisitor::Visit(PrefixDecrementNode& prefixDecrementNode)
3872 {
3873 try
3874 {
3875 prefixDecrementNode.Subject()->Accept(*this);
3876 symbolTable.SetCursorContainer(prefixDecrementNode);
3877 }
3878 catch (const Exception& ex;)
3879 {
3880 if (editMode)
3881 {
3882 errors.push_back(ex.Message());
3883 }
3884 else
3885 {
3886 throw ;
3887 }
3888 }
3889 catch (const std::exception& ex;)
3890 {
3891 if (editMode)
3892 {
3893 errors.push_back(ex.what());
3894 }
3895 else
3896 {
3897 throw ;
3898 }
3899 }
3900 }
3901
3902 void SymbolCreatorVisitor::Visit(DerefNode& derefNode)
3903 {
3904 try
3905 {
3906 derefNode.Subject()->Accept(*this);
3907 symbolTable.SetCursorContainer(derefNode);
3908 }
3909 catch (const Exception& ex;)
3910 {
3911 if (editMode)
3912 {
3913 errors.push_back(ex.Message());
3914 }
3915 else
3916 {
3917 throw ;
3918 }
3919 }
3920 catch (const std::exception& ex;)
3921 {
3922 if (editMode)
3923 {
3924 errors.push_back(ex.what());
3925 }
3926 else
3927 {
3928 throw ;
3929 }
3930 }
3931 }
3932
3933 void SymbolCreatorVisitor::Visit(AddrOfNode& addrOfNode)
3934 {
3935 try
3936 {
3937 addrOfNode.Subject()->Accept(*this);
3938 symbolTable.SetCursorContainer(addrOfNode);
3939 }
3940 catch (const Exception& ex;)
3941 {
3942 if (editMode)
3943 {
3944 errors.push_back(ex.Message());
3945 }
3946 else
3947 {
3948 throw ;
3949 }
3950 }
3951 catch (const std::exception& ex;)
3952 {
3953 if (editMode)
3954 {
3955 errors.push_back(ex.what());
3956 }
3957 else
3958 {
3959 throw ;
3960 }
3961 }
3962 }
3963
3964 void SymbolCreatorVisitor::Visit(ComplementNode& complementNode)
3965 {
3966 try
3967 {
3968 complementNode.Subject()->Accept(*this);
3969 symbolTable.SetCursorContainer(complementNode);
3970 }
3971 catch (const Exception& ex;)
3972 {
3973 if (editMode)
3974 {
3975 errors.push_back(ex.Message());
3976 }
3977 else
3978 {
3979 throw ;
3980 }
3981 }
3982 catch (const std::exception& ex;)
3983 {
3984 if (editMode)
3985 {
3986 errors.push_back(ex.what());
3987 }
3988 else
3989 {
3990 throw ;
3991 }
3992 }
3993 }
3994
3995 void SymbolCreatorVisitor::Visit(IsNode& isNode)
3996 {
3997 try
3998 {
3999 isNode.Expr()->Accept(*this);
4000 if (isNode.TargetTypeExpr())
4001 {
4002 isNode.TargetTypeExpr()->Accept(*this);
4003 }
4004 else
4005 {
4006 throw Exception("target type expected", isNode.GetSpan(), isNode.ModuleId());
4007 }
4008 symbolTable.SetCursorContainer(isNode);
4009 }
4010 catch (const Exception& ex;)
4011 {
4012 if (editMode)
4013 {
4014 errors.push_back(ex.Message());
4015 }
4016 else
4017 {
4018 throw ;
4019 }
4020 }
4021 catch (const std::exception& ex;)
4022 {
4023 if (editMode)
4024 {
4025 errors.push_back(ex.what());
4026 }
4027 else
4028 {
4029 throw ;
4030 }
4031 }
4032 }
4033
4034 void SymbolCreatorVisitor::Visit(AsNode& asNode)
4035 {
4036 try
4037 {
4038 asNode.Expr()->Accept(*this);
4039 if (asNode.TargetTypeExpr())
4040 {
4041 asNode.TargetTypeExpr()->Accept(*this);
4042 }
4043 else
4044 {
4045 throw Exception("target type expected", asNode.GetSpan(), asNode.ModuleId());
4046 }
4047 symbolTable.SetCursorContainer(asNode);
4048 }
4049 catch (const Exception& ex;)
4050 {
4051 if (editMode)
4052 {
4053 errors.push_back(ex.Message());
4054 }
4055 else
4056 {
4057 throw ;
4058 }
4059 }
4060 catch (const std::exception& ex;)
4061 {
4062 if (editMode)
4063 {
4064 errors.push_back(ex.what());
4065 }
4066 else
4067 {
4068 throw ;
4069 }
4070 }
4071 }
4072
4073 void SymbolCreatorVisitor::Visit(IndexingNode& indexingNode)
4074 {
4075 try
4076 {
4077 indexingNode.Subject()->Accept(*this);
4078 if (indexingNode.Index())
4079 {
4080 indexingNode.Index()->Accept(*this);
4081 }
4082 else
4083 {
4084 throw Exception("index expected", indexingNode.GetSpan(), indexingNode.ModuleId());
4085 }
4086 symbolTable.SetCursorContainer(indexingNode);
4087 }
4088 catch (const Exception& ex;)
4089 {
4090 if (editMode)
4091 {
4092 errors.push_back(ex.Message());
4093 }
4094 else
4095 {
4096 throw ;
4097 }
4098 }
4099 catch (const std::exception& ex;)
4100 {
4101 if (editMode)
4102 {
4103 errors.push_back(ex.what());
4104 }
4105 else
4106 {
4107 throw ;
4108 }
4109 }
4110 }
4111
4112 void SymbolCreatorVisitor::Visit(InvokeNode& invokeNode)
4113 {
4114 try
4115 {
4116 invokeNode.Subject()->Accept(*this);
4117 int n = invokeNode.Arguments().Count();
4118 for (int i = 0; i < n; ++i)
4119 {
4120 invokeNode.Arguments()[i]->Accept(*this);
4121 }
4122 symbolTable.SetCursorContainer(invokeNode);
4123 }
4124 catch (const Exception& ex;)
4125 {
4126 if (editMode)
4127 {
4128 errors.push_back(ex.Message());
4129 }
4130 else
4131 {
4132 throw ;
4133 }
4134 }
4135 catch (const std::exception& ex;)
4136 {
4137 if (editMode)
4138 {
4139 errors.push_back(ex.what());
4140 }
4141 else
4142 {
4143 throw ;
4144 }
4145 }
4146 }
4147
4148 void SymbolCreatorVisitor::Visit(PostfixIncrementNode& postfixIncrementNode)
4149 {
4150 try
4151 {
4152 postfixIncrementNode.Subject()->Accept(*this);
4153 symbolTable.SetCursorContainer(postfixIncrementNode);
4154 }
4155 catch (const Exception& ex;)
4156 {
4157 if (editMode)
4158 {
4159 errors.push_back(ex.Message());
4160 }
4161 else
4162 {
4163 throw ;
4164 }
4165 }
4166 catch (const std::exception& ex;)
4167 {
4168 if (editMode)
4169 {
4170 errors.push_back(ex.what());
4171 }
4172 else
4173 {
4174 throw ;
4175 }
4176 }
4177 }
4178
4179 void SymbolCreatorVisitor::Visit(PostfixDecrementNode& postfixDecrementNode)
4180 {
4181 try
4182 {
4183 postfixDecrementNode.Subject()->Accept(*this);
4184 symbolTable.SetCursorContainer(postfixDecrementNode);
4185 }
4186 catch (const Exception& ex;)
4187 {
4188 if (editMode)
4189 {
4190 errors.push_back(ex.Message());
4191 }
4192 else
4193 {
4194 throw ;
4195 }
4196 }
4197 catch (const std::exception& ex;)
4198 {
4199 if (editMode)
4200 {
4201 errors.push_back(ex.what());
4202 }
4203 else
4204 {
4205 throw ;
4206 }
4207 }
4208 }
4209
4210 void SymbolCreatorVisitor::Visit(SizeOfNode& sizeOfNode)
4211 {
4212 try
4213 {
4214 sizeOfNode.Expression()->Accept(*this);
4215 symbolTable.SetCursorContainer(sizeOfNode);
4216 }
4217 catch (const Exception& ex;)
4218 {
4219 if (editMode)
4220 {
4221 errors.push_back(ex.Message());
4222 }
4223 else
4224 {
4225 throw ;
4226 }
4227 }
4228 catch (const std::exception& ex;)
4229 {
4230 if (editMode)
4231 {
4232 errors.push_back(ex.what());
4233 }
4234 else
4235 {
4236 throw ;
4237 }
4238 }
4239 }
4240
4241 void SymbolCreatorVisitor::Visit(TypeNameNode& typeNameNode)
4242 {
4243 try
4244 {
4245 typeNameNode.Expression()->Accept(*this);
4246 symbolTable.SetCursorContainer(typeNameNode);
4247 }
4248 catch (const Exception& ex;)
4249 {
4250 if (editMode)
4251 {
4252 errors.push_back(ex.Message());
4253 }
4254 else
4255 {
4256 throw ;
4257 }
4258 }
4259 catch (const std::exception& ex;)
4260 {
4261 if (editMode)
4262 {
4263 errors.push_back(ex.what());
4264 }
4265 else
4266 {
4267 throw ;
4268 }
4269 }
4270 }
4271
4272 void SymbolCreatorVisitor::Visit(TypeIdNode& typeIdNode)
4273 {
4274 try
4275 {
4276 typeIdNode.Expression()->Accept(*this);
4277 symbolTable.SetCursorContainer(typeIdNode);
4278 }
4279 catch (const Exception& ex;)
4280 {
4281 if (editMode)
4282 {
4283 errors.push_back(ex.Message());
4284 }
4285 else
4286 {
4287 throw ;
4288 }
4289 }
4290 catch (const std::exception& ex;)
4291 {
4292 if (editMode)
4293 {
4294 errors.push_back(ex.what());
4295 }
4296 else
4297 {
4298 throw ;
4299 }
4300 }
4301 }
4302
4303 void SymbolCreatorVisitor::Visit(CastNode& castNode)
4304 {
4305 try
4306 {
4307 castNode.TargetTypeExpr()->Accept(*this);
4308 castNode.SourceExpr()->Accept(*this);
4309 symbolTable.SetCursorContainer(castNode);
4310 }
4311 catch (const Exception& ex;)
4312 {
4313 if (editMode)
4314 {
4315 errors.push_back(ex.Message());
4316 }
4317 else
4318 {
4319 throw ;
4320 }
4321 }
4322 catch (const std::exception& ex;)
4323 {
4324 if (editMode)
4325 {
4326 errors.push_back(ex.what());
4327 }
4328 else
4329 {
4330 throw ;
4331 }
4332 }
4333 }
4334
4335 void SymbolCreatorVisitor::Visit(ConstructNode& constructNode)
4336 {
4337 try
4338 {
4339 constructNode.TypeExpr()->Accept(*this);
4340 int n = constructNode.Arguments().Count();
4341 for (int i = 0; i < n; ++i)
4342 {
4343 constructNode.Arguments()[i]->Accept(*this);
4344 }
4345 symbolTable.SetCursorContainer(constructNode);
4346 }
4347 catch (const Exception& ex;)
4348 {
4349 if (editMode)
4350 {
4351 errors.push_back(ex.Message());
4352 }
4353 else
4354 {
4355 throw ;
4356 }
4357 }
4358 catch (const std::exception& ex;)
4359 {
4360 if (editMode)
4361 {
4362 errors.push_back(ex.what());
4363 }
4364 else
4365 {
4366 throw ;
4367 }
4368 }
4369 }
4370
4371 void SymbolCreatorVisitor::Visit(NewNode& newNode)
4372 {
4373 try
4374 {
4375 newNode.TypeExpr()->Accept(*this);
4376 int n = newNode.Arguments().Count();
4377 for (int i = 0; i < n; ++i)
4378 {
4379 newNode.Arguments()[i]->Accept(*this);
4380 }
4381 symbolTable.SetCursorContainer(newNode);
4382 }
4383 catch (const Exception& ex;)
4384 {
4385 if (editMode)
4386 {
4387 errors.push_back(ex.Message());
4388 }
4389 else
4390 {
4391 throw ;
4392 }
4393 }
4394 catch (const std::exception& ex;)
4395 {
4396 if (editMode)
4397 {
4398 errors.push_back(ex.what());
4399 }
4400 else
4401 {
4402 throw ;
4403 }
4404 }
4405 }
4406
4407 void SymbolCreatorVisitor::Visit(ThisNode& thisNode)
4408 {
4409 symbolTable.SetCursorContainer(thisNode);
4410 }
4411
4412 void SymbolCreatorVisitor::Visit(BaseNode& baseNode)
4413 {
4414 symbolTable.SetCursorContainer(baseNode);
4415 }
4416
4417 void SymbolCreatorVisitor::Visit(ParenthesizedExpressionNode& parenthesizedExpressionNode)
4418 {
4419 try
4420 {
4421 parenthesizedExpressionNode.Subject()->Accept(*this);
4422 symbolTable.SetCursorContainer(parenthesizedExpressionNode);
4423 }
4424 catch (const Exception& ex;)
4425 {
4426 if (editMode)
4427 {
4428 errors.push_back(ex.Message());
4429 }
4430 else
4431 {
4432 throw ;
4433 }
4434 }
4435 catch (const std::exception& ex;)
4436 {
4437 if (editMode)
4438 {
4439 errors.push_back(ex.what());
4440 }
4441 else
4442 {
4443 throw ;
4444 }
4445 }
4446 }
4447
4448 void SymbolCreatorVisitor::Visit(CommentNode& commentNode)
4449 {
4450 symbolTable.SetCursorContainer(commentNode);
4451 }
4452
4453 void SymbolCreatorVisitor::Visit(BoolNode& boolNode)
4454 {
4455 symbolTable.SetCursorContainer(boolNode);
4456 }
4457
4458 void SymbolCreatorVisitor::Visit(SByteNode& sbyteNode)
4459 {
4460 symbolTable.SetCursorContainer(sbyteNode);
4461 }
4462
4463 void SymbolCreatorVisitor::Visit(ByteNode& byteNode)
4464 {
4465 symbolTable.SetCursorContainer(byteNode);
4466 }
4467
4468 void SymbolCreatorVisitor::Visit(ShortNode& shortNode)
4469 {
4470 symbolTable.SetCursorContainer(shortNode);
4471 }
4472
4473 void SymbolCreatorVisitor::Visit(UShortNode& ushortNode)
4474 {
4475 symbolTable.SetCursorContainer(ushortNode);
4476 }
4477
4478 void SymbolCreatorVisitor::Visit(IntNode& intNode)
4479 {
4480 symbolTable.SetCursorContainer(intNode);
4481 }
4482
4483 void SymbolCreatorVisitor::Visit(UIntNode& uintNode)
4484 {
4485 symbolTable.SetCursorContainer(uintNode);
4486 }
4487
4488 void SymbolCreatorVisitor::Visit(LongNode& longNode)
4489 {
4490 symbolTable.SetCursorContainer(longNode);
4491 }
4492
4493 void SymbolCreatorVisitor::Visit(ULongNode& ulongNode)
4494 {
4495 symbolTable.SetCursorContainer(ulongNode);
4496 }
4497
4498 void SymbolCreatorVisitor::Visit(FloatNode& floatNode)
4499 {
4500 symbolTable.SetCursorContainer(floatNode);
4501 }
4502
4503 void SymbolCreatorVisitor::Visit(DoubleNode& doubleNode)
4504 {
4505 symbolTable.SetCursorContainer(doubleNode);
4506 }
4507
4508 void SymbolCreatorVisitor::Visit(CharNode& charNode)
4509 {
4510 symbolTable.SetCursorContainer(charNode);
4511 }
4512
4513 void SymbolCreatorVisitor::Visit(WCharNode& wcharNode)
4514 {
4515 symbolTable.SetCursorContainer(wcharNode);
4516 }
4517
4518 void SymbolCreatorVisitor::Visit(UCharNode& ucharNode)
4519 {
4520 symbolTable.SetCursorContainer(ucharNode);
4521 }
4522
4523 void SymbolCreatorVisitor::Visit(VoidNode& voidNode)
4524 {
4525 symbolTable.SetCursorContainer(voidNode);
4526 }
4527
4528 void SymbolCreatorVisitor::Visit(BooleanLiteralNode& booleanLiteralNode)
4529 {
4530 symbolTable.SetCursorContainer(booleanLiteralNode);
4531 }
4532
4533 void SymbolCreatorVisitor::Visit(SByteLiteralNode& sbyteLiteralNode)
4534 {
4535 symbolTable.SetCursorContainer(sbyteLiteralNode);
4536 }
4537
4538 void SymbolCreatorVisitor::Visit(ByteLiteralNode& byteLiteralNode)
4539 {
4540 symbolTable.SetCursorContainer(byteLiteralNode);
4541 }
4542
4543 void SymbolCreatorVisitor::Visit(ShortLiteralNode& shortLiteralNode)
4544 {
4545 symbolTable.SetCursorContainer(shortLiteralNode);
4546 }
4547
4548 void SymbolCreatorVisitor::Visit(UShortLiteralNode& ushortLiteralNode)
4549 {
4550 symbolTable.SetCursorContainer(ushortLiteralNode);
4551 }
4552
4553 void SymbolCreatorVisitor::Visit(IntLiteralNode& intLiteralNode)
4554 {
4555 symbolTable.SetCursorContainer(intLiteralNode);
4556 }
4557
4558 void SymbolCreatorVisitor::Visit(UIntLiteralNode& uintLiteralNode)
4559 {
4560 symbolTable.SetCursorContainer(uintLiteralNode);
4561 }
4562
4563 void SymbolCreatorVisitor::Visit(LongLiteralNode& longLiteralNode)
4564 {
4565 symbolTable.SetCursorContainer(longLiteralNode);
4566 }
4567
4568 void SymbolCreatorVisitor::Visit(ULongLiteralNode& ulongLiteralNode)
4569 {
4570 symbolTable.SetCursorContainer(ulongLiteralNode);
4571 }
4572
4573 void SymbolCreatorVisitor::Visit(FloatLiteralNode& floatLiteralNode)
4574 {
4575 symbolTable.SetCursorContainer(floatLiteralNode);
4576 }
4577
4578 void SymbolCreatorVisitor::Visit(DoubleLiteralNode& doubleLiteralNode)
4579 {
4580 symbolTable.SetCursorContainer(doubleLiteralNode);
4581 }
4582
4583 void SymbolCreatorVisitor::Visit(CharLiteralNode& charLiteralNode)
4584 {
4585 symbolTable.SetCursorContainer(charLiteralNode);
4586 }
4587
4588 void SymbolCreatorVisitor::Visit(WCharLiteralNode& wcharLiteralNode)
4589 {
4590 symbolTable.SetCursorContainer(wcharLiteralNode);
4591 }
4592
4593 void SymbolCreatorVisitor::Visit(UCharLiteralNode& ucharLiteralNode)
4594 {
4595 symbolTable.SetCursorContainer(ucharLiteralNode);
4596 }
4597
4598 void SymbolCreatorVisitor::Visit(StringLiteralNode& stringLiteralNode)
4599 {
4600 symbolTable.SetCursorContainer(stringLiteralNode);
4601 }
4602
4603 void SymbolCreatorVisitor::Visit(WStringLiteralNode& wstringLiteralNode)
4604 {
4605 symbolTable.SetCursorContainer(wstringLiteralNode);
4606 }
4607
4608 void SymbolCreatorVisitor::Visit(UStringLiteralNode& ustringLiteralNode)
4609 {
4610 symbolTable.SetCursorContainer(ustringLiteralNode);
4611 }
4612
4613 void SymbolCreatorVisitor::Visit(NullLiteralNode& nullLiteralNode)
4614 {
4615 symbolTable.SetCursorContainer(nullLiteralNode);
4616 }
4617
4618 void SymbolCreatorVisitor::Visit(ArrayLiteralNode& arrayLiteralNode)
4619 {
4620 symbolTable.SetCursorContainer(arrayLiteralNode);
4621 }
4622
4623 void SymbolCreatorVisitor::Visit(StructuredLiteralNode& structuredLiteralNode)
4624 {
4625 symbolTable.SetCursorContainer(structuredLiteralNode);
4626 }
4627
4628 void SymbolCreatorVisitor::Visit(UuidLiteralNode& uuidLiteralNode)
4629 {
4630 symbolTable.SetCursorContainer(uuidLiteralNode);
4631 }
4632
4633 void SymbolCreatorVisitor::InsertTracer(CompoundStatementNode* body)
4634 {
4635 if (!GetGlobalFlag(GlobalFlags::trace)) return;
4636 Module* rootModule = GetRootModuleForCurrentThread();
4637 if (!rootModule) return;
4638 if (rootModule->IsCore()) return;
4639 if (rootModule->Name() == U"System.Runtime") return;
4640 if (rootModule->Name() == U"System.Parsing") return;
4641 if (body->TracerInserted()) return;
4642 body->SetTracerInserted();
4643 Span span = body->GetSpan();
4644 boost::uuids::uuid moduleId = body->ModuleId();
4645 DotNode* typeExprNode = new DotNode(span, moduleId, new DotNode(span, moduleId, new IdentifierNode(span, moduleId, U"System"), new IdentifierNode(span, moduleId, U"Runtime")),
4646 new IdentifierNode(span, moduleId, U"Tracer"));
4647 ConstructionStatementNode * constructTracer(new ConstructionStatementNode(span, moduleId, typeExprNode, new IdentifierNode(span, moduleId, U"@tracer")));
4648 constructTracer->AddArgument(new IntLiteralNode(span, moduleId, -1));
4649 body->Statements().Insert(0, constructTracer);
4650 }
4651
4652 } }