Пример #1
0
 override public void LeaveCallableDefinition(CallableDefinition node)
 {
     CheckMemberName(node);
     CantBeMarkedAbstract(node);
     CantBeMarkedTransient(node);
     CantBeMarkedPartial(node);
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        Method CreateInvokeMethod(CallableDefinition node)
        {
            Method method = CreateRuntimeMethod("Invoke", node.ReturnType);

            method.Parameters = node.Parameters;
            return(method);
        }
Пример #4
0
 override public void LeaveCallableDefinition(CallableDefinition node)
 {
     MakeStaticIfNeeded(node);
     CantBeMarkedAbstract(node);
     CantBeMarkedTransient(node);
     CantBeMarkedPartial(node);
 }
Пример #5
0
 private void CompleteOmittedReturnType(CallableDefinition node)
 {
     if (node.ReturnType == null)
     {
         node.ReturnType = CodeBuilder.CreateTypeReference(TypeSystemServices.VoidType);
     }
 }
Пример #6
0
        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);
                    }
                }
            }
        }
Пример #7
0
        override public void OnCallableDefinition(CallableDefinition node)
        {
            CompleteOmittedReturnType(node);
            CompleteOmittedParameterTypes(node);

            ClassDefinition cd = My <CallableTypeBuilder> .Instance.ForCallableDefinition(node);

            ReplaceCurrentNode(cd);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
            }
        }
Пример #13
0
 override public void OnCallableDefinition(CallableDefinition node)
 {
     WriteCallableDefinitionHeader("callable ", node);
 }
Пример #14
0
 public override void OnCallableDefinition(CallableDefinition node)
 {
 }
Пример #15
0
 public override void OnCallableDefinition(CallableDefinition node)
 {
     throw new NotImplementedException();
     IL_0006 :;
 }
Пример #16
0
 public override void OnCallableDefinition(CallableDefinition node)
 {
     base.OnCallableDefinition(node);
     Check(node);
 }