internal ScriptBlockParameterBinder(ReadOnlyCollection<ParameterAst> scriptParameters, ExecutionContext context, ExecutionVisitor executionVisitor) { _scriptParameters = scriptParameters; _executionContext = context; _executionVisitor = executionVisitor; }
public Collection<PSObject> InvokeScript(string script, bool useNewScope, PipelineResultTypes writeToPipeline, IList input, params object[] args) { ScriptBlock scriptBlock = NewScriptBlock(script); var executionVisitor = new ExecutionVisitor(executionContext, commandRuntime); scriptBlock.Ast.Visit(executionVisitor); return new Collection<PSObject>(); }
private void CreateOwnScope() { _originalContext = ExecutionContext; var executionSessionState = CommandInfo.Module != null ? CommandInfo.Module.SessionState : ExecutionContext.SessionState; _scopedContext = ExecutionContext.Clone(executionSessionState, _scriptBlockInfo.ScopeUsage); _scopedExecutionVisitor = new ExecutionVisitor(_scopedContext, CommandRuntime, false); }
protected override void ProcessRecord() { this.ExecutionContext.SetVariable("_", this.InputObject); var executionVisitor = new ExecutionVisitor( this.ExecutionContext, (PipelineCommandRuntime)CommandRuntime ); this.Process.Ast.Visit(executionVisitor); }
internal static SettableExpression Create(ExpressionAst valueExpression, ExecutionVisitor currentExecution) { if (valueExpression is VariableExpressionAst) { return(new SettableVariableExpression((VariableExpressionAst)valueExpression, currentExecution)); } else if (valueExpression is MemberExpressionAst) { return(new SettableMemberExpression((MemberExpressionAst)valueExpression, currentExecution)); } else if (valueExpression is IndexExpressionAst) { return(new SettableIndexExpression((IndexExpressionAst)valueExpression, currentExecution)); } var msg = String.Format("The expression is not a modifiable value, but of type '{0}'. Please report this!", valueExpression.GetType().FullName); throw new InvalidOperationException(msg); }
public Collection<PSObject> InvokeScript(string script, bool useNewScope, PipelineResultTypes writeToPipeline, IList input, params object[] args) { var context = useNewScope ? executionContext.Clone(ScopeUsages.NewScriptScope) : executionContext; //Let's see on the long run if there is an easier solution for this #ExecutionContextChange //we need to change the global execution context to change the scope we are currently operating in executionContext.CurrentRunspace.ExecutionContext = context; try { ScriptBlock scriptBlock = NewScriptBlock(script); var executionVisitor = new ExecutionVisitor(context, commandRuntime); // sburnicki - handle ExitException scriptBlock.Ast.Visit(executionVisitor); } finally //make sure we set back the old execution context, no matter what happened { executionContext.CurrentRunspace.ExecutionContext = executionContext; } return new Collection<PSObject>(); }
internal static SettableExpression Create(ExpressionAst valueExpression, ExecutionVisitor currentExecution) { if (valueExpression is VariableExpressionAst) { return new SettableVariableExpression((VariableExpressionAst)valueExpression, currentExecution); } else if (valueExpression is InvokeMemberExpressionAst) { return new SettableInvokeMemberExpression((InvokeMemberExpressionAst)valueExpression, currentExecution); } else if (valueExpression is MemberExpressionAst) { return new SettableMemberExpression((MemberExpressionAst)valueExpression, currentExecution); } else if (valueExpression is IndexExpressionAst) { return new SettableIndexExpression((IndexExpressionAst)valueExpression, currentExecution); } var msg = String.Format("The expression is not a modifiable value, but of type '{0}'. Please report this!", valueExpression.GetType().FullName); throw new InvalidOperationException(msg); }
internal SettableExpression(ExecutionVisitor currentExecution) { CurrentExecution = currentExecution; }
internal SettableVariableExpression(VariableExpressionAst expressionAst, ExecutionVisitor currentExecution) : base(currentExecution) { _expressionAst = expressionAst; }
private void FilterByScript() { ExecutionContext.SetVariable("_", InputObject); var executionVisitor = new ExecutionVisitor(ExecutionContext, (PipelineCommandRuntime)CommandRuntime); object result = executionVisitor.EvaluateAst(FilterScript.Ast, true); if (IsTrue(result)) { WriteObject(InputObject); } }
public RedirectionVisitor(ExecutionVisitor visitor, IEnumerable <RedirectionAst> redirections) { _visitor = visitor; _redirections = redirections.ToList(); }
internal SettableIndexExpression(IndexExpressionAst expressionAst, ExecutionVisitor currentExecution) : base (currentExecution) { _expressionAst = expressionAst; }
public FileRedirectionVisitor(ExecutionVisitor visitor, PipelineCommandRuntime runtime) { _visitor = visitor; _runtime = runtime; }
internal SettableInvokeMemberExpression(InvokeMemberExpressionAst expressionAst, ExecutionVisitor currentExecution) : base(expressionAst, currentExecution) { _expressionAst = expressionAst; }
public RedirectionVisitor(ExecutionVisitor visitor, IEnumerable<RedirectionAst> redirections) { _visitor = visitor; _redirections = redirections.ToList(); }
private void CreateOwnScope() { _originalContext = ExecutionContext; _scopedContext = ExecutionContext.Clone(_scriptBlockInfo.ScopeUsage); _scopedExecutionVisitor = new ExecutionVisitor(_scopedContext, CommandRuntime, false); }
internal SettableIndexExpression(IndexExpressionAst expressionAst, ExecutionVisitor currentExecution) : base(currentExecution) { _expressionAst = expressionAst; }
internal SettableMemberExpression(MemberExpressionAst expressionAst, ExecutionVisitor currentExecution) : base(currentExecution) { _expressionAst = expressionAst; }