Пример #1
0
        public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            var resolveResult = _resolver.Resolve(operatorDeclaration);

            if (!(resolveResult is MemberResolveResult))
            {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a member.");
                return;
            }
            var method = ((MemberResolveResult)resolveResult).Member as IMethod;

            if (method == null)
            {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
                return;
            }

            var jsClass = GetJsClass(method.DeclaringTypeDefinition);

            if (jsClass == null)
            {
                return;
            }

            MaybeCompileAndAddMethodToType(jsClass, operatorDeclaration, operatorDeclaration.Body, method, _metadataImporter.GetMethodSemantics(method));
        }
Пример #2
0
        public override void VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration)
        {
            var resolveResult = _resolver.Resolve(operatorDeclaration);
            if (!(resolveResult is MemberResolveResult)) {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a member.");
                return;
            }
            var method = ((MemberResolveResult)resolveResult).Member as IMethod;
            if (method == null) {
                _errorReporter.Region = operatorDeclaration.GetRegion();
                _errorReporter.InternalError("Operator declaration " + OperatorDeclaration.GetName(operatorDeclaration.OperatorType) + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
                return;
            }

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

            MaybeCompileAndAddMethodToType(jsClass, operatorDeclaration, operatorDeclaration.Body, method, _metadataImporter.GetMethodSemantics(method));
        }