This repository was archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathStandardVisitor.cs
2061 lines (2050 loc) · 84.5 KB
/
StandardVisitor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Diagnostics;
#if FxCop
using AttributeList = Microsoft.Cci.AttributeNodeCollection;
using BlockList = Microsoft.Cci.BlockCollection;
using ExpressionList = Microsoft.Cci.ExpressionCollection;
using InterfaceList = Microsoft.Cci.InterfaceCollection;
using MemberList = Microsoft.Cci.MemberCollection;
using NodeList = Microsoft.Cci.NodeCollection;
using ParameterList = Microsoft.Cci.ParameterCollection;
using SecurityAttributeList = Microsoft.Cci.SecurityAttributeCollection;
using StatementList = Microsoft.Cci.StatementCollection;
using TypeNodeList = Microsoft.Cci.TypeNodeCollection;
using Property = Microsoft.Cci.PropertyNode;
using Module = Microsoft.Cci.ModuleNode;
using Return = Microsoft.Cci.ReturnNode;
using Class = Microsoft.Cci.ClassNode;
using Interface = Microsoft.Cci.InterfaceNode;
using Event = Microsoft.Cci.EventNode;
using Throw = Microsoft.Cci.ThrowNode;
#endif
#if CCINamespace
namespace Microsoft.Cci{
#else
namespace System.Compiler{
#endif
/// <summary>
/// Base for all classes that process the IR using the visitor pattern.
/// </summary>
#if !FxCop
public
#endif
abstract class Visitor{
/// <summary>
/// Switches on node.NodeType to call a visitor method that has been specialized for node.
/// </summary>
/// <param name="node">The node to be visited.</param>
/// <returns> Returns null if node is null. Otherwise returns an updated node (possibly a different object).</returns>
public abstract Node Visit(Node node);
#if !MinimalReader
/// <summary>
/// Transfers the state from one visitor to another. This enables separate visitor instances to cooperative process a single IR.
/// </summary>
public virtual void TransferStateTo(Visitor targetVisitor){
}
#endif
public virtual ExpressionList VisitExpressionList(ExpressionList list){
if (list == null) return null;
for( int i = 0, n = list.Count; i < n; i++)
list[i] = (Expression)this.Visit(list[i]);
return list;
}
}
/// <summary>
/// Walks an IR, mutuating it into a new form
/// </summary>
#if !FxCop
public
#endif
class StandardVisitor: Visitor{
#if !MinimalReader
public Visitor callingVisitor;
#endif
protected bool memberListNamesChanged;
public StandardVisitor(){
}
#if !MinimalReader
public StandardVisitor(Visitor callingVisitor){
this.callingVisitor = callingVisitor;
}
#endif
public virtual Node VisitUnknownNodeType(Node node){
#if !MinimalReader
Visitor visitor = this.GetVisitorFor(node);
if (visitor == null) return node;
if (this.callingVisitor != null)
//Allow specialized state (unknown to this visitor) to propagate all the way down to the new visitor
this.callingVisitor.TransferStateTo(visitor);
this.TransferStateTo(visitor);
node = visitor.Visit(node);
visitor.TransferStateTo(this);
if (this.callingVisitor != null)
//Propagate specialized state (unknown to this visitor) all the way up the chain
visitor.TransferStateTo(this.callingVisitor);
#else
Debug.Assert(false);
#endif
return node;
}
#if !MinimalReader
public virtual Visitor GetVisitorFor(Node node){
if (node == null) return null;
return (Visitor)node.GetVisitorFor(this, this.GetType().Name);
}
#endif
public override Node Visit(Node node){
if (node == null) return null;
switch (node.NodeType){
#if !MinimalReader && !CodeContracts
case NodeType.Acquire:
return this.VisitAcquire((Acquire)node);
#endif
case NodeType.AddressDereference:
return this.VisitAddressDereference((AddressDereference)node);
#if !MinimalReader && !CodeContracts
case NodeType.AliasDefinition :
return this.VisitAliasDefinition((AliasDefinition)node);
case NodeType.AnonymousNestedFunction:
return this.VisitAnonymousNestedFunction((AnonymousNestedFunction)node);
case NodeType.ApplyToAll :
return this.VisitApplyToAll((ApplyToAll)node);
#endif
case NodeType.Arglist :
return this.VisitExpression((Expression)node);
#if !MinimalReader && !CodeContracts
case NodeType.ArglistArgumentExpression:
return this.VisitArglistArgumentExpression((ArglistArgumentExpression)node);
case NodeType.ArglistExpression:
return this.VisitArglistExpression((ArglistExpression)node);
#endif
case NodeType.ArrayType :
Debug.Assert(false); return null;
case NodeType.Assembly :
return this.VisitAssembly((AssemblyNode)node);
case NodeType.AssemblyReference :
return this.VisitAssemblyReference((AssemblyReference)node);
#if !MinimalReader
case NodeType.Assertion:
return this.VisitAssertion((Assertion)node);
case NodeType.Assumption:
return this.VisitAssumption((Assumption)node);
case NodeType.AssignmentExpression:
return this.VisitAssignmentExpression((AssignmentExpression)node);
#endif
case NodeType.AssignmentStatement :
return this.VisitAssignmentStatement((AssignmentStatement)node);
case NodeType.Attribute :
return this.VisitAttributeNode((AttributeNode)node);
#if !MinimalReader && !CodeContracts
case NodeType.Base :
return this.VisitBase((Base)node);
#endif
case NodeType.Block :
return this.VisitBlock((Block)node);
#if !MinimalReader
case NodeType.BlockExpression :
return this.VisitBlockExpression((BlockExpression)node);
#endif
case NodeType.Branch :
return this.VisitBranch((Branch)node);
#if !MinimalReader && !CodeContracts
case NodeType.Compilation:
return this.VisitCompilation((Compilation)node);
case NodeType.CompilationUnit:
return this.VisitCompilationUnit((CompilationUnit)node);
case NodeType.CompilationUnitSnippet:
return this.VisitCompilationUnitSnippet((CompilationUnitSnippet)node);
#endif
#if ExtendedRuntime
case NodeType.ConstrainedType:
return this.VisitConstrainedType((ConstrainedType)node);
#endif
#if !MinimalReader && !CodeContracts
case NodeType.Continue :
return this.VisitContinue((Continue)node);
case NodeType.CurrentClosure :
return this.VisitCurrentClosure((CurrentClosure)node);
#endif
case NodeType.DebugBreak :
return node;
case NodeType.Call :
case NodeType.Calli :
case NodeType.Callvirt :
case NodeType.Jmp :
#if !MinimalReader
case NodeType.MethodCall :
#endif
return this.VisitMethodCall((MethodCall)node);
#if !MinimalReader && !CodeContracts
case NodeType.Catch :
return this.VisitCatch((Catch)node);
#endif
case NodeType.Class :
return this.VisitClass((Class)node);
#if !MinimalReader && !CodeContracts
case NodeType.CoerceTuple :
return this.VisitCoerceTuple((CoerceTuple)node);
case NodeType.CollectionEnumerator :
return this.VisitCollectionEnumerator((CollectionEnumerator)node);
case NodeType.Composition :
return this.VisitComposition((Composition)node);
#endif
case NodeType.Construct :
return this.VisitConstruct((Construct)node);
case NodeType.ConstructArray :
return this.VisitConstructArray((ConstructArray)node);
#if !MinimalReader && !CodeContracts
case NodeType.ConstructDelegate :
return this.VisitConstructDelegate((ConstructDelegate)node);
case NodeType.ConstructFlexArray :
return this.VisitConstructFlexArray((ConstructFlexArray)node);
case NodeType.ConstructIterator :
return this.VisitConstructIterator((ConstructIterator)node);
case NodeType.ConstructTuple :
return this.VisitConstructTuple((ConstructTuple)node);
#endif
case NodeType.DelegateNode :
return this.VisitDelegateNode((DelegateNode)node);
#if !MinimalReader && !CodeContracts
case NodeType.DoWhile:
return this.VisitDoWhile((DoWhile)node);
#endif
case NodeType.Dup :
return this.VisitExpression((Expression)node);
case NodeType.EndFilter :
return this.VisitEndFilter((EndFilter)node);
case NodeType.EndFinally:
return this.VisitEndFinally((EndFinally)node);
case NodeType.EnumNode :
return this.VisitEnumNode((EnumNode)node);
case NodeType.Event:
return this.VisitEvent((Event)node);
#if ExtendedRuntime || CodeContracts
case NodeType.EnsuresExceptional :
return this.VisitEnsuresExceptional((EnsuresExceptional)node);
#endif
#if !MinimalReader && !CodeContracts
case NodeType.Exit :
return this.VisitExit((Exit)node);
case NodeType.Read :
case NodeType.Write :
return this.VisitExpose((Expose)node);
case NodeType.ExpressionSnippet:
return this.VisitExpressionSnippet((ExpressionSnippet)node);
#endif
case NodeType.ExpressionStatement :
return this.VisitExpressionStatement((ExpressionStatement)node);
#if !MinimalReader && !CodeContracts
case NodeType.FaultHandler :
return this.VisitFaultHandler((FaultHandler)node);
#endif
case NodeType.Field :
return this.VisitField((Field)node);
#if !MinimalReader && !CodeContracts
case NodeType.FieldInitializerBlock:
return this.VisitFieldInitializerBlock((FieldInitializerBlock)node);
case NodeType.Finally :
return this.VisitFinally((Finally)node);
case NodeType.Filter :
return this.VisitFilter((Filter)node);
case NodeType.Fixed:
return this.VisitFixed((Fixed)node);
case NodeType.For :
return this.VisitFor((For)node);
case NodeType.ForEach :
return this.VisitForEach((ForEach)node);
case NodeType.FunctionDeclaration:
return this.VisitFunctionDeclaration((FunctionDeclaration)node);
case NodeType.Goto :
return this.VisitGoto((Goto)node);
case NodeType.GotoCase:
return this.VisitGotoCase((GotoCase)node);
#endif
case NodeType.Identifier :
return this.VisitIdentifier((Identifier)node);
#if !MinimalReader && !CodeContracts
case NodeType.If :
return this.VisitIf((If)node);
case NodeType.ImplicitThis :
return this.VisitImplicitThis((ImplicitThis)node);
#endif
case NodeType.Indexer :
return this.VisitIndexer((Indexer)node);
case NodeType.InstanceInitializer :
return this.VisitInstanceInitializer((InstanceInitializer)node);
#if ExtendedRuntime || CodeContracts
case NodeType.Invariant :
return this.VisitInvariant((Invariant)node);
#endif
case NodeType.StaticInitializer :
return this.VisitStaticInitializer((StaticInitializer)node);
case NodeType.Method:
return this.VisitMethod((Method)node);
#if !MinimalReader && !CodeContracts
case NodeType.TemplateInstance:
return this.VisitTemplateInstance((TemplateInstance)node);
case NodeType.StackAlloc:
return this.VisitStackAlloc((StackAlloc)node);
#endif
case NodeType.Interface :
return this.VisitInterface((Interface)node);
#if !MinimalReader
case NodeType.LabeledStatement :
return this.VisitLabeledStatement((LabeledStatement)node);
#endif
case NodeType.Literal:
return this.VisitLiteral((Literal)node);
case NodeType.Local :
return this.VisitLocal((Local)node);
#if !MinimalReader && !CodeContracts
case NodeType.LocalDeclaration:
return this.VisitLocalDeclaration((LocalDeclaration)node);
case NodeType.LocalDeclarationsStatement:
return this.VisitLocalDeclarationsStatement((LocalDeclarationsStatement)node);
case NodeType.Lock :
return this.VisitLock((Lock)node);
case NodeType.LRExpression:
return this.VisitLRExpression((LRExpression)node);
#endif
case NodeType.MemberBinding :
return this.VisitMemberBinding((MemberBinding)node);
#if ExtendedRuntime || CodeContracts
case NodeType.MethodContract :
return this.VisitMethodContract((MethodContract)node);
#endif
case NodeType.Module :
return this.VisitModule((Module)node);
case NodeType.ModuleReference :
return this.VisitModuleReference((ModuleReference)node);
#if !MinimalReader && !CodeContracts
case NodeType.NameBinding :
return this.VisitNameBinding((NameBinding)node);
#endif
case NodeType.NamedArgument :
return this.VisitNamedArgument((NamedArgument)node);
#if !MinimalReader && !CodeContracts
case NodeType.Namespace :
return this.VisitNamespace((Namespace)node);
#endif
case NodeType.Nop :
#if !MinimalReader
case NodeType.SwitchCaseBottom :
#endif
return node;
#if ExtendedRuntime || CodeContracts
case NodeType.EnsuresNormal :
return this.VisitEnsuresNormal((EnsuresNormal)node);
case NodeType.OldExpression:
return this.VisitOldExpression((OldExpression)node);
case NodeType.ReturnValue:
return this.VisitReturnValue((ReturnValue)node);
case NodeType.RequiresOtherwise :
return this.VisitRequiresOtherwise((RequiresOtherwise)node);
case NodeType.RequiresPlain :
return this.VisitRequiresPlain((RequiresPlain)node);
#endif
case NodeType.OptionalModifier:
case NodeType.RequiredModifier:
//TODO: type modifers should only be visited via VisitTypeReference
return this.VisitTypeModifier((TypeModifier)node);
case NodeType.Parameter :
return this.VisitParameter((Parameter)node);
case NodeType.Pop :
return this.VisitExpression((Expression)node);
#if !MinimalReader
case NodeType.PrefixExpression:
return this.VisitPrefixExpression((PrefixExpression)node);
case NodeType.PostfixExpression:
return this.VisitPostfixExpression((PostfixExpression)node);
#endif
case NodeType.Property:
return this.VisitProperty((Property)node);
#if !MinimalReader && !CodeContracts
case NodeType.Quantifier:
return this.VisitQuantifier((Quantifier)node);
case NodeType.Comprehension:
return this.VisitComprehension((Comprehension)node);
case NodeType.ComprehensionBinding:
return this.VisitComprehensionBinding((ComprehensionBinding)node);
case NodeType.QualifiedIdentifer :
return this.VisitQualifiedIdentifier((QualifiedIdentifier)node);
#endif
case NodeType.Rethrow :
case NodeType.Throw :
return this.VisitThrow((Throw)node);
#if !MinimalReader && !CodeContracts
case NodeType.RefValueExpression:
return this.VisitRefValueExpression((RefValueExpression)node);
case NodeType.RefTypeExpression:
return this.VisitRefTypeExpression((RefTypeExpression)node);
#endif
case NodeType.Return:
return this.VisitReturn((Return)node);
#if !MinimalReader && !CodeContracts
case NodeType.Repeat:
return this.VisitRepeat((Repeat)node);
case NodeType.ResourceUse:
return this.VisitResourceUse((ResourceUse)node);
#endif
case NodeType.SecurityAttribute:
return this.VisitSecurityAttribute((SecurityAttribute)node);
#if !MinimalReader && !CodeContracts
case NodeType.SetterValue:
return this.VisitSetterValue((SetterValue)node);
case NodeType.StatementSnippet:
return this.VisitStatementSnippet((StatementSnippet)node);
#endif
case NodeType.Struct :
return this.VisitStruct((Struct)node);
#if !MinimalReader && !CodeContracts
case NodeType.Switch :
return this.VisitSwitch((Switch)node);
case NodeType.SwitchCase :
return this.VisitSwitchCase((SwitchCase)node);
#endif
case NodeType.SwitchInstruction :
return this.VisitSwitchInstruction((SwitchInstruction)node);
#if !MinimalReader && !CodeContracts
case NodeType.Typeswitch :
return this.VisitTypeswitch((Typeswitch)node);
case NodeType.TypeswitchCase :
return this.VisitTypeswitchCase((TypeswitchCase)node);
#endif
case NodeType.This :
return this.VisitThis((This)node);
#if !MinimalReader && !CodeContracts
case NodeType.Try :
return this.VisitTry((Try)node);
#endif
#if ExtendedRuntime || CodeContracts
case NodeType.TypeContract:
return this.VisitTypeContract((TypeContract)node);
#endif
#if ExtendedRuntime
case NodeType.TupleType:
return this.VisitTupleType((TupleType)node);
case NodeType.TypeAlias:
return this.VisitTypeAlias((TypeAlias)node);
case NodeType.TypeIntersection:
return this.VisitTypeIntersection((TypeIntersection)node);
#endif
#if !MinimalReader && !CodeContracts
case NodeType.TypeMemberSnippet:
return this.VisitTypeMemberSnippet((TypeMemberSnippet)node);
#endif
case NodeType.ClassParameter:
case NodeType.TypeParameter:
return this.VisitTypeParameter((TypeNode)node);
#if ExtendedRuntime
case NodeType.TypeUnion:
return this.VisitTypeUnion((TypeUnion)node);
#endif
#if !MinimalReader && !CodeContracts
case NodeType.TypeReference:
return this.VisitTypeReference((TypeReference)node);
case NodeType.UsedNamespace :
return this.VisitUsedNamespace((UsedNamespace)node);
case NodeType.VariableDeclaration:
return this.VisitVariableDeclaration((VariableDeclaration)node);
case NodeType.While:
return this.VisitWhile((While)node);
case NodeType.Yield:
return this.VisitYield((Yield)node);
case NodeType.Conditional :
#endif
case NodeType.Cpblk :
case NodeType.Initblk :
return this.VisitTernaryExpression((TernaryExpression)node);
case NodeType.Add :
case NodeType.Add_Ovf :
case NodeType.Add_Ovf_Un :
#if !MinimalReader
case NodeType.AddEventHandler :
#endif
case NodeType.And :
#if !MinimalReader
case NodeType.As :
#endif
case NodeType.Box :
case NodeType.Castclass :
case NodeType.Ceq :
case NodeType.Cgt :
case NodeType.Cgt_Un :
case NodeType.Clt :
case NodeType.Clt_Un :
#if !MinimalReader
case NodeType.Comma :
#endif
case NodeType.Div :
case NodeType.Div_Un :
case NodeType.Eq :
#if !MinimalReader
case NodeType.ExplicitCoercion :
#endif
case NodeType.Ge :
case NodeType.Gt :
#if !MinimalReader
case NodeType.Is :
case NodeType.Iff :
case NodeType.Implies :
#endif
case NodeType.Isinst :
case NodeType.Ldvirtftn :
case NodeType.Le :
#if !MinimalReader
case NodeType.LogicalAnd :
case NodeType.LogicalOr :
#endif
case NodeType.Lt :
case NodeType.Mkrefany :
#if !MinimalReader
case NodeType.Maplet :
#endif
case NodeType.Mul :
case NodeType.Mul_Ovf :
case NodeType.Mul_Ovf_Un :
case NodeType.Ne :
case NodeType.Or :
#if !MinimalReader
case NodeType.NullCoalesingExpression:
case NodeType.Range :
#endif
case NodeType.Refanyval :
case NodeType.Rem :
case NodeType.Rem_Un :
#if !MinimalReader
case NodeType.RemoveEventHandler :
#endif
case NodeType.Shl :
case NodeType.Shr :
case NodeType.Shr_Un :
case NodeType.Sub :
case NodeType.Sub_Ovf :
case NodeType.Sub_Ovf_Un :
case NodeType.Unbox :
case NodeType.UnboxAny :
case NodeType.Xor :
return this.VisitBinaryExpression((BinaryExpression)node);
case NodeType.AddressOf:
#if !MinimalReader
case NodeType.OutAddress:
case NodeType.RefAddress:
#endif
case NodeType.Ckfinite :
case NodeType.Conv_I :
case NodeType.Conv_I1 :
case NodeType.Conv_I2 :
case NodeType.Conv_I4 :
case NodeType.Conv_I8 :
case NodeType.Conv_Ovf_I :
case NodeType.Conv_Ovf_I1 :
case NodeType.Conv_Ovf_I1_Un :
case NodeType.Conv_Ovf_I2 :
case NodeType.Conv_Ovf_I2_Un :
case NodeType.Conv_Ovf_I4 :
case NodeType.Conv_Ovf_I4_Un :
case NodeType.Conv_Ovf_I8 :
case NodeType.Conv_Ovf_I8_Un :
case NodeType.Conv_Ovf_I_Un :
case NodeType.Conv_Ovf_U :
case NodeType.Conv_Ovf_U1 :
case NodeType.Conv_Ovf_U1_Un :
case NodeType.Conv_Ovf_U2 :
case NodeType.Conv_Ovf_U2_Un :
case NodeType.Conv_Ovf_U4 :
case NodeType.Conv_Ovf_U4_Un :
case NodeType.Conv_Ovf_U8 :
case NodeType.Conv_Ovf_U8_Un :
case NodeType.Conv_Ovf_U_Un :
case NodeType.Conv_R4 :
case NodeType.Conv_R8 :
case NodeType.Conv_R_Un :
case NodeType.Conv_U :
case NodeType.Conv_U1 :
case NodeType.Conv_U2 :
case NodeType.Conv_U4 :
case NodeType.Conv_U8 :
#if !MinimalReader
case NodeType.Decrement :
case NodeType.DefaultValue :
case NodeType.Increment :
#endif
case NodeType.Ldftn :
case NodeType.Ldlen :
case NodeType.Ldtoken :
case NodeType.Localloc :
case NodeType.LogicalNot :
case NodeType.Neg :
case NodeType.Not :
#if !MinimalReader
case NodeType.Parentheses :
#endif
case NodeType.Refanytype :
case NodeType.ReadOnlyAddressOf :
case NodeType.Sizeof :
case NodeType.SkipCheck :
#if !MinimalReader
case NodeType.Typeof :
case NodeType.UnaryPlus :
#endif
return this.VisitUnaryExpression((UnaryExpression)node);
#if ExtendedRuntime
// query node types
case NodeType.QueryAggregate:
return this.VisitQueryAggregate((QueryAggregate)node);
case NodeType.QueryAlias:
return this.VisitQueryAlias((QueryAlias)node);
case NodeType.QueryAll:
case NodeType.QueryAny:
return this.VisitQueryQuantifier((QueryQuantifier)node);
case NodeType.QueryAxis:
return this.VisitQueryAxis((QueryAxis)node);
case NodeType.QueryCommit:
return this.VisitQueryCommit((QueryCommit)node);
case NodeType.QueryContext:
return this.VisitQueryContext((QueryContext)node);
case NodeType.QueryDelete:
return this.VisitQueryDelete((QueryDelete)node);
case NodeType.QueryDifference:
return this.VisitQueryDifference((QueryDifference)node);
case NodeType.QueryDistinct:
return this.VisitQueryDistinct((QueryDistinct)node);
case NodeType.QueryExists:
return this.VisitQueryExists((QueryExists)node);
case NodeType.QueryFilter:
return this.VisitQueryFilter((QueryFilter)node);
case NodeType.QueryGeneratedType:
return this.VisitQueryGeneratedType((QueryGeneratedType)node);
case NodeType.QueryGroupBy:
return this.VisitQueryGroupBy((QueryGroupBy)node);
case NodeType.QueryInsert:
return this.VisitQueryInsert((QueryInsert)node);
case NodeType.QueryIntersection:
return this.VisitQueryIntersection((QueryIntersection)node);
case NodeType.QueryIterator:
return this.VisitQueryIterator((QueryIterator)node);
case NodeType.QueryJoin:
return this.VisitQueryJoin((QueryJoin)node);
case NodeType.QueryLimit:
return this.VisitQueryLimit((QueryLimit)node);
case NodeType.QueryOrderBy:
return this.VisitQueryOrderBy((QueryOrderBy)node);
case NodeType.QueryOrderItem:
return this.VisitQueryOrderItem((QueryOrderItem)node);
case NodeType.QueryPosition:
return this.VisitQueryPosition((QueryPosition)node);
case NodeType.QueryProject:
return this.VisitQueryProject((QueryProject)node);
case NodeType.QueryQuantifiedExpression:
return this.VisitQueryQuantifiedExpression((QueryQuantifiedExpression)node);
case NodeType.QueryRollback:
return this.VisitQueryRollback((QueryRollback)node);
case NodeType.QuerySelect:
return this.VisitQuerySelect((QuerySelect)node);
case NodeType.QuerySingleton:
return this.VisitQuerySingleton((QuerySingleton)node);
case NodeType.QueryTransact:
return this.VisitQueryTransact((QueryTransact)node);
case NodeType.QueryTypeFilter:
return this.VisitQueryTypeFilter((QueryTypeFilter)node);
case NodeType.QueryUnion:
return this.VisitQueryUnion((QueryUnion)node);
case NodeType.QueryUpdate:
return this.VisitQueryUpdate((QueryUpdate)node);
case NodeType.QueryYielder:
return this.VisitQueryYielder((QueryYielder)node);
#endif
default:
return this.VisitUnknownNodeType(node);
}
}
public virtual Expression VisitAddressDereference(AddressDereference addr){
if (addr == null) return null;
addr.Address = this.VisitExpression(addr.Address);
return addr;
}
#if !MinimalReader && !CodeContracts
public virtual AliasDefinition VisitAliasDefinition(AliasDefinition aliasDefinition){
if (aliasDefinition == null) return null;
aliasDefinition.AliasedType = this.VisitTypeReference(aliasDefinition.AliasedType);
return aliasDefinition;
}
public virtual AliasDefinitionList VisitAliasDefinitionList(AliasDefinitionList aliasDefinitions){
if (aliasDefinitions == null) return null;
for (int i = 0, n = aliasDefinitions.Count; i < n; i++)
aliasDefinitions[i] = this.VisitAliasDefinition(aliasDefinitions[i]);
return aliasDefinitions;
}
public virtual Expression VisitAnonymousNestedFunction(AnonymousNestedFunction func){
if (func == null) return null;
func.Parameters = this.VisitParameterList(func.Parameters);
func.Body = this.VisitBlock(func.Body);
return func;
}
public virtual Expression VisitApplyToAll(ApplyToAll applyToAll){
if (applyToAll == null) return null;
applyToAll.Operand1 = this.VisitExpression(applyToAll.Operand1);
applyToAll.Operand2 = this.VisitExpression(applyToAll.Operand2);
return applyToAll;
}
public ArrayType VisitArrayType(ArrayType array){
Debug.Assert(false, "An array type exists only at runtime. It should be referred to, but never visited.");
return null;
}
#endif
public virtual AssemblyNode VisitAssembly(AssemblyNode assembly){
if (assembly == null) return null;
this.VisitModule(assembly);
assembly.ModuleAttributes = this.VisitAttributeList(assembly.ModuleAttributes);
assembly.SecurityAttributes = this.VisitSecurityAttributeList(assembly.SecurityAttributes);
return assembly;
}
public virtual AssemblyReference VisitAssemblyReference(AssemblyReference assemblyReference){
return assemblyReference;
}
#if !MinimalReader
public virtual Statement VisitAssertion(Assertion assertion){
if (assertion == null) return null;
assertion.Condition = this.VisitExpression(assertion.Condition);
return assertion;
}
public virtual Statement VisitAssumption(Assumption assumption){
if (assumption == null) return null;
assumption.Condition = this.VisitExpression(assumption.Condition);
return assumption;
}
public virtual Expression VisitAssignmentExpression(AssignmentExpression assignment){
if (assignment == null) return null;
assignment.AssignmentStatement = (Statement)this.Visit(assignment.AssignmentStatement);
return assignment;
}
#endif
public virtual Statement VisitAssignmentStatement(AssignmentStatement assignment){
if (assignment == null) return null;
assignment.Target = this.VisitTargetExpression(assignment.Target);
assignment.Source = this.VisitExpression(assignment.Source);
return assignment;
}
public virtual Expression VisitAttributeConstructor(AttributeNode attribute){
if (attribute == null) return null;
return this.VisitExpression(attribute.Constructor);
}
public virtual AttributeNode VisitAttributeNode(AttributeNode attribute){
if (attribute == null) return null;
attribute.Constructor = this.VisitAttributeConstructor(attribute);
attribute.Expressions = this.VisitExpressionList(attribute.Expressions);
return attribute;
}
public virtual AttributeList VisitAttributeList(AttributeList attributes){
if (attributes == null) return null;
for (int i = 0, n = attributes.Count; i < n; i++)
attributes[i] = this.VisitAttributeNode(attributes[i]);
return attributes;
}
#if !MinimalReader && !CodeContracts
public virtual Expression VisitBase(Base Base){
return Base;
}
#endif
public virtual Expression VisitBinaryExpression(BinaryExpression binaryExpression){
if (binaryExpression == null) return null;
binaryExpression.Operand1 = this.VisitExpression(binaryExpression.Operand1);
binaryExpression.Operand2 = this.VisitExpression(binaryExpression.Operand2);
return binaryExpression;
}
public virtual Block VisitBlock(Block block){
if (block == null) return null;
block.Statements = this.VisitStatementList(block.Statements);
return block;
}
#if !MinimalReader
public virtual Expression VisitBlockExpression(BlockExpression blockExpression){
if (blockExpression == null) return null;
blockExpression.Block = this.VisitBlock(blockExpression.Block);
return blockExpression;
}
#endif
public virtual BlockList VisitBlockList(BlockList blockList){
if (blockList == null) return null;
for (int i = 0, n = blockList.Count; i < n; i++)
blockList[i] = this.VisitBlock(blockList[i]);
return blockList;
}
public virtual Statement VisitBranch(Branch branch){
if (branch == null) return null;
branch.Condition = this.VisitExpression(branch.Condition);
return branch;
}
#if !MinimalReader && !CodeContracts
public virtual Statement VisitCatch(Catch Catch){
if (Catch == null) return null;
Catch.Variable = this.VisitTargetExpression(Catch.Variable);
Catch.Type = this.VisitTypeReference(Catch.Type);
Catch.Block = this.VisitBlock(Catch.Block);
return Catch;
}
public virtual CatchList VisitCatchList(CatchList catchers){
if (catchers == null) return null;
for (int i = 0, n = catchers.Count; i < n; i++)
catchers[i] = (Catch)this.VisitCatch(catchers[i]);
return catchers;
}
#endif
public virtual Class VisitClass(Class Class){
return (Class)this.VisitTypeNode(Class);
}
#if !MinimalReader && !CodeContracts
public virtual Expression VisitCoerceTuple(CoerceTuple coerceTuple){
if (coerceTuple == null) return null;
coerceTuple.OriginalTuple = this.VisitExpression(coerceTuple.OriginalTuple);
return this.VisitConstructTuple(coerceTuple);
}
public virtual CollectionEnumerator VisitCollectionEnumerator(CollectionEnumerator ce){
if (ce == null) return null;
ce.Collection = this.VisitExpression(ce.Collection);
return ce;
}
public virtual Compilation VisitCompilation(Compilation compilation){
if (compilation == null) return null;
Module module = compilation.TargetModule;
if (module != null)
module.Attributes = this.VisitAttributeList(module.Attributes);
AssemblyNode assem = module as AssemblyNode;
if (assem != null)
assem.ModuleAttributes = this.VisitAttributeList(assem.ModuleAttributes);
compilation.CompilationUnits = this.VisitCompilationUnitList(compilation.CompilationUnits);
return compilation;
}
public virtual CompilationUnit VisitCompilationUnit(CompilationUnit cUnit){
if (cUnit == null) return null;
cUnit.Nodes = this.VisitNodeList(cUnit.Nodes);
return cUnit;
}
public virtual NodeList VisitNodeList(NodeList nodes){
if (nodes == null) return null;
for (int i = 0, n = nodes.Count; i < n; i++)
nodes[i] = this.Visit(nodes[i]);
return nodes;
}
public virtual CompilationUnitList VisitCompilationUnitList(CompilationUnitList compilationUnits){
if (compilationUnits == null) return null;
for (int i = 0, n = compilationUnits.Count; i < n; i++)
compilationUnits[i] = (CompilationUnit)this.Visit(compilationUnits[i]);
return compilationUnits;
}
public virtual CompilationUnit VisitCompilationUnitSnippet(CompilationUnitSnippet snippet){
return this.VisitCompilationUnit(snippet);
}
public virtual Node VisitComposition(Composition comp){
if (comp == null) return null;
if (comp.GetType() == typeof(Composition)){
comp.Expression = (Expression)this.Visit(comp.Expression);
return comp;
}
return this.VisitUnknownNodeType(comp);
}
#endif
public virtual Expression VisitConstruct(Construct cons){
if (cons == null) return null;
cons.Constructor = this.VisitExpression(cons.Constructor);
cons.Operands = this.VisitExpressionList(cons.Operands);
#if !MinimalReader
cons.Owner = this.VisitExpression(cons.Owner);
#endif
return cons;
}
public virtual Expression VisitConstructArray(ConstructArray consArr){
if (consArr == null) return null;
consArr.ElementType = this.VisitTypeReference(consArr.ElementType);
consArr.Operands = this.VisitExpressionList(consArr.Operands);
#if !MinimalReader
consArr.Initializers = this.VisitExpressionList(consArr.Initializers);
consArr.Owner = this.VisitExpression(consArr.Owner);
#endif
return consArr;
}
#if !MinimalReader && !CodeContracts
public virtual Expression VisitConstructDelegate(ConstructDelegate consDelegate){
if (consDelegate == null) return null;
consDelegate.DelegateType = this.VisitTypeReference(consDelegate.DelegateType);
consDelegate.TargetObject = this.VisitExpression(consDelegate.TargetObject);
return consDelegate;
}
public virtual Expression VisitConstructFlexArray(ConstructFlexArray consArr){
if (consArr == null) return null;
consArr.ElementType = this.VisitTypeReference(consArr.ElementType);
consArr.Operands = this.VisitExpressionList(consArr.Operands);
consArr.Initializers = this.VisitExpressionList(consArr.Initializers);
return consArr;
}
public virtual Expression VisitConstructIterator(ConstructIterator consIterator){
return consIterator;
}
public virtual Expression VisitConstructTuple(ConstructTuple consTuple){
if (consTuple == null) return null;
consTuple.Fields = this.VisitFieldList(consTuple.Fields);
return consTuple;
}
#endif
#if ExtendedRuntime
public virtual TypeNode VisitConstrainedType(ConstrainedType cType){
if (cType == null) return null;
cType.UnderlyingType = this.VisitTypeReference(cType.UnderlyingType);
cType.Constraint = this.VisitExpression(cType.Constraint);
return cType;
}
#endif
#if !MinimalReader && !CodeContracts
public virtual Statement VisitContinue(Continue Continue){
return Continue;
}
public virtual Expression VisitCurrentClosure(CurrentClosure currentClosure){
return currentClosure;
}
#endif
public virtual DelegateNode VisitDelegateNode(DelegateNode delegateNode){
if (delegateNode == null) return null;
delegateNode = (DelegateNode)this.VisitTypeNode(delegateNode);
if (delegateNode == null) return null;
delegateNode.Parameters = this.VisitParameterList(delegateNode.Parameters);
delegateNode.ReturnType = this.VisitTypeReference(delegateNode.ReturnType);
return delegateNode;
}
#if !MinimalReader && !CodeContracts
public virtual Statement VisitDoWhile(DoWhile doWhile){
if (doWhile == null) return null;
doWhile.Invariants = this.VisitLoopInvariantList(doWhile.Invariants);
doWhile.Body = this.VisitBlock(doWhile.Body);
doWhile.Condition = this.VisitExpression(doWhile.Condition);
return doWhile;
}
#endif
public virtual Statement VisitEndFilter(EndFilter endFilter){
if (endFilter == null) return null;
endFilter.Value = this.VisitExpression(endFilter.Value);
return endFilter;
}
public virtual Statement VisitEndFinally(EndFinally endFinally){
return endFinally;
}
#if ExtendedRuntime || CodeContracts
public virtual EnsuresList VisitEnsuresList(EnsuresList Ensures) {
if (Ensures == null) return null;
for (int i = 0, n = Ensures.Count; i < n; i++)
Ensures[i] = (Ensures) this.Visit(Ensures[i]);
return Ensures;
}
#endif
public virtual EnumNode VisitEnumNode(EnumNode enumNode) {
return (EnumNode)this.VisitTypeNode(enumNode);
}
public virtual Event VisitEvent(Event evnt){
if (evnt == null) return null;
evnt.Attributes = this.VisitAttributeList(evnt.Attributes);
evnt.HandlerType = this.VisitTypeReference(evnt.HandlerType);
return evnt;
}
#if ExtendedRuntime || CodeContracts
public virtual EnsuresExceptional VisitEnsuresExceptional(EnsuresExceptional exceptional) {
if (exceptional == null) return null;
exceptional.PostCondition = this.VisitExpression(exceptional.PostCondition);
exceptional.Type = this.VisitTypeReference(exceptional.Type);
exceptional.Variable = this.VisitExpression(exceptional.Variable);
exceptional.UserMessage = this.VisitExpression(exceptional.UserMessage);
return exceptional;
}
#endif
#if !MinimalReader && !CodeContracts
public virtual Statement VisitExit(Exit exit) {
return exit;
}
public virtual Statement VisitExpose(Expose @expose){
if (@expose == null) return null;
@expose.Instance = this.VisitExpression(@expose.Instance);
@expose.Body = this.VisitBlock(expose.Body);
return expose;
}
#endif
public virtual Expression VisitExpression(Expression expression){
if (expression == null) return null;
switch(expression.NodeType){
case NodeType.Dup:
case NodeType.Arglist:
return expression;
case NodeType.Pop:
UnaryExpression uex = expression as UnaryExpression;
if (uex != null){
uex.Operand = this.VisitExpression(uex.Operand);
return uex;
}
return expression;
default:
return (Expression)this.Visit(expression);
}
}
public override ExpressionList VisitExpressionList(ExpressionList expressions){
if (expressions == null) return null;