示例#1
0
        public override void EnterTypeName(GoParser.TypeNameContext context)
        {
            string    type      = context.GetText();
            string    typeName  = ConvertToCSTypeName(type);
            TypeClass typeClass = TypeClass.Simple;

            if (typeName.Equals("error") || (Metadata?.Interfaces.TryGetValue(typeName, out _) ?? false))
            {
                typeClass = TypeClass.Interface;
            }
            else if (Metadata?.Structs.TryGetValue(typeName, out _) ?? false)
            {
                typeClass = TypeClass.Struct;
            }
            else if (Metadata?.Functions.TryGetValue($"{typeName}()", out _) ?? false)
            {
                typeClass = TypeClass.Function;
            }

            Types[context.Parent] = new TypeInfo
            {
                Name         = type,
                TypeName     = ConvertToCSTypeName(type),
                FullTypeName = typeName,
                TypeClass    = typeClass
            };
        }
示例#2
0
        //public override void ExitElementType(GoParser.ElementTypeContext context)
        //{
        //    ExitType_(context.type_());
        //}

        public override void EnterTypeName(GoParser.TypeNameContext context)
        {
            string type = context.GetText();

            Types[context.Parent] = new TypeInfo
            {
                Name         = type,
                TypeName     = ConvertToPrimitiveType(type),
                FullTypeName = ConvertToFrameworkType(type),
                TypeClass    = TypeClass.Simple
            };
        }