Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/ilasm/codegen/BaseTypeRef.cs')
-rw-r--r--mcs/ilasm/codegen/BaseTypeRef.cs101
1 files changed, 101 insertions, 0 deletions
diff --git a/mcs/ilasm/codegen/BaseTypeRef.cs b/mcs/ilasm/codegen/BaseTypeRef.cs
new file mode 100644
index 00000000000..117a629c7c8
--- /dev/null
+++ b/mcs/ilasm/codegen/BaseTypeRef.cs
@@ -0,0 +1,101 @@
+//
+// Mono.ILASM.BaseTypeRef
+//
+// Author(s):
+// Ankit Jain <jankit@novell.com>
+//
+// Copyright 2006 Novell, Inc (http://www.novell.com)
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public abstract class BaseTypeRef : ModifiableType {
+ protected string full_name;
+ protected string sig_mod;
+ protected PEAPI.Type type;
+ protected bool is_resolved;
+ protected Hashtable method_table;
+ protected Hashtable field_table;
+
+ protected BaseTypeRef (string full_name)
+ : this (full_name, null, null)
+ {
+ }
+
+ protected BaseTypeRef (string full_name, ArrayList conv_list, string sig_mod)
+ {
+ this.full_name = full_name;
+ this.sig_mod = sig_mod;
+ is_resolved = false;
+ if (conv_list != null)
+ ConversionList = conv_list;
+ }
+
+ public virtual string FullName {
+ get { return full_name + sig_mod; }
+ }
+
+ public override string SigMod {
+ get { return sig_mod; }
+ set { sig_mod = value; }
+ }
+
+ public PEAPI.Type PeapiType {
+ get { return type; }
+ }
+
+ public bool IsResolved {
+ get { return is_resolved; }
+ }
+
+ public abstract void Resolve (CodeGen code_gen);
+
+ protected abstract BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count);
+
+ public virtual BaseMethodRef GetMethodRef (BaseTypeRef ret_type,
+ PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
+ {
+ BaseMethodRef mr = null;
+
+ /* Note: FullName not reqd as this is cached per object */
+ string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+ if (method_table == null)
+ method_table = new Hashtable ();
+ else
+ mr = (BaseMethodRef) method_table [key];
+
+ if (mr == null) {
+ mr = CreateMethodRef (ret_type, call_conv, name, param, gen_param_count);
+ method_table [key] = mr;
+ }
+
+ return mr;
+ }
+
+ protected abstract IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name);
+
+ public virtual IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
+ {
+ IFieldRef fr = null;
+ string key = ret_type.FullName + name;
+
+ if (field_table == null)
+ field_table = new Hashtable ();
+ else
+ fr = (IFieldRef) field_table [key];
+
+ if (fr == null) {
+ fr = CreateFieldRef (ret_type, name);
+ field_table [key] = fr;
+ }
+
+ return fr;
+ }
+
+ }
+
+}