ikvm-fork/ikvmc/remapper.cs

1561 строка
32 KiB
C#
Исходник Обычный вид История

2004-04-23 18:21:43 +04:00
/*
2008-08-15 16:01:06 +04:00
Copyright (C) 2002-2008 Jeroen Frijters
2004-04-23 18:21:43 +04:00
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
2005-05-30 19:30:13 +04:00
2002-12-18 19:00:25 +03:00
using System;
2008-08-15 16:01:06 +04:00
using System.Collections.Generic;
2002-12-18 19:00:25 +03:00
using System.Xml.Serialization;
using System.Reflection;
#if IKVM_REF_EMIT
using IKVM.Reflection.Emit;
#else
2002-12-18 19:00:25 +03:00
using System.Reflection.Emit;
#endif
2003-04-14 13:41:58 +04:00
using System.Diagnostics;
2004-09-09 15:17:55 +04:00
using IKVM.Attributes;
using IKVM.Internal;
2004-10-19 17:43:55 +04:00
2004-09-09 15:17:55 +04:00
namespace IKVM.Internal.MapXml
2002-12-18 19:00:25 +03:00
{
class CodeGenContext
{
private ClassLoaderWrapper classLoader;
2008-08-15 16:01:06 +04:00
private readonly Dictionary<string, object> h = new Dictionary<string, object>();
internal CodeGenContext(ClassLoaderWrapper classLoader)
{
this.classLoader = classLoader;
}
2008-08-15 16:01:06 +04:00
internal object this[string key]
{
2008-08-15 16:01:06 +04:00
get
{
object val;
h.TryGetValue(key, out val);
return val;
}
set { h[key] = value; }
}
internal ClassLoaderWrapper ClassLoader { get { return classLoader; } }
}
2002-12-18 19:00:25 +03:00
public abstract class Instruction
{
2004-10-19 17:43:55 +04:00
private int lineNumber = Root.LineNumber;
internal int LineNumber
{
get
{
return lineNumber;
}
}
internal abstract void Generate(CodeGenContext context, CodeEmitter ilgen);
2002-12-18 19:00:25 +03:00
}
[XmlType("ldstr")]
public sealed class Ldstr : Instruction
{
[XmlAttribute("value")]
public string Value;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
ilgen.Emit(OpCodes.Ldstr, Value);
}
}
2003-11-17 15:01:50 +03:00
[XmlType("ldnull")]
public sealed class Ldnull : Simple
{
public Ldnull() : base(OpCodes.Ldnull)
{
}
}
2002-12-18 19:00:25 +03:00
[XmlType("call")]
public class Call : Instruction
{
public Call() : this(OpCodes.Call)
{
}
internal Call(OpCode opcode)
{
this.opcode = opcode;
}
[XmlAttribute("class")]
public string Class;
2003-04-14 13:41:58 +04:00
[XmlAttribute("type")]
public string type;
2002-12-18 19:00:25 +03:00
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
private OpCode opcode;
internal sealed override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
2004-10-04 23:30:53 +04:00
Debug.Assert(Name != null);
if(Name == ".ctor")
2002-12-18 19:00:25 +03:00
{
2004-10-04 23:30:53 +04:00
Debug.Assert(Class == null && type != null);
Type[] argTypes = context.ClassLoader.ArgTypeListFromSig(Sig);
2006-04-10 13:09:09 +04:00
ConstructorInfo ci = StaticCompiler.GetType(type).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Standard, argTypes, null);
2004-10-04 23:30:53 +04:00
if(ci == null)
2002-12-18 19:00:25 +03:00
{
2004-10-04 23:30:53 +04:00
throw new InvalidOperationException("Missing .ctor: " + type + "..ctor" + Sig);
2002-12-18 19:00:25 +03:00
}
2004-10-04 23:30:53 +04:00
ilgen.Emit(opcode, ci);
}
else
{
Debug.Assert(Class == null ^ type == null);
if(Class != null)
2002-12-18 19:00:25 +03:00
{
2004-10-04 23:30:53 +04:00
Debug.Assert(Sig != null);
MethodWrapper method = context.ClassLoader.LoadClassByDottedName(Class).GetMethodWrapper(Name, Sig, false);
2004-10-04 23:30:53 +04:00
if(method == null)
2003-01-02 16:46:16 +03:00
{
2004-10-04 23:30:53 +04:00
throw new InvalidOperationException("method not found: " + Class + "." + Name + Sig);
}
method.Link();
// TODO this code is part of what Compiler.CastInterfaceArgs (in compiler.cs) does,
// it would be nice if we could avoid this duplication...
TypeWrapper[] argTypeWrappers = method.GetParameters();
for(int i = 0; i < argTypeWrappers.Length; i++)
{
if(argTypeWrappers[i].IsGhost)
2004-03-16 20:10:09 +03:00
{
2004-10-04 23:30:53 +04:00
LocalBuilder[] temps = new LocalBuilder[argTypeWrappers.Length + (method.IsStatic ? 0 : 1)];
for(int j = temps.Length - 1; j >= 0; j--)
2004-03-16 20:10:09 +03:00
{
2004-10-04 23:30:53 +04:00
TypeWrapper tw;
if(method.IsStatic)
2004-03-16 20:10:09 +03:00
{
2004-10-04 23:30:53 +04:00
tw = argTypeWrappers[j];
}
else
{
if(j == 0)
2004-03-16 20:10:09 +03:00
{
2004-10-04 23:30:53 +04:00
tw = method.DeclaringType;
2004-03-16 20:10:09 +03:00
}
else
{
2004-10-04 23:30:53 +04:00
tw = argTypeWrappers[j - 1];
2004-03-16 20:10:09 +03:00
}
}
2004-10-04 23:30:53 +04:00
if(tw.IsGhost)
2004-03-16 20:10:09 +03:00
{
2005-02-16 14:20:43 +03:00
tw.EmitConvStackTypeToSignatureType(ilgen, null);
2004-03-16 20:10:09 +03:00
}
2005-02-02 18:11:26 +03:00
temps[j] = ilgen.DeclareLocal(tw.TypeAsSignatureType);
2004-10-04 23:30:53 +04:00
ilgen.Emit(OpCodes.Stloc, temps[j]);
}
for(int j = 0; j < temps.Length; j++)
{
ilgen.Emit(OpCodes.Ldloc, temps[j]);
2004-03-16 20:10:09 +03:00
}
2004-10-04 23:30:53 +04:00
break;
2004-03-16 20:10:09 +03:00
}
2003-01-02 16:46:16 +03:00
}
2004-10-04 23:30:53 +04:00
if(opcode.Value == OpCodes.Call.Value)
{
method.EmitCall(ilgen);
}
else if(opcode.Value == OpCodes.Callvirt.Value)
{
method.EmitCallvirt(ilgen);
}
else if(opcode.Value == OpCodes.Newobj.Value)
{
method.EmitNewobj(ilgen);
}
2003-01-02 16:46:16 +03:00
else
{
2004-10-04 23:30:53 +04:00
throw new InvalidOperationException();
2003-01-02 16:46:16 +03:00
}
2002-12-18 19:00:25 +03:00
}
2004-10-04 23:30:53 +04:00
else
2002-12-18 19:00:25 +03:00
{
2005-09-21 18:26:37 +04:00
Type[] argTypes;
if(Sig.StartsWith("("))
{
argTypes = context.ClassLoader.ArgTypeListFromSig(Sig);
2005-09-21 18:26:37 +04:00
}
else
{
string[] types = Sig.Split(';');
argTypes = new Type[types.Length];
for(int i = 0; i < types.Length; i++)
{
2006-04-10 13:09:09 +04:00
argTypes[i] = StaticCompiler.GetType(types[i]);
2005-09-21 18:26:37 +04:00
}
}
2006-04-10 13:09:09 +04:00
MethodInfo mi = StaticCompiler.GetType(type).GetMethod(Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, null, argTypes, null);
2004-10-04 23:30:53 +04:00
if(mi == null)
{
throw new InvalidOperationException("Missing method: " + type + "." + Name + Sig);
}
ilgen.Emit(opcode, mi);
2002-12-18 19:00:25 +03:00
}
}
}
}
[XmlType("callvirt")]
public sealed class Callvirt : Call
{
public Callvirt() : base(OpCodes.Callvirt)
{
}
}
[XmlType("newobj")]
public sealed class NewObj : Call
{
public NewObj() : base(OpCodes.Newobj)
{
}
}
public abstract class Simple : Instruction
{
private OpCode opcode;
public Simple(OpCode opcode)
{
this.opcode = opcode;
}
internal sealed override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
ilgen.Emit(opcode);
}
}
[XmlType("dup")]
public sealed class Dup : Simple
{
public Dup() : base(OpCodes.Dup)
{
}
}
[XmlType("pop")]
public sealed class Pop : Instruction
2002-12-18 19:00:25 +03:00
{
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
ilgen.LazyEmitPop();
2002-12-18 19:00:25 +03:00
}
}
2004-01-11 16:14:42 +03:00
public abstract class TypeOrTypeWrapperInstruction : Instruction
2002-12-18 19:00:25 +03:00
{
[XmlAttribute("class")]
public string Class;
2003-04-14 13:41:58 +04:00
[XmlAttribute("type")]
public string type;
2004-01-11 16:14:42 +03:00
internal TypeWrapper typeWrapper;
internal Type typeType;
2002-12-18 19:00:25 +03:00
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
2003-04-14 13:41:58 +04:00
if(typeWrapper == null && typeType == null)
2002-12-18 19:00:25 +03:00
{
2003-04-14 13:41:58 +04:00
Debug.Assert(Class == null ^ type == null);
if(Class != null)
{
typeWrapper = context.ClassLoader.LoadClassByDottedName(Class);
2003-04-14 13:41:58 +04:00
}
else
{
2006-04-10 13:09:09 +04:00
typeType = StaticCompiler.GetType(type);
2003-04-14 13:41:58 +04:00
}
2002-12-18 19:00:25 +03:00
}
2003-04-14 13:41:58 +04:00
}
}
[XmlType("isinst")]
2004-01-11 16:14:42 +03:00
public sealed class IsInst : TypeOrTypeWrapperInstruction
2003-04-14 13:41:58 +04:00
{
2004-01-11 16:14:42 +03:00
public IsInst()
2003-04-14 13:41:58 +04:00
{
}
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-01-11 16:14:42 +03:00
{
base.Generate(context, ilgen);
if(typeType != null)
{
ilgen.Emit(OpCodes.Isinst, typeType);
}
else
{
2004-08-17 13:05:21 +04:00
if(typeWrapper.IsGhost || typeWrapper.IsGhostArray)
{
ilgen.Emit(OpCodes.Dup);
// NOTE we pass a null context, but that shouldn't be a problem, because
// typeWrapper should never be an UnloadableTypeWrapper
typeWrapper.EmitInstanceOf(null, ilgen);
CodeEmitterLabel endLabel = ilgen.DefineLabel();
2004-08-17 13:05:21 +04:00
ilgen.Emit(OpCodes.Brtrue_S, endLabel);
ilgen.Emit(OpCodes.Pop);
ilgen.Emit(OpCodes.Ldnull);
ilgen.MarkLabel(endLabel);
}
else
{
ilgen.Emit(OpCodes.Isinst, typeWrapper.TypeAsTBD);
}
2004-01-11 16:14:42 +03:00
}
}
2003-04-14 13:41:58 +04:00
}
[XmlType("castclass")]
2004-01-11 16:14:42 +03:00
public sealed class Castclass : TypeOrTypeWrapperInstruction
{
public Castclass()
{
}
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-01-11 16:14:42 +03:00
{
base.Generate(context, ilgen);
if(typeType != null)
{
ilgen.Emit(OpCodes.Castclass, typeType);
}
else
{
// NOTE we pass a null context, but that shouldn't be a problem, because
// typeWrapper should never be an UnloadableTypeWrapper
typeWrapper.EmitCheckcast(null, ilgen);
}
}
}
[XmlType("castclass_impl")]
public sealed class Castclass_impl : Instruction
{
[XmlAttribute("class")]
public string Class;
public Castclass_impl()
{
}
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Castclass, context.ClassLoader.LoadClassByDottedName(Class).TypeAsBaseType);
}
}
2004-01-11 16:14:42 +03:00
public abstract class TypeInstruction : Instruction
2003-04-14 13:41:58 +04:00
{
2004-01-11 16:14:42 +03:00
[XmlAttribute("type")]
public string type;
private OpCode opcode;
private Type typeType;
internal TypeInstruction(OpCode opcode)
2003-04-14 13:41:58 +04:00
{
2004-01-11 16:14:42 +03:00
this.opcode = opcode;
}
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-01-11 16:14:42 +03:00
{
if(typeType == null)
{
2004-02-10 20:16:35 +03:00
Debug.Assert(type != null);
2006-04-10 13:09:09 +04:00
typeType = StaticCompiler.GetType(type);
2004-01-11 16:14:42 +03:00
}
ilgen.Emit(opcode, typeType);
2002-12-18 19:00:25 +03:00
}
}
2004-11-29 16:58:21 +03:00
[XmlType("ldobj")]
public sealed class Ldobj : TypeInstruction
{
public Ldobj() : base(OpCodes.Ldobj)
{
}
}
2003-08-08 16:37:14 +04:00
[XmlType("unbox")]
public sealed class Unbox : TypeInstruction
{
public Unbox() : base(OpCodes.Unbox)
{
}
}
2003-11-17 15:01:50 +03:00
[XmlType("box")]
public sealed class Box : TypeInstruction
{
public Box() : base(OpCodes.Box)
{
}
}
2002-12-18 19:00:25 +03:00
public abstract class Branch : Instruction
{
private OpCode opcode;
public Branch(OpCode opcode)
{
this.opcode = opcode;
}
internal sealed override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
CodeEmitterLabel l;
2002-12-18 19:00:25 +03:00
if(context[Name] == null)
{
l = ilgen.DefineLabel();
context[Name] = l;
}
else
{
l = (CodeEmitterLabel)context[Name];
2002-12-18 19:00:25 +03:00
}
ilgen.Emit(opcode, l);
}
[XmlAttribute("name")]
public string Name;
}
[XmlType("brfalse")]
public sealed class BrFalse : Branch
{
public BrFalse() : base(OpCodes.Brfalse)
{
}
}
2003-04-14 13:41:58 +04:00
[XmlType("brtrue")]
public sealed class BrTrue : Branch
{
public BrTrue() : base(OpCodes.Brtrue)
{
}
}
2002-12-18 19:00:25 +03:00
[XmlType("br")]
public sealed class Br : Branch
{
public Br() : base(OpCodes.Br)
{
}
}
2007-04-23 12:14:55 +04:00
[XmlType("beq")]
public sealed class Beq : Branch
{
public Beq()
: base(OpCodes.Beq)
{
}
}
[XmlType("bne_un")]
public sealed class Bne_Un : Branch
{
public Bne_Un()
: base(OpCodes.Bne_Un)
{
}
}
2004-06-25 13:38:07 +04:00
[XmlType("bge_un")]
public sealed class Bge_Un : Branch
{
public Bge_Un() : base(OpCodes.Bge_Un)
{
}
}
[XmlType("ble_un")]
public sealed class Ble_Un : Branch
{
public Ble_Un() : base(OpCodes.Ble_Un)
{
}
}
2004-10-19 17:43:55 +04:00
[XmlType("blt")]
public sealed class Blt : Branch
{
public Blt() : base(OpCodes.Blt)
{
}
}
2004-11-23 20:46:39 +03:00
[XmlType("blt_un")]
public sealed class Blt_Un : Branch
{
public Blt_Un() : base(OpCodes.Blt_Un)
{
}
}
2002-12-18 19:00:25 +03:00
[XmlType("label")]
public sealed class BrLabel : Instruction
{
[XmlAttribute("name")]
public string Name;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
CodeEmitterLabel l;
2002-12-18 19:00:25 +03:00
if(context[Name] == null)
{
l = ilgen.DefineLabel();
context[Name] = l;
}
else
{
l = (CodeEmitterLabel)context[Name];
2002-12-18 19:00:25 +03:00
}
ilgen.MarkLabel(l);
}
}
[XmlType("stloc")]
public sealed class StLoc : Instruction
{
[XmlAttribute("name")]
public string Name;
[XmlAttribute("class")]
public string Class;
2003-04-14 13:41:58 +04:00
[XmlAttribute("type")]
public string type;
private TypeWrapper typeWrapper;
private Type typeType;
2002-12-18 19:00:25 +03:00
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
LocalBuilder lb = (LocalBuilder)context[Name];
if(lb == null)
{
2003-04-14 13:41:58 +04:00
if(typeWrapper == null && typeType == null)
2002-12-18 19:00:25 +03:00
{
2003-04-14 13:41:58 +04:00
Debug.Assert(Class == null ^ type == null);
if(type != null)
{
2006-04-10 13:09:09 +04:00
typeType = StaticCompiler.GetType(type);
2003-04-14 13:41:58 +04:00
}
else
{
typeWrapper = context.ClassLoader.LoadClassByDottedName(Class);
2003-04-14 13:41:58 +04:00
}
2002-12-18 19:00:25 +03:00
}
2004-01-11 16:14:42 +03:00
lb = ilgen.DeclareLocal(typeType != null ? typeType : typeWrapper.TypeAsTBD);
2002-12-18 19:00:25 +03:00
context[Name] = lb;
}
ilgen.Emit(OpCodes.Stloc, lb);
}
}
[XmlType("ldloc")]
public sealed class LdLoc : Instruction
{
[XmlAttribute("name")]
public string Name;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
ilgen.Emit(OpCodes.Ldloc, (LocalBuilder)context[Name]);
}
}
2004-11-23 20:46:39 +03:00
[XmlType("ldarga")]
public sealed class LdArga : Instruction
{
[XmlAttribute("argNum")]
public ushort ArgNum;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-11-23 20:46:39 +03:00
{
2005-12-19 18:12:49 +03:00
ilgen.Emit(OpCodes.Ldarga, (short)ArgNum);
2004-11-23 20:46:39 +03:00
}
}
2002-12-18 19:00:25 +03:00
[XmlType("ldarg_0")]
public sealed class LdArg_0 : Simple
{
public LdArg_0() : base(OpCodes.Ldarg_0)
{
}
}
2003-01-02 16:46:16 +03:00
[XmlType("ldarg_1")]
public sealed class LdArg_1 : Simple
{
public LdArg_1() : base(OpCodes.Ldarg_1)
{
}
}
[XmlType("ldarg_2")]
public sealed class LdArg_2 : Simple
{
public LdArg_2() : base(OpCodes.Ldarg_2)
{
}
}
[XmlType("ldarg_3")]
public sealed class LdArg_3 : Simple
{
public LdArg_3() : base(OpCodes.Ldarg_3)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("ldind_i1")]
public sealed class Ldind_i1 : Simple
{
public Ldind_i1() : base(OpCodes.Ldind_I1)
{
}
}
[XmlType("ldind_i2")]
public sealed class Ldind_i2 : Simple
{
public Ldind_i2() : base(OpCodes.Ldind_I2)
{
}
}
2003-08-08 16:37:14 +04:00
[XmlType("ldind_i4")]
public sealed class Ldind_i4 : Simple
{
public Ldind_i4() : base(OpCodes.Ldind_I4)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("ldind_i8")]
public sealed class Ldind_i8 : Simple
{
public Ldind_i8() : base(OpCodes.Ldind_I8)
{
}
}
[XmlType("ldind_r4")]
public sealed class Ldind_r4 : Simple
{
public Ldind_r4() : base(OpCodes.Ldind_R4)
{
}
}
[XmlType("ldind_r8")]
public sealed class Ldind_r8 : Simple
{
public Ldind_r8() : base(OpCodes.Ldind_R8)
{
}
}
2006-06-08 13:26:33 +04:00
[XmlType("ldind_ref")]
public sealed class Ldind_ref : Simple
{
public Ldind_ref() : base(OpCodes.Ldind_Ref)
{
}
}
2004-11-23 20:46:39 +03:00
[XmlType("stind_i1")]
public sealed class Stind_i1 : Simple
{
public Stind_i1() : base(OpCodes.Stind_I1)
{
}
}
2006-06-08 13:26:33 +04:00
[XmlType("stind_i2")]
public sealed class Stind_i2 : Simple
{
public Stind_i2() : base(OpCodes.Stind_I2)
{
}
}
[XmlType("stind_i4")]
public sealed class Stind_i4 : Simple
{
public Stind_i4() : base(OpCodes.Stind_I4)
{
}
}
[XmlType("stind_ref")]
public sealed class Stind_ref : Simple
{
public Stind_ref() : base(OpCodes.Stind_Ref)
{
}
}
2002-12-18 19:00:25 +03:00
[XmlType("ret")]
public sealed class Ret : Simple
{
public Ret() : base(OpCodes.Ret)
{
}
}
2003-04-14 13:41:58 +04:00
[XmlType("throw")]
public sealed class Throw : Simple
{
public Throw() : base(OpCodes.Throw)
{
}
}
2004-11-23 20:46:39 +03:00
[XmlType("ldflda")]
public sealed class Ldflda : Instruction
{
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-11-23 20:46:39 +03:00
{
FieldWrapper fw = ClassLoaderWrapper.LoadClassCritical(Class).GetFieldWrapper(Name, Sig);
fw.Link();
ilgen.Emit(OpCodes.Ldflda, fw.GetField());
}
}
[XmlType("ldfld")]
public sealed class Ldfld : Instruction
{
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-11-23 20:46:39 +03:00
{
FieldWrapper fw = ClassLoaderWrapper.LoadClassCritical(Class).GetFieldWrapper(Name, Sig);
fw.Link();
// we don't use fw.EmitGet because we don't want automatic unboxing and whatever
ilgen.Emit(OpCodes.Ldfld, fw.GetField());
2004-11-23 20:46:39 +03:00
}
}
2005-05-20 13:32:36 +04:00
[XmlType("ldsfld")]
public sealed class Ldsfld : Instruction
{
[XmlAttribute("class")]
public string Class;
2006-11-20 12:21:38 +03:00
[XmlAttribute("type")]
public string Type;
2005-05-20 13:32:36 +04:00
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2005-05-20 13:32:36 +04:00
{
2006-11-20 12:21:38 +03:00
if(Type != null)
{
ilgen.Emit(OpCodes.Ldsfld, StaticCompiler.GetType(Type).GetField(Name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
}
else
{
FieldWrapper fw = ClassLoaderWrapper.LoadClassCritical(Class).GetFieldWrapper(Name, Sig);
fw.Link();
// we don't use fw.EmitGet because we don't want automatic unboxing and whatever
ilgen.Emit(OpCodes.Ldsfld, fw.GetField());
2006-11-20 12:21:38 +03:00
}
2005-05-20 13:32:36 +04:00
}
}
2004-11-23 20:46:39 +03:00
[XmlType("stfld")]
public sealed class Stfld : Instruction
{
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-11-23 20:46:39 +03:00
{
FieldWrapper fw = ClassLoaderWrapper.LoadClassCritical(Class).GetFieldWrapper(Name, Sig);
fw.Link();
// we don't use fw.EmitSet because we don't want automatic unboxing and whatever
ilgen.Emit(OpCodes.Stfld, fw.GetField());
}
}
2004-03-08 18:18:47 +03:00
[XmlType("stsfld")]
public sealed class Stsfld : Instruction
{
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-03-08 18:18:47 +03:00
{
2004-10-04 23:30:53 +04:00
FieldWrapper fw = ClassLoaderWrapper.LoadClassCritical(Class).GetFieldWrapper(Name, Sig);
2004-08-17 13:05:21 +04:00
fw.Link();
2004-11-23 20:46:39 +03:00
// we don't use fw.EmitSet because we don't want automatic unboxing and whatever
ilgen.Emit(OpCodes.Stsfld, fw.GetField());
2004-03-08 18:18:47 +03:00
}
}
2004-06-25 13:38:07 +04:00
[XmlType("ldc_i4")]
public sealed class Ldc_I4 : Instruction
{
[XmlAttribute("value")]
public int val;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-06-25 13:38:07 +04:00
{
ilgen.Emit(OpCodes.Ldc_I4, val);
}
}
2004-03-08 18:18:47 +03:00
[XmlType("ldc_i4_0")]
public sealed class Ldc_I4_0 : Simple
{
public Ldc_I4_0() : base(OpCodes.Ldc_I4_0)
{
}
}
2004-10-19 17:43:55 +04:00
[XmlType("ldc_i4_1")]
public sealed class Ldc_I4_1 : Simple
{
public Ldc_I4_1() : base(OpCodes.Ldc_I4_1)
{
}
}
2004-06-25 13:38:07 +04:00
[XmlType("ldc_i4_m1")]
public sealed class Ldc_I4_M1 : Simple
{
public Ldc_I4_M1() : base(OpCodes.Ldc_I4_M1)
{
}
}
2004-11-23 20:46:39 +03:00
[XmlType("conv_i")]
public sealed class Conv_I : Simple
{
public Conv_I() : base(OpCodes.Conv_I)
{
}
}
2005-01-03 11:26:21 +03:00
[XmlType("conv_i1")]
public sealed class Conv_I1 : Simple
{
public Conv_I1() : base(OpCodes.Conv_I1)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("conv_u1")]
public sealed class Conv_U1 : Simple
{
public Conv_U1() : base(OpCodes.Conv_U1)
{
}
}
2005-01-03 11:26:21 +03:00
[XmlType("conv_i2")]
public sealed class Conv_I2 : Simple
{
public Conv_I2() : base(OpCodes.Conv_I2)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("conv_u2")]
public sealed class Conv_U2 : Simple
{
public Conv_U2() : base(OpCodes.Conv_U2)
{
}
}
2005-01-03 11:26:21 +03:00
[XmlType("conv_i4")]
public sealed class Conv_I4 : Simple
{
public Conv_I4() : base(OpCodes.Conv_I4)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("conv_u4")]
public sealed class Conv_U4 : Simple
{
public Conv_U4() : base(OpCodes.Conv_U4)
{
}
}
2005-01-03 11:26:21 +03:00
[XmlType("conv_i8")]
public sealed class Conv_I8 : Simple
{
public Conv_I8() : base(OpCodes.Conv_I8)
{
}
}
2004-06-14 14:36:38 +04:00
[XmlType("conv_u8")]
public sealed class Conv_U8 : Simple
{
public Conv_U8() : base(OpCodes.Conv_U8)
{
}
}
2004-06-17 18:38:09 +04:00
[XmlType("ldlen")]
public sealed class Ldlen : Simple
{
public Ldlen() : base(OpCodes.Ldlen)
{
}
}
2004-10-19 17:43:55 +04:00
[XmlType("add")]
public sealed class Add : Simple
{
public Add() : base(OpCodes.Add)
{
}
}
2007-04-23 12:14:55 +04:00
[XmlType("sub")]
public sealed class Sub : Simple
{
public Sub()
: base(OpCodes.Sub)
{
}
}
2004-10-19 17:43:55 +04:00
[XmlType("mul")]
public sealed class Mul : Simple
{
public Mul() : base(OpCodes.Mul)
{
}
}
2004-11-23 20:46:39 +03:00
[XmlType("unaligned")]
public sealed class Unaligned : Instruction
{
[XmlAttribute("alignment")]
public int Alignment;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-11-23 20:46:39 +03:00
{
ilgen.Emit(OpCodes.Unaligned, (byte)Alignment);
}
}
[XmlType("cpblk")]
public sealed class Cpblk : Simple
{
public Cpblk() : base(OpCodes.Cpblk)
{
}
}
2005-09-21 18:26:37 +04:00
[XmlType("ceq")]
public sealed class Ceq : Simple
{
public Ceq() : base(OpCodes.Ceq)
{
}
}
2007-06-11 13:11:42 +04:00
[XmlType("leave")]
public sealed class Leave : Branch
{
public Leave() : base(OpCodes.Leave)
{
}
}
2004-08-17 13:05:21 +04:00
[XmlType("exceptionBlock")]
public sealed class ExceptionBlock : Instruction
{
public InstructionList @try;
public CatchBlock @catch;
public InstructionList @finally;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2004-08-17 13:05:21 +04:00
{
ilgen.BeginExceptionBlock();
2004-10-19 17:43:55 +04:00
@try.Generate(context, ilgen);
2004-08-17 13:05:21 +04:00
if(@catch != null)
{
2006-04-05 12:18:58 +04:00
Type type;
if(@catch.type != null)
{
2006-04-10 13:09:09 +04:00
type = StaticCompiler.GetType(@catch.type);
2006-04-05 12:18:58 +04:00
}
else
{
type = context.ClassLoader.LoadClassByDottedName(@catch.Class).TypeAsExceptionType;
2006-04-05 12:18:58 +04:00
}
ilgen.BeginCatchBlock(type);
2004-10-19 17:43:55 +04:00
@catch.Generate(context, ilgen);
2004-08-17 13:05:21 +04:00
}
if(@finally != null)
{
ilgen.BeginFinallyBlock();
2004-10-19 17:43:55 +04:00
@finally.Generate(context, ilgen);
2004-08-17 13:05:21 +04:00
}
ilgen.EndExceptionBlock();
}
}
public class CatchBlock : InstructionList
{
[XmlAttribute("type")]
public string type;
2006-04-05 12:18:58 +04:00
[XmlAttribute("class")]
public string Class;
2004-08-17 13:05:21 +04:00
}
2005-12-07 12:06:32 +03:00
[XmlType("conditional")]
public class ConditionalInstruction : Instruction
{
[XmlAttribute("framework")]
public string framework;
public InstructionList code;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2005-12-07 12:06:32 +03:00
{
if (Environment.Version.ToString().StartsWith(framework))
{
code.Generate(context, ilgen);
}
}
}
2006-04-05 12:18:58 +04:00
[XmlType("volatile")]
public sealed class Volatile : Simple
{
public Volatile() : base(OpCodes.Volatile)
{
}
}
2006-06-08 13:26:33 +04:00
[XmlType("ldelema")]
public sealed class Ldelema : Instruction
{
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2006-06-08 13:26:33 +04:00
{
ilgen.Emit(OpCodes.Ldelema, context.ClassLoader.FieldTypeWrapperFromSig(Sig).TypeAsArrayType);
2006-06-08 13:26:33 +04:00
}
}
2009-03-13 07:59:21 +03:00
[XmlType("newarr")]
public sealed class Newarr : Instruction
{
[XmlAttribute("sig")]
public string Sig;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Newarr, context.ClassLoader.FieldTypeWrapperFromSig(Sig).TypeAsArrayType);
}
}
2006-11-20 12:21:38 +03:00
[XmlType("ldtoken")]
public sealed class Ldtoken : Instruction
{
[XmlAttribute("type")]
public string type;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
2006-11-20 12:21:38 +03:00
{
ilgen.Emit(OpCodes.Ldtoken, StaticCompiler.GetType(type));
}
}
[XmlType("runclassinit")]
public sealed class RunClassInit : Instruction
{
[XmlAttribute("class")]
public string Class;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
{
context.ClassLoader.LoadClassByDottedName(Class).EmitRunClassConstructor(ilgen);
}
}
[XmlType("exceptionMapping")]
public sealed class EmitExceptionMapping : Instruction
{
internal ExceptionMapping[] mapping;
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
{
CompilerClassLoader.ExceptionMapEmitter emitter = new CompilerClassLoader.ExceptionMapEmitter(mapping);
emitter.Emit(context, ilgen);
}
}
public class InstructionList
2002-12-18 19:00:25 +03:00
{
[XmlElement(typeof(Ldstr))]
[XmlElement(typeof(Call))]
[XmlElement(typeof(Callvirt))]
[XmlElement(typeof(Dup))]
[XmlElement(typeof(Pop))]
[XmlElement(typeof(IsInst))]
2003-04-14 13:41:58 +04:00
[XmlElement(typeof(Castclass))]
[XmlElement(typeof(Castclass_impl))]
2004-11-29 16:58:21 +03:00
[XmlElement(typeof(Ldobj))]
2003-08-08 16:37:14 +04:00
[XmlElement(typeof(Unbox))]
2003-11-17 15:01:50 +03:00
[XmlElement(typeof(Box))]
2002-12-18 19:00:25 +03:00
[XmlElement(typeof(BrFalse))]
2003-04-14 13:41:58 +04:00
[XmlElement(typeof(BrTrue))]
2002-12-18 19:00:25 +03:00
[XmlElement(typeof(Br))]
2007-04-23 12:14:55 +04:00
[XmlElement(typeof(Beq))]
[XmlElement(typeof(Bne_Un))]
2004-06-25 13:38:07 +04:00
[XmlElement(typeof(Bge_Un))]
[XmlElement(typeof(Ble_Un))]
2004-10-19 17:43:55 +04:00
[XmlElement(typeof(Blt))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Blt_Un))]
2002-12-18 19:00:25 +03:00
[XmlElement(typeof(BrLabel))]
[XmlElement(typeof(NewObj))]
[XmlElement(typeof(StLoc))]
[XmlElement(typeof(LdLoc))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(LdArga))]
2002-12-18 19:00:25 +03:00
[XmlElement(typeof(LdArg_0))]
2003-01-02 16:46:16 +03:00
[XmlElement(typeof(LdArg_1))]
[XmlElement(typeof(LdArg_2))]
[XmlElement(typeof(LdArg_3))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Ldind_i1))]
[XmlElement(typeof(Ldind_i2))]
2003-08-08 16:37:14 +04:00
[XmlElement(typeof(Ldind_i4))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Ldind_i8))]
[XmlElement(typeof(Ldind_r4))]
[XmlElement(typeof(Ldind_r8))]
2006-06-08 13:26:33 +04:00
[XmlElement(typeof(Ldind_ref))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Stind_i1))]
2006-06-08 13:26:33 +04:00
[XmlElement(typeof(Stind_i2))]
[XmlElement(typeof(Stind_i4))]
[XmlElement(typeof(Stind_ref))]
2002-12-18 19:00:25 +03:00
[XmlElement(typeof(Ret))]
2003-04-14 13:41:58 +04:00
[XmlElement(typeof(Throw))]
2003-11-17 15:01:50 +03:00
[XmlElement(typeof(Ldnull))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Ldflda))]
[XmlElement(typeof(Ldfld))]
2005-05-20 13:32:36 +04:00
[XmlElement(typeof(Ldsfld))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Stfld))]
2004-03-08 18:18:47 +03:00
[XmlElement(typeof(Stsfld))]
2004-06-25 13:38:07 +04:00
[XmlElement(typeof(Ldc_I4))]
2004-03-08 18:18:47 +03:00
[XmlElement(typeof(Ldc_I4_0))]
2004-10-19 17:43:55 +04:00
[XmlElement(typeof(Ldc_I4_1))]
2004-06-25 13:38:07 +04:00
[XmlElement(typeof(Ldc_I4_M1))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Conv_I))]
2005-01-03 11:26:21 +03:00
[XmlElement(typeof(Conv_I1))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Conv_U1))]
2005-01-03 11:26:21 +03:00
[XmlElement(typeof(Conv_I2))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Conv_U2))]
2005-01-03 11:26:21 +03:00
[XmlElement(typeof(Conv_I4))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Conv_U4))]
2005-01-03 11:26:21 +03:00
[XmlElement(typeof(Conv_I8))]
2004-06-14 14:36:38 +04:00
[XmlElement(typeof(Conv_U8))]
2004-06-17 18:38:09 +04:00
[XmlElement(typeof(Ldlen))]
2004-08-17 13:05:21 +04:00
[XmlElement(typeof(ExceptionBlock))]
2004-10-19 17:43:55 +04:00
[XmlElement(typeof(Add))]
2007-04-23 12:14:55 +04:00
[XmlElement(typeof(Sub))]
2004-10-19 17:43:55 +04:00
[XmlElement(typeof(Mul))]
2004-11-23 20:46:39 +03:00
[XmlElement(typeof(Unaligned))]
[XmlElement(typeof(Cpblk))]
2005-09-21 18:26:37 +04:00
[XmlElement(typeof(Ceq))]
2005-12-07 12:06:32 +03:00
[XmlElement(typeof(ConditionalInstruction))]
2006-04-05 12:18:58 +04:00
[XmlElement(typeof(Volatile))]
2006-06-08 13:26:33 +04:00
[XmlElement(typeof(Ldelema))]
2009-03-13 07:59:21 +03:00
[XmlElement(typeof(Newarr))]
2006-11-20 12:21:38 +03:00
[XmlElement(typeof(Ldtoken))]
2007-06-11 13:11:42 +04:00
[XmlElement(typeof(Leave))]
[XmlElement(typeof(RunClassInit))]
[XmlElement(typeof(EmitExceptionMapping))]
2002-12-18 19:00:25 +03:00
public Instruction[] invoke;
internal void Generate(CodeGenContext context, CodeEmitter ilgen)
2002-12-18 19:00:25 +03:00
{
2004-08-17 13:05:21 +04:00
if(invoke != null)
2002-12-18 19:00:25 +03:00
{
2004-08-17 13:05:21 +04:00
for(int i = 0; i < invoke.Length; i++)
{
2004-10-19 17:43:55 +04:00
if(invoke[i].LineNumber != -1)
{
ilgen.SetLineNumber((ushort)invoke[i].LineNumber);
}
2004-08-17 13:05:21 +04:00
invoke[i].Generate(context, ilgen);
}
2002-12-18 19:00:25 +03:00
}
}
2004-10-19 17:43:55 +04:00
internal void Emit(ClassLoaderWrapper loader, CodeEmitter ilgen)
2004-10-19 17:43:55 +04:00
{
Generate(new CodeGenContext(loader), ilgen);
2004-10-19 17:43:55 +04:00
}
2002-12-18 19:00:25 +03:00
}
2003-11-17 15:01:50 +03:00
public class Throws
{
[XmlAttribute("class")]
public string Class;
}
2002-12-18 19:00:25 +03:00
public class Constructor
{
[XmlAttribute("sig")]
public string Sig;
[XmlAttribute("modifiers")]
public MapModifiers Modifiers;
2005-05-24 15:54:20 +04:00
[XmlElement("parameter")]
public Param[] Params;
2004-03-08 18:18:47 +03:00
public InstructionList body;
public InstructionList alternateBody;
2002-12-18 19:00:25 +03:00
public Redirect redirect;
2003-11-17 15:01:50 +03:00
[XmlElement("throws", typeof(Throws))]
public Throws[] throws;
2005-04-27 10:10:01 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
2002-12-18 19:00:25 +03:00
}
public class Redirect
{
2004-10-19 17:43:55 +04:00
private int linenum = Root.LineNumber;
internal int LineNumber
{
get
{
return linenum;
}
}
2002-12-18 19:00:25 +03:00
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
[XmlAttribute("type")]
public string Type;
2006-10-02 11:10:52 +04:00
internal void Emit(ClassLoaderWrapper loader, CodeEmitter ilgen)
2006-10-02 11:10:52 +04:00
{
if(Type != "static" || Class == null || Name == null || Sig == null)
{
throw new NotImplementedException();
}
Type[] redirParamTypes = loader.ArgTypeListFromSig(Sig);
2006-10-02 11:10:52 +04:00
for(int i = 0; i < redirParamTypes.Length; i++)
{
ilgen.Emit(OpCodes.Ldarg, (short)i);
}
// HACK if the class name contains a comma, we assume it is a .NET type
if(Class.IndexOf(',') >= 0)
{
2009-10-16 11:06:50 +04:00
Type type = JVM.GetType(Class, true);
2006-10-02 11:10:52 +04:00
MethodInfo mi = type.GetMethod(Name, redirParamTypes);
if(mi == null)
{
throw new InvalidOperationException();
}
ilgen.Emit(OpCodes.Call, mi);
}
else
{
TypeWrapper tw = loader.LoadClassByDottedName(Class);
2006-10-02 11:10:52 +04:00
MethodWrapper mw = tw.GetMethodWrapper(Name, Sig, false);
if(mw == null)
{
throw new InvalidOperationException();
}
mw.Link();
mw.EmitCall(ilgen);
}
// TODO we may need a cast here (or a stack to return type conversion)
ilgen.Emit(OpCodes.Ret);
}
2002-12-18 19:00:25 +03:00
}
public class Override
{
[XmlAttribute("class")]
public string Class;
2002-12-18 19:00:25 +03:00
[XmlAttribute("name")]
public string Name;
}
public class ReplaceMethodCall
{
[XmlAttribute("class")]
public string Class;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
public InstructionList code;
}
2004-03-08 18:18:47 +03:00
public class Method
2002-12-18 19:00:25 +03:00
{
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
[XmlAttribute("modifiers")]
public MapModifiers Modifiers;
2005-08-19 13:08:43 +04:00
[XmlAttribute("attributes")]
public MethodAttributes MethodAttributes;
2007-04-23 12:14:55 +04:00
[XmlAttribute("nonullcheck")]
public bool NoNullCheck;
2005-05-24 15:54:20 +04:00
[XmlElement("parameter")]
public Param[] Params;
2004-03-08 18:18:47 +03:00
public InstructionList body;
public InstructionList alternateBody;
2004-08-17 13:05:21 +04:00
public InstructionList nonvirtualAlternateBody;
2002-12-18 19:00:25 +03:00
public Redirect redirect;
public Override @override;
2003-11-17 15:01:50 +03:00
[XmlElement("throws", typeof(Throws))]
public Throws[] throws;
2005-04-27 10:10:01 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
[XmlElement("replace-method-call")]
public ReplaceMethodCall[] ReplaceMethodCalls;
2006-10-02 11:10:52 +04:00
internal void Emit(ClassLoaderWrapper loader, CodeEmitter ilgen)
2006-10-02 11:10:52 +04:00
{
if(redirect != null)
{
redirect.Emit(loader, ilgen);
2006-10-02 11:10:52 +04:00
}
else
{
body.Emit(loader, ilgen);
2006-10-02 11:10:52 +04:00
}
}
2002-12-18 19:00:25 +03:00
}
public class Field
{
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
[XmlAttribute("modifiers")]
public MapModifiers Modifiers;
2003-11-17 15:01:50 +03:00
[XmlAttribute("constant")]
public string Constant;
2002-12-18 19:00:25 +03:00
public Redirect redirect;
2005-04-27 10:10:01 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
2002-12-18 19:00:25 +03:00
}
2005-04-15 11:54:31 +04:00
public class Property
{
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig;
public Method getter;
public Method setter;
2005-04-27 10:10:01 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
2005-04-15 11:54:31 +04:00
}
2002-12-27 12:01:16 +03:00
public class Interface
{
[XmlAttribute("class")]
public string Name;
2006-10-02 11:10:52 +04:00
[XmlElement("method")]
public Method[] Methods;
2002-12-27 12:01:16 +03:00
}
2002-12-18 19:00:25 +03:00
[Flags]
public enum MapModifiers
{
[XmlEnum("public")]
Public = Modifiers.Public,
[XmlEnum("protected")]
Protected = Modifiers.Protected,
2003-11-17 15:01:50 +03:00
[XmlEnum("private")]
Private = Modifiers.Private,
2002-12-18 19:00:25 +03:00
[XmlEnum("final")]
Final = Modifiers.Final,
[XmlEnum("interface")]
Interface = Modifiers.Interface,
[XmlEnum("static")]
2003-10-17 12:08:31 +04:00
Static = Modifiers.Static,
[XmlEnum("abstract")]
Abstract = Modifiers.Abstract
2002-12-18 19:00:25 +03:00
}
2004-04-23 18:21:43 +04:00
public enum Scope
{
[XmlEnum("public")]
Public = 0,
[XmlEnum("private")]
Private = 1
}
2005-04-27 10:10:01 +04:00
public class Element
{
[XmlText]
public string Value;
}
public class Param
{
[XmlText]
public string Value;
[XmlAttribute("name")]
public string Name;
[XmlAttribute("sig")]
public string Sig; // optional (for object type args)
[XmlElement("element")]
public Element[] Elements;
2005-05-26 12:05:47 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
2005-04-27 10:10:01 +04:00
}
public class Attribute
{
[XmlAttribute("type")]
public string Type;
[XmlAttribute("class")]
public string Class;
[XmlAttribute("sig")]
public string Sig;
[XmlElement("parameter")]
public Param[] Params;
[XmlElement("property")]
public Param[] Properties;
[XmlElement("field")]
public Param[] Fields;
}
2002-12-18 19:00:25 +03:00
[XmlType("class")]
public class Class
{
[XmlAttribute("name")]
public string Name;
2004-04-23 18:21:43 +04:00
[XmlAttribute("shadows")]
public string Shadows;
2002-12-18 19:00:25 +03:00
[XmlAttribute("modifiers")]
public MapModifiers Modifiers;
2004-04-23 18:21:43 +04:00
[XmlAttribute("scope")]
public Scope scope;
2002-12-18 19:00:25 +03:00
[XmlElement("constructor")]
public Constructor[] Constructors;
[XmlElement("method")]
public Method[] Methods;
[XmlElement("field")]
public Field[] Fields;
2005-04-15 11:54:31 +04:00
[XmlElement("property")]
public Property[] Properties;
2002-12-27 12:01:16 +03:00
[XmlElement("implements")]
public Interface[] Interfaces;
2004-03-08 18:18:47 +03:00
[XmlElement("clinit")]
public Method Clinit;
2005-04-27 10:10:01 +04:00
[XmlElement("attribute")]
public Attribute[] Attributes;
}
public class Assembly
{
[XmlElement("class")]
public Class[] Classes;
[XmlElement("attribute")]
public Attribute[] Attributes;
2002-12-18 19:00:25 +03:00
}
2003-12-20 01:19:18 +03:00
[XmlType("exception")]
public class ExceptionMapping
{
[XmlAttribute]
public string src;
[XmlAttribute]
public string dst;
public InstructionList code;
}
2002-12-18 19:00:25 +03:00
[XmlRoot("root")]
public class Root
{
2004-10-19 17:43:55 +04:00
internal static System.Xml.XmlTextReader xmlReader;
internal static string filename;
internal static int LineNumber
{
get
{
return xmlReader == null ? -1: xmlReader.LineNumber;
}
}
2005-04-27 10:10:01 +04:00
[XmlElement("assembly")]
public Assembly assembly;
2003-12-20 01:19:18 +03:00
public ExceptionMapping[] exceptionMappings;
2002-12-18 19:00:25 +03:00
}
}