diff options
Diffstat (limited to 'mcs/ilasm/codegen/ExternFieldRef.cs')
-rw-r--r-- | mcs/ilasm/codegen/ExternFieldRef.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mcs/ilasm/codegen/ExternFieldRef.cs b/mcs/ilasm/codegen/ExternFieldRef.cs new file mode 100644 index 00000000000..3a20ad5872f --- /dev/null +++ b/mcs/ilasm/codegen/ExternFieldRef.cs @@ -0,0 +1,60 @@ +// +// Mono.ILASM.ExternFieldRef +// +// Author(s): +// Jackson Harper (Jackson@LatitudeGeo.com) +// +// (C) 2003 Jackson Harper, All rights reserved +// + + +using System; + +namespace Mono.ILASM { + + public class ExternFieldRef : IFieldRef { + + private ExternTypeRef owner; + private BaseTypeRef type; + private string name; + + private bool is_resolved; + private PEAPI.FieldRef peapi_field; + + public ExternFieldRef (ExternTypeRef owner, BaseTypeRef type, string name) + { + this.owner = owner; + this.type = type; + this.name = name; + + is_resolved = false; + } + + public PEAPI.Field PeapiField { + get { return peapi_field; } + } + + public void Resolve (CodeGen code_gen) + { + if (is_resolved) + return; + + owner.Resolve (code_gen); + + if (owner.UseTypeSpec) { + PEAPI.Type owner_ref = owner.PeapiType; + code_gen.PEFile.AddFieldToTypeSpec (owner_ref, name, + type.PeapiType); + } else { + PEAPI.ClassRef owner_ref; + owner_ref = (PEAPI.ClassRef) owner.PeapiType; + type.Resolve (code_gen); + peapi_field = owner_ref.AddField (name, type.PeapiType); + } + + is_resolved = true; + } + } + +} + |