@ -93,18 +93,28 @@ namespace Debugger.AddIn
public override object VisitInvocationExpression ( InvocationExpression invocationExpression , object data )
public override object VisitInvocationExpression ( InvocationExpression invocationExpression , object data )
{
{
Value target ;
string methodName ;
MemberReferenceExpression memberRef = invocationExpression . TargetObject as MemberReferenceExpression ;
MemberReferenceExpression memberRef = invocationExpression . TargetObject as MemberReferenceExpression ;
if ( memberRef = = null ) {
if ( memberRef ! = null ) {
throw new GetValueException ( "Member reference expected duting method invocation" ) ;
target = ( ( Value ) memberRef . TargetObject . AcceptVisitor ( this , null ) ) . GetPermanentReference ( ) ;
methodName = memberRef . MemberName ;
} else {
IdentifierExpression ident = invocationExpression . TargetObject as IdentifierExpression ;
if ( ident ! = null ) {
target = context . GetThisValue ( ) ;
methodName = ident . Identifier ;
} else {
throw new GetValueException ( "Member reference expected for method invocation" ) ;
}
}
}
Value target = ( ( Value ) memberRef . TargetObject . AcceptVisitor ( this , null ) ) . GetPermanentReference ( ) ;
List < Value > args = new List < Value > ( ) ;
List < Value > args = new List < Value > ( ) ;
foreach ( Expression expr in invocationExpression . Arguments ) {
foreach ( Expression expr in invocationExpression . Arguments ) {
args . Add ( ( ( Value ) expr . AcceptVisitor ( this , null ) ) . GetPermanentReference ( ) ) ;
args . Add ( ( ( Value ) expr . AcceptVisitor ( this , null ) ) . GetPermanentReference ( ) ) ;
}
}
MethodInfo method = target . Type . GetMember ( memberRef . MemberName , BindingFlags . Method | BindingFlags . IncludeSuperType ) as MethodInfo ;
MethodInfo method = target . Type . GetMember ( method Name , BindingFlags . Method | BindingFlags . IncludeSuperType ) as MethodInfo ;
if ( method = = null ) {
if ( method = = null ) {
throw new GetValueException ( "Method " + memberRef . MemberName + " not found" ) ;
throw new GetValueException ( "Method " + method Name + " not found" ) ;
}
}
return target . InvokeMethod ( method , args . ToArray ( ) ) ;
return target . InvokeMethod ( method , args . ToArray ( ) ) ;
}
}
@ -175,8 +185,8 @@ namespace Debugger.AddIn
// case BinaryOperatorType.GreaterThanOrEqual :
// case BinaryOperatorType.GreaterThanOrEqual :
// val.PrimitiveValue = (right.PrimitiveValue >= left.PrimitiveValue);
// val.PrimitiveValue = (right.PrimitiveValue >= left.PrimitiveValue);
// break;
// break;
default :
default :
throw new NotImplementedException ( "BinaryOperator: " + binaryOperatorExpression . Op + "!" ) ;
throw new NotImplementedException ( "BinaryOperator: " + binaryOperatorExpression . Op ) ;
}
}
} catch ( System . Exception e ) {
} catch ( System . Exception e ) {
throw new GetValueException ( e . Message ) ;
throw new GetValueException ( e . Message ) ;