示例#1
0
 private static MetaEntry[] _getCilHints(IHasMetaTable table, bool keyMustExist)
 {
     MetaEntry cilHintsEntry;
     if (table.Meta.TryGetValue(Loader.CilHintsKey, out cilHintsEntry))
     {
         Assert.IsTrue(cilHintsEntry.IsList, "CIL hints entry must be a list.");
         return cilHintsEntry.List;
     }
     else if (keyMustExist)
     {
         Assert.Fail("Meta table of {0} does not contain cil hints.", table);
         return null;
     }
     else
     {
         table.Meta[Loader.CilHintsKey] = (MetaEntry) new MetaEntry[0];
         return _getCilHints(table, true);
     }
 }
示例#2
0
 public void EnsureInitialization(Engine targetEngine, IHasMetaTable context)
 {
     EnsureInitialization(targetEngine);
 }
示例#3
0
文件: Compiler.cs 项目: SealedSun/prx
 public static void AddCilHint(IHasMetaTable target, ICilHint hint)
 {
     if (target.Meta.ContainsKey(Loader.CilHintsKey))
         target.Meta.AddTo(Loader.CilHintsKey, hint.ToMetaEntry());
     else
         target.Meta[Loader.CilHintsKey] = (MetaEntry) new[] {hint.ToMetaEntry()};
 }
示例#4
0
文件: Compiler.cs 项目: SealedSun/prx
 private static void _registerCheckResults(IHasMetaTable source, bool qualifies,
     string reason)
 {
     if (!qualifies && source.Meta[PFunction.DeficiencyKey].Text == "" && reason != null)
     {
         source.Meta[PFunction.DeficiencyKey] = reason;
     } //else nothing
     if ((!qualifies) || source.Meta.ContainsKey(PFunction.VolatileKey))
     {
         source.Meta[PFunction.VolatileKey] = !qualifies;
     }
 }
示例#5
0
文件: Compiler.cs 项目: SealedSun/prx
        public static void SetCilHint(IHasMetaTable target, ICilHint newHint)
        {
            MetaEntry cilHints;
            if (target.Meta.TryGetValue(Loader.CilHintsKey, out cilHints))
            {
                var hints = cilHints.List;
                var replaced = false;
                var excessHints = 0;
                for (var i = 0; i < hints.Length; i++)
                {
                    var cilHint = hints[i].List;

                    //We're only interested in CIL hints that conflict with the new one.
                    if (!Engine.StringsAreEqual(cilHint[0].Text, newHint.CilKey))
                        continue;


                    if (replaced)
                    {
                        hints[i] = null;
                        excessHints++;
                    }
                    else
                    {
                        hints[i] = newHint.ToMetaEntry();
                        replaced = true;
                    }
                }

                if (excessHints == 0)
                {
                    if (!replaced)
                        target.Meta.AddTo(Loader.CilHintsKey, newHint.ToMetaEntry());
                    //otherwise the array has already been modified by ref.
                }
                else
                {
                    //need to resize array (and possibly add new CIL hint)
                    var newHints = new MetaEntry[hints.Length - excessHints + (replaced ? 0 : 1)];
                    int idxNew;
                    int idxOld;
                    for (idxNew = idxOld = 0; idxOld < hints.Length; idxOld++)
                    {
                        var oldHint = hints[idxOld];
                        if (oldHint == null)
                            continue;

                        newHints[idxNew++] = oldHint;
                    }
                    if (!replaced)
                        newHints[idxNew] = newHint.ToMetaEntry();

                    target.Meta[Loader.CilHintsKey] = (MetaEntry) newHints;
                }
            }
            else
            {
                target.Meta[Loader.CilHintsKey] = (MetaEntry) new[] {newHint.ToMetaEntry()};
            }
        }