Esempio n. 1
0
        public static string Next(object on, string root, params IEnumerable <string>[] inUse)
        {
            var key = SigilTuple.Create(on, root);

            lock (State)
            {
                int next;
                if (!State.TryGetValue(key, out next))
                {
                    next       = 0;
                    State[key] = next;
                }

                State[key]++;

                var ret = root + next;

                if (LinqAlternative.Any(inUse, a => LinqAlternative.Any(a, x => x == ret)))
                {
                    return(Next(on, root, inUse));
                }

                return(ret);
            }
        }
Esempio n. 2
0
        public static TypeOnStack GetKnownFunctionPointer(CallingConventions conv, Type instanceType, Type returnType, Type[] parameterTypes)
        {
            var key = SigilTuple.Create(conv, instanceType, returnType, parameterTypes);

            TypeOnStack ret;

            lock (KnownFunctionPointerCache)
            {
                if (!KnownFunctionPointerCache.TryGetValue(key, out ret))
                {
                    ret =
                        new TypeOnStack
                    {
                        HasAttachedMethodInfo = true,
                        Type = typeof(NativeIntType),
                        CallingConvention = conv,
                        InstanceType      = instanceType,
                        ReturnType        = returnType,
                        ParameterTypes    = parameterTypes,
                        UsedBy            = new LinqHashSet <SigilTuple <InstructionAndTransitions, int> >()
                    };

                    KnownFunctionPointerCache[key] = ret;
                }
            }

            return(ret);
        }
Esempio n. 3
0
        private static IEnumerable <T> _QuickSort <T, V>(T[] data, int[] ixs, V[] keys, IComparer <V> c)
        {
            var nextYield = 0;

            var stack = new Stack <SigilTuple <int, int> >();

            stack.Push(SigilTuple.Create(0, ixs.Length - 1));
            while (stack.Count > 0)
            {
                var leftRight = stack.Pop();
                var left      = leftRight.Item1;
                var right     = leftRight.Item2;
                if (right > left)
                {
                    int pivot         = left + (right - left) / 2;
                    int pivotPosition = _Partition(ixs, keys, left, right, pivot, c);
                    stack.Push(SigilTuple.Create(pivotPosition + 1, right));
                    stack.Push(SigilTuple.Create(left, pivotPosition - 1));
                }
                else
                {
                    while (nextYield <= right)
                    {
                        yield return(data[ixs[nextYield]]);

                        nextYield++;
                    }
                }
            }
        }
Esempio n. 4
0
        private SigilTuple <bool, LinqStack <LinqList <TypeOnStack> > > GetCurrentStack()
        {
            SigilTuple <bool, LinqStack <LinqList <TypeOnStack> > > ret = null;

            for (var i = 0; i < CurrentlyInScope.Count; i++)
            {
                var c     = CurrentlyInScope[i];
                var stack = CurrentlyInScopeStacks[i];

                var stackCopy = CopyStack(stack);

                var innerRet = SigilTuple.Create(c.IsBaseless, stackCopy);

                if (ret == null || (innerRet.Item1 && !ret.Item1) || innerRet.Item2.Count > ret.Item2.Count)
                {
                    ret = innerRet;
                }
            }

            return(ret);
        }
Esempio n. 5
0
 /// <summary>
 /// Call to indicate that something on the stack was used
 /// as the #{index}'d (starting at 0) parameter to the {code}
 /// opcode.
 /// </summary>
 public void Mark(InstructionAndTransitions instr, int index)
 {
     UsedBy.Add(SigilTuple.Create(instr, index));
 }