Пример #1
0
        //------------------------------------------------------------
        // FUNCBREC.EnsureNubHasValue
        //
        /// <summary>
        /// Make sure the HasValue property of System.Nullable&lt;T&gt; is appropriate (and return it).
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        private PROPSYM EnsureNubHasValue(BASENODE treeNode)
        {
            PROPSYM propSym = Compiler.MainSymbolManager.NullableHasValuePropertySym;

            if (propSym == null)
            {
                AGGSYM nubAggSym = Compiler.GetOptPredefAggErr(PREDEFTYPE.G_OPTIONAL, true);
                if (nubAggSym == null)
                {
                    return(null);
                }
                string name = Compiler.NameManager.GetPredefinedName(PREDEFNAME.HASVALUE);

                SYM sym = Compiler.MainSymbolManager.LookupAggMember(
                    name, nubAggSym, SYMBMASK.PROPSYM);
                propSym = sym as PROPSYM;
                if (propSym == null ||
                    propSym.IsStatic ||
                    propSym.Access != ACCESS.PUBLIC ||
                    propSym.ParameterTypes.Count > 0 ||
                    !propSym.ReturnTypeSym.IsPredefType(PREDEFTYPE.BOOL) ||
                    propSym.GetMethodSym == null)
                {
                    Compiler.Error(treeNode, CSCERRID.ERR_MissingPredefinedMember,
                                   new ErrArg(nubAggSym), new ErrArg(name));
                    return(null);
                }
                Compiler.MainSymbolManager.NullableHasValuePropertySym = propSym;
            }

            return(propSym);
        }
Пример #2
0
        //------------------------------------------------------------
        // FUNCBREC.EnsureNubGetValOrDef
        //
        /// <summary>
        /// Make sure the HasValue property of System.Nullable&lt;T&gt; is appropriate (and return it).
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        private METHSYM EnsureNubGetValOrDef(BASENODE treeNode)
        {
            METHSYM methSym = Compiler.MainSymbolManager.NullableGetValOrDefMethodSym;

            if (methSym == null)
            {
                AGGSYM nubAggSym = Compiler.GetOptPredefAggErr(PREDEFTYPE.G_OPTIONAL, true);
                if (nubAggSym == null)
                {
                    return(null);
                }
                string name = Compiler.NameManager.GetPredefinedName(PREDEFNAME.GET_VALUE_OR_DEF);

                for (SYM sym = Compiler.MainSymbolManager.LookupAggMember(name, nubAggSym, SYMBMASK.ALL);
                     ;
                     sym = sym.NextSameNameSym)
                {
                    if (sym == null)
                    {
                        Compiler.Error(treeNode, CSCERRID.ERR_MissingPredefinedMember,
                                       new ErrArg(nubAggSym), new ErrArg(name));
                        return(null);
                    }
                    if (sym.IsMETHSYM)
                    {
                        methSym = sym as METHSYM;
                        if (methSym.ParameterTypes.Count == 0 &&
                            methSym.ParameterTypes.Count == 0 &&
                            methSym.ReturnTypeSym.IsTYVARSYM &&
                            !methSym.IsStatic &&
                            methSym.Access == ACCESS.PUBLIC)
                        {
                            break;
                        }
                    }
                }
                Compiler.MainSymbolManager.NullableGetValOrDefMethodSym = methSym;
            }

            return(methSym);
        }