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); }
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}"); }
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}"); }
protected ValueBase(EilangType type, object value) { Type = type; Value = value; }
public RequiredArgumentValidator(EilangType type, string name) { Type = type; Name = name; }
public TypeValue(string typeName, EilangType type) : base(EilangType.Type, typeName) { TypeOf = type; }
public ArgumentListBuilderWithOptionalArguments OptionalArgument(EilangType type, string name, object @default) { _arguments.Add(new OptionalArgumentValidator(type, name, @default)); return(new ArgumentListBuilderWithOptionalArguments(_value, _function, _arguments)); }
public ArgumentListBuilderWithArguments Argument(EilangType type, string name) { _arguments.Add(new RequiredArgumentValidator(type, name)); return(this); }
public OptionalArgumentValidator(EilangType type, string name, object @default) { Type = type; Name = name; _default = @default; }
public ParameterType(string name, EilangType type) { Name = name; Type = type; }
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}")); }
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}"); }
public static InvalidValueException TypeMismatch(string usedOperator, EilangType unary) { return(new InvalidValueException( $"({usedOperator}{unary}): {unary} does not support unary operator '{usedOperator}'")); }
public InstanceValue(Instance value, EilangType eilangType = EilangType.Instance) : base(eilangType, value) { }
public IValue Instance(Instance instance, EilangType type = EilangType.Instance) { return(new InstanceValue(instance, type)); }