1 // NRefactoryEvaluator.cs
4 // Lluis Sanchez Gual <lluis@novell.com>
6 // Copyright (c) 2008 Novell, Inc (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 using System
.Collections
.Generic
;
31 using System
.Runtime
.InteropServices
;
33 using Mono
.Debugger
.Languages
;
34 using DC
= Mono
.Debugging
.Client
;
35 using ICSharpCode
.NRefactory
;
36 using ICSharpCode
.NRefactory
.Parser
;
37 using ICSharpCode
.NRefactory
.Visitors
;
38 using ICSharpCode
.NRefactory
.Ast
;
40 namespace DebuggerServer
42 public class NRefactoryEvaluator
: ExpressionEvaluator
44 public override ValueReference
Evaluate (EvaluationContext ctx
, string exp
, EvaluationOptions options
)
46 StringReader codeStream
= new StringReader (exp
);
47 IParser parser
= ParserFactory
.CreateParser (SupportedLanguage
.CSharp
, codeStream
);
48 Expression expObj
= parser
.ParseExpression ();
49 EvaluatorVisitor ev
= new EvaluatorVisitor (ctx
, exp
, options
);
50 return (ValueReference
) expObj
.AcceptVisitor (ev
, null);
54 class EvaluatorVisitor
: AbstractAstVisitor
56 EvaluationContext ctx
;
58 EvaluationOptions options
;
60 public EvaluatorVisitor (EvaluationContext ctx
, string name
, EvaluationOptions options
)
64 this.options
= options
;
67 public override object VisitUnaryOperatorExpression (ICSharpCode
.NRefactory
.Ast
.UnaryOperatorExpression unaryOperatorExpression
, object data
)
69 ValueReference vref
= (ValueReference
) unaryOperatorExpression
.Expression
.AcceptVisitor (this, null);
70 object val
= vref
.ObjectValue
;
72 switch (unaryOperatorExpression
.Op
) {
73 case UnaryOperatorType
.BitNot
: {
74 long num
= Convert
.ToInt64 (val
);
76 val
= Convert
.ChangeType (num
, val
.GetType ());
79 case UnaryOperatorType
.Minus
: {
80 long num
= Convert
.ToInt64 (val
);
82 val
= Convert
.ChangeType (num
, val
.GetType ());
85 case UnaryOperatorType
.Not
:
88 case UnaryOperatorType
.Plus
:
91 throw CreateNotSupportedError ();
94 return new LiteralValueReference (ctx
, name
, val
);
97 public override object VisitTypeReference (ICSharpCode
.NRefactory
.Ast
.TypeReference typeReference
, object data
)
99 TargetType type
= ctx
.Frame
.Language
.LookupType (typeReference
.SystemType
);
101 return new TypeValueReference (ctx
, type
);
103 throw CreateParseError ("Unknown type: " + typeReference
.Type
);
106 public override object VisitTypeReferenceExpression (ICSharpCode
.NRefactory
.Ast
.TypeReferenceExpression typeReferenceExpression
, object data
)
108 throw CreateNotSupportedError ();
111 public override object VisitTypeOfExpression (ICSharpCode
.NRefactory
.Ast
.TypeOfExpression typeOfExpression
, object data
)
113 TargetObject ob
= ObjectUtil
.GetTypeOf (ctx
, typeOfExpression
.TypeReference
.SystemType
);
115 return new LiteralValueReference (ctx
, typeOfExpression
.TypeReference
.SystemType
, ob
);
117 throw CreateNotSupportedError ();
120 public override object VisitThisReferenceExpression (ICSharpCode
.NRefactory
.Ast
.ThisReferenceExpression thisReferenceExpression
, object data
)
122 if (ctx
.Frame
.Method
!= null && ctx
.Frame
.Method
.HasThis
) {
123 DC
.ObjectValueFlags flags
= DC
.ObjectValueFlags
.Field
| DC
.ObjectValueFlags
.ReadOnly
;
124 TargetVariable
var = ctx
.Frame
.Method
.GetThis (ctx
.Thread
);
125 return new VariableReference (ctx
, var, flags
);
128 throw CreateParseError ("'this' reference not available in static methods");
131 public override object VisitPrimitiveExpression (ICSharpCode
.NRefactory
.Ast
.PrimitiveExpression primitiveExpression
, object data
)
133 if (primitiveExpression
.Value
!= null)
134 return new LiteralValueReference (ctx
, name
, primitiveExpression
.Value
);
135 else if (options
.ExpectedType
!= null)
136 return new NullValueReference (ctx
, options
.ExpectedType
);
138 return new NullValueReference (ctx
, ctx
.Frame
.Language
.ObjectType
);
141 public override object VisitParenthesizedExpression (ICSharpCode
.NRefactory
.Ast
.ParenthesizedExpression parenthesizedExpression
, object data
)
143 return parenthesizedExpression
.Expression
.AcceptVisitor (this, data
);
146 public override object VisitObjectCreateExpression (ICSharpCode
.NRefactory
.Ast
.ObjectCreateExpression objectCreateExpression
, object data
)
148 throw CreateNotSupportedError ();
151 public override object VisitInvocationExpression (ICSharpCode
.NRefactory
.Ast
.InvocationExpression invocationExpression
, object data
)
153 if (!options
.CanEvaluateMethods
)
154 throw CreateNotSupportedError ();
156 ValueReference target
= null;
159 if (invocationExpression
.TargetObject
is MemberReferenceExpression
) {
160 MemberReferenceExpression field
= (MemberReferenceExpression
)invocationExpression
.TargetObject
;
161 target
= (ValueReference
) field
.TargetObject
.AcceptVisitor (this, data
);
162 methodName
= field
.MemberName
;
163 } else if (invocationExpression
.TargetObject
is IdentifierExpression
) {
164 IdentifierExpression exp
= (IdentifierExpression
) invocationExpression
.TargetObject
;
165 methodName
= exp
.Identifier
;
169 throw CreateNotSupportedError ();
171 TargetType
[] argtypes
= new TargetType
[invocationExpression
.Arguments
.Count
];
172 TargetObject
[] args
= new TargetObject
[invocationExpression
.Arguments
.Count
];
173 for (int n
=0; n
<args
.Length
; n
++) {
174 Expression exp
= invocationExpression
.Arguments
[n
];
175 ValueReference vref
= (ValueReference
) exp
.AcceptVisitor (this, data
);
176 args
[n
] = vref
.Value
;
177 argtypes
[n
] = args
[n
].Type
;
182 bool allowStatic
= false, allowInstance
= false;
184 TargetStructType type
= null;
186 if (target
== null) {
187 if (ctx
.Frame
.Method
!= null) {
188 type
= ctx
.Frame
.Method
.GetDeclaringType (ctx
.Frame
.Thread
);
190 allowInstance
= ctx
.Frame
.Method
.HasThis
;
192 } else if (target
is TypeValueReference
) {
193 TypeValueReference tv
= (TypeValueReference
) target
;
194 allowInstance
= false;
196 type
= tv
.Type
as TargetStructType
;
199 allowInstance
= true;
201 type
= target
.Value
.Type
as TargetStructType
;
205 throw CreateParseError ("Unknown method: {0}", methodName
);
207 TargetFunctionType method
= OverloadResolve (methodName
, type
, argtypes
, allowInstance
, allowStatic
);
209 TargetMethodSignature sig
= method
.GetSignature (ctx
.Thread
);
211 TargetObject
[] objs
= new TargetObject
[args
.Length
];
212 for (int i
= 0; i
< args
.Length
; i
++) {
213 objs
[i
] = TargetObjectConvert
.ImplicitConversionRequired (
214 ctx
, args
[i
], sig
.ParameterTypes
[i
]);
217 TargetStructObject thisobj
= null;
219 if (!method
.IsStatic
) {
221 thisobj
= target
.Value
as TargetStructObject
;
222 else if (ctx
.Frame
.Method
.HasThis
) {
223 TargetVariable
var = ctx
.Frame
.Method
.GetThis (ctx
.Thread
);
224 thisobj
= (TargetStructObject
) var.GetObject (ctx
.Frame
);
228 TargetObject obj
= Server
.Instance
.RuntimeInvoke (ctx
, method
, thisobj
, objs
);
229 return new LiteralValueReference (ctx
, name
, obj
);
232 public TargetFunctionType
OverloadResolve (string methodName
, TargetStructType type
, TargetType
[] argtypes
, bool allowInstance
, bool allowStatic
)
234 List
<TargetFunctionType
> candidates
= new List
<TargetFunctionType
> ();
236 foreach (MemberReference mem
in ObjectUtil
.GetTypeMembers (ctx
, type
, false, false, false, true, ReqMemberAccess
.All
)) {
237 TargetMethodInfo met
= (TargetMethodInfo
) mem
.Member
;
238 if (met
.Name
== methodName
&& met
.Type
.ParameterTypes
.Length
== argtypes
.Length
&& (met
.IsStatic
&& allowStatic
|| !met
.IsStatic
&& allowInstance
))
239 candidates
.Add (met
.Type
);
242 TargetFunctionType candidate
;
243 if (candidates
.Count
== 1) {
244 candidate
= (TargetFunctionType
) candidates
[0];
246 if (IsApplicable (candidate
, argtypes
, out error
))
249 throw CreateParseError ("The best overload of method `{0}' has some invalid arguments:\n{1}", methodName
, error
);
252 if (candidates
.Count
== 0)
253 throw CreateParseError ("No overload of method `{0}' has {1} arguments.", methodName
, argtypes
.Length
);
255 candidate
= OverloadResolve (argtypes
, candidates
);
257 if (candidate
== null)
258 throw CreateParseError ("Ambiguous method `{0}'; need to use full name", methodName
);
263 public bool IsApplicable (TargetFunctionType method
, TargetType
[] types
, out string error
)
265 TargetMethodSignature sig
= method
.GetSignature (ctx
.Thread
);
267 for (int i
= 0; i
< types
.Length
; i
++) {
268 TargetType param_type
= sig
.ParameterTypes
[i
];
270 if (param_type
== types
[i
])
273 if (TargetObjectConvert
.ImplicitConversionExists (ctx
, types
[i
], param_type
))
276 error
= String
.Format (
277 "Argument {0}: Cannot implicitly convert `{1}' to `{2}'",
278 i
, types
[i
].Name
, param_type
.Name
);
286 TargetFunctionType
OverloadResolve (TargetType
[] argtypes
, List
<TargetFunctionType
> candidates
)
288 // Ok, no we need to find an exact match.
289 TargetFunctionType match
= null;
290 foreach (TargetFunctionType method
in candidates
) {
292 if (!IsApplicable (method
, argtypes
, out error
))
295 // We need to find exactly one match
305 public override object VisitInnerClassTypeReference (ICSharpCode
.NRefactory
.Ast
.InnerClassTypeReference innerClassTypeReference
, object data
)
307 throw CreateNotSupportedError ();
310 public override object VisitIndexerExpression (ICSharpCode
.NRefactory
.Ast
.IndexerExpression indexerExpression
, object data
)
312 ValueReference val
= (ValueReference
) indexerExpression
.TargetObject
.AcceptVisitor (this, data
);
313 TargetObject ob
= val
.Value
;
314 TargetArrayObject arr
= ob
as TargetArrayObject
;
316 int[] indexes
= new int [indexerExpression
.Indexes
.Count
];
317 for (int n
=0; n
<indexes
.Length
; n
++) {
318 ValueReference vi
= (ValueReference
) indexerExpression
.Indexes
[n
].AcceptVisitor (this, data
);
319 indexes
[n
] = (int) Convert
.ChangeType (vi
.ObjectValue
, typeof(int));
321 return new ArrayValueReference (ctx
, arr
, indexes
);
324 if (indexerExpression
.Indexes
.Count
== 1) {
325 ValueReference vi
= (ValueReference
) indexerExpression
.Indexes
[0].AcceptVisitor (this, data
);
326 IndexerValueReference idx
= IndexerValueReference
.CreateIndexerValueReference (ctx
, ob
, vi
.Value
);
331 throw CreateNotSupportedError ();
334 public override object VisitIdentifierExpression (ICSharpCode
.NRefactory
.Ast
.IdentifierExpression identifierExpression
, object data
)
336 string name
= identifierExpression
.Identifier
;
340 foreach (TargetVariable
var in ctx
.Frame
.Method
.GetLocalVariables (ctx
.Thread
)) {
341 if (var.Name
== name
)
342 return new VariableReference (ctx
, var, DC
.ObjectValueFlags
.Variable
);
345 // Look in parameters
347 foreach (TargetVariable
var in ctx
.Frame
.Method
.GetParameters (ctx
.Thread
))
348 if (var.Name
== name
)
349 return new VariableReference (ctx
, var, DC
.ObjectValueFlags
.Parameter
);
351 // Look in fields and properties
353 TargetStructObject thisobj
= null;
355 if (ctx
.Frame
.Method
.HasThis
) {
356 TargetObject ob
= ctx
.Frame
.Method
.GetThis (ctx
.Thread
).GetObject (ctx
.Frame
);
357 thisobj
= ObjectUtil
.GetRealObject (ctx
, ob
) as TargetStructObject
;
360 TargetStructType type
= ctx
.Frame
.Method
.GetDeclaringType (ctx
.Thread
);
362 foreach (MemberReference mem
in ObjectUtil
.GetTypeMembers (ctx
, type
, thisobj
==null, true, true, false, ReqMemberAccess
.All
)) {
363 if (mem
.Member
.Name
!= name
)
365 if (mem
.Member
is TargetFieldInfo
) {
366 TargetFieldInfo field
= (TargetFieldInfo
) mem
.Member
;
367 return new FieldReference (ctx
, thisobj
, mem
.DeclaringType
, field
);
369 if (mem
.Member
is TargetPropertyInfo
) {
370 TargetPropertyInfo prop
= (TargetPropertyInfo
) mem
.Member
;
372 return new PropertyReference (ctx
, prop
, thisobj
);
378 TargetType vtype
= ctx
.Frame
.Language
.LookupType (name
);
380 return new TypeValueReference (ctx
, vtype
);
382 if (ctx
.Frame
.Method
!= null && ctx
.Frame
.Method
.HasLineNumbers
) {
383 string[] namespaces
= ctx
.Frame
.Method
.GetNamespaces ();
385 if (namespaces
!= null) {
386 // Look in types from included namespaces
388 foreach (string ns
in namespaces
) {
389 vtype
= ctx
.Frame
.Language
.LookupType (ns
+ "." + name
);
391 return new TypeValueReference (ctx
, vtype
);
394 // Look in namespaces
396 foreach (string ns
in namespaces
) {
397 if (ns
== name
|| ns
.StartsWith (name
+ "."))
398 return new NamespaceValueReference (ctx
, name
);
403 throw CreateParseError ("Unknwon identifier: {0}", name
);
406 public override object VisitMemberReferenceExpression (MemberReferenceExpression memberReferenceExpression
, object data
)
408 ValueReference vref
= (ValueReference
) memberReferenceExpression
.TargetObject
.AcceptVisitor (this, data
);
409 ValueReference ch
= vref
.GetChild (memberReferenceExpression
.MemberName
);
411 throw CreateParseError ("Unknown member: {0}", memberReferenceExpression
.MemberName
);
415 public override object VisitConditionalExpression (ICSharpCode
.NRefactory
.Ast
.ConditionalExpression conditionalExpression
, object data
)
417 ValueReference vc
= (ValueReference
) conditionalExpression
.Condition
.AcceptVisitor (this, data
);
418 bool cond
= (bool) vc
.ObjectValue
;
420 return conditionalExpression
.TrueExpression
.AcceptVisitor (this, data
);
422 return conditionalExpression
.FalseExpression
.AcceptVisitor (this, data
);
425 public override object VisitClassReferenceExpression (ICSharpCode
.NRefactory
.Ast
.ClassReferenceExpression classReferenceExpression
, object data
)
427 throw CreateNotSupportedError ();
430 public override object VisitCastExpression (ICSharpCode
.NRefactory
.Ast
.CastExpression castExpression
, object data
)
432 ValueReference val
= (ValueReference
) castExpression
.Expression
.AcceptVisitor (this, data
);
433 TypeValueReference type
= castExpression
.CastTo
.AcceptVisitor (this, data
) as TypeValueReference
;
435 throw CreateParseError ("Invalid cast type.");
436 TargetObject ob
= TargetObjectConvert
.Cast (ctx
, val
.Value
, type
.Type
);
438 if (castExpression
.CastType
== CastType
.TryCast
)
439 return new NullValueReference (ctx
, type
.Type
);
441 throw CreateParseError ("Invalid cast.");
446 public override object VisitBinaryOperatorExpression (ICSharpCode
.NRefactory
.Ast
.BinaryOperatorExpression binaryOperatorExpression
, object data
)
448 ValueReference left
= (ValueReference
) binaryOperatorExpression
.Left
.AcceptVisitor (this, data
);
452 switch (binaryOperatorExpression
.Op
) {
453 case BinaryOperatorType
.LogicalAnd
: {
454 if (!(bool)left
.ObjectValue
)
456 return binaryOperatorExpression
.Right
.AcceptVisitor (this, data
);
458 case BinaryOperatorType
.LogicalOr
: {
459 if ((bool)left
.ObjectValue
)
461 return binaryOperatorExpression
.Right
.AcceptVisitor (this, data
);
465 ValueReference right
= (ValueReference
) binaryOperatorExpression
.Right
.AcceptVisitor (this, data
);
467 if (binaryOperatorExpression
.Op
== BinaryOperatorType
.Add
|| binaryOperatorExpression
.Op
== BinaryOperatorType
.Concat
) {
468 if (left
.Type
== ctx
.Frame
.Language
.StringType
|| right
.Type
== ctx
.Frame
.Language
.StringType
)
469 return new LiteralValueReference (ctx
, name
, left
.CallToString () + right
.CallToString ());
472 object val1
= left
.ObjectValue
;
473 object val2
= right
.ObjectValue
;
475 if ((binaryOperatorExpression
.Op
== BinaryOperatorType
.ExclusiveOr
) && (val1
is bool) && !(val2
is bool))
476 return new LiteralValueReference (ctx
, name
, (bool)val1 ^
(bool)val2
);
478 switch (binaryOperatorExpression
.Op
) {
479 case BinaryOperatorType
.Equality
:
480 return new LiteralValueReference (ctx
, name
, val1
.Equals (val2
));
481 case BinaryOperatorType
.InEquality
:
482 return new LiteralValueReference (ctx
, name
, !val1
.Equals (val2
));
483 case BinaryOperatorType
.ReferenceEquality
:
484 return new LiteralValueReference (ctx
, name
, val1
== val2
);
485 case BinaryOperatorType
.ReferenceInequality
:
486 return new LiteralValueReference (ctx
, name
, val1
!= val2
);
487 case BinaryOperatorType
.Concat
:
488 throw CreateParseError ("Invalid binary operator.");
491 long v1
= Convert
.ToInt64 (left
.ObjectValue
);
492 long v2
= Convert
.ToInt64 (right
.ObjectValue
);
495 switch (binaryOperatorExpression
.Op
) {
496 case BinaryOperatorType
.Add
: res
= v1
+ v2
; break;
497 case BinaryOperatorType
.BitwiseAnd
: res
= v1
& v2
; break;
498 case BinaryOperatorType
.BitwiseOr
: res
= v1
| v2
; break;
499 case BinaryOperatorType
.ExclusiveOr
: res
= v1 ^ v2
; break;
500 case BinaryOperatorType
.DivideInteger
:
501 case BinaryOperatorType
.Divide
: res
= v1
/ v2
; break;
502 case BinaryOperatorType
.Modulus
: res
= v1
% v2
; break;
503 case BinaryOperatorType
.Multiply
: res
= v1
* v2
; break;
504 case BinaryOperatorType
.Power
: res
= v1 ^ v2
; break;
505 case BinaryOperatorType
.ShiftLeft
: res
= v1
<< (int)v2
; break;
506 case BinaryOperatorType
.ShiftRight
: res
= v1
>> (int)v2
; break;
507 case BinaryOperatorType
.Subtract
: res
= v1
- v2
; break;
508 case BinaryOperatorType
.GreaterThan
: res
= v1
> v2
; break;
509 case BinaryOperatorType
.GreaterThanOrEqual
: res
= v1
>= v2
; break;
510 case BinaryOperatorType
.LessThan
: res
= v1
< v2
; break;
511 case BinaryOperatorType
.LessThanOrEqual
: res
= v1
<= v2
; break;
512 default: throw CreateParseError ("Invalid binary operator.");
516 res
= (long) Convert
.ChangeType (res
, GetCommonType (v1
, v2
));
517 return new LiteralValueReference (ctx
, name
, res
);
520 Type
GetCommonType (object v1
, object v2
)
522 int s1
= Marshal
.SizeOf (v1
);
525 int s2
= Marshal
.SizeOf (v2
);
529 return v1
.GetType ();
531 return v2
.GetType ();
534 bool IsUnsigned (object v
)
536 return (v
is byte) || (v
is ushort) || (v
is uint) || (v
is ulong);
539 public override object VisitBaseReferenceExpression (ICSharpCode
.NRefactory
.Ast
.BaseReferenceExpression baseReferenceExpression
, object data
)
541 if (ctx
.Frame
.Method
!= null && ctx
.Frame
.Method
.HasThis
) {
542 TargetVariable
var = ctx
.Frame
.Method
.GetThis (ctx
.Thread
);
543 TargetClassObject ob
= (TargetClassObject
) var.GetObject (ctx
.Frame
);
544 TargetObject baseob
= ob
.GetParentObject (ctx
.Thread
);
546 throw CreateParseError ("'base' reference not available.");
547 return new LiteralValueReference (ctx
, name
, baseob
);
550 throw CreateParseError ("'base' reference not available in static methods.");
553 public override object VisitAssignmentExpression (ICSharpCode
.NRefactory
.Ast
.AssignmentExpression assignmentExpression
, object data
)
555 throw CreateNotSupportedError ();
558 public override object VisitArrayCreateExpression (ICSharpCode
.NRefactory
.Ast
.ArrayCreateExpression arrayCreateExpression
, object data
)
560 throw CreateNotSupportedError ();
563 #region Unsupported expressions
565 public override object VisitPointerReferenceExpression (ICSharpCode
.NRefactory
.Ast
.PointerReferenceExpression pointerReferenceExpression
, object data
)
567 throw CreateNotSupportedError ();
570 public override object VisitSizeOfExpression (ICSharpCode
.NRefactory
.Ast
.SizeOfExpression sizeOfExpression
, object data
)
572 throw CreateNotSupportedError ();
575 public override object VisitTypeOfIsExpression (ICSharpCode
.NRefactory
.Ast
.TypeOfIsExpression typeOfIsExpression
, object data
)
577 throw CreateNotSupportedError ();
580 public override object VisitYieldStatement (ICSharpCode
.NRefactory
.Ast
.YieldStatement yieldStatement
, object data
)
582 throw CreateNotSupportedError ();
585 public override object VisitWithStatement (ICSharpCode
.NRefactory
.Ast
.WithStatement withStatement
, object data
)
587 throw CreateNotSupportedError ();
590 public override object VisitVariableDeclaration (ICSharpCode
.NRefactory
.Ast
.VariableDeclaration variableDeclaration
, object data
)
592 throw CreateNotSupportedError ();
595 public override object VisitUsing (ICSharpCode
.NRefactory
.Ast
.Using
@using, object data
)
597 throw CreateNotSupportedError ();
600 public override object VisitUsingStatement (ICSharpCode
.NRefactory
.Ast
.UsingStatement usingStatement
, object data
)
602 throw CreateNotSupportedError ();
605 public override object VisitUsingDeclaration (ICSharpCode
.NRefactory
.Ast
.UsingDeclaration usingDeclaration
, object data
)
607 throw CreateNotSupportedError ();
610 public override object VisitUnsafeStatement (ICSharpCode
.NRefactory
.Ast
.UnsafeStatement unsafeStatement
, object data
)
612 throw CreateNotSupportedError ();
615 public override object VisitUncheckedStatement (ICSharpCode
.NRefactory
.Ast
.UncheckedStatement uncheckedStatement
, object data
)
617 throw CreateNotSupportedError ();
620 public override object VisitTypeDeclaration (ICSharpCode
.NRefactory
.Ast
.TypeDeclaration typeDeclaration
, object data
)
622 throw CreateNotSupportedError ();
625 public override object VisitTryCatchStatement (ICSharpCode
.NRefactory
.Ast
.TryCatchStatement tryCatchStatement
, object data
)
627 throw CreateNotSupportedError ();
630 public override object VisitThrowStatement (ICSharpCode
.NRefactory
.Ast
.ThrowStatement throwStatement
, object data
)
632 throw CreateNotSupportedError ();
635 public override object VisitTemplateDefinition (ICSharpCode
.NRefactory
.Ast
.TemplateDefinition templateDefinition
, object data
)
637 throw CreateNotSupportedError ();
640 public override object VisitSwitchStatement (ICSharpCode
.NRefactory
.Ast
.SwitchStatement switchStatement
, object data
)
642 throw CreateNotSupportedError ();
645 public override object VisitSwitchSection (ICSharpCode
.NRefactory
.Ast
.SwitchSection switchSection
, object data
)
647 throw CreateNotSupportedError ();
650 public override object VisitStopStatement (ICSharpCode
.NRefactory
.Ast
.StopStatement stopStatement
, object data
)
652 throw CreateNotSupportedError ();
655 public override object VisitStackAllocExpression (ICSharpCode
.NRefactory
.Ast
.StackAllocExpression stackAllocExpression
, object data
)
657 throw CreateNotSupportedError ();
660 public override object VisitReturnStatement (ICSharpCode
.NRefactory
.Ast
.ReturnStatement returnStatement
, object data
)
662 throw CreateNotSupportedError ();
665 public override object VisitResumeStatement (ICSharpCode
.NRefactory
.Ast
.ResumeStatement resumeStatement
, object data
)
667 throw CreateNotSupportedError ();
670 public override object VisitRemoveHandlerStatement (ICSharpCode
.NRefactory
.Ast
.RemoveHandlerStatement removeHandlerStatement
, object data
)
672 throw CreateNotSupportedError ();
675 public override object VisitReDimStatement (ICSharpCode
.NRefactory
.Ast
.ReDimStatement reDimStatement
, object data
)
677 throw CreateNotSupportedError ();
680 public override object VisitRaiseEventStatement (ICSharpCode
.NRefactory
.Ast
.RaiseEventStatement raiseEventStatement
, object data
)
682 throw CreateNotSupportedError ();
685 public override object VisitPropertySetRegion (ICSharpCode
.NRefactory
.Ast
.PropertySetRegion propertySetRegion
, object data
)
687 throw CreateNotSupportedError ();
690 public override object VisitPropertyGetRegion (ICSharpCode
.NRefactory
.Ast
.PropertyGetRegion propertyGetRegion
, object data
)
692 throw CreateNotSupportedError ();
695 public override object VisitPropertyDeclaration (ICSharpCode
.NRefactory
.Ast
.PropertyDeclaration propertyDeclaration
, object data
)
697 throw CreateNotSupportedError ();
700 public override object VisitParameterDeclarationExpression (ICSharpCode
.NRefactory
.Ast
.ParameterDeclarationExpression parameterDeclarationExpression
, object data
)
702 throw CreateNotSupportedError ();
705 public override object VisitOptionDeclaration (ICSharpCode
.NRefactory
.Ast
.OptionDeclaration optionDeclaration
, object data
)
707 throw CreateNotSupportedError ();
710 public override object VisitOperatorDeclaration (ICSharpCode
.NRefactory
.Ast
.OperatorDeclaration operatorDeclaration
, object data
)
712 throw CreateNotSupportedError ();
715 public override object VisitOnErrorStatement (ICSharpCode
.NRefactory
.Ast
.OnErrorStatement onErrorStatement
, object data
)
717 throw CreateNotSupportedError ();
720 public override object VisitNamespaceDeclaration (ICSharpCode
.NRefactory
.Ast
.NamespaceDeclaration namespaceDeclaration
, object data
)
722 throw CreateNotSupportedError ();
725 public override object VisitNamedArgumentExpression (ICSharpCode
.NRefactory
.Ast
.NamedArgumentExpression namedArgumentExpression
, object data
)
727 throw CreateNotSupportedError ();
730 public override object VisitMethodDeclaration (ICSharpCode
.NRefactory
.Ast
.MethodDeclaration methodDeclaration
, object data
)
732 throw CreateNotSupportedError ();
735 public override object VisitLockStatement (ICSharpCode
.NRefactory
.Ast
.LockStatement lockStatement
, object data
)
737 throw CreateNotSupportedError ();
740 public override object VisitLocalVariableDeclaration (ICSharpCode
.NRefactory
.Ast
.LocalVariableDeclaration localVariableDeclaration
, object data
)
742 throw CreateNotSupportedError ();
745 public override object VisitLabelStatement (ICSharpCode
.NRefactory
.Ast
.LabelStatement labelStatement
, object data
)
747 throw CreateNotSupportedError ();
750 public override object VisitInterfaceImplementation (ICSharpCode
.NRefactory
.Ast
.InterfaceImplementation interfaceImplementation
, object data
)
752 throw CreateNotSupportedError ();
755 public override object VisitIndexerDeclaration (ICSharpCode
.NRefactory
.Ast
.IndexerDeclaration indexerDeclaration
, object data
)
757 throw CreateNotSupportedError ();
760 public override object VisitIfElseStatement (ICSharpCode
.NRefactory
.Ast
.IfElseStatement ifElseStatement
, object data
)
762 throw CreateNotSupportedError ();
765 public override object VisitGotoStatement (ICSharpCode
.NRefactory
.Ast
.GotoStatement gotoStatement
, object data
)
767 throw CreateNotSupportedError ();
770 public override object VisitGotoCaseStatement (ICSharpCode
.NRefactory
.Ast
.GotoCaseStatement gotoCaseStatement
, object data
)
772 throw CreateNotSupportedError ();
775 public override object VisitForStatement (ICSharpCode
.NRefactory
.Ast
.ForStatement forStatement
, object data
)
777 throw CreateNotSupportedError ();
780 public override object VisitForNextStatement (ICSharpCode
.NRefactory
.Ast
.ForNextStatement forNextStatement
, object data
)
782 throw CreateNotSupportedError ();
785 public override object VisitForeachStatement (ICSharpCode
.NRefactory
.Ast
.ForeachStatement foreachStatement
, object data
)
787 throw CreateNotSupportedError ();
790 public override object VisitFixedStatement (ICSharpCode
.NRefactory
.Ast
.FixedStatement fixedStatement
, object data
)
792 throw CreateNotSupportedError ();
795 public override object VisitFieldDeclaration (ICSharpCode
.NRefactory
.Ast
.FieldDeclaration fieldDeclaration
, object data
)
797 throw CreateNotSupportedError ();
800 public override object VisitExpressionStatement (ICSharpCode
.NRefactory
.Ast
.ExpressionStatement expressionStatement
, object data
)
802 throw CreateNotSupportedError ();
805 public override object VisitExitStatement (ICSharpCode
.NRefactory
.Ast
.ExitStatement exitStatement
, object data
)
807 throw CreateNotSupportedError ();
810 public override object VisitEventRemoveRegion (ICSharpCode
.NRefactory
.Ast
.EventRemoveRegion eventRemoveRegion
, object data
)
812 throw CreateNotSupportedError ();
815 public override object VisitEventRaiseRegion (ICSharpCode
.NRefactory
.Ast
.EventRaiseRegion eventRaiseRegion
, object data
)
817 throw CreateNotSupportedError ();
820 public override object VisitEventDeclaration (ICSharpCode
.NRefactory
.Ast
.EventDeclaration eventDeclaration
, object data
)
822 throw CreateNotSupportedError ();
825 public override object VisitEventAddRegion (ICSharpCode
.NRefactory
.Ast
.EventAddRegion eventAddRegion
, object data
)
827 throw CreateNotSupportedError ();
830 public override object VisitErrorStatement (ICSharpCode
.NRefactory
.Ast
.ErrorStatement errorStatement
, object data
)
832 throw CreateNotSupportedError ();
835 public override object VisitEraseStatement (ICSharpCode
.NRefactory
.Ast
.EraseStatement eraseStatement
, object data
)
837 throw CreateNotSupportedError ();
840 public override object VisitEndStatement (ICSharpCode
.NRefactory
.Ast
.EndStatement endStatement
, object data
)
842 throw CreateNotSupportedError ();
845 public override object VisitEmptyStatement (ICSharpCode
.NRefactory
.Ast
.EmptyStatement emptyStatement
, object data
)
847 throw CreateNotSupportedError ();
850 public override object VisitElseIfSection (ICSharpCode
.NRefactory
.Ast
.ElseIfSection elseIfSection
, object data
)
852 throw CreateNotSupportedError ();
855 public override object VisitDoLoopStatement (ICSharpCode
.NRefactory
.Ast
.DoLoopStatement doLoopStatement
, object data
)
857 throw CreateNotSupportedError ();
860 public override object VisitDirectionExpression (ICSharpCode
.NRefactory
.Ast
.DirectionExpression directionExpression
, object data
)
862 throw CreateNotSupportedError ();
865 public override object VisitDestructorDeclaration (ICSharpCode
.NRefactory
.Ast
.DestructorDeclaration destructorDeclaration
, object data
)
867 throw CreateNotSupportedError ();
870 public override object VisitDelegateDeclaration (ICSharpCode
.NRefactory
.Ast
.DelegateDeclaration delegateDeclaration
, object data
)
872 throw CreateNotSupportedError ();
875 public override object VisitDefaultValueExpression (ICSharpCode
.NRefactory
.Ast
.DefaultValueExpression defaultValueExpression
, object data
)
877 throw CreateNotSupportedError ();
880 public override object VisitDeclareDeclaration (ICSharpCode
.NRefactory
.Ast
.DeclareDeclaration declareDeclaration
, object data
)
882 throw CreateNotSupportedError ();
885 public override object VisitContinueStatement (ICSharpCode
.NRefactory
.Ast
.ContinueStatement continueStatement
, object data
)
887 throw CreateNotSupportedError ();
890 public override object VisitConstructorInitializer (ICSharpCode
.NRefactory
.Ast
.ConstructorInitializer constructorInitializer
, object data
)
892 throw CreateNotSupportedError ();
895 public override object VisitConstructorDeclaration (ICSharpCode
.NRefactory
.Ast
.ConstructorDeclaration constructorDeclaration
, object data
)
897 throw CreateNotSupportedError ();
900 public override object VisitCompilationUnit (ICSharpCode
.NRefactory
.Ast
.CompilationUnit compilationUnit
, object data
)
902 throw CreateNotSupportedError ();
905 public override object VisitCheckedStatement (ICSharpCode
.NRefactory
.Ast
.CheckedStatement checkedStatement
, object data
)
907 throw CreateNotSupportedError ();
910 public override object VisitCatchClause (ICSharpCode
.NRefactory
.Ast
.CatchClause catchClause
, object data
)
912 throw CreateNotSupportedError ();
915 public override object VisitCaseLabel (ICSharpCode
.NRefactory
.Ast
.CaseLabel caseLabel
, object data
)
917 throw CreateNotSupportedError ();
920 public override object VisitBreakStatement (ICSharpCode
.NRefactory
.Ast
.BreakStatement breakStatement
, object data
)
922 throw CreateNotSupportedError ();
925 public override object VisitAttributeSection (ICSharpCode
.NRefactory
.Ast
.AttributeSection attributeSection
, object data
)
927 throw CreateNotSupportedError ();
930 public override object VisitAttribute (ICSharpCode
.NRefactory
.Ast
.Attribute attribute
, object data
)
932 throw CreateNotSupportedError ();
935 public override object VisitAnonymousMethodExpression (ICSharpCode
.NRefactory
.Ast
.AnonymousMethodExpression anonymousMethodExpression
, object data
)
937 throw CreateNotSupportedError ();
940 public override object VisitAddressOfExpression (ICSharpCode
.NRefactory
.Ast
.AddressOfExpression addressOfExpression
, object data
)
942 throw CreateNotSupportedError ();
945 public override object VisitAddHandlerStatement (ICSharpCode
.NRefactory
.Ast
.AddHandlerStatement addHandlerStatement
, object data
)
947 throw CreateNotSupportedError ();
952 Exception
CreateParseError (string message
, params object[] args
)
954 return new EvaluatorException (message
, args
);
957 Exception
CreateNotSupportedError ()
959 return new NotSupportedExpressionException ();
962 public string[] GetNamespaces ()
964 Method method
= ctx
.Frame
.Method
;
965 if ((method
== null) || !method
.HasLineNumbers
)
968 return method
.GetNamespaces ();
971 public static string MakeFqn (string nsn
, string name
)
975 return String
.Concat (nsn
, ".", name
);
979 class NotSupportedExpressionException
: EvaluatorException
981 public NotSupportedExpressionException (): base ("Expression not supported.")