X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FPEAPI%2FCode.cs;h=b681a4cf24deabaef67e19b0c29f70ee3f240bf4;hb=ab0b591ca59d99a2370bf9f579b091c5edf09ae5;hp=af8ae771cfa48247779c2f81463aa9719be4c282;hpb=89d0ba3968d36576553e0f483b0c69465f94e8ae;p=mono.git diff --git a/mcs/class/PEAPI/Code.cs b/mcs/class/PEAPI/Code.cs index af8ae771cfa..b681a4cf24d 100644 --- a/mcs/class/PEAPI/Code.cs +++ b/mcs/class/PEAPI/Code.cs @@ -284,7 +284,6 @@ namespace PEAPI { internal class BranchInstr : Instr { CILLabel dest; private bool shortVer = true; - private static readonly byte longInstrOffset = 13; private int target = 0; internal BranchInstr(int inst, CILLabel dst) : base(inst) @@ -359,7 +358,6 @@ namespace PEAPI { private static readonly ushort MoreSects = 0x8; private static readonly ushort InitLocals = 0x10; private static readonly uint FatSize = 12; - private static readonly uint FatWords = FatSize/4; private static readonly byte FatExceptTable = 0x41; private static readonly byte SmlExceptTable = 0x01; @@ -701,6 +699,7 @@ namespace PEAPI { exceptions = new ArrayList(); else if (exceptions.Contains(tryBlock)) return; exceptions.Add(tryBlock); + tryBlock.ResolveCatchBlocks (metaData); } /// @@ -975,6 +974,16 @@ namespace PEAPI { return fatFormat; } + //Hackish + internal void ResolveCatchBlocks (MetaData md) + { + for (int i=0; i < handlers.Count; i++) { + Catch c = handlers [i] as Catch; + if (c != null) + c.ResolveType (md); + } + } + internal override void Write(FileImage output, bool fatFormat) { // Console.WriteLine("writing exception details"); @@ -1013,7 +1022,7 @@ namespace PEAPI { /// public class Catch : HandlerBlock { - Class exceptType; + MetaDataElement exceptType; /// /// Create a new catch clause @@ -1021,12 +1030,23 @@ namespace PEAPI { /// the exception to be caught /// start of the handler code /// end of the handler code - public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd) + public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd) + : base(handlerStart, handlerEnd) + { + exceptType = except; + } + + public Catch(Type except, CILLabel handlerStart, CILLabel handlerEnd) : base(handlerStart,handlerEnd) { exceptType = except; } + internal void ResolveType (MetaData md) + { + exceptType = ((Type) exceptType).GetTypeSpec (md); + } + internal override void Write(FileImage output, bool fatFormat) { base.Write(output,fatFormat); @@ -1274,10 +1294,17 @@ namespace PEAPI { int tide = 0; CILInstruction labInstr; uint offset = 0; + bool absolute; - public CILLabel (uint offset) + + public CILLabel (uint offset, bool absolute) { this.offset = offset; + this.absolute = absolute; + } + + public CILLabel (uint offset) : this (offset, false) + { } @@ -1310,6 +1337,7 @@ namespace PEAPI { internal uint GetLabelOffset() { + if (absolute) return offset; if (labInstr == null) return 0; return labInstr.offset + offset; }