// // Query parameter reference can include transparent parameters // protected override Expression GetParameterReferenceExpression(string name, SourceSpan span) { var reference = base.GetParameterReferenceExpression(name, span); if (reference != null) { return(reference); } var transparentParameter = Parameters[0] as TransparentParameter; while (transparentParameter != null) { if (transparentParameter.Identifier == name) { break; } var nextTransparentParameter = transparentParameter.Parent[0] as TransparentParameter; if (nextTransparentParameter == null) { if (transparentParameter.Parent.GetParameterIndexByName(name) >= 0) { break; } } transparentParameter = nextTransparentParameter; } if (transparentParameter != null) { reference = new NameExpression { Name = Parameters[0].Name, Span = span }; var transparentParameterCursor = (TransparentParameter)Parameters[0]; while (transparentParameterCursor != transparentParameter) { transparentParameterCursor = (TransparentParameter)transparentParameterCursor.Parent[0]; reference = new MemberAccessExpression { Left = reference, Name = transparentParameterCursor.Name }; } return(new MemberAccessExpression { Left = reference, Name = name }); } return(null); }
public TypeNameExpression GetTypeExpression() { if (Left == null) { return(new TypeNameExpression(BaseName, TypeArguments, Span)); } if (IsDoubleColon) { if (Left.Left != null) { throw new SyntaxErrorException("The left side of a :: should be an identifier"); } var qualifiedAliasMember = new QualifiedAliasMember { Alias = Left.Name, Name = Name, Span = Span }; qualifiedAliasMember.TypeArguments.Add(TypeArguments); return(qualifiedAliasMember); } Expression lexpr = Left.GetTypeExpression(); var memberAccessExpression = new MemberAccessExpression { Name = Name, Span = Span, Left = lexpr }; memberAccessExpression.TypeArguments.Add(TypeArguments); return(memberAccessExpression); }
public override Expression DoResolve(ParseContext ec) { // Don't resolve already resolved expression if (ExpressionClass != ExpressionClass.Invalid) { return(this); } var resolvedTarget = Target.Resolve(ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup); if (resolvedTarget == null) { return(null); } // Next, evaluate all the expressions in the argument list if (_arguments != null && !_argumentsResolved) { _arguments.Resolve(ec); _argumentsResolved = true; } var expressionType = resolvedTarget.Type; MethodGroup = resolvedTarget as MethodGroupExpression; if (MethodGroup == null) { if (expressionType != null && TypeManager.IsDelegateType(expressionType)) { MethodGroup = (resolvedTarget = new MemberAccessExpression { Left = resolvedTarget, Name = "Invoke", Span = Span }.Resolve(ec)) as MethodGroupExpression; } var memberExpression = resolvedTarget as MemberExpression; if (memberExpression == null) { resolvedTarget.OnErrorUnexpectedKind(ec, ResolveFlags.MethodGroup, Span); return(null); } if (MethodGroup == null) { MethodGroup = ec.LookupExtensionMethod( memberExpression.Type, memberExpression.Name, Span); if (MethodGroup != null) { ((ExtensionMethodGroupExpression)MethodGroup).ExtensionExpression = memberExpression.InstanceExpression; } } if (MethodGroup == null) { ec.ReportError( 1955, string.Format( "The member '{0}' cannot be used as method or delegate.", resolvedTarget.GetSignatureForError()), Span); return(null); } } MethodGroup = DoResolveOverload(ec); if (MethodGroup == null) { return(null); } var method = (MethodInfo)MethodGroup; if (method != null) { Type = method.ReturnType; // TODO: this is a copy of mg.ResolveMemberAccess method var instanceExpression = MethodGroup.InstanceExpression; if (method.IsStatic) { if (instanceExpression == null || instanceExpression is EmptyExpression || MethodGroup.IdenticalTypeName) { MethodGroup.InstanceExpression = null; } else { // TODO: MemberExpression.error176(ec, loc, mg.GetSignatureForError()); return(null); } } else { if (instanceExpression == null || instanceExpression == EmptyExpression.Null) { // TODO: SimpleName.Error_ObjectRefRequired(ec, loc, mg.GetSignatureForError()); } } } if (method == null) { return(null); } IsSpecialMethodInvocation(ec, method, Span); ExpressionClass = ExpressionClass.Value; return(this); }