Пример #1
0
        //------------------------------------------------------------
        // CController.CheckDisplayWarning
        //
        /// <summary>
        /// <para>This function determines whether a warning should be displayed or suppressed,
        /// taking into account the warning level and "no warn" list.</para>
        /// </summary>
        /// <param name="errorId"></param>
        /// <param name="warnLevel"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal bool CheckDisplayWarning(CSCERRID errorId, int warnLevel)
        {
            // this must be a warning.
            DebugUtil.Assert(warnLevel > 0);
            int errNo;
            int level;

            // Get error level by errorId.
            if (!CSCErrorInfo.Manager.GetInfo(errorId, out errNo, out level))
            {
                return(false);
            }

            // Error level 99 means that it is obsolete.
            if (level == 99)
            {
                return(false);
            }

            // Not show errors whose level are lower than warnLevel.
            if (warnLevel > OptionManager.WarningLevel)
            {
                return(false);
            }

            if (OptionManager.IsNoWarnNumber(errNo))
            {
                return(false);
            }
            return(true);
        }
Пример #2
0
        //------------------------------------------------------------
        // ERRLOC Constructor (2)
        //
        /// <summary>
        /// <para>Constructor.</para>
        /// <para>Get the current position from the BASENODE argument and
        /// mapping information from INFILESYM.SourceData.</para>
        /// </summary>
        /// <param name="inputFile"></param>
        /// <param name="node"></param>
        //------------------------------------------------------------
        internal ERRLOC(INFILESYM inputFile, BASENODE node, bool fullPath)
        {
            DebugUtil.Assert(inputFile != null);

            sourceData = inputFile.SourceData;

            sourceFileName    = (fullPath ? inputFile.FullName : inputFile.Name);
            sourceMapFileName = inputFile.Name;

            if (node != null)
            {
                SetLine(node);
                SetStart(node);
                this.endPos = new POSDATA();    //endPos.SetUninitialized();
                SetEnd(node);
                mapStartPos = (startPos != null ? startPos.Clone() : null);
                mapEndPos   = (endPos != null ? endPos.Clone() : null);

                string sd;       // dummy
                bool   bd1, bd2; // dummy

                // mapStart、mapEnd の行番号をマップ先のもので置き換え、ファイル名を取得する。
                sourceData.Module.MapLocation(mapStartPos, out sourceMapFileName, out bd1, out bd2);
                sourceData.Module.MapLocation(mapEndPos, out sd, out bd1, out bd2);
            }
        }
Пример #3
0
        //------------------------------------------------------------
        // CreateGetTypeFromHandleMethodSym
        //
        /// <summary>
        /// <para>Defined in FuncBindUtil.cs</para>
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal METHSYM CreateGetTypeFromHandleMethodSym(BASENODE treeNode)
        {
            if (GetTypeFromHandleMethodSym != null)
            {
                return(GetTypeFromHandleMethodSym);
            }

            // System.RuntimeTypeHandle
            TYPESYM handleTypeSym = this.GetRequiredPredefinedType(PREDEFTYPE.TYPEHANDLE);

            DebugUtil.Assert(handleTypeSym != null);

            TypeArray paramArray = new TypeArray();

            paramArray.Add(handleTypeSym);
            paramArray = Compiler.MainSymbolManager.AllocParams(paramArray);

            GetTypeFromHandleMethodSym = FindPredefMeth(
                treeNode,
                PREDEFNAME.GETTYPEFROMHANDLE,
                this.GetRequiredPredefinedType(PREDEFTYPE.TYPE),
                paramArray,
                true,
                MemLookFlagsEnum.None);
            DebugUtil.Assert(GetTypeFromHandleMethodSym != null);

            return(GetTypeFromHandleMethodSym);
        }
Пример #4
0
        //------------------------------------------------------------
        // OptionUtil.IsVaildWarningID
        //
        /// <summary></summary>
        /// <param name="errNo"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal static bool IsValidWarningNumber(int errNo, out int index)
        {
            DebugUtil.Assert(OptionUtil.WarningNumbers != null);

            index = Array.BinarySearch(WarningNumbers, errNo);
            return(index >= 0 && index < WarningNumbers.Length);
        }
Пример #5
0
        //------------------------------------------------------------
        //  BitSet.ClearBitRange
        //
        /// <summary></summary>
        /// <param name="min"></param>
        /// <param name="lim"></param>
        //------------------------------------------------------------
        internal void ClearBitRange(int min, int lim)
        {
            int cbit = this.Cbit();

            if (lim > cbit)
            {
                lim = cbit;
            }
            if (min >= lim)
            {
                return;
            }
            DebugUtil.Assert(0 <= min && min <= lim && lim <= cbit);

            int set1 = 0, pos1 = 0, set2 = 0, pos2 = 0;

            if (!RangeToPositions(min, lim - 1, out set1, out pos1, out set2, out pos2))
            {
                return;
            }

            for (int i = set1; i <= set2; ++i)
            {
                int j1 = (i == set1) ? pos1 : 0;
                int j2 = (i == set2) ? pos2 : BLOBBITS - 1;

                for (int j = j1; j <= j2; ++j)
                {
                    ClearBit(i, j);
                }
            }
        }
Пример #6
0
        //------------------------------------------------------------
        // CAsmLink::EmitInternalExportedTypes (sscli)
        //------------------------------------------------------------
        //virtual internal HRESULT EmitInternalExportedTypes(mdAssembly AssemblyID)
        //{
        //    DebugUtil.Assert(m_bInited && !m_bAssemblyEmitted && !m_bPreClosed);
        //    DebugUtil.Assert(AssemblyID == TokenFromRid(mdtAssembly, 1));
        //
        //    return m_pAssem.EmitInternalTypes();
        //}

        // virtual internal HRESULT  ExportTypeForwarder(mdAssembly AssemblyID, LPCWSTR pszTypename, DWORD dwFlags, mdExportedType* pType);
        // virtual internal HRESULT  ExportNestedTypeForwarder(mdAssembly AssemblyID, mdToken FileToken, mdTypeDef TypeToken,
        //     mdExportedType ParentType, LPCWSTR pszTypename, DWORD dwFlags, mdExportedType* pType);

        // Resources

        // virtual internal HRESULT  EmbedResource(mdAssembly AssemblyID, mdToken FileToken, LPCWSTR pszResourceName, DWORD dwOffset, DWORD dwFlags);
        // virtual internal HRESULT  LinkResource(mdAssembly AssemblyID, LPCWSTR pszFileName, LPCWSTR pszNewLocation, LPCWSTR pszResourceName, DWORD dwFlags);

        // virtual internal HRESULT  GetFileDef(mdAssembly AssemblyID, mdFile TargetFile, mdFile* pScope);
        // virtual internal HRESULT  GetResolutionScope(mdAssembly AssemblyID, mdToken FileToken, mdToken TargetFile, mdToken* pScope);
        // virtual internal HRESULT  GetWin32ResBlob(mdAssembly AssemblyID, mdToken FileToken, BOOL fDll, LPCWSTR pszIconFile,
        //     const void **ppResBlob, DWORD *pcbResBlob);
        // virtual internal HRESULT  FreeWin32ResBlob(const void **ppResBlob);

        // Custom Attributes and Assembly properties

        //------------------------------------------------------------
        // CAsmLink.SetAssemblyProps
        //
        /// <summary>
        /// Set an assembly custom attribute.
        /// </summary>
        /// <param name="caConstInfo"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        virtual internal bool SetAssemblyProps(
            ConstructorInfo caConstInfo,
            params object[] args)
        {
            DebugUtil.Assert(this.assemblyBuilderEx != null);
            return(this.assemblyBuilderEx.SetCustomAttribute(caConstInfo, args));
        }
Пример #7
0
        //------------------------------------------------------------
        //  BitSet.AreBitsOne (static)
        //
        /// <summary>
        /// Return true iff the blobs have all bits set.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        static internal bool AreBitsOne(List <uint> list, int start, int count)
        {
            DebugUtil.Assert(list != null);

            if (start < 0)
            {
                return(false);
            }

            int lim = start + count;

            if (lim > list.Count)
            {
                return(false);
            }

            for (int i = start; i < count; ++i)
            {
                if ((~list[i]) != 0)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #8
0
        //------------------------------------------------------------
        //  BitSet.SetOrClearRange
        //
        /// <summary></summary>
        /// <param name="min"></param>
        /// <param name="lim"></param>
        /// <param name="setBit"></param>
        //------------------------------------------------------------
        private void SetOrClearRange(int min, int lim, bool setBit)
        {
            DebugUtil.Assert(0 <= min && min <= lim);

            int set1 = 0, pos1 = 0, set2 = 0, pos2 = 0;

            if (!RangeToPositions(min, lim - 1, out set1, out pos1, out set2, out pos2))
            {
                return;
            }
            Grow(lim);
            DebugUtil.Assert(lim <= this.Cbit());

            for (int i = set1; i <= set2; ++i)
            {
                int j1 = (i == set1) ? pos1 : 0;
                int j2 = (i == set2) ? pos2 : BLOBBITS - 1;

                for (int j = j1; j <= j2; ++j)
                {
                    if (setBit)
                    {
                        SetBit(i, j);
                    }
                    else
                    {
                        ClearBit(i, j);
                    }
                }
            }
        }
Пример #9
0
        //------------------------------------------------------------
        //  BitSet.AreBitsZero (2) (static)
        //
        /// <summary>
        /// Return true iff the blobs are all zero.
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        static internal bool AreBitsZero(List <uint> list, int start, int count)
        {
            DebugUtil.Assert(list != null);

            if (start < 0)
            {
                start = 0;
            }

            int lim = start + count;

            if (lim > list.Count)
            {
                lim = list.Count;
            }

            for (int i = 0; i < lim; ++i)
            {
                if (list[i] != 0)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #10
0
        //------------------------------------------------------------
        //  BitSet.Intersect
        //
        /// <summary>
        /// Ensures that any bits that are clear in bset are also clear in this bitset.
        /// </summary>
        /// <param name="other"></param>
        //------------------------------------------------------------
        internal void Intersect(BitSet other)
        {
            DebugUtil.Assert(other != null);

            if (this.Cbit() == 0)
            {
                return;
            }
            if (other.Cbit() == 0)
            {
                ClearAll();
            }

            int count;

            if (this.blobList.Count > other.blobList.Count)
            {
                count = other.blobList.Count;
                for (int i = count; i < this.blobList.Count; ++i)
                {
                    this.blobList[i] = 0;
                }
            }
            else
            {
                count = this.blobList.Count;
            }

            for (int i = 0; i < count; ++i)
            {
                blobList[i] &= other.blobList[i];
            }
        }
Пример #11
0
        //------------------------------------------------------------
        // CNameManager.AddKeywords
        //
        /// <summary>
        /// <para>Add all the keywords to the name table.
        /// To enable fast determination of whether a particular NAME is a keyword,
        /// a seperate keyword hash table is used that is indexed by the hash value of the name.
        /// At most one keyword has the same index,
        /// so we don't need a collision resolution scheme.</para>
        /// <para>
        /// <list type="bullet">
        /// <item>Get keywords form CParser,
        /// and Register them to namesDictionary and keywordsDictionary.</item>
        /// <item>Register keywords of preprocessor to namesDictionary.</item>
        /// <item>Register predefined names to namesDictionary.</item>
        /// </list>
        /// </para>
        /// </summary>
        //------------------------------------------------------------
        private void AddKeywords()
        {
            TOKINFO tok = null;

            // TOKENID.ARGS = 1 (TOKENID == 0 means UNDEFINED.)
            for (TOKENID id = TOKENID.ARGS; id < TOKENID.IDENTIFIER; ++id)
            {
                tok = CParser.GetTokenInfo(id);
                DebugUtil.Assert(tok != null);

                AddString(tok.Text);
                keywordsDictionary.Add(tok.Text, id);
            }

            for (int i = 1; i < preprocessourKeywords.Length; ++i)
            {
                string kw = preprocessourKeywords[i];
                AddString(kw);
                this.preprocessorKeyWordDictionary.Add(kw, i);
            }

            for (int i = 1; i < attributeTargets.Length; ++i)
            {
                string target = attributeTargets[i];
                AddString(target);
                attributeTargetDictionary.Add(target, (ATTRTARGET)i);
            }
        }
Пример #12
0
        //------------------------------------------------------------
        // ERRLOC Constructor (3)
        //
        /// <para>Constructor.</para>
        /// <para>Get the current position from the BASENODE argument and
        /// mapping information from INFILESYM.SourceData of BSYMMGR.</para>
        /// <param name="symmgr"></param>
        /// <param name="node"></param>
        //------------------------------------------------------------
        internal ERRLOC(BSYMMGR symmgr, BASENODE node, bool fullPath)
        {
            if (node != null)
            {
                DebugUtil.Assert(symmgr != null);

                string    inputFileName = node.GetContainingFileName(fullPath);
                INFILESYM inputFile     = symmgr.FindInfileSym(inputFileName);

                sourceFileName    = inputFileName;
                sourceMapFileName = inputFileName;

                if (inputFile != null)
                {
                    sourceData = inputFile.SourceData;
                    SetLine(node);
                    SetStart(node);
                    SetEnd(node);
                    mapStartPos = (startPos != null ? startPos.Clone() : null);
                    mapEndPos   = (endPos != null ? endPos.Clone() : null);

                    string sd;
                    bool   bd1, bd2;
                    sourceData.Module.MapLocation(mapStartPos, out sourceMapFileName, out bd1, out bd2);
                    sourceData.Module.MapLocation(mapEndPos, out sd, out bd1, out bd2);
                    return;
                }
            }
        }
Пример #13
0
        // Instance methods.

        //------------------------------------------------------------
        // MetaDataHelper.GetMetaDataName (1) instance method
        //
        /// <summary>
        /// Returns a class/type name as it should appear in metadata
        /// Basically the same as GetFullName except inner classes
        /// are NOT qualified by their outer class or namespace
        /// </summary>
        /// <param name="bagSym"></param>
        /// <param name="builder"></param>
        //------------------------------------------------------------
        internal void GetMetaDataName(BAGSYM bagSym, StringBuilder builder)
        {
            DebugUtil.Assert(bagSym != null);

            // Special case -- the root namespace.
            if (bagSym.ParentSym == null)
            {
                // At the root namespace.
                return;
            }

            BAGSYM parentBagSym = bagSym.ParentSym as BAGSYM;

            // If Our parent isn't the root or an outer type,
            // get the parent name and seperator and advance beyond it.
            if (parentBagSym is NSSYM && parentBagSym.ParentSym != null)
            {
                GetMetaDataName(parentBagSym, builder);
                builder.Append('.');
            }

            // Get the current name and add it on
            builder.Append(bagSym.Name);

            EscapeSpecialChars(builder);
            GetTypeVars(bagSym, builder, null);
        }
Пример #14
0
        //------------------------------------------------------------
        // CNameManager.GetNameID
        //
        /// <summary></summary>
        /// <param name="name"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        virtual internal int GetNameID(string name)
        {
            if (name == null)
            {
                return(0);   // id starts from 1;
            }

            int id = 0;

            if (this.nameDictionary.TryGetValue(name, out id))
            {
                return(id);
            }

            id = CObjectID.GenerateID();
            try
            {
                this.nameDictionary.Add(name, id);
            }
            catch (ArgumentException)
            {
                DebugUtil.Assert(false);
                return(0);
            }
            return(id);
        }
Пример #15
0
        //------------------------------------------------------------
        // POSDATA.Adjust
        //
        /// <summary>
        /// Move this by reference to posOld and posNew.
        /// </summary>
        /// <param name="posOld"></param>
        /// <param name="posNew"></param>
        /// <returns></returns>
        /// <remarks>
        /// <para>Like string insertion of editors.</para>
        /// <para>Why do nothing when this and old are equal?</para>
        /// </remarks>
        //------------------------------------------------------------
        internal bool Adjust(POSDATA posOld, POSDATA posNew)
        {
            DebugUtil.Assert(posOld != null && posNew != null);
            DebugUtil.Assert(!this.IsUninitialized && !posOld.IsUninitialized && !posNew.IsUninitialized);

            // Nothing to adjust if the change is below us, or isn't really a change
            if (posOld.LineIndex > LineIndex || posOld.Equals(posNew))
            {
                return(false);
            }

            if (posOld.LineIndex == LineIndex)
            {
                // The old position is on the same line as us.  If the
                // char position is before us, update it.
                if (posOld.CharIndex < CharIndex)
                {
                    CharIndex += (posNew.CharIndex - posOld.CharIndex);
                    LineIndex  = posNew.LineIndex;
                    return(true);
                }
                return(false);
            }
            // The line must be above us, so just update our line
            LineIndex += (posNew.LineIndex - posOld.LineIndex);
            return(((posNew.LineIndex - posOld.LineIndex) != 0) ? true : false);
        }
Пример #16
0
        //------------------------------------------------------------
        // MetaDataHelper.AddTypeModifiers
        //
        /// <summary>
        /// appends array and ptr modifiers
        /// </summary>
        /// <param name="typeSym"></param>
        /// <param name="strBuilder"></param>
        //------------------------------------------------------------
        protected void AddTypeModifiers(TYPESYM typeSym, StringBuilder strBuilder)
        {
            switch (typeSym.Kind)
            {
            case SYMKIND.AGGTYPESYM:
            case SYMKIND.TYVARSYM:
            case SYMKIND.ERRORSYM:
            case SYMKIND.NUBSYM:
                break;

            case SYMKIND.ARRAYSYM:
                // NOTE: In C# a 2-dim array of 1-dim array of int is int[,][].
                // This produces int[][,] as metadata requires.
                AddTypeModifiers((typeSym as ARRAYSYM).ElementTypeSym, strBuilder);
                strBuilder.Append('[');
                for (int i = 1; i < (typeSym as ARRAYSYM).Rank; ++i)
                {
                    strBuilder.Append(',');
                }
                strBuilder.Append(']');
                break;

            case SYMKIND.PTRSYM:
                AddTypeModifiers((typeSym as PTRSYM).BaseTypeSym, strBuilder);
                strBuilder.Append('*');
                break;

            default:
                DebugUtil.Assert(false, "Unknown symbol typeSym");
                break;
            }
        }
Пример #17
0
        //------------------------------------------------------------
        // CTextReader.SetText
        //
        /// <summary></summary>
        /// <param name="tx"></param>
        //------------------------------------------------------------
        internal void SetText(string tx)
        {
            DebugUtil.Assert(tx != null);

            this.text  = tx;
            this.Index = (this.text != null ? 0 : -1);
        }
Пример #18
0
        //------------------------------------------------------------
        // CTextReader.Assign
        //
        /// <summary></summary>
        /// <param name="src"></param>
        //------------------------------------------------------------
        internal void Assign(CTextReader src)
        {
            DebugUtil.Assert(src != null);

            this.text  = src.text;
            this.Index = src.Index;
        }
Пример #19
0
        //------------------------------------------------------------
        // ReflectionUtil.GetBracketedRange
        //
        /// <summary>
        /// <para>Return the substring between "[" and "]" (coupling "[" and "]").</para>
        /// <para>pos must be the index of "[",
        /// and shall be set the index of "]" or the end of source.</para>
        /// </summary>
        /// <param name="source"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal static void GetBracketedRange(string source, ref int index)
        {
            DebugUtil.Assert(index < source.Length - 1);
            DebugUtil.Assert(source[index] == '[');

            int start = ++index;
            int depth = 0;

            while (index < source.Length)
            {
                if (source[index] == ']' && depth == 0)
                {
                    break;
                }
                if (source[index] == '[')
                {
                    ++depth;
                }
                else if (source[index] == ']')
                {
                    --depth;
                }
                ++index;
            }
        }
Пример #20
0
        //------------------------------------------------------------
        // ReflectionUtil.GetMethodInfo (2)
        //
        /// <summary>
        /// Get a MethodInfo from a TypeBuilderInstration.
        /// </summary>
        /// <param name="typeDefinition"></param>
        /// <param name="constructedType"></param>
        /// <param name="name"></param>
        /// <param name="paramTypes"></param>
        /// <param name="excp"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal static MethodInfo GetMethodInfo(
            Type constructedType,
            MethodInfo methInfo,
            out Exception excp)
        {
            MethodInfo defInfo = null;

            excp = null;

            if (!methInfo.IsGenericMethod ||
                methInfo.IsGenericMethodDefinition)
            {
                defInfo = methInfo;
            }
            else
            {
                defInfo = methInfo.GetGenericMethodDefinition();
            }
            DebugUtil.Assert(defInfo != null);

            try
            {
                return(TypeBuilder.GetMethod(constructedType, defInfo));
            }
            catch (ArgumentException ex)
            {
                excp = ex;
            }
            return(null);
        }
Пример #21
0
        //------------------------------------------------------------
        // ReflectionUtil.CreateTypeSearchName
        //
        /// <summary>
        /// Create a type name with the names of namespaces and arity.
        /// </summary>
        /// <param name="nsSym"></param>
        /// <param name="name"></param>
        /// <param name="arity"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal static string CreateTypeSearchName(NSSYM nsSym, string name, int arity)
        {
            DebugUtil.Assert(!String.IsNullOrEmpty(name));

            StringBuilder  sb        = new StringBuilder();
            Stack <string> nameStack = new Stack <string>();

            nameStack.Push(null);
            while (nsSym != null)
            {
                nameStack.Push(nsSym.Name);
                nsSym = nsSym.ParentNsSym;
            }

            string temp = null;

            while ((temp = nameStack.Pop()) != null)
            {
                sb.Append(temp);
                if (sb.Length > 0)
                {
                    sb.Append('.');
                }
            }

            sb.Append(name);

            if (arity > 0 && name.IndexOf('`') < 0)
            {
                sb.AppendFormat("`{0}", arity);
            }

            return(sb.ToString());
        }
Пример #22
0
        //------------------------------------------------------------
        // FUNCBREC.BindNubValue
        //
        /// <summary>
        /// Create an expr for exprSrc.Value where exprSrc->type is a NUBSYM.
        /// </summary>
        /// <param name="treeNode"></param>
        /// <param name="srcExpr"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        private EXPR BindNubValue(BASENODE treeNode, EXPR srcExpr)
        {
            DebugUtil.Assert(srcExpr != null && srcExpr.TypeSym.IsNUBSYM);

            // For new T?(x), the answer is x.
            if (IsNubCtor(srcExpr))
            {
                DebugUtil.Assert(
                    (srcExpr as EXPRCALL).ArgumentsExpr != null &&
                    (srcExpr as EXPRCALL).ArgumentsExpr.Kind != EXPRKIND.LIST);
                return((srcExpr as EXPRCALL).ArgumentsExpr);
            }

            TYPESYM    baseTypeSym = (srcExpr.TypeSym as NUBSYM).BaseTypeSym;
            AGGTYPESYM ats         = (srcExpr.TypeSym as NUBSYM).GetAggTypeSym();

            if (ats == null)
            {
                return(NewError(treeNode, baseTypeSym));
            }
            compiler.EnsureState(ats, AggStateEnum.Prepared);

            PROPSYM propertySym = compiler.MainSymbolManager.NullableValuePropertySym;

            if (propertySym == null)
            {
                string name = compiler.NameManager.GetPredefinedName(PREDEFNAME.CAP_VALUE);

                propertySym = compiler.MainSymbolManager.LookupAggMember(
                    name,
                    ats.GetAggregate(),
                    SYMBMASK.PROPSYM) as PROPSYM;
                if (propertySym == null ||
                    propertySym.IsStatic ||
                    propertySym.Access != ACCESS.PUBLIC ||
                    propertySym.ParameterTypes.Count > 0 ||
                    !propertySym.ReturnTypeSym.IsTYVARSYM ||
                    propertySym.GetMethodSym == null)
                {
                    compiler.Error(
                        treeNode,
                        CSCERRID.ERR_MissingPredefinedMember,
                        new ErrArg(ats),
                        new ErrArg(name));
                    return(NewError(treeNode, baseTypeSym));
                }
                compiler.MainSymbolManager.NullableValuePropertySym = propertySym;
            }

            CheckFieldUse(srcExpr, true);

            EXPRPROP propertyExpr = NewExpr(treeNode, EXPRKIND.PROP, baseTypeSym) as EXPRPROP;

            propertyExpr.SlotPropWithType.Set(propertySym, ats);
            propertyExpr.GetMethodWithType.Set(propertySym.GetMethodSym, ats);
            propertyExpr.ArgumentsExpr = null;
            propertyExpr.ObjectExpr    = srcExpr;

            return(propertyExpr);
        }
Пример #23
0
        //------------------------------------------------------------
        // AggIterator
        //------------------------------------------------------------
        internal AGGSYM Reset(INFILESYM infile)
        {
            DebugUtil.Assert(infile.RootNsDeclSym != null);

            aggCur = GetFirstInListNsDecl(infile.RootNsDeclSym.FirstChildSym);
            return(aggCur);
        }
Пример #24
0
        //------------------------------------------------------------
        // CNameManager.AddPredefNames
        //
        /// <summary>
        /// Register to predefinedNameDictionary.
        /// </summary>
        //------------------------------------------------------------
        private void AddPredefNames()
        {
            //predefinedNames = new string[CPredefinedName.InfoTable.Length];
            this.predefinedNames = CPredefinedName.InfoTable;

            for (int i = 0; i < CPredefinedName.InfoTable.Length; ++i)
            {
                //predefinedNames[i] = CPredefinedName.InfoTable[i];
                string name = this.predefinedNames[i];
                if (String.IsNullOrEmpty(name))
                {
                    continue;
                }
                AddString(name);

                try
                {
                    if (!predefinedNameDictionary.ContainsKey(name))
                    {
                        predefinedNameDictionary.Add(name, name);
                    }
                }
                catch (ArgumentException)
                {
                    DebugUtil.Assert(false);
                }
            }
        }
Пример #25
0
        //------------------------------------------------------------
        // ERRLOC Constructor (5)
        //
        /// <summary></summary>
        /// <param name="scope"></param>
        //------------------------------------------------------------
        internal ERRLOC(ImportScope scope, bool fullPath)
        {
            DebugUtil.Assert(scope != null);

            sourceData        = null;
            sourceFileName    = scope.GetFileName(fullPath);
            sourceMapFileName = sourceFileName;
        }
Пример #26
0
        //------------------------------------------------------------
        // POSDATA Operator -
        //
        /// <summary>
        /// If two POSDATA instance are in the same line,
        /// return the deference of CharIndex.
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        static public int operator -(POSDATA p1, POSDATA p2)
        {
            DebugUtil.Assert(!p1.IsUninitialized && !p2.IsUninitialized);
            DebugUtil.Assert(p1.LineIndex == p2.LineIndex);
            DebugUtil.Assert(p1.CharIndex >= p2.CharIndex);

            return((int)(p1.CharIndex - p2.CharIndex));
        }
Пример #27
0
        //------------------------------------------------------------
        // POSDATA.After
        //
        /// <summary></summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal bool After(POSDATA pos)
        {
            DebugUtil.Assert(pos != null);

            int ld = this.LineIndex - pos.LineIndex;

            return((ld != 0) ? ld > 0 : (this.CharIndex > pos.CharIndex));
        }
Пример #28
0
        //------------------------------------------------------------
        // POSDATA.Before
        //
        /// <summary></summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal bool Before(POSDATA pos)
        {
            DebugUtil.Assert(pos != null);

            int ld = this.LineIndex - pos.LineIndex;

            return((ld != 0) ? ld < 0 : (this.CharIndex < pos.CharIndex));
        }
Пример #29
0
        //------------------------------------------------------------
        // POSDATA.Compare
        //
        /// <summary>
        /// Compare position with other instance and return a integer.
        /// <list type="bullet">
        /// <item>&lt; 0  : this precedes p.</item>
        /// <item>= 0  : same position.</item>
        /// <item>&gt; 0  : p precedes this.</item>
        /// </list>
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal int Compare(POSDATA p)
        {
            DebugUtil.Assert(!this.IsUninitialized && p != null && !p.IsUninitialized);

            int ld = this.LineIndex - p.LineIndex;

            return((ld != 0) ? ld: this.CharIndex - p.CharIndex);
        }
Пример #30
0
        //------------------------------------------------------------
        // ERRLOC Constructor (4)
        //
        /// <summary></summary>
        /// <param name="sym"></param>
        //------------------------------------------------------------
        internal ERRLOC(INFILESYM sym, bool fullPath)
        {
            DebugUtil.Assert(sym != null);

            sourceData        = sym.SourceData;
            sourceFileName    = (fullPath ? sym.FullName : sym.Name);
            sourceMapFileName = sourceFileName;
        }