Пример #1
0
        public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
        {
            var resolveResult = _resolver.Resolve(methodDeclaration);

            if (!(resolveResult is MemberResolveResult))
            {
                _errorReporter.Region = methodDeclaration.GetRegion();
                _errorReporter.InternalError("Method declaration " + methodDeclaration.Name + " does not resolve to a member.");
                return;
            }
            var method = ((MemberResolveResult)resolveResult).Member as IMethod;

            if (method == null)
            {
                _errorReporter.Region = methodDeclaration.GetRegion();
                _errorReporter.InternalError("Method declaration " + methodDeclaration.Name + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
                return;
            }

            var jsClass = GetJsClass(method.DeclaringTypeDefinition);

            if (jsClass == null)
            {
                return;
            }

            if (method.IsAbstract || !methodDeclaration.Body.IsNull)                    // The second condition is used to ignore partial method parts without definitions.
            {
                MaybeCompileAndAddMethodToType(jsClass, methodDeclaration, methodDeclaration.Body, method, _metadataImporter.GetMethodSemantics(method));
            }
        }
Пример #2
0
        public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
        {
            var resolveResult = _resolver.Resolve(methodDeclaration);
            if (!(resolveResult is MemberResolveResult)) {
                _errorReporter.Region = methodDeclaration.GetRegion();
                _errorReporter.InternalError("Method declaration " + methodDeclaration.Name + " does not resolve to a member.");
                return;
            }
            var method = ((MemberResolveResult)resolveResult).Member as IMethod;
            if (method == null) {
                _errorReporter.Region = methodDeclaration.GetRegion();
                _errorReporter.InternalError("Method declaration " + methodDeclaration.Name + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
                return;
            }

            var jsClass = GetJsClass(method.DeclaringTypeDefinition);
            if (jsClass == null)
                return;

            if (method.IsAbstract || !methodDeclaration.Body.IsNull) {	// The second condition is used to ignore partial method parts without definitions.
                MaybeCompileAndAddMethodToType(jsClass, methodDeclaration, methodDeclaration.Body, method, _metadataImporter.GetMethodSemantics(method));
            }
        }