예제 #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());
 }
예제 #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);
     }
 }
예제 #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;
 }
예제 #4
0
 public DoUntilStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body) : base(extent, label, condition, body)
 {
     if (condition == null)
     {
         throw PSTraceSource.NewArgumentNullException("condition");
     }
 }
예제 #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;
 }
예제 #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;
             }
         }
     }
 }
예제 #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);
     }
 }
예제 #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;
 }
예제 #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());
        }
예제 #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);
 }
예제 #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;
 }
예제 #12
0
 public ArrayExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock) : base(extent)
 {
     if (statementBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("statementBlock");
     }
     this.SubExpression = statementBlock;
     base.SetParent(statementBlock);
 }
예제 #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);
 }
예제 #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());
     }
 }
예제 #15
0
 public SubExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock) : base(extent)
 {
     if (statementBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("statementBlock");
     }
     this.SubExpression = statementBlock;
     base.SetParent(statementBlock);
 }
예제 #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);
 }
예제 #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);
     }
 }
예제 #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))));
        }
예제 #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);
     }
 }
예제 #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));
        }
예제 #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);
 }
예제 #22
0
파일: NamedBlockAst.cs 프로젝트: b333z/Pash
 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;
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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;
 }
예제 #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);
        }
예제 #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;
        }
예제 #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);
 }
예제 #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;
 }
예제 #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);
                }
            }
        }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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));
    }
예제 #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);
         }
     }
 }
예제 #37
0
 public virtual AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return AstVisitAction.Continue;
 }
예제 #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;
 }
예제 #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;
 }
 /// <summary/>
 public virtual object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return _decorated.VisitStatementBlock(statementBlockAst);
 }
예제 #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))));
 }
예제 #42
0
 /// <summary/>
 public virtual object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(null);
 }
예제 #43
0
 public WhileStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
 }
예제 #44
0
 public override AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return base.VisitStatementBlock(statementBlockAst);
 }
예제 #45
0
 protected LoopStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition)
 {
     this.Body = body;
 }
예제 #46
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(this.VisitStatementBlock(statementBlockAst.Statements));
 }
예제 #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;
        }
예제 #48
0
 protected LoopStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition)
 {
     this.Body = body;
 }
예제 #49
0
 public override AstVisitAction VisitStatementBlock(StatementBlockAst ast)
 {
     return(Check(ast));
 }
예제 #50
0
 /// <summary/>
 public virtual AstVisitAction VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(AstVisitAction.Continue);
 }
예제 #51
0
 public DoUntilStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body)
     : base(extent, label, condition, body)
 {
 }
예제 #52
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     CheckIsConstant(statementBlockAst, "Caller to verify ast is constant");
     return(statementBlockAst.Statements[0].Accept(this));
 }
예제 #53
0
 public WhileStatementAst(IScriptExtent extent, string label, PipelineBaseAst condition, StatementBlockAst body) : base(extent, label, condition, body)
 {
     if (condition == null)
     {
         throw PSTraceSource.NewArgumentNullException("condition");
     }
 }
예제 #54
0
 public object VisitStatementBlock(StatementBlockAst statementBlockAst)
 {
     return(statementBlockAst.Statements.First <StatementAst>().Accept(this));
 }
예제 #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;
 }
예제 #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;
 }
예제 #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);
 }
예제 #58
0
 public IfStatementAst(IScriptExtent extent, IEnumerable<Tuple<PipelineBaseAst, StatementBlockAst>> clauses, StatementBlockAst elseClause)
     : base(extent)
 {
     this.Clauses = clauses.ToReadOnlyCollection();
     this.ElseClause = elseClause;
 }
예제 #59
0
파일: AstBuilder.cs 프로젝트: Ventero/Pash
 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
         );
 }
예제 #60
0
 public ArrayExpressionAst(IScriptExtent extent, StatementBlockAst statementBlock)
     : base(extent)
 {
     this.SubExpression = statementBlock;
 }