Ejemplo n.º 1
0
        private IfBranch(IExpression condition, IEnumerable <IExpression> body, IfBranch next)
        {
            this.condition = condition;
            // we have to postpone calculating read-mode because the last instruction can be function call
            // and it is resolved only after finding its target
            if (!body.Any())
            {
                body = new[] { UnitLiteral.Create() }
            }
            ;
            this.Body = Block.Create((block) => block.Instructions.Last().ReadMode, body);
            this.Next = next;

            this.attachPostConstructor();

            this.flow = Later.Create(() => this.IsElse
                ? ExecutionFlow.CreateElse(Body, Next) : ExecutionFlow.CreateFork(Condition, Body, Next));
        }
Ejemplo n.º 2
0
 public static IfBranch CreateElse(IEnumerable <IExpression> body, IfBranch next = null)
 {
     return(new IfBranch(condition: null, body: body, next: next));
 }
Ejemplo n.º 3
0
 public static IfBranch CreateIf(IExpression condition, IEnumerable <IExpression> body, IfBranch next = null)
 {
     return(new IfBranch(condition, body, next));
 }
Ejemplo n.º 4
0
 public static IfBranch CreateElse(IExpression body, IfBranch next = null)
 {
     return(CreateElse(new[] { body }, next));
 }
Ejemplo n.º 5
0
 public static IfBranch CreateIf(IExpression condition, IExpression body, IfBranch next = null)
 {
     return(CreateIf(condition, new[] { body }, next));
 }