public void ToMemberId_returns_expected_value_for_array_types_03() { // ARRANGE var cs = @" using System; using System.Collections.Generic; namespace Namespace1.Namespace2 { public class Class1 { public void Method1(string[,] parameter) { } } } "; using var assembly = Compile(cs); var typeReference = assembly.MainModule.Types .Single(x => x.Name == "Class1") .Methods .Single(x => x.Name == "Method1") .Parameters .Single() .ParameterType; var expectedMemberId = new ArrayTypeId(new SimpleTypeId("System", "String"), 2); // ACT var actualMemberId = typeReference.ToMemberId(); // ASSERT Assert.NotNull(actualMemberId); Assert.Equal(expectedMemberId, actualMemberId); }
internal ArrayType GetMirrorOf(ArrayTypeId arrayTypeId) { if (arrayTypeId == default(ArrayTypeId)) { return(null); } return(new ArrayType(this, arrayTypeId)); }
private TypeId ParseArraySuffix(TypeId elementType) { if (Current.Kind != MemberIdTokenKind.OpenSquareBracket) { return(elementType); } var type = elementType; while (Current.Kind == MemberIdTokenKind.OpenSquareBracket) { MatchToken(MemberIdTokenKind.OpenSquareBracket); var dimensions = ParseArrayDimensions(); MatchToken(MemberIdTokenKind.CloseSquareBracket); // wrap type into an array type = new ArrayTypeId(type, dimensions); } return(type); }
internal ArrayType(VirtualMachine virtualMachine, ArrayTypeId typeId) : base(virtualMachine, new TaggedReferenceTypeId(TypeTag.Array, typeId)) { Contract.Requires(virtualMachine != null); }
public Error CreateArrayInstance(out TaggedObjectId newArray, ArrayTypeId arrayType, int length) { throw new NotImplementedException(); }
public Error CreateArrayInstance(ArrayTypeId arrayType, int length, out TaggedObjectId newArray) { newArray = default(TaggedObjectId); JniEnvironment nativeEnvironment; JvmtiEnvironment environment; jvmtiError error = GetEnvironment(out environment, out nativeEnvironment); if (error != jvmtiError.None) return GetStandardError(error); using (var arrayTypeHandle = VirtualMachine.GetLocalReferenceForClass(nativeEnvironment, arrayType)) { if (!arrayTypeHandle.IsAlive) return Error.InvalidClass; string signature; string genericSignature; error = environment.GetClassSignature(arrayTypeHandle.Value, out signature, out genericSignature); if (error != jvmtiError.None) return GetStandardError(error); jobject array; switch (signature[1]) { case 'Z': array = nativeEnvironment.NewBooleanArray(length); break; case 'B': array = nativeEnvironment.NewByteArray(length); break; case 'C': array = nativeEnvironment.NewCharArray(length); break; case 'D': array = nativeEnvironment.NewDoubleArray(length); break; case 'F': array = nativeEnvironment.NewFloatArray(length); break; case 'I': array = nativeEnvironment.NewIntegerArray(length); break; case 'J': array = nativeEnvironment.NewLongArray(length); break; case 'S': array = nativeEnvironment.NewShortArray(length); break; case '[': case 'L': throw new NotImplementedException(); //array = nativeEnvironment.NewObjectArray(length, elementType, jobject.Null); //break; case 'V': default: throw new FormatException(); } if (array == jobject.Null) throw new NotImplementedException(); newArray = VirtualMachine.TrackLocalObjectReference(array, environment, nativeEnvironment, false); VirtualMachine.AddGlobalReference(environment, nativeEnvironment, array); nativeEnvironment.DeleteLocalReference(array); return Error.None; } }
internal ArrayType GetMirrorOf(ArrayTypeId arrayTypeId) { if (arrayTypeId == default(ArrayTypeId)) return null; return new ArrayType(this, arrayTypeId); }