示例#1
0
        /// <summary>
        /// Read the program fragment represented by this list of opcodes and packs all args it sees.
        /// </summary>
        /// <param name="fragment">the section being packed</param>
        private static void PackArgs(List <Opcode> fragment)
        {
            for (int index = 0; index < fragment.Count; ++index)
            {
                Opcode op            = fragment[index];
                string expectedLabel = NextConsecutiveLabel(previousLabel);

                // in cases where there's a gap or jump in the consecutive labels, we'll be needing
                // that label value in the argument pack to refer to later:
                if ((!string.IsNullOrEmpty(op.Label)) &&
                    (op.Label != expectedLabel))
                {
                    PackedArgumentLocation(op.Label);
                }

                IEnumerable <MLArgInfo> args = op.GetArgumentDefs();
                foreach (MLArgInfo arg in args)
                {
                    object argVal = arg.PropertyInfo.GetValue(op, null);

                    // Just trying to add the argument to the pack.  Don't
                    // care where in the pack it is (yet).
                    PackedArgumentLocation(argVal);
                }

                previousLabel = op.Label;
            }
        }