Exemple #1
0
    internal CCNodeOpcode GetNode(int off)
    {
        CCNodeOpcode node = cfi.GetNode(off);

        if (node == null)
        {
            node = new CCNodeOpcode(cfi, off);
            cfi.SetNode(off, node);
        }
        return(node);
    }
Exemple #2
0
    internal static CCNodeEntry EnterFunction(FunctionInterpreted fi,
                                              CCStack stack, CCNodeEntry parent, CCNode next)
    {
        if (Compiler.PrintFunctions != null)
        {
            fi.Print(Compiler.PrintFunctions, 1);
        }

        CCLocals locals            = new CCLocals(fi.numLocalFieldsCoalesced);
        CCFunctionInterpreted cfi  = new CCFunctionInterpreted(fi, next);
        CCNodeEntry           node = new CCNodeEntry(parent, cfi);

        cfi.SetNode(0, node);
        node.MergeStack(stack);
        node.MergeLocals(locals);

        /*
         * All instances allocated locally by this function must
         * have instantiable types.
         */
        foreach (XType xt in fi.localEmbedTypes)
        {
            xt.Close();
        }

        /*
         * Infinite recursion detection: if the same function is
         * already present several times in the ancestry,
         * complains. (TODO: make the threshold configurable)
         */
        int rc = 0;

        for (CCNodeEntry e = parent; e != null; e = e.parent)
        {
            if (e.cfi.fi == fi)
            {
                if (++rc >= 5)
                {
                    throw new Exception(string.Format("possible infinite recursion on function {0}", fi.DebugName));
                }
            }
        }

        return(node);
    }