diff options
Diffstat (limited to 'src/msil/ch/epfl/lamp/compiler')
10 files changed, 43 insertions, 22 deletions
diff --git a/src/msil/ch/epfl/lamp/compiler/msil/Attribute.java b/src/msil/ch/epfl/lamp/compiler/msil/Attribute.java index b136f9423e..0a9ef6929e 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/Attribute.java +++ b/src/msil/ch/epfl/lamp/compiler/msil/Attribute.java @@ -55,7 +55,7 @@ public class Attribute { return value; } - /**@return an array with the arguments to the attribute's contructor. */ + /**@return an array with the arguments to the attribute's constructor. */ public Object[] getConstructorArguments() { parseBlob(); Object[] cas = new Object[constrArgs.length]; 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: diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala index 4644cade72..0e0e337ceb 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala @@ -20,7 +20,7 @@ import ch.epfl.lamp.compiler.msil._ import ch.epfl.lamp.compiler.msil.util.Table /** - * The MSIL printer Vistor. It prints a complete + * The MSIL printer Visitor. It prints a complete * assembly in a single or multiple files. Then this file can be compiled by ilasm. * * @author Nikolay Mihaylov diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/MethodBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/MethodBuilder.scala index eb86c96de5..a1c5091547 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/MethodBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/MethodBuilder.scala @@ -40,7 +40,7 @@ class MethodBuilder(name: String, declType: Type, attrs: Int, returnType: Type, def GetILGenerator(): ILGenerator = { if (ilGenerator == null) throw new RuntimeException - ("No code generator avaiable for this method: " + this) + ("No code generator available for this method: " + this) return ilGenerator } diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala index 63776cc084..b1b6d41eb5 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala @@ -20,8 +20,8 @@ import ch.epfl.lamp.compiler.msil.emit import ch.epfl.lamp.compiler.msil.util.Table /** - * The MSIL printer Vistor. It prints a complete - * assembly into seperate files. Then these files can be compiled by ilasm. + * The MSIL printer Visitor. It prints a complete + * assembly into separate files. Then these files can be compiled by ilasm. * * @author Nikolay Mihaylov * @author Daniel Lorch diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala index 1bd8e48633..835bdcadd0 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala @@ -1139,7 +1139,7 @@ object OpCode { opcode(Rem_Un, CEE_REM_UN, "rem.un" , 0xFFFFFF5E, POP_1_1, PUSH_1 , INLINE_NONE, FLOW_NEXT) /** - * Computes the bitwise AND of two values and pushes the result onto the evalution stack. + * Computes the bitwise AND of two values and pushes the result onto the evaluation stack. */ final val And = new OpCode() opcode(And, CEE_AND, "and" , 0xFFFFFF5F, POP_1_1, PUSH_1 , INLINE_NONE, FLOW_NEXT) @@ -1585,7 +1585,7 @@ object OpCode { opcode(Conv_Ovf_I2, CEE_CONV_OVF_I2, "conv.ovf.i2", 0xFFFFFFB5, POP_1, PUSH_I , INLINE_NONE , FLOW_NEXT) /** - * Converts the signed value on top of the sevaluation tack to signed int32, + * Converts the signed value on top of the evaluation stack to signed int32, * throwing OverflowException on overflow. */ final val Conv_Ovf_I4 = new OpCode() diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCodes.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCodes.scala index f8e0f140a8..557b022f54 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCodes.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCodes.scala @@ -521,7 +521,7 @@ object OpCodes { final val Rem_Un = OpCode.Rem_Un /** - * Computes the bitwise AND of two values and pushes the result onto the evalution stack. + * Computes the bitwise AND of two values and pushes the result onto the evaluation stack. */ final val And = OpCode.And @@ -899,7 +899,7 @@ object OpCodes { final val Conv_Ovf_I2 = OpCode.Conv_Ovf_I2 /** - * Converts the signed value on top of the sevaluation tack to signed int32, + * Converts the signed value on top of the evaluation stack to signed int32, * throwing OverflowException on overflow. */ final val Conv_Ovf_I4 = OpCode.Conv_Ovf_I4 diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala index 5ebc5ea32f..7a880f2ac6 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala @@ -19,7 +19,7 @@ import ch.epfl.lamp.compiler.msil.emit import ch.epfl.lamp.compiler.msil.util.Table /** - * The MSIL printer Vistor. It prints a complete + * The MSIL printer Visitor. It prints a complete * assembly in a single file. Then this file can be compiled by ilasm. * * @author Nikolay Mihaylov diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala index 84fd2a4023..2c0ab29b90 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala @@ -141,14 +141,19 @@ class TypeBuilder (module: Module, attributes: Int, fullName: String, baseType: /** Searches for the nested type with the specified name. */ override def GetNestedType(name: String): Type = { - testRaw(name) - return super.GetNestedType(name) + testRaw(name) + super.GetNestedType(name) } /** Returns all the types nested within the current Type. */ override def GetNestedTypes(): Array[Type] = { - testRaw("<GetNestedTypes>") - return super.GetNestedTypes() + testRaw("<GetNestedTypes>") + super.GetNestedTypes() + } + + /** Returns a Type object that represents a one-dimensional array of the current type */ + def MakeArrayType(): Type = { + Type.mkArray(this, 1) } /** Sets a custom attribute. */ @@ -184,8 +189,7 @@ class TypeBuilder (module: Module, attributes: Int, fullName: String, baseType: // i.e. not finalized by call to CreateType protected def testRaw(member: String) { if (raw) - throw new RuntimeException - ("Not supported for TypeBuilder before CreateType(): " + + throw new RuntimeException("Not supported for TypeBuilder before CreateType(): " + FullName + "::" + member) } |