public static LoopStatement While(this SourceCode source, Expression conditionExpression)
        {
            var loop = new LoopStatement()
            {
                Where = conditionExpression
            };

            source.Add(loop);

            return(loop);
        }
        public TryStatement Try(SourceCode self)
        {
            self._parent = this;

            var tryStatement = new TryStatement()
            {
                Body = self,
            };

            this.Add(tryStatement);

            return(tryStatement);
        }
Exemple #3
0
        public SourceCode If(Expression e, SourceCode @then, SourceCode @else)
        {
            var n = new ConditionalStatement()
            {
                Expression = e,
                Then       = @then,
                Else       = @else
            };

            this.Add(n);

            return(this);
        }
Exemple #4
0
        public SourceCode If(Expression e, params Expression[] codes)
        {
            var _then = new SourceCode()
            {
            };

            _then.AddRange(codes.Select(c => new ExpressionStatement()
            {
                Expression = c
            }));

            this.If(e, _then, null);

            return(this);
        }
        public static ForStatement For(this SourceCode source, Expression initialValueExpression, Expression endValueExpression)
        {
            var Index = source.AddVar(typeof(int), null, initialValueExpression);

            var loop = new ForStatement(initialValueExpression)
            {
                Where     = Expression.LessThan(Index, endValueExpression),
                Index     = Index,
                MoveIndex = Index.PostIncrementAssign(),
            };

            source.Add(loop);

            return(loop);
        }
        public static ConditionalStatement If(this SourceCode source, Expression test, SourceCode @then, SourceCode @else)
        {
            var n = new ConditionalStatement()
            {
                ConditionalExpression = test,
            };

            n.Then.Merge(@then);

            if (@else != null)
            {
                n.Else.Merge(@else);
            }

            source.Add(n);

            return(n);
        }
Exemple #7
0
        public SourceCode Try(SourceCode self, params CatchStatement[] catchs)
        {
            self._parent = this;

            var tryStatement = new TryStatement()
            {
                Try = self,
            };

            foreach (var item in catchs)
            {
                item.Body._parent = this;
                tryStatement.Catchs.Add(item);
            }

            this.Add(tryStatement);

            return(this);
        }
Exemple #8
0
 public SourceCode(SourceCode parent = null)
 {
     this._parent = parent;
 }
 public static SourceCode Assign(this SourceCode source, Expression left, Expression right)
 {
     source.Add(left.AssignFrom(right));
     return(source);
 }
 public static ConditionalStatement If(this SourceCode source, Expression test, params Statement[] thenCodes)
 {
     return(source.If(test, thenCodes, null));
 }