internal override void WriteTo(CCodeWriterBase c) { if (this.Method.IsStaticMethod()) { c.WriteTypeFullName(this.Method.ContainingType); c.TextSpan("::"); c.WriteMethodName(this.Method, addTemplate: true); } else { var receiverOpt = this.ReceiverOpt; if (receiverOpt != null) { receiverOpt = this.PrepareMethodReceiver(receiverOpt, this.Method); // if method name is empty then receiverOpt returns function pointer if (!string.IsNullOrWhiteSpace(this.Method.Name)) { c.WriteAccess(receiverOpt); } else { c.WriteExpressionInParenthesesIfNeeded(receiverOpt); } } c.WriteMethodName(this.Method, addTemplate: true /*, methodSymbolForName: explicitMethod*/); } WriteCallArguments(this._arguments, this.Method != null ? this.Method.Parameters : (IEnumerable <IParameterSymbol>)null, c); }
internal override void WriteTo(CCodeWriterBase c) { if (!this.Method.ReturnsVoid && (this.Method.IsVirtualGenericMethod() || this.CallGenericMethodFromInterfaceMethod)) { c.TextSpan("(("); c.WriteType(this.Method.ReturnType, callGenericMethodFromInterfaceMethod: this.CallGenericMethodFromInterfaceMethod, containingNamespace: MethodOwner?.ContainingNamespace); c.TextSpan(")"); } if (this.Method.IsStatic) { if (!this.Method.IsExternDeclaration()) { c.WriteTypeFullName(this.Method.ContainingType, containingNamespace: MethodOwner?.ContainingNamespace); c.TextSpan("::"); } else { c.WriteNamespace(this.Method.ContainingType, containingNamespace: MethodOwner?.ContainingNamespace); } c.WriteMethodName(this.Method, addTemplate: true, containingNamespace: MethodOwner?.ContainingNamespace); } else { IMethodSymbol receiverIsNotInterfacesButAccessingExplicitInterfaceMethod = null; var receiverOpt = this.ReceiverOpt; if (receiverOpt != null) { receiverOpt = this.PrepareMethodReceiver(receiverOpt, this.Method); // if method name is empty then receiverOpt returns function pointer if (!string.IsNullOrWhiteSpace(this.Method.Name)) { c.WriteAccess(receiverOpt); } else { c.WriteWrappedExpressionIfNeeded(receiverOpt); } if (receiverOpt.Type.TypeKind != TypeKind.Interface && this.Method.ReceiverType != null && this.Method.ReceiverType.TypeKind == TypeKind.Interface) { receiverIsNotInterfacesButAccessingExplicitInterfaceMethod = receiverOpt.Type.GetMembers().OfType <IMethodSymbol>().FirstOrDefault(m => m.ExplicitInterfaceImplementations.Any() && m.ExplicitInterfaceImplementations.First().CompareTo(this.Method) == 0); } } c.WriteMethodName(receiverIsNotInterfacesButAccessingExplicitInterfaceMethod ?? this.Method, addTemplate: true, callGenericMethodFromInterfaceMethod: this.CallGenericMethodFromInterfaceMethod, containingNamespace: MethodOwner?.ContainingNamespace); } WriteCallArguments(c, this.Method != null ? this.Method.Parameters : (IEnumerable <IParameterSymbol>)null, this._arguments, this.Method, methodOwner: MethodOwner, specialCaseInterfaceWrapperCall: this.SpecialCaseInterfaceWrapperCall, specialCaseCreateInstanceNewObjectReplacement: this.SpecialCaseCreateInstanceNewObjectReplacement); if (!this.Method.ReturnsVoid && (this.Method.IsVirtualGenericMethod() || this.CallGenericMethodFromInterfaceMethod)) { c.TextSpan(")"); } }
internal override void WriteTo(CCodeWriterBase c) { if (!this.Method.ReturnsVoid && this.Method.IsVirtualGenericMethod()) { c.TextSpan("(("); c.WriteType(this.Method.ReturnType, containingNamespace: MethodOwner?.ContainingNamespace); c.TextSpan(")"); } if (this.Method.IsStaticMethod()) { if (!this.Method.IsExternDeclaration()) { c.WriteTypeFullName(this.Method.ContainingType, containingNamespace: MethodOwner?.ContainingNamespace); c.TextSpan("::"); } else { c.WriteNamespace(this.Method.ContainingType, containingNamespace: MethodOwner?.ContainingNamespace); c.TextSpan("::"); } c.WriteMethodName(this.Method, addTemplate: true, containingNamespace: MethodOwner?.ContainingNamespace); } else { var receiverOpt = this.ReceiverOpt; if (receiverOpt != null) { receiverOpt = this.PrepareMethodReceiver(receiverOpt, this.Method); // if method name is empty then receiverOpt returns function pointer if (!string.IsNullOrWhiteSpace(this.Method.Name)) { c.WriteAccess(receiverOpt); } else { c.WriteWrappedExpressionIfNeeded(receiverOpt); } } c.WriteMethodName(this.Method, addTemplate: true /*, methodSymbolForName: explicitMethod*/, interfaceWrapperMethodSpecialCase: InterfaceWrapperSpecialCall, containingNamespace: MethodOwner?.ContainingNamespace); } WriteCallArguments(c, this.Method != null ? this.Method.Parameters : (IEnumerable <IParameterSymbol>)null, this._arguments, this.Method, methodOwner: MethodOwner); if (!this.Method.ReturnsVoid && this.Method.IsVirtualGenericMethod()) { c.TextSpan(")"); } }
internal override void WriteTo(CCodeWriterBase c) { if (this.clone) { new Cast { Operand = new Call { ReceiverOpt = this.cloneArgument, Method = new MethodImpl { Name = "__clone", Parameters = ImmutableArray <IParameterSymbol> .Empty } }, Type = Type, CCast = true, }.WriteTo(c); } else { var methodGroup = Arguments.First() as MethodGroup; var isStatic = methodGroup != null && methodGroup.Method.IsStatic; var newDelegateMethod = new CCodeDelegateWrapperClass((INamedTypeSymbol)Type).GetNewMethod(isStatic, true); if (newDelegateMethod.ContainingNamespace != null) { c.WriteNamespace(newDelegateMethod.ContainingNamespace); c.TextSpan("::"); } c.WriteMethodName(newDelegateMethod, addTemplate: true, containingNamespace: MethodOwner?.ContainingNamespace); WriteCallArguments(c, this.Method != null ? this.Method.Parameters : (IEnumerable <IParameterSymbol>)null, this.Arguments, methodOwner: MethodOwner); } }
public override void WriteTo(CCodeWriterBase c) { c.Separate(); c.TextSpan(string.Format("// adapter: {0}", Method)); c.NewLine(); foreach (var statement in this.typeDefs) { statement.WriteTo(c); } var namedTypeSymbol = (INamedTypeSymbol)this.type; if (namedTypeSymbol.IsGenericType) { c.WriteTemplateDeclaration(namedTypeSymbol); c.NewLine(); } c.WriteMethodReturn(Method, true); c.WriteMethodNamespace(namedTypeSymbol); c.WriteMethodName(Method, false, interfaceWrapperMethodSpecialCase: true); c.WriteMethodParameters(Method, true, MethodBodyOpt != null); if (MethodBodyOpt == null) { c.EndStatement(); } else { MethodBodyOpt.WriteTo(c); } }
public override void WriteTo(CCodeWriterBase c) { c.TextSpan(string.Format("// adapter: {0}", Method)); c.NewLine(); foreach (var statement in this.typeDefs) { statement.WriteTo(c); } c.WriteMethodReturn(Method, true); c.WriteMethodName(Method, allowKeywords: false, interfaceWrapperMethodSpecialCase: true); c.WriteMethodParameters(Method, true, MethodBodyOpt != null); if (MethodBodyOpt == null) { c.EndStatement(); } else { MethodBodyOpt.WriteTo(c); } }