/// <nodoc /> public void ReportCycle(ModuleLiteral env, LineInfo lineInfo) { Contract.Requires(env != null); var location = lineInfo.AsUniversalLocation(env, Context); Logger.ReportCycle(LoggingContext, location.AsLoggingLocation(), Context.GetStackTraceAsErrorMessage(location)); }
/// <nodoc /> public void ReportContractFail(ModuleLiteral env, string message, LineInfo lineInfo, string callStack) { var location = lineInfo.AsUniversalLocation(env, Context); Logger.ReportContractFail( LoggingContext, location.AsLoggingLocation(), message, callStack); }
/// <nodoc /> public void ReportWhileLoopOverflow(ModuleLiteral env, LineInfo lineInfo, int loopThreshold) { Contract.Requires(env != null); var location = lineInfo.AsUniversalLocation(env, Context); Logger.ReportWhileLoopOverflow( LoggingContext, location.AsLoggingLocation(), loopThreshold, Context.GetStackTraceAsErrorMessage(location)); }
/// <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)); }
/// <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)); }
/// <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); }
public void DirectoryNotSupportedException( ModuleLiteral env, Expression expression, LineInfo lineInfo) { Contract.Requires(env != null); Contract.Requires(expression != null); var location = lineInfo.AsUniversalLocation(env, Context); Logger.DirectoryNotSupportedException( LoggingContext, location.AsLoggingLocation(), expression.ToDisplayString(Context), Context.GetStackTraceAsErrorMessage(location)); }
public void ReportFileOperationError( ModuleLiteral env, Expression expression, string errorInformation, LineInfo lineInfo) { Contract.Requires(env != null); Contract.Requires(expression != null); var location = lineInfo.AsUniversalLocation(env, Context); Logger.ReportFileOperationError( LoggingContext, location.AsLoggingLocation(), expression.ToDisplayString(Context), errorInformation, Context.GetStackTraceAsErrorMessage(location)); }
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); }
/// <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)); }
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)); }
/// <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)); }
/// <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}"); }
/// <inheritdoc /> public sealed override bool TryProject(Context context, SymbolAtom name, ModuleLiteral origin, PredefinedTypes predefinedTypes, out EvaluationResult result, LineInfo location) { result = GetOrEvalField(context, name, recurs: false, origin: origin, location: Location); return(true); }
private EvaluationResult EvaluateResolvedSymbol(Context context, ModuleLiteral module, LineInfo location, ResolvedEntry resolvedEntry) { Contract.Requires(module != null); if (resolvedEntry.Thunk != null) { var thunk = resolvedEntry.Thunk; return(thunk.EvaluateWithNewNamedContext(context, module, resolvedEntry.ThunkContextName, location)); } return(EvaluateNonThunkedResolvedSymbol(context, module, resolvedEntry)); }
/// <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)); }
/// <summary> /// Gets module or namespace based on module id. /// </summary> public EvaluationResult GetNamespace(ImmutableContextBase context, FullSymbol fullName, bool recurs, ModuleLiteral origin, LineInfo location) { ModuleBinding binding = GetNamespaceBinding(context, fullName, recurs); if (binding == null) { context.Errors.ReportMissingNamespace(origin ?? this, fullName, this, location); return(EvaluationResult.Error); } return(EvaluationResult.Create(binding.Body)); }
public void ReportInputValidationException(ModuleLiteral env, InputValidationException inputValidationException, LineInfo lineInfo) { var location = lineInfo.AsUniversalLocation(env, Context); Logger.ReportInputValidationError( LoggingContext, location.AsLoggingLocation(), inputValidationException.ErrorContext.ToErrorString(Context), !string.IsNullOrEmpty(inputValidationException.Message) ? ": " + inputValidationException.Message : string.Empty, Context.GetStackTraceAsErrorMessage(location)); }
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)); }
/// <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)); }
/// <summary> /// Adds a binding. /// </summary> public bool AddBinding(SymbolAtom name, object body, Declaration.DeclarationFlags modifier, LineInfo location) { Contract.Requires(name.IsValid); Contract.Requires(Qualifier == QualifierValue.Unqualified); return(AddBinding(name, new ModuleBinding(body, modifier, location))); }
/// <summary> /// Evaluates given <paramref name="binding"/> that corresponds to field <paramref name="name"/> /// (<seealso cref="GetOrEvalField(Context, SymbolAtom, bool, ModuleLiteral, LineInfo)"/>) /// </summary> public EvaluationResult GetOrEvalFieldBinding(Context context, SymbolAtom name, ModuleBinding binding, LineInfo callingLocation) { object o = binding.Body; if (o is Thunk thunk) { return(GetOrEvalFieldBindingThunk(context, name, binding, thunk)); } if (o is Expression expr) { using (var frame = EvaluationStackFrame.Empty()) { return(expr.Eval(context, this, frame)); } } return(EvaluationResult.Create(o)); }
/// <summary> /// Evaluates a member by resolving a symbol at a given location. /// </summary> /// <remarks> /// DScript V2 feature. /// </remarks> internal EvaluationResult EvaluateByLocation(Context context, FilePosition filePosition, FullSymbol nameForDebuggingPurposes, LineInfo location) { if (TryResolveEntryByLocation(context, filePosition, nameForDebuggingPurposes, out var resolvedEntry, out var owningFileModule)) { return(EvaluateResolvedSymbol(context, owningFileModule, location, resolvedEntry)); } return(EvaluationResult.Undefined); }
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)); }
/// <summary> /// Evaluates a member using by resolving a symbol by a full name. /// </summary> /// <remarks> /// DScript V2 feature. /// </remarks> internal EvaluationResult EvaluateEntryByFullName(Context context, FullSymbol fullName, LineInfo location) { ResolvedEntry resolvedEntry = default(ResolvedEntry); if (CurrentFileModule?.TryGetResolvedEntryByFullName(fullName, out resolvedEntry) == true) { return(EvaluateResolvedSymbol(context, this, location, resolvedEntry)); } // This is an assertion but not a graceful error, because resolution may fail only if something went wrong. string message = I($"Can't find resolved symbol by a full name '{fullName.ToString(context.FrontEndContext.SymbolTable)}'"); Contract.Assert(false, message); return(EvaluationResult.Undefined); }
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)); }
/// <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)); }
/// <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)); }
/// <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)); }
private EvaluationResult GetOrEvalField(Context context, SymbolAtom name, ModuleLiteral startEnv, bool recurs, ModuleLiteral origin, LineInfo location) { // This logic is still used only V1 evaluation if (IsFileModule && name == context.Names.Qualifier) { // Someone references 'qualifier' on the file level. return(EvaluationResult.Create(Qualifier.Qualifier)); } ModuleBinding binding = null; // TODO:ST: sounds reasonable to add "warning" if name was resolved but it is not exposed! if (m_bindings?.TryGetValue(name, out binding) == true && (recurs || binding.IsExported)) { return(GetOrEvalFieldBinding(context, name, binding, location)); } if (recurs && OuterScope != null) { return(OuterScope.GetOrEvalField(context, name, startEnv, true, origin, location)); } context.Errors.ReportMissingMember(origin ?? startEnv, name, startEnv, location); return(EvaluationResult.Error); }