Beispiel #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));
        }
Beispiel #2
0
 public static IfBranch CreateElse(IEnumerable <IExpression> body, IfBranch next = null)
 {
     return(new IfBranch(condition: null, body: body, next: next));
 }
Beispiel #3
0
 public static IfBranch CreateIf(IExpression condition, IEnumerable <IExpression> body, IfBranch next = null)
 {
     return(new IfBranch(condition, body, next));
 }
Beispiel #4
0
 public static IfBranch CreateElse(IExpression body, IfBranch next = null)
 {
     return(CreateElse(new[] { body }, next));
 }
Beispiel #5
0
 public static IfBranch CreateIf(IExpression condition, IExpression body, IfBranch next = null)
 {
     return(CreateIf(condition, new[] { body }, next));
 }