From daf9227e7323c31257fe34bb4f2d38c7c1abbff1 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Fri, 22 Jan 2010 16:55:23 +0000 Subject: fix several issues in .net backend / type parsing. --- src/msil/ch/epfl/lamp/compiler/msil/PEFile.java | 16 ++++++++++++---- src/msil/ch/epfl/lamp/compiler/msil/PEModule.java | 13 +++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/msil/ch') diff --git a/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java b/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java index 459bb39a20..457a1d8c2b 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java +++ b/src/msil/ch/epfl/lamp/compiler/msil/PEFile.java @@ -854,10 +854,18 @@ public class PEFile { while (getByte() == ELEMENT_TYPE_CMOD_OPT || getByte() == ELEMENT_TYPE_CMOD_REQD) { - Type t = decodeType(); - System.err.println("CMOD: " + t); - if (getByte() == ELEMENT_TYPE_CMOD_REQD) - throw new RuntimeException("Reqired CMOD: " + t); + // skip the tag 23.2.7 + readByte(); + // skip the TypeDefOrRefEncoded (23.2.8) + readByte(); + readByte(); + + // @FIXME: could be 4 bytes, not always 2... + + //Type t = decodeType(); + //System.err.println("CMOD: " + t); + //if (getByte() == ELEMENT_TYPE_CMOD_REQD) + //throw new RuntimeException("Reqired CMOD: " + t); } } diff --git a/src/msil/ch/epfl/lamp/compiler/msil/PEModule.java b/src/msil/ch/epfl/lamp/compiler/msil/PEModule.java index a6e7bb31b2..78c17038cb 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/PEModule.java +++ b/src/msil/ch/epfl/lamp/compiler/msil/PEModule.java @@ -143,8 +143,17 @@ final class PEModule extends Module { Assembly assem = getAssembly(name); type = assem.GetType(typeName); if (type == null) { - throw new RuntimeException("Failed to locate type " + - typeName + " in assembly " + assem); + // HACK: the IKVM.OpenJDK.Core assembly is compiled against mscorlib.dll v2.0 + // The MSIL library cannot parse the v2.0 mscorlib because of generics, so we + // use the v1.0 + // However, the java.io.FileDescriptor.FlushFileBuffers method uses a type + // Microsoft.Win32.SafeHandles.SafeFileHandle, which only exists in mscorlib + // v2.0 + // For now, jsut return Object (fine as long as we don't use that method). + Assembly asmb = getAssembly("mscorlib"); + type = asmb.GetType("System.Object"); + //throw new RuntimeException("Failed to locate type " + + //typeName + " in assembly " + assem); } break; case ModuleDef.ID: -- cgit v1.2.3