merge r98600
[mono.git] / mcs / class / Mono.Cecil / Mono.Cecil.Metadata / MetadataRowWriter.cs
1 //
2 // MetadataRowWriter.cs
3 //
4 // Author:
5 //   Jb Evain (jbevain@gmail.com)
6 //
7 // Generated by /CodeGen/cecil-gen.rb do not edit
8 // Sat Feb 16 23:24:17 +0100 2008
9 //
10 // (C) 2005 Jb Evain
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 namespace Mono.Cecil.Metadata {
33
34         using System;
35         using System.Collections;
36
37         using Mono.Cecil.Binary;
38
39         class MetadataRowWriter : BaseMetadataRowVisitor {
40
41                 MetadataRoot m_root;
42                 MemoryBinaryWriter m_binaryWriter;
43                 int [] m_ciCache;
44
45                 int m_blobHeapIdxSz;
46                 int m_stringsHeapIdxSz;
47                 int m_guidHeapIdxSz;
48
49                 public MetadataRowWriter (MetadataTableWriter mtwv)
50                 {
51                         m_binaryWriter = mtwv.GetWriter ();
52                         m_root = mtwv.GetMetadataRoot ();
53                         m_ciCache = new int [13];
54                 }
55
56                 void WriteBlobPointer (uint pointer)
57                 {
58                         WriteByIndexSize (pointer, m_blobHeapIdxSz);
59                 }
60
61                 void WriteStringPointer (uint pointer)
62                 {
63                         WriteByIndexSize (pointer, m_stringsHeapIdxSz);
64                 }
65
66                 void WriteGuidPointer (uint pointer)
67                 {
68                         WriteByIndexSize (pointer, m_guidHeapIdxSz);
69                 }
70
71                 void WriteTablePointer (uint pointer, int rid)
72                 {
73                         WriteByIndexSize (pointer, GetNumberOfRows (rid) < (1 << 16) ? 2 : 4);
74                 }
75
76                 void WriteMetadataToken (MetadataToken token, CodedIndex ci)
77                 {
78                         WriteByIndexSize (Utilities.CompressMetadataToken (ci, token),
79                                 Utilities.GetCodedIndexSize (
80                                         ci, new Utilities.TableRowCounter (GetNumberOfRows), m_ciCache));
81                 }
82
83                 int GetNumberOfRows (int rid)
84                 {
85                         IMetadataTable t = m_root.Streams.TablesHeap [rid];
86                         if (t == null || t.Rows == null)
87                                 return 0;
88                         return t.Rows.Count;
89                 }
90
91                 void WriteByIndexSize (uint value, int size)
92                 {
93                         if (size == 4)
94                                 m_binaryWriter.Write (value);
95                         else if (size == 2)
96                                 m_binaryWriter.Write ((ushort) value);
97                         else
98                                 throw new MetadataFormatException ("Non valid size for indexing");
99                 }
100
101                 public AssemblyRow CreateAssemblyRow (AssemblyHashAlgorithm _hashAlgId, ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKey, uint _name, uint _culture)
102                 {
103                         AssemblyRow row = new AssemblyRow ();
104                         row.HashAlgId = _hashAlgId;
105                         row.MajorVersion = _majorVersion;
106                         row.MinorVersion = _minorVersion;
107                         row.BuildNumber = _buildNumber;
108                         row.RevisionNumber = _revisionNumber;
109                         row.Flags = _flags;
110                         row.PublicKey = _publicKey;
111                         row.Name = _name;
112                         row.Culture = _culture;
113                         return row;
114                 }
115
116                 public AssemblyOSRow CreateAssemblyOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion)
117                 {
118                         AssemblyOSRow row = new AssemblyOSRow ();
119                         row.OSPlatformID = _oSPlatformID;
120                         row.OSMajorVersion = _oSMajorVersion;
121                         row.OSMinorVersion = _oSMinorVersion;
122                         return row;
123                 }
124
125                 public AssemblyProcessorRow CreateAssemblyProcessorRow (uint _processor)
126                 {
127                         AssemblyProcessorRow row = new AssemblyProcessorRow ();
128                         row.Processor = _processor;
129                         return row;
130                 }
131
132                 public AssemblyRefRow CreateAssemblyRefRow (ushort _majorVersion, ushort _minorVersion, ushort _buildNumber, ushort _revisionNumber, AssemblyFlags _flags, uint _publicKeyOrToken, uint _name, uint _culture, uint _hashValue)
133                 {
134                         AssemblyRefRow row = new AssemblyRefRow ();
135                         row.MajorVersion = _majorVersion;
136                         row.MinorVersion = _minorVersion;
137                         row.BuildNumber = _buildNumber;
138                         row.RevisionNumber = _revisionNumber;
139                         row.Flags = _flags;
140                         row.PublicKeyOrToken = _publicKeyOrToken;
141                         row.Name = _name;
142                         row.Culture = _culture;
143                         row.HashValue = _hashValue;
144                         return row;
145                 }
146
147                 public AssemblyRefOSRow CreateAssemblyRefOSRow (uint _oSPlatformID, uint _oSMajorVersion, uint _oSMinorVersion, uint _assemblyRef)
148                 {
149                         AssemblyRefOSRow row = new AssemblyRefOSRow ();
150                         row.OSPlatformID = _oSPlatformID;
151                         row.OSMajorVersion = _oSMajorVersion;
152                         row.OSMinorVersion = _oSMinorVersion;
153                         row.AssemblyRef = _assemblyRef;
154                         return row;
155                 }
156
157                 public AssemblyRefProcessorRow CreateAssemblyRefProcessorRow (uint _processor, uint _assemblyRef)
158                 {
159                         AssemblyRefProcessorRow row = new AssemblyRefProcessorRow ();
160                         row.Processor = _processor;
161                         row.AssemblyRef = _assemblyRef;
162                         return row;
163                 }
164
165                 public ClassLayoutRow CreateClassLayoutRow (ushort _packingSize, uint _classSize, uint _parent)
166                 {
167                         ClassLayoutRow row = new ClassLayoutRow ();
168                         row.PackingSize = _packingSize;
169                         row.ClassSize = _classSize;
170                         row.Parent = _parent;
171                         return row;
172                 }
173
174                 public ConstantRow CreateConstantRow (ElementType _type, MetadataToken _parent, uint _value)
175                 {
176                         ConstantRow row = new ConstantRow ();
177                         row.Type = _type;
178                         row.Parent = _parent;
179                         row.Value = _value;
180                         return row;
181                 }
182
183                 public CustomAttributeRow CreateCustomAttributeRow (MetadataToken _parent, MetadataToken _type, uint _value)
184                 {
185                         CustomAttributeRow row = new CustomAttributeRow ();
186                         row.Parent = _parent;
187                         row.Type = _type;
188                         row.Value = _value;
189                         return row;
190                 }
191
192                 public DeclSecurityRow CreateDeclSecurityRow (SecurityAction _action, MetadataToken _parent, uint _permissionSet)
193                 {
194                         DeclSecurityRow row = new DeclSecurityRow ();
195                         row.Action = _action;
196                         row.Parent = _parent;
197                         row.PermissionSet = _permissionSet;
198                         return row;
199                 }
200
201                 public EventRow CreateEventRow (EventAttributes _eventFlags, uint _name, MetadataToken _eventType)
202                 {
203                         EventRow row = new EventRow ();
204                         row.EventFlags = _eventFlags;
205                         row.Name = _name;
206                         row.EventType = _eventType;
207                         return row;
208                 }
209
210                 public EventMapRow CreateEventMapRow (uint _parent, uint _eventList)
211                 {
212                         EventMapRow row = new EventMapRow ();
213                         row.Parent = _parent;
214                         row.EventList = _eventList;
215                         return row;
216                 }
217
218                 public EventPtrRow CreateEventPtrRow (uint _event)
219                 {
220                         EventPtrRow row = new EventPtrRow ();
221                         row.Event = _event;
222                         return row;
223                 }
224
225                 public ExportedTypeRow CreateExportedTypeRow (TypeAttributes _flags, uint _typeDefId, uint _typeName, uint _typeNamespace, MetadataToken _implementation)
226                 {
227                         ExportedTypeRow row = new ExportedTypeRow ();
228                         row.Flags = _flags;
229                         row.TypeDefId = _typeDefId;
230                         row.TypeName = _typeName;
231                         row.TypeNamespace = _typeNamespace;
232                         row.Implementation = _implementation;
233                         return row;
234                 }
235
236                 public FieldRow CreateFieldRow (FieldAttributes _flags, uint _name, uint _signature)
237                 {
238                         FieldRow row = new FieldRow ();
239                         row.Flags = _flags;
240                         row.Name = _name;
241                         row.Signature = _signature;
242                         return row;
243                 }
244
245                 public FieldLayoutRow CreateFieldLayoutRow (uint _offset, uint _field)
246                 {
247                         FieldLayoutRow row = new FieldLayoutRow ();
248                         row.Offset = _offset;
249                         row.Field = _field;
250                         return row;
251                 }
252
253                 public FieldMarshalRow CreateFieldMarshalRow (MetadataToken _parent, uint _nativeType)
254                 {
255                         FieldMarshalRow row = new FieldMarshalRow ();
256                         row.Parent = _parent;
257                         row.NativeType = _nativeType;
258                         return row;
259                 }
260
261                 public FieldPtrRow CreateFieldPtrRow (uint _field)
262                 {
263                         FieldPtrRow row = new FieldPtrRow ();
264                         row.Field = _field;
265                         return row;
266                 }
267
268                 public FieldRVARow CreateFieldRVARow (RVA _rVA, uint _field)
269                 {
270                         FieldRVARow row = new FieldRVARow ();
271                         row.RVA = _rVA;
272                         row.Field = _field;
273                         return row;
274                 }
275
276                 public FileRow CreateFileRow (FileAttributes _flags, uint _name, uint _hashValue)
277                 {
278                         FileRow row = new FileRow ();
279                         row.Flags = _flags;
280                         row.Name = _name;
281                         row.HashValue = _hashValue;
282                         return row;
283                 }
284
285                 public GenericParamRow CreateGenericParamRow (ushort _number, GenericParameterAttributes _flags, MetadataToken _owner, uint _name)
286                 {
287                         GenericParamRow row = new GenericParamRow ();
288                         row.Number = _number;
289                         row.Flags = _flags;
290                         row.Owner = _owner;
291                         row.Name = _name;
292                         return row;
293                 }
294
295                 public GenericParamConstraintRow CreateGenericParamConstraintRow (uint _owner, MetadataToken _constraint)
296                 {
297                         GenericParamConstraintRow row = new GenericParamConstraintRow ();
298                         row.Owner = _owner;
299                         row.Constraint = _constraint;
300                         return row;
301                 }
302
303                 public ImplMapRow CreateImplMapRow (PInvokeAttributes _mappingFlags, MetadataToken _memberForwarded, uint _importName, uint _importScope)
304                 {
305                         ImplMapRow row = new ImplMapRow ();
306                         row.MappingFlags = _mappingFlags;
307                         row.MemberForwarded = _memberForwarded;
308                         row.ImportName = _importName;
309                         row.ImportScope = _importScope;
310                         return row;
311                 }
312
313                 public InterfaceImplRow CreateInterfaceImplRow (uint _class, MetadataToken _interface)
314                 {
315                         InterfaceImplRow row = new InterfaceImplRow ();
316                         row.Class = _class;
317                         row.Interface = _interface;
318                         return row;
319                 }
320
321                 public ManifestResourceRow CreateManifestResourceRow (uint _offset, ManifestResourceAttributes _flags, uint _name, MetadataToken _implementation)
322                 {
323                         ManifestResourceRow row = new ManifestResourceRow ();
324                         row.Offset = _offset;
325                         row.Flags = _flags;
326                         row.Name = _name;
327                         row.Implementation = _implementation;
328                         return row;
329                 }
330
331                 public MemberRefRow CreateMemberRefRow (MetadataToken _class, uint _name, uint _signature)
332                 {
333                         MemberRefRow row = new MemberRefRow ();
334                         row.Class = _class;
335                         row.Name = _name;
336                         row.Signature = _signature;
337                         return row;
338                 }
339
340                 public MethodRow CreateMethodRow (RVA _rVA, MethodImplAttributes _implFlags, MethodAttributes _flags, uint _name, uint _signature, uint _paramList)
341                 {
342                         MethodRow row = new MethodRow ();
343                         row.RVA = _rVA;
344                         row.ImplFlags = _implFlags;
345                         row.Flags = _flags;
346                         row.Name = _name;
347                         row.Signature = _signature;
348                         row.ParamList = _paramList;
349                         return row;
350                 }
351
352                 public MethodImplRow CreateMethodImplRow (uint _class, MetadataToken _methodBody, MetadataToken _methodDeclaration)
353                 {
354                         MethodImplRow row = new MethodImplRow ();
355                         row.Class = _class;
356                         row.MethodBody = _methodBody;
357                         row.MethodDeclaration = _methodDeclaration;
358                         return row;
359                 }
360
361                 public MethodPtrRow CreateMethodPtrRow (uint _method)
362                 {
363                         MethodPtrRow row = new MethodPtrRow ();
364                         row.Method = _method;
365                         return row;
366                 }
367
368                 public MethodSemanticsRow CreateMethodSemanticsRow (MethodSemanticsAttributes _semantics, uint _method, MetadataToken _association)
369                 {
370                         MethodSemanticsRow row = new MethodSemanticsRow ();
371                         row.Semantics = _semantics;
372                         row.Method = _method;
373                         row.Association = _association;
374                         return row;
375                 }
376
377                 public MethodSpecRow CreateMethodSpecRow (MetadataToken _method, uint _instantiation)
378                 {
379                         MethodSpecRow row = new MethodSpecRow ();
380                         row.Method = _method;
381                         row.Instantiation = _instantiation;
382                         return row;
383                 }
384
385                 public ModuleRow CreateModuleRow (ushort _generation, uint _name, uint _mvid, uint _encId, uint _encBaseId)
386                 {
387                         ModuleRow row = new ModuleRow ();
388                         row.Generation = _generation;
389                         row.Name = _name;
390                         row.Mvid = _mvid;
391                         row.EncId = _encId;
392                         row.EncBaseId = _encBaseId;
393                         return row;
394                 }
395
396                 public ModuleRefRow CreateModuleRefRow (uint _name)
397                 {
398                         ModuleRefRow row = new ModuleRefRow ();
399                         row.Name = _name;
400                         return row;
401                 }
402
403                 public NestedClassRow CreateNestedClassRow (uint _nestedClass, uint _enclosingClass)
404                 {
405                         NestedClassRow row = new NestedClassRow ();
406                         row.NestedClass = _nestedClass;
407                         row.EnclosingClass = _enclosingClass;
408                         return row;
409                 }
410
411                 public ParamRow CreateParamRow (ParameterAttributes _flags, ushort _sequence, uint _name)
412                 {
413                         ParamRow row = new ParamRow ();
414                         row.Flags = _flags;
415                         row.Sequence = _sequence;
416                         row.Name = _name;
417                         return row;
418                 }
419
420                 public ParamPtrRow CreateParamPtrRow (uint _param)
421                 {
422                         ParamPtrRow row = new ParamPtrRow ();
423                         row.Param = _param;
424                         return row;
425                 }
426
427                 public PropertyRow CreatePropertyRow (PropertyAttributes _flags, uint _name, uint _type)
428                 {
429                         PropertyRow row = new PropertyRow ();
430                         row.Flags = _flags;
431                         row.Name = _name;
432                         row.Type = _type;
433                         return row;
434                 }
435
436                 public PropertyMapRow CreatePropertyMapRow (uint _parent, uint _propertyList)
437                 {
438                         PropertyMapRow row = new PropertyMapRow ();
439                         row.Parent = _parent;
440                         row.PropertyList = _propertyList;
441                         return row;
442                 }
443
444                 public PropertyPtrRow CreatePropertyPtrRow (uint _property)
445                 {
446                         PropertyPtrRow row = new PropertyPtrRow ();
447                         row.Property = _property;
448                         return row;
449                 }
450
451                 public StandAloneSigRow CreateStandAloneSigRow (uint _signature)
452                 {
453                         StandAloneSigRow row = new StandAloneSigRow ();
454                         row.Signature = _signature;
455                         return row;
456                 }
457
458                 public TypeDefRow CreateTypeDefRow (TypeAttributes _flags, uint _name, uint _namespace, MetadataToken _extends, uint _fieldList, uint _methodList)
459                 {
460                         TypeDefRow row = new TypeDefRow ();
461                         row.Flags = _flags;
462                         row.Name = _name;
463                         row.Namespace = _namespace;
464                         row.Extends = _extends;
465                         row.FieldList = _fieldList;
466                         row.MethodList = _methodList;
467                         return row;
468                 }
469
470                 public TypeRefRow CreateTypeRefRow (MetadataToken _resolutionScope, uint _name, uint _namespace)
471                 {
472                         TypeRefRow row = new TypeRefRow ();
473                         row.ResolutionScope = _resolutionScope;
474                         row.Name = _name;
475                         row.Namespace = _namespace;
476                         return row;
477                 }
478
479                 public TypeSpecRow CreateTypeSpecRow (uint _signature)
480                 {
481                         TypeSpecRow row = new TypeSpecRow ();
482                         row.Signature = _signature;
483                         return row;
484                 }
485
486                 public override void VisitRowCollection (RowCollection coll)
487                 {
488                         m_blobHeapIdxSz = m_root.Streams.BlobHeap != null ?
489                                 m_root.Streams.BlobHeap.IndexSize : 2;
490                         m_stringsHeapIdxSz = m_root.Streams.StringsHeap != null ?
491                                 m_root.Streams.StringsHeap.IndexSize : 2;
492                         m_guidHeapIdxSz = m_root.Streams.GuidHeap != null ?
493                                 m_root.Streams.GuidHeap.IndexSize : 2;
494                 }
495
496                 public override void VisitAssemblyRow (AssemblyRow row)
497                 {
498                         m_binaryWriter.Write ((uint) row.HashAlgId);
499                         m_binaryWriter.Write (row.MajorVersion);
500                         m_binaryWriter.Write (row.MinorVersion);
501                         m_binaryWriter.Write (row.BuildNumber);
502                         m_binaryWriter.Write (row.RevisionNumber);
503                         m_binaryWriter.Write ((uint) row.Flags);
504                         WriteBlobPointer (row.PublicKey);
505                         WriteStringPointer (row.Name);
506                         WriteStringPointer (row.Culture);
507                 }
508
509                 public override void VisitAssemblyOSRow (AssemblyOSRow row)
510                 {
511                         m_binaryWriter.Write (row.OSPlatformID);
512                         m_binaryWriter.Write (row.OSMajorVersion);
513                         m_binaryWriter.Write (row.OSMinorVersion);
514                 }
515
516                 public override void VisitAssemblyProcessorRow (AssemblyProcessorRow row)
517                 {
518                         m_binaryWriter.Write (row.Processor);
519                 }
520
521                 public override void VisitAssemblyRefRow (AssemblyRefRow row)
522                 {
523                         m_binaryWriter.Write (row.MajorVersion);
524                         m_binaryWriter.Write (row.MinorVersion);
525                         m_binaryWriter.Write (row.BuildNumber);
526                         m_binaryWriter.Write (row.RevisionNumber);
527                         m_binaryWriter.Write ((uint) row.Flags);
528                         WriteBlobPointer (row.PublicKeyOrToken);
529                         WriteStringPointer (row.Name);
530                         WriteStringPointer (row.Culture);
531                         WriteBlobPointer (row.HashValue);
532                 }
533
534                 public override void VisitAssemblyRefOSRow (AssemblyRefOSRow row)
535                 {
536                         m_binaryWriter.Write (row.OSPlatformID);
537                         m_binaryWriter.Write (row.OSMajorVersion);
538                         m_binaryWriter.Write (row.OSMinorVersion);
539                         WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId);
540                 }
541
542                 public override void VisitAssemblyRefProcessorRow (AssemblyRefProcessorRow row)
543                 {
544                         m_binaryWriter.Write (row.Processor);
545                         WriteTablePointer (row.AssemblyRef, AssemblyRefTable.RId);
546                 }
547
548                 public override void VisitClassLayoutRow (ClassLayoutRow row)
549                 {
550                         m_binaryWriter.Write (row.PackingSize);
551                         m_binaryWriter.Write (row.ClassSize);
552                         WriteTablePointer (row.Parent, TypeDefTable.RId);
553                 }
554
555                 public override void VisitConstantRow (ConstantRow row)
556                 {
557                         m_binaryWriter.Write ((ushort) row.Type);
558                         WriteMetadataToken (row.Parent, CodedIndex.HasConstant);
559                         WriteBlobPointer (row.Value);
560                 }
561
562                 public override void VisitCustomAttributeRow (CustomAttributeRow row)
563                 {
564                         WriteMetadataToken (row.Parent, CodedIndex.HasCustomAttribute);
565                         WriteMetadataToken (row.Type, CodedIndex.CustomAttributeType);
566                         WriteBlobPointer (row.Value);
567                 }
568
569                 public override void VisitDeclSecurityRow (DeclSecurityRow row)
570                 {
571                         m_binaryWriter.Write ((short) row.Action);
572                         WriteMetadataToken (row.Parent, CodedIndex.HasDeclSecurity);
573                         WriteBlobPointer (row.PermissionSet);
574                 }
575
576                 public override void VisitEventRow (EventRow row)
577                 {
578                         m_binaryWriter.Write ((ushort) row.EventFlags);
579                         WriteStringPointer (row.Name);
580                         WriteMetadataToken (row.EventType, CodedIndex.TypeDefOrRef);
581                 }
582
583                 public override void VisitEventMapRow (EventMapRow row)
584                 {
585                         WriteTablePointer (row.Parent, TypeDefTable.RId);
586                         WriteTablePointer (row.EventList, EventTable.RId);
587                 }
588
589                 public override void VisitEventPtrRow (EventPtrRow row)
590                 {
591                         WriteTablePointer (row.Event, EventTable.RId);
592                 }
593
594                 public override void VisitExportedTypeRow (ExportedTypeRow row)
595                 {
596                         m_binaryWriter.Write ((uint) row.Flags);
597                         m_binaryWriter.Write (row.TypeDefId);
598                         WriteStringPointer (row.TypeName);
599                         WriteStringPointer (row.TypeNamespace);
600                         WriteMetadataToken (row.Implementation, CodedIndex.Implementation);
601                 }
602
603                 public override void VisitFieldRow (FieldRow row)
604                 {
605                         m_binaryWriter.Write ((ushort) row.Flags);
606                         WriteStringPointer (row.Name);
607                         WriteBlobPointer (row.Signature);
608                 }
609
610                 public override void VisitFieldLayoutRow (FieldLayoutRow row)
611                 {
612                         m_binaryWriter.Write (row.Offset);
613                         WriteTablePointer (row.Field, FieldTable.RId);
614                 }
615
616                 public override void VisitFieldMarshalRow (FieldMarshalRow row)
617                 {
618                         WriteMetadataToken (row.Parent, CodedIndex.HasFieldMarshal);
619                         WriteBlobPointer (row.NativeType);
620                 }
621
622                 public override void VisitFieldPtrRow (FieldPtrRow row)
623                 {
624                         WriteTablePointer (row.Field, FieldTable.RId);
625                 }
626
627                 public override void VisitFieldRVARow (FieldRVARow row)
628                 {
629                         m_binaryWriter.Write (row.RVA.Value);
630                         WriteTablePointer (row.Field, FieldTable.RId);
631                 }
632
633                 public override void VisitFileRow (FileRow row)
634                 {
635                         m_binaryWriter.Write ((uint) row.Flags);
636                         WriteStringPointer (row.Name);
637                         WriteBlobPointer (row.HashValue);
638                 }
639
640                 public override void VisitGenericParamRow (GenericParamRow row)
641                 {
642                         m_binaryWriter.Write (row.Number);
643                         m_binaryWriter.Write ((ushort) row.Flags);
644                         WriteMetadataToken (row.Owner, CodedIndex.TypeOrMethodDef);
645                         WriteStringPointer (row.Name);
646                 }
647
648                 public override void VisitGenericParamConstraintRow (GenericParamConstraintRow row)
649                 {
650                         WriteTablePointer (row.Owner, GenericParamTable.RId);
651                         WriteMetadataToken (row.Constraint, CodedIndex.TypeDefOrRef);
652                 }
653
654                 public override void VisitImplMapRow (ImplMapRow row)
655                 {
656                         m_binaryWriter.Write ((ushort) row.MappingFlags);
657                         WriteMetadataToken (row.MemberForwarded, CodedIndex.MemberForwarded);
658                         WriteStringPointer (row.ImportName);
659                         WriteTablePointer (row.ImportScope, ModuleRefTable.RId);
660                 }
661
662                 public override void VisitInterfaceImplRow (InterfaceImplRow row)
663                 {
664                         WriteTablePointer (row.Class, TypeDefTable.RId);
665                         WriteMetadataToken (row.Interface, CodedIndex.TypeDefOrRef);
666                 }
667
668                 public override void VisitManifestResourceRow (ManifestResourceRow row)
669                 {
670                         m_binaryWriter.Write (row.Offset);
671                         m_binaryWriter.Write ((uint) row.Flags);
672                         WriteStringPointer (row.Name);
673                         WriteMetadataToken (row.Implementation, CodedIndex.Implementation);
674                 }
675
676                 public override void VisitMemberRefRow (MemberRefRow row)
677                 {
678                         WriteMetadataToken (row.Class, CodedIndex.MemberRefParent);
679                         WriteStringPointer (row.Name);
680                         WriteBlobPointer (row.Signature);
681                 }
682
683                 public override void VisitMethodRow (MethodRow row)
684                 {
685                         m_binaryWriter.Write (row.RVA.Value);
686                         m_binaryWriter.Write ((ushort) row.ImplFlags);
687                         m_binaryWriter.Write ((ushort) row.Flags);
688                         WriteStringPointer (row.Name);
689                         WriteBlobPointer (row.Signature);
690                         WriteTablePointer (row.ParamList, ParamTable.RId);
691                 }
692
693                 public override void VisitMethodImplRow (MethodImplRow row)
694                 {
695                         WriteTablePointer (row.Class, TypeDefTable.RId);
696                         WriteMetadataToken (row.MethodBody, CodedIndex.MethodDefOrRef);
697                         WriteMetadataToken (row.MethodDeclaration, CodedIndex.MethodDefOrRef);
698                 }
699
700                 public override void VisitMethodPtrRow (MethodPtrRow row)
701                 {
702                         WriteTablePointer (row.Method, MethodTable.RId);
703                 }
704
705                 public override void VisitMethodSemanticsRow (MethodSemanticsRow row)
706                 {
707                         m_binaryWriter.Write ((ushort) row.Semantics);
708                         WriteTablePointer (row.Method, MethodTable.RId);
709                         WriteMetadataToken (row.Association, CodedIndex.HasSemantics);
710                 }
711
712                 public override void VisitMethodSpecRow (MethodSpecRow row)
713                 {
714                         WriteMetadataToken (row.Method, CodedIndex.MethodDefOrRef);
715                         WriteBlobPointer (row.Instantiation);
716                 }
717
718                 public override void VisitModuleRow (ModuleRow row)
719                 {
720                         m_binaryWriter.Write (row.Generation);
721                         WriteStringPointer (row.Name);
722                         WriteGuidPointer (row.Mvid);
723                         WriteGuidPointer (row.EncId);
724                         WriteGuidPointer (row.EncBaseId);
725                 }
726
727                 public override void VisitModuleRefRow (ModuleRefRow row)
728                 {
729                         WriteStringPointer (row.Name);
730                 }
731
732                 public override void VisitNestedClassRow (NestedClassRow row)
733                 {
734                         WriteTablePointer (row.NestedClass, TypeDefTable.RId);
735                         WriteTablePointer (row.EnclosingClass, TypeDefTable.RId);
736                 }
737
738                 public override void VisitParamRow (ParamRow row)
739                 {
740                         m_binaryWriter.Write ((ushort) row.Flags);
741                         m_binaryWriter.Write (row.Sequence);
742                         WriteStringPointer (row.Name);
743                 }
744
745                 public override void VisitParamPtrRow (ParamPtrRow row)
746                 {
747                         WriteTablePointer (row.Param, ParamTable.RId);
748                 }
749
750                 public override void VisitPropertyRow (PropertyRow row)
751                 {
752                         m_binaryWriter.Write ((ushort) row.Flags);
753                         WriteStringPointer (row.Name);
754                         WriteBlobPointer (row.Type);
755                 }
756
757                 public override void VisitPropertyMapRow (PropertyMapRow row)
758                 {
759                         WriteTablePointer (row.Parent, TypeDefTable.RId);
760                         WriteTablePointer (row.PropertyList, PropertyTable.RId);
761                 }
762
763                 public override void VisitPropertyPtrRow (PropertyPtrRow row)
764                 {
765                         WriteTablePointer (row.Property, PropertyTable.RId);
766                 }
767
768                 public override void VisitStandAloneSigRow (StandAloneSigRow row)
769                 {
770                         WriteBlobPointer (row.Signature);
771                 }
772
773                 public override void VisitTypeDefRow (TypeDefRow row)
774                 {
775                         m_binaryWriter.Write ((uint) row.Flags);
776                         WriteStringPointer (row.Name);
777                         WriteStringPointer (row.Namespace);
778                         WriteMetadataToken (row.Extends, CodedIndex.TypeDefOrRef);
779                         WriteTablePointer (row.FieldList, FieldTable.RId);
780                         WriteTablePointer (row.MethodList, MethodTable.RId);
781                 }
782
783                 public override void VisitTypeRefRow (TypeRefRow row)
784                 {
785                         WriteMetadataToken (row.ResolutionScope, CodedIndex.ResolutionScope);
786                         WriteStringPointer (row.Name);
787                         WriteStringPointer (row.Namespace);
788                 }
789
790                 public override void VisitTypeSpecRow (TypeSpecRow row)
791                 {
792                         WriteBlobPointer (row.Signature);
793                 }
794
795         }
796 }