62 inst.Type = (string)element.Attribute(
"type");
63 inst.Class = (string)element.Attribute(
"class");
64 inst.Method = (string)element.Attribute(
"method");
65 inst.Field = (string)element.Attribute(
"field");
66 inst.Sig = (string)element.Attribute(
"sig");
69 public string Type {
get;
set; }
71 public string Class {
get;
set; }
73 public string Method {
get;
set; }
75 public string Field {
get;
set; }
77 public string Sig {
get;
set; }
81 if (!Validate(context))
86 MemberInfo member = Resolve(context);
87 Type type = member as
Type;
94 ilgen.Emit(OpCodes.Ldtoken, type);
96 else if (method !=
null)
98 ilgen.Emit(OpCodes.Ldtoken, method);
100 else if (constructor !=
null)
102 ilgen.Emit(OpCodes.Ldtoken, constructor);
104 else if (field !=
null)
106 ilgen.Emit(OpCodes.Ldtoken, field);
114 private bool Validate(CodeGenContext context)
116 if (Type !=
null &&
Class ==
null)
120 context.ClassLoader.Diagnostics.MapXmlError(
"not implemented: cannot use 'type' attribute with 'method' or 'field' attribute for ldtoken");
125 else if (
Class !=
null && Type ==
null)
131 context.ClassLoader.Diagnostics.MapXmlError(
"cannot specify 'sig' attribute without either 'method' or 'field' attribute for ldtoken");
137 context.ClassLoader.Diagnostics.MapXmlError(
"cannot specify both 'method' and 'field' attribute for ldtoken");
144 context.ClassLoader.Diagnostics.MapXmlError(
"must specify either 'type' or 'class' attribute for ldtoken");
149 private MemberInfo Resolve(CodeGenContext context)
155 throw new NotImplementedException();
157 return context.ClassLoader.Context.StaticCompiler.GetTypeForMapXml(context.ClassLoader, Type);
159 else if (
Class !=
null)
161 var tw = context.ClassLoader.TryLoadClassByName(
Class);
168 var mw = tw.GetMethod(
Method,
Sig,
false);
173 return mw.GetMethod();
175 else if (
Field !=
null)
177 var fw = tw.GetFieldWrapper(
Field,
Sig);
182 return fw.GetField();
186 return tw.TypeAsBaseType;