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