Example #1
0
        void LinkAndOptimize(CodeBox box)
        {
            box.LinkedCode = null;  // Force top-level re-link
            box.LinkCode();

            int minOpt = box.Symbol.CodeExprIndex + box.Symbol.ArraySize;

            if (box.Params.Count != 0)
            {
                minOpt = Math.Max(minOpt, box.Params[box.Params.Count - 1].CodeExprIndex
                                  + box.Params[box.Params.Count - 1].ArraySize);
            }

            if (box.Locals.Count != 0)
            {
                minOpt = Math.Max(minOpt, box.Locals[box.Locals.Count - 1].CodeExprIndex
                                  + box.Locals[box.Locals.Count - 1].ArraySize);
            }

            // Optimize, unless disabled
            if (!checkDisableOptimizer.Checked)
            {
                new Optimizer(box.LinkedCode, minOpt);
            }
        }