示例#1
0
            private void LoadFields()
            {
                if (!_metadataStream.Tables.ContainsKey(MetadataTables.Field))
                {
                    return;
                }

                MetadataRow[] table           = _metadataStream.Tables[MetadataTables.Field];
                int           endOfFieldIndex = table.Length + 1;

                if (_nextRowIndex != -1)
                {
                    endOfFieldIndex = ((TypeDefMetadataTableRow)_metadataStream.Tables[MetadataTables.TypeDef][_nextRowIndex]).FieldList;
                }

                // Now load all the fields between our index and the endOfFieldIndex
                for (int i = _fromRow.FieldList; i < endOfFieldIndex; i++)
                {
                    FieldMetadataTableRow fieldDefRow = table[i - 1] as FieldMetadataTableRow;

                    FieldDef field = new FieldDef(
                        _references.Assembly.StringStream.GetString(fieldDefRow.Name.Value),
                        _references.Assembly,
                        _builtType,
                        fieldDefRow.Flags,
                        fieldDefRow.Signiture
                        );

                    _map.Add(MetadataTables.Field, fieldDefRow, field);
                    _builtType.Fields.Add(field);
                }
            }
示例#2
0
            private void LoadParameters()
            {
                MetadataTablesDictionary tables = _metadataStream.Tables;

                if (tables.ContainsKey(MetadataTables.Param))
                {
                    for (int i = _fromRow.ParamList; i < _endOfMethodIndex; i++)
                    {
                        ParamMetadataTableRow metadataRow = tables[MetadataTables.Param][i - 1] as ParamMetadataTableRow;

                        ParamDef param = new ParamDef(
                            _references.Assembly.StringStream.GetString(metadataRow.Name.Value),
                            _methodToBuild,
                            metadataRow.Sequence,
                            _references.Assembly,
                            metadataRow.Flags
                            );

                        //ParamDef param = new ParamDef(_references, _methodToBuild, metadataRow);

                        _map.Add(MetadataTables.Param, metadataRow, param);
                        _methodToBuild.Parameters.Add(param);
                    }
                }

                if (_methodToBuild.IsSpecialName && _methodToBuild.Name.Contains("set_Item"))
                {
                    // for setter methods on indexers the last parameter is actually the return value
                    _methodToBuild.Parameters.RemoveAt(_methodToBuild.Parameters.Count - 1);
                }
            }
        private void LoadTypeSpecMetadata()
        {
            if (!_stream.Tables.ContainsKey(MetadataTables.TypeSpec))
            {
                return;
            }

            foreach (TypeSpecMetadataTableRow typeSpecRow in _stream.Tables[MetadataTables.TypeSpec])
            {
                TypeSpec typeRef = new TypeSpec(_assembly, typeSpecRow.Signiture);
                _map.Add(MetadataTables.TypeSpec, typeSpecRow, typeRef);
            }
        }