Пример #1
0
 public override void WriteTo(System.IO.TextWriter w)
 {
     Condition.WriteTo(w);
     w.Write(" ? ");
     TrueExpr.WriteTo(w);
     w.Write(" : ");
     FalseExpr.WriteTo(w);
 }
Пример #2
0
        protected override IType ValidateExpr(Environment env)
        {
            ConditionExpr.Validate(env);
            ConditionExpr.AssertType(new BooleanType());

            TrueExpr.Validate(env);
            FalseExpr.Validate(env);

            FalseExpr.AssertType(TrueExpr.Type);

            return(TrueExpr.Type);
        }
Пример #3
0
        public TMonad Evaluate(IContext <TMonad> context)
        {
            var c = ConditionExpr.Evaluate(context);

            return(Monad.Bind(c, BindC));

            TMonad BindC(object res)
            {
                return(res is bool b
                    ? (b ? TrueExpr.Evaluate(context) : FalseExpr.Evaluate(context))
                    : Monad.Unit);
            }
        }
Пример #4
0
 internal abstract T_Return VisitTrue(TrueExpr <T_Identifier> expression);
 internal override CellTreeNode VisitTrue(TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     return(_topLevelTree);
 }
 internal override BoolExpr <DomainConstraint <BoolLiteral, Constant> > VisitTrue(
     TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     return((BoolExpr <DomainConstraint <BoolLiteral, Constant> >)FalseExpr <DomainConstraint <BoolLiteral, Constant> > .Value);
 }
 internal override int VisitTrue(TrueExpr <T_Identifier> expression)
 {
     return(0);
 }
 internal override StringBuilder VisitTrue(
     TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     this.m_builder.Append("True");
     return(this.m_builder);
 }
 internal override IEnumerable <TermExpr <DomainConstraint <BoolLiteral, Constant> > > VisitTrue(
     TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     yield break;
 }
 internal override DbExpression VisitTrue(
     TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     return((DbExpression)DbExpressionBuilder.True);
 }
 internal override bool VisitTrue(
     TrueExpr <DomainConstraint <BoolLiteral, Constant> > expression)
 {
     return(true);
 }
Пример #12
0
 internal override DomainBoolExpr VisitTrue(TrueExpr <DomainConstraint> expression)
 {
     return(FalseExpr <DomainConstraint> .Value);
 }
Пример #13
0
 public override string ToCode()
 {
     return
         ($"{Condition.ToCode()} {TokenValues.QuestionMark} {TrueExpr.ToCode()} {TokenValues.Colon} : {FalseExpr.ToCode()}");
 }