Beispiel #1
0
        public static Func <IWorkshopTree, IWorkshopTree, IWorkshopTree> DefaultFromOperator(TypeOperator op)
        {
            switch (op)
            {
            case TypeOperator.Add: return((l, r) => Element.Add(l, r));

            case TypeOperator.And: return((l, r) => Element.And(l, r));

            case TypeOperator.Divide: return((l, r) => Element.Divide(l, r));

            case TypeOperator.Modulo: return((l, r) => Element.Modulo(l, r));

            case TypeOperator.Multiply: return((l, r) => Element.Multiply(l, r));

            case TypeOperator.Or: return((l, r) => Element.Or(l, r));

            case TypeOperator.Pow: return((l, r) => Element.Pow(l, r));

            case TypeOperator.Subtract: return((l, r) => Element.Subtract(l, r));

            case TypeOperator.Equal: return((l, r) => Element.Compare(l, Elements.Operator.Equal, r));

            case TypeOperator.GreaterThan: return((l, r) => Element.Compare(l, Elements.Operator.GreaterThan, r));

            case TypeOperator.GreaterThanOrEqual: return((l, r) => Element.Compare(l, Elements.Operator.GreaterThanOrEqual, r));

            case TypeOperator.LessThan: return((l, r) => Element.Compare(l, Elements.Operator.LessThan, r));

            case TypeOperator.LessThanOrEqual: return((l, r) => Element.Compare(l, Elements.Operator.LessThanOrEqual, r));

            case TypeOperator.NotEqual: return((l, r) => Element.Compare(l, Elements.Operator.NotEqual, r));

            default: throw new NotImplementedException(op.ToString());
            }
        }
Beispiel #2
0
        public static CodeType DefaultTypeFromOperator(TypeOperator op, ITypeSupplier supplier)
        {
            switch (op)
            {
            case TypeOperator.And:
            case TypeOperator.Or:
            case TypeOperator.NotEqual:
            case TypeOperator.Equal:
            case TypeOperator.GreaterThan:
            case TypeOperator.GreaterThanOrEqual:
            case TypeOperator.LessThan:
            case TypeOperator.LessThanOrEqual:
                return(supplier.Boolean());

            case TypeOperator.Add:
            case TypeOperator.Divide:
            case TypeOperator.Modulo:
            case TypeOperator.Multiply:
            case TypeOperator.Pow:
            case TypeOperator.Subtract:
                return(supplier.Number());

            default: throw new NotImplementedException(op.ToString());
            }
        }