public OpSignature(ValueType @return, CustomOps opType, params ValueType[] @params)
 {
     Params   = @params;
     Return   = @return;
     CustomOp = opType;
     MathOp   = MathOps.None;
     OpType   = opType.ToString();
     StableId = MathCodeGeneration.GenerateStableValueForCustomOp(opType, @return, @params);
 }
        public static TypeHandle ValueTypeToTypeHandle(this ValueType valueType)
        {
            switch (valueType)
            {
            case ValueType.Unknown:
                return(TypeHandle.Unknown);

            case ValueType.Bool:
                return(TypeHandle.Bool);

            case ValueType.Int:
                return(TypeHandle.Int);

            case ValueType.Float:
                return(TypeHandle.Float);

            case ValueType.Float2:
                return(TypeHandle.Vector2);

            case ValueType.Float3:
                return(TypeHandle.Vector3);

            case ValueType.Float4:
                return(TypeHandle.Vector4);

            case ValueType.Quaternion:
                return(TypeHandle.Quaternion);

            case ValueType.Entity:
                return(DotsTypeHandle.Entity);

            case ValueType.StringReference:
                return(TypeHandle.String);

            default:
                throw new ArgumentOutOfRangeException(nameof(valueType), valueType, null);
            }
        }
        static List <OpSignature> GetMathMethods()
        {
            var funcNames   = Enum.GetValues(typeof(MathOps)).Cast <MathOps>().ToDictionary(s => s.ToString().ToLower());
            var mathMethods = typeof(math).GetMethods(BindingFlags.Public | BindingFlags.Static);
            var res         = new List <OpSignature>(mathMethods.Length);

            foreach (var m in mathMethods)
            {
                if (funcNames.TryGetValue(m.Name, out var op))
                {
                    ValueType returnType = TypeToValueType(m.ReturnType);
                    if (returnType != ValueType.Unknown)
                    {
                        var paramTypes = m.GetParameters().Select(p => TypeToValueType(p.ParameterType)).ToArray();
                        if (paramTypes.All(p => p != ValueType.Unknown))
                        {
                            res.Add(new OpSignature(returnType, op, paramTypes));
                        }
                    }
                }
            }
            return(res);
        }
 public static OpSignature LinearBinOp(CustomOps opType, ValueType valueType)
 {
     return(new OpSignature(valueType, opType, valueType, valueType));
 }