Exemplo n.º 1
0
        /// <summary>
        /// Convert a type from the debugger's type system into X# type system
        /// </summary>
        /// <param name="lmrType">LMR Type</param>
        /// <returns>X# type</returns>
        public static XSharpType GetXSharpTypeForLmrType(Type lmrType)
        {
            if (lmrType.IsPrimitive)
            {
                return(XSharpType.Create(lmrType.FullName));
            }
            else if (lmrType.IsArray)
            {
                XSharpType elementType = GetXSharpTypeForLmrType(lmrType.GetElementType());

                return(elementType.MakeArrayType());
            }
            else if (lmrType.IsByRef)
            {
                XSharpType elementType = GetXSharpTypeForLmrType(lmrType.GetElementType());

                return(elementType.MakeByRefType());
            }
            else if (lmrType.FullName.Equals("System.String"))
            {
                return(XSharpType.String);
            }

            // Unknown
            return(XSharpType.Create(lmrType.FullName));
        }
Exemplo n.º 2
0
        internal static XSharpType Create(Meta.Type gentype, Meta.Type[] args)
        {
            var        name       = gentype.FullName;
            XSharpType baseType   = Create(name);
            var        resultName = baseType.ToString();

            if (baseType != ArrayBase)
            {
                resultName += "<";
            }
            else
            {
                resultName += " ";
            }
            bool first = true;

            foreach (var arg in args)
            {
                if (!first)
                {
                    resultName += ",";
                }
                var t = Create(arg.FullName);
                resultName += t.ToString();
                first       = false;
            }
            if (baseType != ArrayBase)
            {
                resultName += ">";
            }

            var result = Create(resultName);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Convert a type from the debugger's type system into X# type system
        /// </summary>
        /// <param name="lmrType">LMR Type</param>
        /// <returns>X# type</returns>
        public static XSharpType GetXSharpTypeForLmrType(Type lmrType)
        {
            if (lmrType.IsPrimitive)
            {
                return(XSharpType.Create(lmrType.FullName));
            }
            else if (lmrType.IsArray)
            {
                XSharpType elementType = GetXSharpTypeForLmrType(lmrType.GetElementType());

                return(elementType.MakeArrayType());
            }
            else if (lmrType.IsByRef)
            {
                XSharpType elementType = GetXSharpTypeForLmrType(lmrType.GetElementType());

                return(elementType.MakeByRefType());
            }
            else if (lmrType.IsGenericType)
            {
                var args = lmrType.GetGenericArguments();
                var td   = lmrType.GetGenericTypeDefinition();
                return(XSharpType.Create(td, args));
            }

            else if (lmrType.FullName.Equals("System.String"))
            {
                return(XSharpType.String);
            }

            // Unknown
            return(XSharpType.Create(lmrType.FullName));
        }
Exemplo n.º 4
0
        internal static XSharpType Create(string name)
        {
            if (s_types.ContainsKey(name))
            {
                return(s_types[name]);
            }
            var result = new XSharpType(name);

            s_types.Add(name, result);
            return(result);
        }
Exemplo n.º 5
0
        internal static XSharpType Create(string name)
        {
            var pos = name.IndexOf("`");

            if (pos > 0)
            {
                name = name.Substring(0, pos);
            }
            if (s_types.ContainsKey(name))
            {
                return(s_types[name]);
            }
            var result = new XSharpType(name);

            s_types.Add(name, result);
            return(result);
        }
Exemplo n.º 6
0
        public ImportedMethod TryFindMethod(string name, bool instance, XSharpType returnType, XSharpType[] paramTypes)
        {
            EnsureMethods();

            foreach (ImportedMethod method in _methods)
            {
                if (method.IsStatic == instance)
                {
                    continue;
                }

                if (method.ReturnType != returnType)
                {
                    continue;
                }

                if (!string.Equals(method.Name, name))
                {
                    continue;
                }

                Variable[] methodParams = method.GetParameters();
                if (methodParams.Length != paramTypes.Length)
                {
                    continue;
                }

                bool match = true;
                for (int i = 0; i < paramTypes.Length; i++)
                {
                    if (paramTypes[i] != methodParams[i].Type)
                    {
                        match = false;
                        break;
                    }
                }

                if (match)
                {
                    return(method); // Found
                }
            }

            return(null); // Not found
        }
Exemplo n.º 7
0
        public XSharpType ConvertToXSharpType()
        {
            switch (FullName)
            {
            case "System.Boolean":
                return(XSharpType.Logic);

            case "System.Int32":
                return(XSharpType.Integer);

            case "System.String":
                return(XSharpType.String);

            case "System.Void":
                return(XSharpType.Void);

            default:
                return(XSharpType.Create(FullName));
            }
        }
Exemplo n.º 8
0
 internal static ByRefType InternalCreate(XSharpType elementType)
 {
     return(new ByRefType(elementType));
 }
Exemplo n.º 9
0
 protected ByRefType(XSharpType elementType)
     : base(elementType + "&")
 {
     _elementType = elementType;
 }
Exemplo n.º 10
0
 internal static ArrayType InternalCreate(XSharpType elementType)
 {
     return(new ArrayType(elementType));
 }
Exemplo n.º 11
0
 protected ArrayType(XSharpType elementType)
     : base(string.Format("{0}[]", elementType))
 {
     _elementType = elementType;
 }
Exemplo n.º 12
0
 public static Function Create(XSharpType returnType, Variable[] parameters)
 {
     return(new Function(returnType, parameters));
 }
Exemplo n.º 13
0
 protected Function(XSharpType returnType, Variable[] parameters)
     : base("function", parameters)
 {
     _returnType = returnType;
 }
Exemplo n.º 14
0
        static XSharpType()
        {
            try
            {
                KeywordCase = (KeywordCase)Constants.GetSetting(Constants.RegistryKeywordCase, (int)KeywordCase.None);
            }
            catch
            {
                KeywordCase = KeywordCase.None;
            }

            Byte    = new XSharpType("Byte");
            Char    = new XSharpType("Char");
            DWord   = new XSharpType("Dword");
            Integer = new XSharpType("Int");
            Int64   = new XSharpType("Int64");
            Logic   = new XSharpType("Logic");
            Object  = new XSharpType("Object");
            Ptr     = new XSharpType("Ptr");
            Real4   = new XSharpType("Real4");
            Real8   = new XSharpType("Real8");
            SByte   = new XSharpType("Sbyte");
            Short   = new XSharpType("Short");
            String  = new XSharpType("String");
            UInt64  = new XSharpType("Uint64");
            Void    = new XSharpType("Void");
            Word    = new XSharpType("Word");

            Array     = new XSharpType("Array");
            ArrayBase = new XSharpType("Array Of");
            Binary    = new XSharpType("Binary");
            Currency  = new XSharpType("Currency");
            Date      = new XSharpType("Date");
            Float     = new XSharpType("Float");
            FoxArray  = new XSharpType("Foxarray");
            Invalid   = new XSharpType("Invalid");
            Psz       = new XSharpType("Psz");
            Symbol    = new XSharpType("Symbol");
            Usual     = new XSharpType("Usual");
            // types below are sorted by name
            s_types.Add("System.Boolean", XSharpType.Logic);
            s_types.Add("System.Byte", XSharpType.Byte);
            s_types.Add("System.Char", XSharpType.Char);
            s_types.Add("System.Double", XSharpType.Real8);
            s_types.Add("System.Int16", XSharpType.Short);
            s_types.Add("System.Int32", XSharpType.Integer);
            s_types.Add("System.Int64", XSharpType.Int64);
            s_types.Add("System.IntPtr", XSharpType.Ptr);
            s_types.Add("System.Object", XSharpType.Object);
            s_types.Add("System.SByte", XSharpType.SByte);
            s_types.Add("System.Single", XSharpType.Real4);
            s_types.Add("System.String", XSharpType.String);
            s_types.Add("System.UInt16", XSharpType.Word);
            s_types.Add("System.UInt32", XSharpType.DWord);
            s_types.Add("System.UInt64", XSharpType.UInt64);
            s_types.Add("System.Void", XSharpType.Void);

            s_types.Add("Vulcan.__Array", XSharpType.Array);
            s_types.Add("Vulcan.__Psz", XSharpType.Psz);
            s_types.Add("Vulcan.__Usual", XSharpType.Usual);
            s_types.Add("Vulcan.__Symbol", XSharpType.Symbol);
            s_types.Add("Vulcan.__VODate", XSharpType.Date);
            s_types.Add("Vulcan.__VOFloat", XSharpType.Float);

            s_types.Add("XSharp.__Array", XSharpType.Array);
            s_types.Add("XSharp.__ArrayBase", XSharpType.ArrayBase);
            s_types.Add("XSharp.__Binary", XSharpType.Binary);
            s_types.Add("XSharp.__Currency", XSharpType.Currency);
            s_types.Add("XSharp.__Date", XSharpType.Date);
            s_types.Add("XSharp.__FoxArray", XSharpType.FoxArray);
            s_types.Add("XSharp.__Float", XSharpType.Float);
            s_types.Add("XSharp.__Psz", XSharpType.Psz);
            s_types.Add("XSharp.__Symbol", XSharpType.Symbol);
            s_types.Add("XSharp.__Usual", XSharpType.Usual);
            s_types.Add("XSharp.__VODate", XSharpType.Date);
            s_types.Add("XSharp.__VOFloat", XSharpType.Float);
        }