예제 #1
0
        public bool AnalyRet( )
        {
            var methodContext = this.MethodAST.MethodContext;
            var symbols       = MethodAST.MethodContext.Symbols;

            if (RetToken == null)
            {
                methodContext.RetType = typeof(void);
            }
            else
            {
                string     retName = RetToken.GetText();
                SymbolInfo symbol  = symbols.Get(retName);
                if (symbol is SymbolArg)
                {
                    SymbolArg argSymbol = symbol as SymbolArg;
                    if (argSymbol.IsGeneric)
                    {
                        IsGenericRet               = true;
                        GenericRetIndex            = argSymbol.ArgIndex;
                        methodContext.RetType      = typeof(object);
                        methodContext.RetIsGeneric = true;
                    }
                    else
                    {
                        error("非‘类型’的参数不能用作返回类型");
                        return(false);
                    }
                }
                else if (symbol is SymbolDefClass)
                {
                    methodContext.RetType = (symbol as SymbolDefClass).GetRealType();
                }
                else
                {
                    IGcl gcl = this.MethodAST.ClassContext.SearchType(retName);
                    if (gcl != null)
                    {
                        methodContext.RetType = gcl.ForType;
                    }
                    else
                    {
                        errorf("返回结果'{0}'不是类型", retName);
                        return(false);
                    }
                }
            }
            return(true);
        }