Ejemplo n.º 1
0
 public ScriptBlockAst(IScriptExtent extent, ParamBlockAst paramBlock, StatementBlockAst statements, bool isFilter)
     : base(extent)
 {
     this.ParamBlock = paramBlock;
     this.EndBlock = new NamedBlockAst(extent, TokenKind.End, statements, true);
     if (isFilter) throw new NotImplementedException(this.ToString());
 }
Ejemplo n.º 2
0
 public TryStatementAst(IScriptExtent extent, StatementBlockAst body, IEnumerable <CatchClauseAst> catchClauses, StatementBlockAst @finally) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (((catchClauses == null) || !catchClauses.Any <CatchClauseAst>()) && (@finally == null))
     {
         throw PSTraceSource.NewArgumentException("catchClauses");
     }
     this.Body = body;
     base.SetParent(body);
     if ((catchClauses != null) && catchClauses.Any <CatchClauseAst>())
     {
         this.CatchClauses = new ReadOnlyCollection <CatchClauseAst>(catchClauses.ToArray <CatchClauseAst>());
         base.SetParents((IEnumerable <Ast>) this.CatchClauses);
     }
     else
     {
         this.CatchClauses = EmptyCatchClauses;
     }
     if (@finally != null)
     {
         this.Finally = @finally;
         base.SetParent(@finally);
     }
 }
Ejemplo n.º 3
0
 public TryStatementAst(IScriptExtent extent, StatementBlockAst body, IEnumerable <CatchClauseAst> catchClauses, StatementBlockAst @finally)
     : base(extent)
 {
     this.Body         = body;
     this.CatchClauses = catchClauses.ToReadOnlyCollection();
     this.Finally      = @finally;
 }
Ejemplo n.º 4
0
 public DoUntilStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body) : base(extent, label, condition, body)
 {
     if (condition == null)
     {
         throw PSTraceSource.NewArgumentNullException("condition");
     }
 }
Ejemplo n.º 5
0
 public TryStatementAst(IScriptExtent extent, StatementBlockAst body, IEnumerable<CatchClauseAst> catchClauses, StatementBlockAst @finally)
     : base(extent)
 {
     this.Body = body;
     this.CatchClauses = catchClauses.ToReadOnlyCollection();
     this.Finally = @finally;
 }
Ejemplo n.º 6
0
 private void CheckForFlowOutOfFinally(Ast ast, string label)
 {
     for (Ast ast2 = ast.Parent; ast2 != null; ast2 = ast2.Parent)
     {
         if ((ast2 is ScriptBlockAst) || (ast2 is TrapStatementAst))
         {
             break;
         }
         if (ast2 is NamedBlockAst)
         {
             return;
         }
         if (((label != null) && (ast2 is LoopStatementAst)) && LoopFlowException.MatchLoopLabel(label, ((LoopStatementAst)ast2).Label ?? ""))
         {
             return;
         }
         StatementBlockAst ast3 = ast2 as StatementBlockAst;
         if (ast3 != null)
         {
             TryStatementAst parent = ast3.Parent as TryStatementAst;
             if ((parent != null) && (parent.Finally == ast3))
             {
                 this._parser.ReportError(ast.Extent, ParserStrings.ControlLeavingFinally, new object[0]);
                 return;
             }
         }
     }
 }
Ejemplo n.º 7
0
 public TryStatementAst(IScriptExtent extent, StatementBlockAst body, IEnumerable<CatchClauseAst> catchClauses, StatementBlockAst @finally) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (((catchClauses == null) || !catchClauses.Any<CatchClauseAst>()) && (@finally == null))
     {
         throw PSTraceSource.NewArgumentException("catchClauses");
     }
     this.Body = body;
     base.SetParent(body);
     if ((catchClauses != null) && catchClauses.Any<CatchClauseAst>())
     {
         this.CatchClauses = new ReadOnlyCollection<CatchClauseAst>(catchClauses.ToArray<CatchClauseAst>());
         base.SetParents((IEnumerable<Ast>) this.CatchClauses);
     }
     else
     {
         this.CatchClauses = EmptyCatchClauses;
     }
     if (@finally != null)
     {
         this.Finally = @finally;
         base.SetParent(@finally);
     }
 }
Ejemplo n.º 8
0
 public SwitchStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, SwitchFlags flags, IEnumerable<Tuple<ExpressionAst, StatementBlockAst>> clauses, StatementBlockAst @default)
     : base(extent, label, condition)
 {
     this.Flags = flags;
     this.Clauses = clauses.ToReadOnlyCollection();
     this.Default = @default;
 }
Ejemplo n.º 9
0
        public object VisitStatementBlock(StatementBlockAst statementBlockAst)
        {
            ArrayList statementList = new ArrayList();

            foreach (var statement in statementBlockAst.Statements)
            {
                if (statement != null)
                {
                    var obj        = statement.Accept(this);
                    var enumerator = LanguagePrimitives.GetEnumerator(obj);
                    if (enumerator != null)
                    {
                        while (enumerator.MoveNext())
                        {
                            statementList.Add(enumerator.Current);
                        }
                    }
                    else
                    {
                        statementList.Add(obj);
                    }
                }
                else
                {
                    throw PSTraceSource.NewArgumentException("ast");
                }
            }

            return(statementList.ToArray());
        }
Ejemplo n.º 10
0
 public DataStatementAst(IScriptExtent extent, string variableName, IEnumerable<ExpressionAst> commandsAllowed, StatementBlockAst body) : base(extent)
 {
     this._tupleIndex = -1;
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (string.IsNullOrWhiteSpace(variableName))
     {
         variableName = null;
     }
     this.Variable = variableName;
     if ((commandsAllowed != null) && commandsAllowed.Any<ExpressionAst>())
     {
         this.CommandsAllowed = new ReadOnlyCollection<ExpressionAst>(commandsAllowed.ToArray<ExpressionAst>());
         base.SetParents((IEnumerable<Ast>) this.CommandsAllowed);
         this.HasNonConstantAllowedCommand = (from ast in this.CommandsAllowed
             where !(ast is StringConstantExpressionAst)
             select ast).Any<ExpressionAst>();
     }
     else
     {
         this.CommandsAllowed = new ReadOnlyCollection<ExpressionAst>(EmptyCommandsAllowed);
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 11
0
 public DataStatementAst(IScriptExtent extent, string variableName, IEnumerable<ExpressionAst> commandsAllowed, StatementBlockAst body)
     : base(extent)
 {
     this.Variable = variableName;
     this.CommandsAllowed = commandsAllowed.ToReadOnlyCollection();
     this.Body = body;
 }
Ejemplo n.º 12
0
 public ArrayExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock) : base(extent)
 {
     if (statementBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("statementBlock");
     }
     this.SubExpression = statementBlock;
     base.SetParent(statementBlock);
 }
Ejemplo n.º 13
0
 protected LoopStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body) : base(extent, label, condition)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 14
0
 public ScriptBlockAst(IScriptExtent extent, ParamBlockAst paramBlock, StatementBlockAst statements, bool isFilter)
     : base(extent)
 {
     this.EndBlock = new NamedBlockAst(extent, TokenKind.End, statements, true);
     if (isFilter)
     {
         throw new NotImplementedException(this.ToString());
     }
 }
Ejemplo n.º 15
0
 public SubExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock) : base(extent)
 {
     if (statementBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("statementBlock");
     }
     this.SubExpression = statementBlock;
     base.SetParent(statementBlock);
 }
Ejemplo n.º 16
0
 public ForEachStatementAst(IScriptExtent extent, string label, ForEachFlags flags, VariableExpressionAst variable, PipelineBaseAst expression, StatementBlockAst body) : base(extent, label, expression, body)
 {
     if ((expression == null) || (variable == null))
     {
         throw PSTraceSource.NewArgumentNullException((expression == null) ? "expression" : "variablePath");
     }
     this.Flags = flags;
     this.Variable = variable;
     base.SetParent(variable);
 }
Ejemplo n.º 17
0
 public ForStatementAst(IScriptExtent extent, string label, PipelineBaseAst initializer, PipelineBaseAst condition, PipelineBaseAst iterator, StatementBlockAst body) : base(extent, label, condition, body)
 {
     if (initializer != null)
     {
         this.Initializer = initializer;
         base.SetParent(initializer);
     }
     if (iterator != null)
     {
         this.Iterator = iterator;
         base.SetParent(iterator);
     }
 }
Ejemplo n.º 18
0
        public object VisitStatementBlock(StatementBlockAst statementBlockAst)
        {
            if (statementBlockAst.Traps != null)
            {
                return(false);
            }
            if (statementBlockAst.Statements.Count > 1)
            {
                return(false);
            }
            StatementAst ast = statementBlockAst.Statements.FirstOrDefault <StatementAst>();

            return((ast == null) ? ((object)false) : ((object)((bool)ast.Accept(this))));
        }
Ejemplo n.º 19
0
 public IfStatementAst(IScriptExtent extent, IEnumerable<Tuple<PipelineBaseAst, StatementBlockAst>> clauses, StatementBlockAst elseClause) : base(extent)
 {
     if ((clauses == null) || !clauses.Any<Tuple<PipelineBaseAst, StatementBlockAst>>())
     {
         throw PSTraceSource.NewArgumentException("clauses");
     }
     this.Clauses = new ReadOnlyCollection<Tuple<PipelineBaseAst, StatementBlockAst>>(clauses.ToArray<Tuple<PipelineBaseAst, StatementBlockAst>>());
     base.SetParents<PipelineBaseAst, StatementBlockAst>(this.Clauses);
     if (elseClause != null)
     {
         this.ElseClause = elseClause;
         base.SetParent(elseClause);
     }
 }
Ejemplo n.º 20
0
        public object VisitStatementBlock(StatementBlockAst statementBlockAst)
        {
            if (statementBlockAst.Traps != null)
            {
                return(false);
            }
            if (statementBlockAst.Statements.Count > 1)
            {
                return(false);
            }
            var pipeline = statementBlockAst.Statements.FirstOrDefault();

            return(pipeline != null && (bool)pipeline.Accept(this));
        }
Ejemplo n.º 21
0
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (trapType != null)
     {
         this.TrapType = trapType;
         base.SetParent(trapType);
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 22
0
 public NamedBlockAst(IScriptExtent extent, TokenKind blockName, StatementBlockAst statementBlock, bool unnamed)
     : base(extent)
 {
     this.BlockKind = blockName;
     if (statementBlock == null)
     {
         this.Statements = new ReadOnlyCollection<StatementAst>(new StatementAst[] { });
     }
     else
     {
         this.Statements = statementBlock.Statements;
     }
     this.Unnamed = unnamed;
 }
Ejemplo n.º 23
0
 public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if (trapType != null)
     {
         this.TrapType = trapType;
         base.SetParent(trapType);
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 24
0
 public BlockStatementAst(IScriptExtent extent, Token kind, StatementBlockAst body) : base(extent)
 {
     if ((kind == null) || (body == null))
     {
         throw PSTraceSource.NewArgumentNullException((kind == null) ? "kind" : "body");
     }
     if ((kind.Kind != TokenKind.Sequence) && (kind.Kind != TokenKind.Parallel))
     {
         throw PSTraceSource.NewArgumentException("kind");
     }
     this.Kind = kind;
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 25
0
 public BlockStatementAst(IScriptExtent extent, Token kind, StatementBlockAst body) : base(extent)
 {
     if ((kind == null) || (body == null))
     {
         throw PSTraceSource.NewArgumentNullException((kind == null) ? "kind" : "body");
     }
     if ((kind.Kind != TokenKind.Sequence) && (kind.Kind != TokenKind.Parallel))
     {
         throw PSTraceSource.NewArgumentException("kind");
     }
     this.Kind = kind;
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 26
0
 public NamedBlockAst(IScriptExtent extent, TokenKind blockName, StatementBlockAst statementBlock, bool unnamed)
     : base(extent)
 {
     this.BlockKind = blockName;
     if (statementBlock == null)
     {
         this.Statements = new ReadOnlyCollection <StatementAst>(new StatementAst[] { });
     }
     else
     {
         this.Statements = statementBlock.Statements;
     }
     this.Unnamed = unnamed;
 }
Ejemplo n.º 27
0
        internal override AstVisitAction InternalVisit(AstVisitor visitor)
        {
            AstVisitAction action = visitor.VisitNamedBlock(this);

            switch (action)
            {
            case AstVisitAction.SkipChildren:
                return(AstVisitAction.Continue);

            case AstVisitAction.Continue:
                action = StatementBlockAst.InternalVisit(visitor, this.Traps, this.Statements, action);
                break;
            }
            return(action);
        }
Ejemplo n.º 28
0
 public SwitchStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, SwitchFlags flags, IEnumerable<Tuple<ExpressionAst, StatementBlockAst>> clauses, StatementBlockAst @default) : base(extent, label, condition)
 {
     if (((clauses == null) || !clauses.Any<Tuple<ExpressionAst, StatementBlockAst>>()) && (@default == null))
     {
         throw PSTraceSource.NewArgumentException("clauses");
     }
     this.Flags = flags;
     this.Clauses = new ReadOnlyCollection<Tuple<ExpressionAst, StatementBlockAst>>(((clauses != null) && clauses.Any<Tuple<ExpressionAst, StatementBlockAst>>()) ? ((IList<Tuple<ExpressionAst, StatementBlockAst>>) clauses.ToArray<Tuple<ExpressionAst, StatementBlockAst>>()) : ((IList<Tuple<ExpressionAst, StatementBlockAst>>) EmptyClauseArray));
     base.SetParents<ExpressionAst, StatementBlockAst>(this.Clauses);
     if (@default != null)
     {
         this.Default = @default;
         base.SetParent(@default);
     }
 }
        public object VisitStatementBlock(StatementBlockAst statementBlockAst)
        {
            if (statementBlockAst != null)
            {
                var statements = statementBlockAst.Statements;
                if (statements != null)
                {
                    var firstStatement = statements.FirstOrDefault();
                    if (firstStatement != null)
                    {
                        return firstStatement.Visit(this);
                    }
                }
            }

            return null;
        }
Ejemplo n.º 30
0
 public CatchClauseAst(IScriptExtent extent, IEnumerable<TypeConstraintAst> catchTypes, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if ((catchTypes != null) && catchTypes.Any<TypeConstraintAst>())
     {
         this.CatchTypes = new ReadOnlyCollection<TypeConstraintAst>(catchTypes.ToArray<TypeConstraintAst>());
         base.SetParents((IEnumerable<Ast>) this.CatchTypes);
     }
     else
     {
         this.CatchTypes = EmptyCatchTypes;
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 31
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     bool isSafe = true;
     foreach (var statement in statementBlockAst.Statements)
     {
         _visitCount++;
         if (statement == null)
         {
             isSafe = false;
             break;
         }
         if (!(bool)statement.Accept(this))
         {
             isSafe = false;
             break;
         }
     }
     return isSafe;
 }
Ejemplo n.º 32
0
        public NamedBlockAst(IScriptExtent extent, TokenKind blockName, StatementBlockAst statementBlock, bool unnamed) : base(extent)
        {
            if (!blockName.HasTrait(TokenFlags.ScriptBlockBlockName) || (unnamed && ((blockName == TokenKind.Begin) || (blockName == TokenKind.Dynamicparam))))
            {
                throw PSTraceSource.NewArgumentException("blockName");
            }
            if (statementBlock == null)
            {
                throw PSTraceSource.NewArgumentNullException("statementBlock");
            }
            this.Unnamed   = unnamed;
            this.BlockKind = blockName;
            ReadOnlyCollection <StatementAst> statements = statementBlock.Statements;

            this.Statements = statements;
            foreach (StatementAst ast in statements)
            {
                ast.ClearParent();
            }
            base.SetParents((IEnumerable <Ast>)statements);
            ReadOnlyCollection <TrapStatementAst> traps = statementBlock.Traps;

            if ((traps != null) && traps.Any <TrapStatementAst>())
            {
                this.Traps = traps;
                foreach (TrapStatementAst ast2 in traps)
                {
                    ast2.ClearParent();
                }
                base.SetParents((IEnumerable <Ast>)traps);
            }
            if (!unnamed)
            {
                InternalScriptExtent extent2 = statementBlock.Extent as InternalScriptExtent;
                if (extent2 != null)
                {
                    this.OpenCurlyExtent  = new InternalScriptExtent(extent2.PositionHelper, extent2.StartOffset, extent2.StartOffset + 1);
                    this.CloseCurlyExtent = new InternalScriptExtent(extent2.PositionHelper, extent2.EndOffset - 1, extent2.EndOffset);
                }
            }
        }
Ejemplo n.º 33
0
 public ScriptBlockAst(IScriptExtent extent, ParamBlockAst paramBlock, StatementBlockAst statements, bool isFilter) : base(extent)
 {
     if (statements == null)
     {
         throw PSTraceSource.NewArgumentNullException("statements");
     }
     if (paramBlock != null)
     {
         this.ParamBlock = paramBlock;
         base.SetParent(paramBlock);
     }
     if (isFilter)
     {
         this.ProcessBlock = new NamedBlockAst(statements.Extent, TokenKind.Process, statements, true);
         base.SetParent(this.ProcessBlock);
     }
     else
     {
         this.EndBlock = new NamedBlockAst(statements.Extent, TokenKind.End, statements, true);
         base.SetParent(this.EndBlock);
     }
 }
Ejemplo n.º 34
0
 public ScriptBlockAst(IScriptExtent extent, ParamBlockAst paramBlock, StatementBlockAst statements, bool isFilter) : base(extent)
 {
     if (statements == null)
     {
         throw PSTraceSource.NewArgumentNullException("statements");
     }
     if (paramBlock != null)
     {
         this.ParamBlock = paramBlock;
         base.SetParent(paramBlock);
     }
     if (isFilter)
     {
         this.ProcessBlock = new NamedBlockAst(statements.Extent, TokenKind.Process, statements, true);
         base.SetParent(this.ProcessBlock);
     }
     else
     {
         this.EndBlock = new NamedBlockAst(statements.Extent, TokenKind.End, statements, true);
         base.SetParent(this.EndBlock);
     }
 }
Ejemplo n.º 35
0
    public System.Object VisitStatementBlock(System.Management.Automation.Language.StatementBlockAst statementBlockAst)
    {
        IScriptExtent mappedExtent = MapExtent(statementBlockAst.Extent);

        LinkedList <StatementAst> mappedStatements = new LinkedList <StatementAst>();

        foreach (StatementAst s in statementBlockAst.Statements)
        {
            mappedStatements.AddLast(_VisitStatement(s));
        }
        LinkedList <TrapStatementAst> mappedTraps = new LinkedList <TrapStatementAst>();

        if (statementBlockAst.Traps != null)
        {
            foreach (TrapStatementAst ts in statementBlockAst.Traps)
            {
                mappedTraps.AddLast((TrapStatementAst)VisitTrap(ts));
            }
        }

        return(new StatementBlockAst(mappedExtent, mappedStatements, mappedTraps));
    }
Ejemplo n.º 36
0
 public NamedBlockAst(IScriptExtent extent, TokenKind blockName, StatementBlockAst statementBlock, bool unnamed) : base(extent)
 {
     if (!blockName.HasTrait(TokenFlags.ScriptBlockBlockName) || (unnamed && ((blockName == TokenKind.Begin) || (blockName == TokenKind.Dynamicparam))))
     {
         throw PSTraceSource.NewArgumentException("blockName");
     }
     if (statementBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("statementBlock");
     }
     this.Unnamed = unnamed;
     this.BlockKind = blockName;
     ReadOnlyCollection<StatementAst> statements = statementBlock.Statements;
     this.Statements = statements;
     foreach (StatementAst ast in statements)
     {
         ast.ClearParent();
     }
     base.SetParents((IEnumerable<Ast>) statements);
     ReadOnlyCollection<TrapStatementAst> traps = statementBlock.Traps;
     if ((traps != null) && traps.Any<TrapStatementAst>())
     {
         this.Traps = traps;
         foreach (TrapStatementAst ast2 in traps)
         {
             ast2.ClearParent();
         }
         base.SetParents((IEnumerable<Ast>) traps);
     }
     if (!unnamed)
     {
         InternalScriptExtent extent2 = statementBlock.Extent as InternalScriptExtent;
         if (extent2 != null)
         {
             this.OpenCurlyExtent = new InternalScriptExtent(extent2.PositionHelper, extent2.StartOffset, extent2.StartOffset + 1);
             this.CloseCurlyExtent = new InternalScriptExtent(extent2.PositionHelper, extent2.EndOffset - 1, extent2.EndOffset);
         }
     }
 }
Ejemplo n.º 37
0
 public virtual AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return AstVisitAction.Continue;
 }
Ejemplo n.º 38
0
 public ForEachStatementAst(IScriptExtent extent, string label, ForEachFlags flags, VariableExpressionAst variable, PipelineBaseAst expression, StatementBlockAst body)
     : base(extent, label, expression, body)
 {
     this.Flags    = flags;
     this.Variable = variable;
 }
Ejemplo n.º 39
0
 public ForStatementAst(IScriptExtent extent, string label, PipelineBaseAst initializer, PipelineBaseAst condition, PipelineBaseAst iterator, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
     this.Initializer = initializer;
     this.Iterator = iterator;
 }
Ejemplo n.º 40
0
 /// <summary/>
 public virtual object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return _decorated.VisitStatementBlock(statementBlockAst);
 }
Ejemplo n.º 41
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     if (statementBlockAst.Traps != null)
     {
         return false;
     }
     if (statementBlockAst.Statements.Count > 1)
     {
         return false;
     }
     StatementAst ast = statementBlockAst.Statements.FirstOrDefault<StatementAst>();
     return ((ast == null) ? ((object) false) : ((object) ((bool) ast.Accept(this))));
 }
Ejemplo n.º 42
0
 /// <summary/>
 public virtual object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(null);
 }
Ejemplo n.º 43
0
 public WhileStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
 }
Ejemplo n.º 44
0
 public override AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return base.VisitStatementBlock(statementBlockAst);
 }
Ejemplo n.º 45
0
 protected LoopStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition)
 {
     this.Body = body;
 }
Ejemplo n.º 46
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(this.VisitStatementBlock(statementBlockAst.Statements));
 }
Ejemplo n.º 47
0
        private AstVisitAction VisitSimpleLoopStatement(StatementBlockAst body, PipelineBaseAst condition,
                                                    bool preExecuteBody, bool invertCond)
        {
            // TODO: pass loop label
            // preExecuteBody is for do while/until loops
            if (preExecuteBody && !EvaluateLoopBodyAst(body, null))
            {
                return AstVisitAction.SkipChildren;
            }

            // the condition is XORed with invertCond and menas: (true && !invertCond) || (false && invertCond)
            while (LanguagePrimitives.ConvertTo<bool>(EvaluateAst(condition)) ^ invertCond)
            {
                if (!EvaluateLoopBodyAst(body, null))
                {
                    break;
                }
            }
            return AstVisitAction.SkipChildren;
        }
Ejemplo n.º 48
0
 protected LoopStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition)
 {
     this.Body = body;
 }
Ejemplo n.º 49
0
 public override AstVisitAction VisitStatementBlock(StatementBlockAst ast)
 {
     return(Check(ast));
 }
Ejemplo n.º 50
0
 /// <summary/>
 public virtual AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(AstVisitAction.Continue);
 }
Ejemplo n.º 51
0
 public DoUntilStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
 }
Ejemplo n.º 52
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     CheckIsConstant(statementBlockAst, "Caller to verify ast is constant");
     return(statementBlockAst.Statements[0].Accept(this));
 }
Ejemplo n.º 53
0
 public WhileStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body) : base(extent, label, condition, body)
 {
     if (condition == null)
     {
         throw PSTraceSource.NewArgumentNullException("condition");
     }
 }
Ejemplo n.º 54
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(statementBlockAst.Statements.First <StatementAst>().Accept(this));
 }
Ejemplo n.º 55
0
 public ForStatementAst(IScriptExtent extent, string label, PipelineBaseAst initializer, PipelineBaseAst condition, PipelineBaseAst iterator, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
     this.Initializer = initializer;
     this.Iterator    = iterator;
 }
Ejemplo n.º 56
0
 public SwitchStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, SwitchFlags flags, IEnumerable <Tuple <ExpressionAst, StatementBlockAst> > clauses, StatementBlockAst @default)
     : base(extent, label, condition)
 {
     this.Flags   = flags;
     this.Clauses = clauses.ToReadOnlyCollection();
     this.Default = @default;
 }
Ejemplo n.º 57
0
 public CatchClauseAst(IScriptExtent extent, IEnumerable <TypeConstraintAst> catchTypes, StatementBlockAst body) : base(extent)
 {
     if (body == null)
     {
         throw PSTraceSource.NewArgumentNullException("body");
     }
     if ((catchTypes != null) && catchTypes.Any <TypeConstraintAst>())
     {
         this.CatchTypes = new ReadOnlyCollection <TypeConstraintAst>(catchTypes.ToArray <TypeConstraintAst>());
         base.SetParents((IEnumerable <Ast>) this.CatchTypes);
     }
     else
     {
         this.CatchTypes = EmptyCatchTypes;
     }
     this.Body = body;
     base.SetParent(body);
 }
Ejemplo n.º 58
0
 public IfStatementAst(IScriptExtent extent, IEnumerable<Tuple<PipelineBaseAst, StatementBlockAst>> clauses, StatementBlockAst elseClause)
     : base(extent)
 {
     this.Clauses = clauses.ToReadOnlyCollection();
     this.ElseClause = elseClause;
 }
Ejemplo n.º 59
0
 ArrayExpressionAst BuildArrayExpressionAst(ParseTreeNode parseTreeNode)
 {
     VerifyTerm(parseTreeNode, this._grammar.array_expression);
     StatementBlockAst statements;
     // check if we have statements or it's empty
     if (parseTreeNode.ChildNodes[1].Term == _grammar.statement_list)
     {
         statements = BuildStatementListAst(parseTreeNode.ChildNodes[1]);
     }
     else
     {
         // otherwise make such an Ast without statements
         statements = new StatementBlockAst(new ScriptExtent(parseTreeNode.ChildNodes[1]),
                                            new StatementAst[] { }, new TrapStatementAst[] { });
     }
     return new ArrayExpressionAst(
         new ScriptExtent(parseTreeNode),
         statements
         );
 }
Ejemplo n.º 60
0
 public ArrayExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock)
     : base(extent)
 {
     this.SubExpression = statementBlock;
 }