コード例 #1
0
ファイル: VecArray.cs プロジェクト: vectorize-dsl/antlr
        public VecBool IsEqualTo(IVecValue other)
        {
            switch (other)
            {
            case VecArray <T> otherArray:
                return(new VecBool(Values.SequenceEqual(otherArray.Values)));

            default:
                throw new InvalidOperationException($"Can only equal with string type! Type: {other.Type}");
            }
        }
コード例 #2
0
        public VecBool IsEqualTo(IVecValue other)
        {
            switch (other)
            {
            case VecString otherString:
                return(new VecBool(Value == otherString.Value));

            default:
                throw new InvalidOperationException($"Can only equal with string type! Type: {other.Type}");
            }
        }
コード例 #3
0
        public VecBool IsEqualTo(IVecValue other)
        {
            switch (other)
            {
            case VecBool otherBool:
                return(new VecBool(Value == otherBool.Value));

            default:
                throw new InvalidOperationException($"Can only equal with bools! Type: {other.Type}");
            }
        }
コード例 #4
0
        public VecBool IsEqualTo(IVecValue other)
        {
            switch (other)
            {
            case VecNull _:
                return(new VecBool(true));

            default:
                throw new InvalidOperationException($"Can only equal with null type! Type: {other.Type}");
            }
        }
コード例 #5
0
ファイル: VecFloat.cs プロジェクト: vectorize-dsl/antlr
        public IVecValue Multiply(IVecValue other)
        {
            switch (other)
            {
            case VecInt otherInt:
                return(new VecFloat(Value * otherInt.Value));

            case VecFloat otherFloat:
                return(new VecFloat(Value * otherFloat.Value));

            default:
                throw new InvalidOperationException($"Can only multiply numeric type! Type: {other.Type}");
            }
        }
コード例 #6
0
ファイル: VecFloat.cs プロジェクト: vectorize-dsl/antlr
        public VecBool IsLesserThan(IVecValue other)
        {
            switch (other)
            {
            case VecInt otherInt:
                return(new VecBool(Value < otherInt.Value));

            case VecFloat otherFloat:
                return(new VecBool(Value < otherFloat.Value));

            default:
                throw new InvalidOperationException($"Can only compare with numeric type! Type: {other.Type}");
            }
        }
コード例 #7
0
ファイル: VecFloat.cs プロジェクト: vectorize-dsl/antlr
        public VecBool IsEqualTo(IVecValue other)
        {
            switch (other)
            {
            case VecInt otherInt:
                return(new VecBool(Value == otherInt.Value));

            case VecFloat otherFloat:
                return(new VecBool(Value == otherFloat.Value));

            default:
                throw new InvalidOperationException($"Can only equal with numeric type! Type: {other.Type}");
            }
        }
コード例 #8
0
ファイル: VecArray.cs プロジェクト: vectorize-dsl/antlr
        public void Set(int idx, IVecValue value)
        {
            if (idx < 0 || idx >= Size)
            {
                throw new InvalidOperationException($"Index must be between 0 and {Values.Length - 1}!");
            }

            if (value is T valueT)
            {
                Values[idx] = valueT;
            }
            else
            {
                throw new InvalidOperationException($"Wrong element type for this {ElementType} array! Was: {value.Type}");
            }
        }
コード例 #9
0
ファイル: IVecValue.cs プロジェクト: vectorize-dsl/antlr
        public static bool TryConvertToFloat(this IVecValue value, out VecFloat valueAsFloat)
        {
            if (value is VecFloat valF)
            {
                valueAsFloat = valF;
                return(true);
            }
            if (value is VecInt valI)
            {
                valueAsFloat = new VecFloat(valI.Value);
                return(true);
            }

            valueAsFloat = default(VecFloat);
            return(false);
        }
コード例 #10
0
ファイル: VecArray.cs プロジェクト: vectorize-dsl/antlr
 public IVecValue Modulo(IVecValue other)
 => throw new InvalidOperationException("Array does not support numeric operations!");
コード例 #11
0
ファイル: VecArray.cs プロジェクト: vectorize-dsl/antlr
 public VecBool IsLesserThan(IVecValue other)
 => throw new InvalidOperationException("Array does not support relational operations!");
コード例 #12
0
ファイル: IVecValue.cs プロジェクト: vectorize-dsl/antlr
 public static VecBool IsLesserOrEqualTo(this IVecValue lhs, IVecValue rhs)
 => lhs.IsEqualTo(rhs).Or(lhs.IsLesserThan(rhs));
コード例 #13
0
ファイル: IVecValue.cs プロジェクト: vectorize-dsl/antlr
 public static VecBool IsGreaterThan(this IVecValue lhs, IVecValue rhs)
 => lhs.IsLesserThan(rhs).Not();
コード例 #14
0
 public IVecValue Divide(IVecValue other)
 => throw new InvalidOperationException("String does not support numeric operations!");
コード例 #15
0
 public IVecValue Multiply(IVecValue other)
 => throw new InvalidOperationException("Bool does not support numeric operations!");
コード例 #16
0
 public IVecValue Subtract(IVecValue other)
 => throw new InvalidOperationException("Null does not support numeric operations!");