Esempio n. 1
0
    public short IDMethodName(string name)
    {
        byte[] bytes = ByteArrayManager.GetCString(name);
        fixed(byte *m = bytes)
        {
            short imax = numMethodNames;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(methodNames[icur], m);
                if (icmp == 0)
                {
                    return(icur);
                }
                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
Esempio n. 2
0
    public short IDType(string type)
    {
        byte[] bytes = ByteArrayManager.GetCString(type);
        fixed(byte *t = bytes)
        {
            short imax = numTypes;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(types[icur].name, t);
                if (icmp == 0)
                {
                    return(icur);
                }

                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
Esempio n. 3
0
    public short IDClass(string name)
    {
        byte[] bytes = ByteArrayManager.GetCString(name);
        fixed(byte *c = bytes)
        {
            short imax = numClasses;
            short imin = 1;

            while (imax >= imin)
            {
                short icur = (short)((imin + imax) / 2);
                long  icmp = ByteArrayManager.strcmp(classes[icur].className, c);
                if (icmp == 0)
                {
                    return(icur);
                }
                if (icmp > 0)
                {
                    imax = (short)(icur - 1);
                }
                else
                {
                    imin = (short)(icur + 1);
                }
            }

            return(0);
        }
    }
    public bool Equals(Smoke.ModuleIndex first, Smoke.ModuleIndex second)
    {
        Smoke.Method *firstMeth  = first.smoke->methods + first.index;
        Smoke.Method *secondMeth = second.smoke->methods + second.index;

        bool firstConst  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_const) > 0);
        bool secondConst = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_const) > 0);

        bool firstStatic  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_static) > 0);
        bool secondStatic = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_static) > 0);

        bool firstAbstract  = ((firstMeth->flags & (ushort)Smoke.MethodFlags.mf_purevirtual) > 0);
        bool secondAbstract = ((secondMeth->flags & (ushort)Smoke.MethodFlags.mf_purevirtual) > 0);

        if (firstConst != secondConst || firstStatic != secondStatic ||
            (m_abstractIsDifference && (firstAbstract != secondAbstract)))
        {
            return(false);
        }

        if (first.smoke == second.smoke)
        {
            // when the methods are in the same module, we can be rather quick
            if (firstMeth->name == secondMeth->name && firstMeth->args == secondMeth->args && firstMeth->ret == secondMeth->ret)
            {
                return(true);
            }
            return(false);
        }
        else
        {
            if (ByteArrayManager.strcmp(first.smoke->methodNames[firstMeth->name], second.smoke->methodNames[secondMeth->name]) == 0 &&
                ByteArrayManager.strcmp(first.smoke->types[firstMeth->ret].name, second.smoke->types[secondMeth->ret].name) == 0 &&
                firstMeth->numArgs == secondMeth->numArgs)
            {
                // name and number of arguments match, now compare the arguments individually
                short *firstMethodArgPtr  = first.smoke->argumentList + firstMeth->args;
                short *secondMethodArgPtr = second.smoke->argumentList + secondMeth->args;

                while ((*firstMethodArgPtr) > 0)
                {
                    if (ByteArrayManager.strcmp(first.smoke->types[*firstMethodArgPtr].name, second.smoke->types[*secondMethodArgPtr].name) != 0)
                    {
                        return(false);
                    }
                    firstMethodArgPtr++;
                    secondMethodArgPtr++;
                }

                return(true);
            }

            return(false);
        }
    }