Пример #1
0
        public static IValue make(Func <int, int> val)
        {
            Func <IValue, IValue> func = f => {
                return(ValueFactory.make(val(f.Get <int>())));
            };

            return(new Value(Type.Of(ValueType.FUNCTION), func));
        }
Пример #2
0
        private Func <IValue, IValue> makeListTypeChecker(IEnumerable <IValue> types)
        {
            Func <IValue, IValue> typeChecker = l => {
                var typeCheck = new TypeChecker(ValueFactory.make(types));
                return(ValueFactory.make(typeCheck.Check(l)));
            };

            return(typeChecker);
        }
Пример #3
0
 public ListType(IValue types, String description)
 {
     if (!types.Type.Check(ValueType.LIST))
     {
         throw new TypeException("List type must be actually a list!");
     }
     this.predicate    = ValueFactory.make(makeListTypeChecker(types.Get <IEnumerable <IValue> >()));
     this.friendlyName = description;
     this.creationList = types;
 }
Пример #4
0
 public static IValue make(Func <IValue, IValue> val, IValue paramType = null, IValue returnType = null)
 {
     if (paramType == null)
     {
         paramType = ValueFactory.make(Type.Of(ValueType.ANY));
     }
     if (returnType == null)
     {
         returnType = ValueFactory.make(Type.Of(ValueType.ANY));
     }
     return(new FunctionValue(val, paramType, returnType));
 }
Пример #5
0
 public FunctionValue(Func <IValue, IValue> func, IValue parameterType)
 {
     this.innerFunction = func;
     this.parameterType = parameterType;
     this.returnType    = ValueFactory.make(new Type(ValueType.ANY));
 }
Пример #6
0
 public bool Check(IValue val)
 {
     return(Check(val.Type) || (val.Type.RawTypeOf == RawTypeOf && Predicate.Operator("()", val).Equals(ValueFactory.make(true))));
 }
Пример #7
0
 public ListType(IEnumerable <IValue> types, String description)
 {
     this.predicate    = ValueFactory.make(makeListTypeChecker(types));
     this.friendlyName = description;
     this.creationList = ValueFactory.make(types);
 }