Esempio n. 1
0
        public override void VisitVariableDefinitionCollection(VariableDefinitionCollection variables)
        {
            MethodBody body = variables.Container as MethodBody;

            if (body == null || body.LocalVarToken == 0)
            {
                return;
            }

            StandAloneSigTable sasTable = m_reflectReader.TableReader.GetStandAloneSigTable();
            StandAloneSigRow   sasRow   = sasTable [(int)GetRid(body.LocalVarToken) - 1];
            LocalVarSig        sig      = m_reflectReader.SigReader.GetLocalVarSig(sasRow.Signature);

            for (int i = 0; i < sig.Count; i++)
            {
                LocalVarSig.LocalVariable lv      = sig.LocalVariables [i];
                TypeReference             varType = m_reflectReader.GetTypeRefFromSig(
                    lv.Type, new GenericContext(body.Method));

                if (lv.ByRef)
                {
                    varType = new ReferenceType(varType);
                }
                if ((lv.Constraint & Constraint.Pinned) != 0)
                {
                    varType = new PinnedType(varType);
                }

                varType = m_reflectReader.GetModifierType(lv.CustomMods, varType);

                body.Variables.Add(new VariableDefinition(
                                       string.Concat("V_", i), i, body.Method, varType));
            }
        }
Esempio n. 2
0
        public override void VisitVariableDefinitionCollection(VariableDefinitionCollection variables)
        {
            MethodBody body = variables.Container as MethodBody;

            if (body == null || stripped)
            {
                return;
            }

            uint sig = m_reflectWriter.SignatureWriter.AddLocalVarSig(
                GetLocalVarSig(variables));

            if (m_localSigCache.Contains(sig))
            {
                body.LocalVarToken = (int)m_localSigCache [sig];
                return;
            }

            StandAloneSigTable sasTable = m_reflectWriter.MetadataTableWriter.GetStandAloneSigTable();
            StandAloneSigRow   sasRow   = m_reflectWriter.MetadataRowWriter.CreateStandAloneSigRow(
                sig);

            sasTable.Rows.Add(sasRow);
            body.LocalVarToken    = sasTable.Rows.Count;
            m_localSigCache [sig] = body.LocalVarToken;
        }
Esempio n. 3
0
        public LocalVarSig GetLocalVarSig(VariableDefinitionCollection vars)
        {
            LocalVarSig lvs = new LocalVarSig();

            lvs.CallingConvention |= 0x7;
            lvs.Count              = vars.Count;
            lvs.LocalVariables     = new LocalVarSig.LocalVariable [lvs.Count];
            for (int i = 0; i < lvs.Count; i++)
            {
                lvs.LocalVariables [i] = GetLocalVariableSig(vars [i]);
            }

            return(lvs);
        }