public AD7StackFrame(AD7Engine engine, IRStackFrame stackFrame) { Engine = engine; StackFrame = stackFrame; _property = Lazy.Create(() => new AD7Property(this, TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.DescribeEnvironmentAsync(cancellationToken: ct)), isFrameEnvironment: true)); }
/// <summary> /// Same as <see cref="EvaluateAndDescribeAsync(IRStackFrame, string, string, REvaluationResultProperties, string, CancellationToken)"/>, /// but uses <see langword="null"/> for <c>name</c>. /// </summary> public static Task <IRValueInfo> EvaluateAndDescribeAsync( this IRStackFrame frame, string expression, REvaluationResultProperties properties, string repr, CancellationToken cancellationToken = default(CancellationToken) ) => frame.EvaluateAndDescribeAsync(expression, null, properties, repr, cancellationToken);
/// <summary> /// Like <see cref="RSessionExtensions.DescribeChildrenAsync"/>, but returns children of this environment. /// </summary> /// <remarks> /// If this method is called on a stale frame (i.e if call stack has changed since the <see cref="RSessionExtensions.TracebackAsync"/> /// call that produced this frame), the result is undefined - the method can throw <see cref="RException"/>, or produce meaningless /// output. /// </remarks> public static Task <IReadOnlyList <IREvaluationResultInfo> > DescribeChildrenAsync( this IRStackFrame frame, REvaluationResultProperties properties, string repr, int?maxCount = null, CancellationToken cancellationToken = default(CancellationToken) ) => frame.Session.DescribeChildrenAsync(frame.EnvironmentExpression, "base::environment()", properties, repr, maxCount, cancellationToken);
/// <summary> /// Same as <see cref="Microsoft.R.DataInspection.RSessionExtensions.TryEvaluateAndDescribeAsync(string, string, string, REvaluationResultProperties, int?, CancellationToken)"/>, /// but passes <see cref="EnvironmentExpression"/> of this frame as <c>environmentExpression</c> argument, /// </summary> public static Task <IREvaluationResultInfo> TryEvaluateAndDescribeAsync( this IRStackFrame frame, string expression, string name, REvaluationResultProperties properties, string repr, CancellationToken cancellationToken = default(CancellationToken) ) => frame.Session.TryEvaluateAndDescribeAsync(frame.EnvironmentExpression, expression, name, properties, repr, cancellationToken);
/// <summary> /// Produces an object describing this frame's environment. <see cref="REvaluationResultInfoExtensions.DescribeChildrenAsync"/> /// method can then be used to retrieve the variables in the frame. /// </summary> /// <param name="properties"> /// Which properties of the returned object should be provided. Note that it should include at least the following flags /// argument value in order for <see cref="REvaluationResultInfoExtensions.DescribeChildrenAsync"/> to be working. /// </param> /// <remarks> /// <para> /// There is no guarantee that the returned evaluation result is <see cref="IRValueInfo"/>. Retrieving the frame environment involves /// evaluating <see cref="EnvironmentExpression"/>, and like any evaluation, it can fail. Caller should check for <see cref="IRErrorInfo"/> /// and handle it accordingly. However, it is never <see cref="IRPromiseInfo"/> or <see cref="IRActiveBindingInfo"/>. /// </para> /// <para> /// If this method is called on a stale frame (i.e if call stack has changed since the <see cref="RSessionExtensions.TracebackAsync"/> /// call that produced this frame), the result is undefined, and can be an error result, or contain unrelated data. /// </para> /// </remarks> public static Task <IRValueInfo> DescribeEnvironmentAsync( this IRStackFrame frame, REvaluationResultProperties properties, CancellationToken cancellationToken = default(CancellationToken) ) { properties |= ExpressionProperty | LengthProperty | AttributeCountProperty | FlagsProperty; return(frame.EvaluateAndDescribeAsync("base::environment()", properties, null, cancellationToken)); }
/// <summary> /// Same as <see cref="DescribeEnvironmentAsync(IRStackFrame, REvaluationResultProperties, CancellationToken)"/>, /// but the only <c>properties</c> that are fetched are those that are necessary to invoke /// <see cref="REvaluationResultInfoExtensions.DescribeChildrenAsync"/> on the returned value. /// </summary> public static Task <IRValueInfo> DescribeEnvironmentAsync(this IRStackFrame frame, CancellationToken cancellationToken = default(CancellationToken)) => frame.DescribeEnvironmentAsync(REvaluationResultProperties.None, cancellationToken);
public REnvironment(IRStackFrame frame) : this(frame.CallingFrame.Call, frame.EnvironmentExpression, REnvironmentKind.Function) { }
private static bool IsDoTrace(IRStackFrame frame) => frame.Call != null && _doTraceRegex.IsMatch(frame.Call);