Ejemplo n.º 1
0
        /// <summary>
        /// Loads the node.
        /// </summary>
        /// <param name="io">[in] The node is read from io.</param>
        /// <exception cref="Columbus.ColumbusIOException">Throws ColumbusIOException if there is something wrong with the file.</exception>
        public override void load(IO binIo)
        {
            base.load(binIo);

            m_simpleTypeKind = (Types.SimpleTypeKind)binIo.readUByte1();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor, only factory can instantiates nodes.
 /// </summary>
 /// <param name="nodeId">[in] The id of the node.</param>
 /// <param name="factory">[in] Poiter to the Factory the node belongs to.</param>
 public SimpleType(uint nodeId, Factory factory) : base(nodeId, factory)
 {
     m_simpleTypeKind = Types.SimpleTypeKind.stkBoolean;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Type building strategy
        /// </summary>
        /// <param name="node"></param>
        /// <param name="refs"></param>
        public static void AddLimTypeFormers(ISymbol node, ISymbol refs = null)
        {
            switch (node.Kind)
            {
            case SymbolKind.ArrayType:
                MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerArray().Id);
                var arrayTypeSymbol = node as IArrayTypeSymbol;
                if (arrayTypeSymbol.ElementType != null)
                {
                    if (arrayTypeSymbol.ElementType.IsInMetadata())
                    {
                        AddLimTypeFormers(arrayTypeSymbol.ElementType);
                    }
                    else
                    {
                        SyntaxNode syntaxNode = null;
                        var        @ref       = arrayTypeSymbol.ElementType.GetDefinition(out syntaxNode);
                        if (@ref != null && @ref.Kind == arrayTypeSymbol.ElementType.Kind)
                        {
                            if (@ref is INamedTypeSymbol && ((INamedTypeSymbol)@ref).IsGenericType)
                            {
                                AddLimTypeFormers(arrayTypeSymbol.ElementType, @ref);
                            }
                            else
                            {
                                AddLimTypeFormers(@ref);
                            }
                        }
                    }
                }
                break;

            case SymbolKind.TypeParameter:

                GenericParameter gp = (GenericParameter)node.ConvertToLimNode();
                if (gp == null)
                {
                    return;
                }

                MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerType(gp.Id).Id);

                break;

            case SymbolKind.PointerType:
                IPointerTypeSymbol pointerType = node as IPointerTypeSymbol;
                if (pointerType.IsReferenceType)
                {
                    MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerPointer(Types.PointerKind.ptkReference).Id);
                }
                else
                {
                    MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerPointer(Types.PointerKind.ptkPointer).Id);
                }
                AddLimTypeFormers(pointerType.PointedAtType);
                break;

            case SymbolKind.NamedType:
                var namedTypeSymbol = node as INamedTypeSymbol;
                if (namedTypeSymbol.IsGenericType)
                {
                    ClassGenericInstance cgi = node.GetCGI(refs as INamedTypeSymbol);
                    MainDeclaration.Instance.LimFactory.addTypeFormer(
                        MainDeclaration.Instance.LimFactory.createTypeFormerType(cgi.Id).Id
                        );
                }
                else
                {
                    Types.SimpleTypeKind stk = Types.SimpleTypeKind.stkUnknown;

                    switch (namedTypeSymbol.SpecialType)
                    {
                    case SpecialType.System_Object: stk = Types.SimpleTypeKind.stkObject; break;

                    case SpecialType.System_Void: stk = Types.SimpleTypeKind.stkVoid; break;

                    case SpecialType.System_Single: stk = Types.SimpleTypeKind.stkSingle; break;

                    case SpecialType.System_Boolean: stk = Types.SimpleTypeKind.stkBoolean; break;

                    case SpecialType.System_Char: stk = Types.SimpleTypeKind.stkCharacter; break;

                    case SpecialType.System_SByte: stk = Types.SimpleTypeKind.stkByte; break;

                    case SpecialType.System_Byte: stk = Types.SimpleTypeKind.stkByte; break;

                    case SpecialType.System_Int16: stk = Types.SimpleTypeKind.stkShort; break;

                    case SpecialType.System_UInt16: stk = Types.SimpleTypeKind.stkUnsignedShort; break;

                    case SpecialType.System_Int32: stk = Types.SimpleTypeKind.stkInteger; break;

                    case SpecialType.System_UInt32: stk = Types.SimpleTypeKind.stkUnsignedInteger; break;

                    case SpecialType.System_Int64: stk = Types.SimpleTypeKind.stkLong; break;

                    case SpecialType.System_UInt64: stk = Types.SimpleTypeKind.stkUnsignedLong; break;

                    case SpecialType.System_Decimal: stk = Types.SimpleTypeKind.stkDecimal; break;

                    case SpecialType.System_Double: stk = Types.SimpleTypeKind.stkDouble; break;

                    case SpecialType.System_String: stk = Types.SimpleTypeKind.stkString; break;

                    default:
                        SyntaxNode __node;
                        var        _node = node.GetDefinition(out __node);
                        if (!node.IsInMetadata() && _node == null)
                        {
                            break;
                        }

                        Base refLimNode = node.ConvertToLimNode();
                        if (node.IsInMetadata())
                        {
                            MetaDataNameFiller(node, (Member)refLimNode);
                        }

                        MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerType(refLimNode.Id).Id);
                        return;
                    }

                    MainDeclaration.Instance.LimFactory.addTypeFormer(
                        MainDeclaration.Instance.LimFactory.createTypeFormerType(
                            MainDeclaration.Instance.LimFactory.createSimpleType(stk).Id
                            ).Id
                        );
                }
                break;

            case SymbolKind.DynamicType:
            case SymbolKind.ErrorType:
                MainDeclaration.Instance.LimFactory.addTypeFormer(MainDeclaration.Instance.LimFactory.createTypeFormerNonType().Id);
                break;
            }
        }