示例#1
0
        /// <nodoc />
        public void ReportForLoopOverflow(ModuleLiteral env, LineInfo lineInfo, int loopThreshold)
        {
            Contract.Requires(env != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportForLoopOverflow(
                LoggingContext,
                location.AsLoggingLocation(),
                loopThreshold,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#2
0
        /// <nodoc />
        public void ReportStackOverflow(ModuleLiteral env, LineInfo lineInfo)
        {
            Contract.Requires(env != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportStackOverflow(
                LoggingContext,
                location.AsLoggingLocation(),
                Context.CallStackSize,
                ImmutableContextBase.CallStackThreshold,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#3
0
        public void ReportDivideByZeroException(ModuleLiteral env, Expression expression, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(expression != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportDivideByZero(
                LoggingContext,
                location.AsLoggingLocation(),
                expression.ToDisplayString(Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#4
0
        public void ReportSpreadIsNotAppliedToArrayValue(ModuleLiteral env, Expression expression, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(expression != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportSpreadIsNotAppliedToArrayValue(
                LoggingContext,
                location.AsLoggingLocation(),
                expression.ToDisplayString(Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#5
0
        /// <nodoc />
        public void ReportArgumentIndexOutOfBound(ModuleLiteral env, int index, int numberOfArguments, LineInfo lineInfo)
        {
            Contract.Requires(env != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportArgumentIndexOutOfBound(
                LoggingContext,
                location.AsLoggingLocation(),
                index,
                numberOfArguments,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#6
0
        /// <nodoc />
        public void ReportArithmeticOverflow(
            ModuleLiteral env,
            Expression expression,
            LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportArithmeticOverflow(
                LoggingContext,
                location.AsLoggingLocation(),
                expression.ToDisplayString(Context));
        }
示例#7
0
        /// <nodoc />
        public void ReportUnexpectedAmbientException(ModuleLiteral env, Exception exception, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(exception != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            // TODO: print nested messages as well!!
            Logger.ReportUnexpectedAmbientException(
                LoggingContext,
                location.AsLoggingLocation(),
                exception.Message,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#8
0
        public void ReportFailResolveSelectorDueToUndefined(ModuleLiteral env, Expression thisExpression, SymbolAtom name, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(name.IsValid);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportFailResolveSelectorDueToUndefined(
                LoggingContext,
                location.AsLoggingLocation(),
                name.ToDisplayString(Context),
                thisExpression.ToDisplayString(Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#9
0
        /// <nodoc />
        public void ReportMissingProperty(ModuleLiteral env, SymbolAtom selector, object receiver, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(receiver != null);

            var locationForLogging = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportMissingInstanceMember(
                LoggingContext,
                locationForLogging.AsLoggingLocation(),
                selector.ToDisplayString(Context),
                receiver.GetType().ToDisplayString(Context),
                Context.GetStackTraceAsString(locationForLogging));
        }
示例#10
0
        /// <nodoc />
        public void ReportStringIndexOufOfRange(ModuleLiteral env, int index, string target, LineInfo lineInfo)
        {
            Contract.Requires(env != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportStringIndexOufOfRange(
                LoggingContext,
                location.AsLoggingLocation(),
                index,
                target,
                target.Length,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#11
0
        /// <nodoc />
        public void ReportInvalidRadix(
            ModuleLiteral env,
            Expression expression,
            LineInfo lineInfo,
            int radix)
        {
            Contract.Requires(env != null);
            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportInvalidRadix(
                LoggingContext,
                location.AsLoggingLocation(),
                expression.ToDisplayString(Context),
                radix);
        }
示例#12
0
        /// <nodoc />
        public void ReportMissingNamespace(ModuleLiteral env, FullSymbol name, ModuleLiteral relatedEnv, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(name.IsValid);
            Contract.Requires(relatedEnv != null);
            var relatedLocation = relatedEnv.Location.AsLoggingLocation(relatedEnv, Context).ToDisplayString();
            var relatedMessage  = env == relatedEnv ? string.Empty : I($", related location '{relatedLocation}'");

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportMissingNamespace(
                LoggingContext,
                location.AsLoggingLocation(),
                name.ToDisplayString(Context),
                relatedMessage,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#13
0
        public void ReportContractRequire(ModuleLiteral env, Expression expression, string message, LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(expression != null);

            string additionalInformation = string.IsNullOrEmpty(message)
                ? string.Empty
                : I($" : {message}");

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportContractRequire(
                LoggingContext,
                location.AsLoggingLocation(),
                expression.ToDisplayString(Context),
                additionalInformation,
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#14
0
        /// <nodoc />
        public void ReportUnexpectedValueTypeOnConversion(
            ModuleLiteral env,
            ConvertException exception,
            LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(exception != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportUnexpectedValueTypeOnConversion(
                LoggingContext,
                location.AsLoggingLocation(),
                exception.ExpectedTypesToString(Context),
                exception.ErrorContext.ErrorReceiverAsString(Context),
                ValueToString(exception.Value, Context),
                ValueTypeToString(exception.Value, Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#15
0
        public void ReportApplyAmbientNumberOfArgumentsLessThanMinArity(
            ModuleLiteral env,
            Expression functor,
            int minArity,
            int numOfArguments,
            LineInfo lineInfo = default(LineInfo))
        {
            Contract.Requires(env != null);
            Contract.Requires(functor != null);
            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportApplyAmbientNumberOfArgumentsLessThanMinArity(
                LoggingContext,
                location.AsLoggingLocation(),
                Context.GetStackTraceAsErrorMessage(location),
                functor.ToDisplayString(Context),
                minArity,
                numOfArguments);
        }
示例#16
0
        public void ReportDisallowedUnsafeAmbientCallError(
            ModuleLiteral env,
            Expression expression,
            string methodName,
            LineInfo lineInfo)
        {
            Contract.Requires(env != null);
            Contract.Requires(expression != null);
            Contract.Requires(!string.IsNullOrEmpty(methodName));

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportDisallowedUnsafeAmbientCallError(
                LoggingContext,
                location.AsLoggingLocation(),
                methodName,
                expression.ToDisplayString(Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#17
0
        /// <nodoc />
        public void ReportUnexpectedValueTypeForName(
            ModuleLiteral env,
            SymbolAtom name,
            string expectedTypes,
            EvaluationResult value,
            LineInfo lineInfo = default(LineInfo))
        {
            Contract.Requires(env != null);
            Contract.Requires(name.IsValid);
            Contract.Requires(expectedTypes != null);

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportUnexpectedValueTypeForName(
                LoggingContext,
                location.AsLoggingLocation(),
                name.ToString(Context.FrontEndContext.SymbolTable),
                expectedTypes,
                ValueToString(value, Context),
                ValueTypeToString(value, Context),
                Context.GetStackTraceAsErrorMessage(location));
        }
示例#18
0
        /// <nodoc />
        public void ReportCycle(ModuleLiteral env, LineInfo lineInfo, FullSymbol?pending = null)
        {
            Contract.Requires(env != null);

            var chain = Context.GetTopLevelValueChain()
                        .Select(fs => fs.ToString(Context.SymbolTable))
                        .ToList();

            if (pending.HasValue)
            {
                chain.Insert(0, pending.Value.ToString(Context.SymbolTable) + " (pending)");
            }

            var formatted = chain
                            .Select(sym => Environment.NewLine + "  " + sym)
                            .Aggregate(new StringBuilder(), (acc, elem) => acc.Append(elem))
                            .ToString();

            var location = lineInfo.AsUniversalLocation(env, Context);

            Logger.ReportCycle(LoggingContext, location.AsLoggingLocation(),
                               Context.GetStackTraceAsErrorMessage(location),
                               $"{Environment.NewLine}Top-level value chain:{formatted}");
        }