Пример #1
0
        private static Type GetCSharpType(string paramName, IValue value, EilangType type)
        {
            switch (type)
            {
            case EilangType.String:
                return(typeof(string));    // TODO: this may require a pointer

            case EilangType.Integer:
                return(typeof(int));

            case EilangType.Long:
                return(typeof(long));

            case EilangType.Double:
                return(typeof(double));

            case EilangType.Uninitialized:
                return(typeof(string));

            case EilangType.Bool:
                return(typeof(bool));

            case EilangType.IntPtr:
                return(typeof(IntPtr));

            case EilangType.Instance:
                if (value is StructInstanceValue)
                {
                    return(typeof(IntPtr));
                }
                break;
            }
            throw ThrowHelper.InvalidArgumentType("interop::invoke_func", paramName, value, ValidInteropTypes);
        }
Пример #2
0
        public IValue EilangValue(EilangType typeFlags, string argumentName)
        {
            if ((_value.Type & typeFlags) != 0)
            {
                return(_value);
            }

            throw new InvalidValueException(
                      $"{_function} takes 1 argument: {typeFlags.GetFlagsSeparatedByPipe()} {argumentName}, received {_value.Type}");
        }
Пример #3
0
        public T Single <T>(EilangType type, string argumentName)
        {
            if (type == EilangType.Any || _value.Type == type)
            {
                return(_value.To <T>());
            }

            throw new InvalidValueException(
                      $"{_function} takes 1 argument: {type} {argumentName}, received {_value.Type}");
        }
Пример #4
0
 protected ValueBase(EilangType type, object value)
 {
     Type  = type;
     Value = value;
 }
Пример #5
0
 public RequiredArgumentValidator(EilangType type, string name)
 {
     Type = type;
     Name = name;
 }
Пример #6
0
 public TypeValue(string typeName, EilangType type) : base(EilangType.Type, typeName)
 {
     TypeOf = type;
 }
Пример #7
0
        public ArgumentListBuilderWithOptionalArguments OptionalArgument(EilangType type, string name, object @default)
        {
            _arguments.Add(new OptionalArgumentValidator(type, name, @default));

            return(new ArgumentListBuilderWithOptionalArguments(_value, _function, _arguments));
        }
Пример #8
0
 public ArgumentListBuilderWithArguments Argument(EilangType type, string name)
 {
     _arguments.Add(new RequiredArgumentValidator(type, name));
     return(this);
 }
Пример #9
0
 public OptionalArgumentValidator(EilangType type, string name, object @default)
 {
     Type     = type;
     Name     = name;
     _default = @default;
 }
Пример #10
0
 public ParameterType(string name, EilangType type)
 {
     Name = name;
     Type = type;
 }
Пример #11
0
 public static InvalidValueException TypeMismatch(EilangType a, string usedOperator, EilangType b)
 {
     return(new InvalidValueException(
                $"({a} {usedOperator} {b}): {a} does not support binary operator '{usedOperator}' with {b}"));
 }
Пример #12
0
 public static ArgumentValidationFailedException ArgumentValidationFailed(string name, EilangType type, EilangType actual, string function)
 {
     throw new ArgumentValidationFailedException($"In function {function}: argument {type.ToString().ToLower()} {name} received value of type {actual}");
 }
Пример #13
0
 public static InvalidValueException TypeMismatch(string usedOperator, EilangType unary)
 {
     return(new InvalidValueException(
                $"({usedOperator}{unary}): {unary} does not support unary operator '{usedOperator}'"));
 }
Пример #14
0
 public InstanceValue(Instance value, EilangType eilangType = EilangType.Instance) : base(eilangType, value)
 {
 }
Пример #15
0
 public IValue Instance(Instance instance, EilangType type = EilangType.Instance)
 {
     return(new InstanceValue(instance, type));
 }