override public void LeaveCallableDefinition(CallableDefinition node) { CheckMemberName(node); CantBeMarkedAbstract(node); CantBeMarkedTransient(node); CantBeMarkedPartial(node); }
void WriteCallableDefinitionHeader(string keyword, CallableDefinition node) { WriteAttributes(node.Attributes, true); WriteModifiers(node); WriteKeyword(keyword); IExplicitMember em = node as IExplicitMember; if (null != em) { Visit(em.ExplicitInfo); } Write(node.Name); if (node.GenericParameters.Count > 0) { WriteGenericParameterList(node.GenericParameters); } WriteParameterList(node.Parameters); WriteTypeReference(node.ReturnType); if (node.ReturnTypeAttributes.Count > 0) { Write(" "); WriteAttributes(node.ReturnTypeAttributes, false); } }
Method CreateInvokeMethod(CallableDefinition node) { Method method = CreateRuntimeMethod("Invoke", node.ReturnType); method.Parameters = node.Parameters; return(method); }
override public void LeaveCallableDefinition(CallableDefinition node) { MakeStaticIfNeeded(node); CantBeMarkedAbstract(node); CantBeMarkedTransient(node); CantBeMarkedPartial(node); }
private void CompleteOmittedReturnType(CallableDefinition node) { if (node.ReturnType == null) { node.ReturnType = CodeBuilder.CreateTypeReference(TypeSystemServices.VoidType); } }
private void CompleteOmittedParameterType(CallableDefinition node) { ParameterDeclarationCollection parameters = node.Parameters; if (0 == parameters.Count) { return; } ParameterDeclaration last = parameters[-1]; foreach (ParameterDeclaration parameter in parameters) { if (null == parameter.Type) { if (parameters.VariableNumber && last == parameter) { parameter.Type = CodeBuilder.CreateTypeReference(TypeSystemServices.ObjectArrayType); } else { parameter.Type = CodeBuilder.CreateTypeReference(TypeSystemServices.ObjectType); } } } }
override public void OnCallableDefinition(CallableDefinition node) { CompleteOmittedReturnType(node); CompleteOmittedParameterTypes(node); ClassDefinition cd = My <CallableTypeBuilder> .Instance.ForCallableDefinition(node); ReplaceCurrentNode(cd); }
public ClassDefinition ForCallableDefinition(CallableDefinition node) { ClassDefinition cd = CreateEmptyCallableDefinition(node.Name); cd.LexicalInfo = node.LexicalInfo; cd.GenericParameters = node.GenericParameters; cd.Members.Add(CreateInvokeMethod(node)); cd.Members.Add(CreateBeginInvokeMethod(node)); cd.Members.Add(CreateEndInvokeMethod(node)); return(cd); }
Method CreateBeginInvokeMethod(CallableDefinition node) { Method method = CreateRuntimeMethod("BeginInvoke", CodeBuilder.CreateTypeReference(typeof(IAsyncResult))); method.Parameters.ExtendWithClones(node.Parameters); method.Parameters.Add( new ParameterDeclaration("callback", CodeBuilder.CreateTypeReference(typeof(AsyncCallback)))); method.Parameters.Add( new ParameterDeclaration("asyncState", CodeBuilder.CreateTypeReference(TypeSystemServices.ObjectType))); return(method); }
override public void OnCallableDefinition(CallableDefinition node) { if (null == node.ReturnType) { node.ReturnType = CodeBuilder.CreateTypeReference(TypeSystemServices.VoidType); } CompleteOmittedParameterType(node); ClassDefinition cd = TypeSystemServices.CreateCallableDefinition(node.Name); cd.LexicalInfo = node.LexicalInfo; cd.Members.Add(CreateInvokeMethod(node)); cd.Members.Add(CreateBeginInvokeMethod(node)); cd.Members.Add(CreateEndInvokeMethod(node)); ReplaceCurrentNode(cd); }
Method CreateEndInvokeMethod(CallableDefinition node) { Method method = CreateRuntimeMethod("EndInvoke", node.ReturnType); foreach (ParameterDeclaration p in node.Parameters) { if (p.IsByRef) { method.Parameters.Add(p.CloneNode()); } } method.Parameters.Add( new ParameterDeclaration("asyncResult", CodeBuilder.CreateTypeReference(typeof(IAsyncResult)))); return(method); }
private void CompleteOmittedParameterTypes(CallableDefinition node) { ParameterDeclarationCollection parameters = node.Parameters; if (parameters.Count == 0) { return; } foreach (ParameterDeclaration parameter in parameters) { if (parameter.Type != null) { continue; } parameter.Type = CodeBuilder.CreateTypeReference( parameter.IsParamArray ? TypeSystemServices.ObjectArrayType : TypeSystemServices.ObjectType); } }
override public void OnCallableDefinition(CallableDefinition node) { WriteCallableDefinitionHeader("callable ", node); }
public override void OnCallableDefinition(CallableDefinition node) { }
public override void OnCallableDefinition(CallableDefinition node) { throw new NotImplementedException(); IL_0006 :; }
public override void OnCallableDefinition(CallableDefinition node) { base.OnCallableDefinition(node); Check(node); }