상속: System.Management.Automation.Language.AstVisitor
예제 #1
0
 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>();
        }
예제 #3
0
 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);
 }
예제 #4
0
        protected override void ProcessRecord()
        {
            this.ExecutionContext.SetVariable("_", this.InputObject);

            var executionVisitor = new ExecutionVisitor(
                this.ExecutionContext,
                (PipelineCommandRuntime)CommandRuntime
                );

            this.Process.Ast.Visit(executionVisitor);
        }
예제 #5
0
        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);
        }
예제 #6
0
 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>();
 }
예제 #7
0
 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);
 }
예제 #8
0
 internal SettableExpression(ExecutionVisitor currentExecution)
 {
     CurrentExecution = currentExecution;
 }
예제 #9
0
 internal SettableVariableExpression(VariableExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base(currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #10
0
        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);
            }
        }
예제 #11
0
 public RedirectionVisitor(ExecutionVisitor visitor, IEnumerable <RedirectionAst> redirections)
 {
     _visitor      = visitor;
     _redirections = redirections.ToList();
 }
예제 #12
0
 internal SettableIndexExpression(IndexExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base (currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #13
0
 public FileRedirectionVisitor(ExecutionVisitor visitor, PipelineCommandRuntime runtime)
 {
     _visitor = visitor;
     _runtime = runtime;
 }
예제 #14
0
 internal SettableInvokeMemberExpression(InvokeMemberExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base(expressionAst, currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #15
0
 public RedirectionVisitor(ExecutionVisitor visitor, IEnumerable<RedirectionAst> redirections)
 {
     _visitor = visitor;
     _redirections = redirections.ToList();
 }
예제 #16
0
 private void CreateOwnScope()
 {
     _originalContext = ExecutionContext;
     _scopedContext = ExecutionContext.Clone(_scriptBlockInfo.ScopeUsage);
     _scopedExecutionVisitor = new ExecutionVisitor(_scopedContext, CommandRuntime, false);
 }
예제 #17
0
 internal SettableIndexExpression(IndexExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base(currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #18
0
 internal SettableVariableExpression(VariableExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base(currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #19
0
 internal SettableExpression(ExecutionVisitor currentExecution)
 {
     CurrentExecution = currentExecution;
 }
예제 #20
0
 internal SettableMemberExpression(MemberExpressionAst expressionAst, ExecutionVisitor currentExecution)
     : base(currentExecution)
 {
     _expressionAst = expressionAst;
 }
예제 #21
0
 public FileRedirectionVisitor(ExecutionVisitor visitor, PipelineCommandRuntime runtime)
 {
     _visitor = visitor;
     _runtime = runtime;
 }