internal ArrayReference GetMirrorOf(ArrayId array) { if (array == default(ArrayId)) { return(null); } return(new ArrayReference(this, array)); }
public override void CheckSemantic(SymbolTable symbolTable, List <CompileError> errors) { ///no se pude declarar un array en función de si mismo if (ArrayId.Equals(ElementsId)) { errors.Add(new CompileError { Line = this.Line, Column = this.CharPositionInLine, ErrorMessage = "Defining a self recursive 'array' type is not allowed", Kind = ErrorKind.Semantic }); ///el nodo evalúa de error NodeInfo = SemanticInfo.SemanticError; } SemanticInfo elementsTypeInfo; ///el tipo de los elementos del array tiene que existir if (!symbolTable.GetDefinedTypeDeep(ElementsId, out elementsTypeInfo)) { errors.Add(new CompileError { Line = GetChild(1).Line, Column = Line = GetChild(1).CharPositionInLine, ErrorMessage = string.Format("Type '{0}' could not be found in current context", ElementsId), Kind = ErrorKind.Semantic }); ///el nodo evalúa de error NodeInfo = SemanticInfo.SemanticError; } ///si no ha evaluado de error le seteamos los valores if (!Object.Equals(NodeInfo, SemanticInfo.SemanticError)) { NodeInfo.BuiltInType = BuiltInType.Void; NodeInfo.Type = SemanticInfo.Void; } SemanticInfo arrayAlias; symbolTable.GetDefinedTypeShallow(ArrayId, out arrayAlias); arrayAlias.BuiltInType = BuiltInType.Array; arrayAlias.IsPending = false; arrayAlias.Type = arrayAlias; arrayAlias.ElementsType = elementsTypeInfo; NodeInfo.ElementsType = arrayAlias.ElementsType; }
internal ArrayReference(VirtualMachine virtualMachine, ArrayId arrayId, IReferenceType arrayType) : base(virtualMachine, arrayId, arrayType) { Contract.Requires(virtualMachine != null); }
public ArrayStructure() { _id = ++ArrayExtensions.LastestArrayId; }
public Error SetArrayValues(ArrayId arrayObject, int firstIndex, Value[] values) { throw new NotImplementedException(); }
public Error GetArrayValues(out Value[] values, ArrayId arrayObject, int firstIndex, int length) { if (length == 0) { // The JDWP implementation doesn't handle zero-length requests at the end of an array int arrayLength; Error lengthErrorCode = GetArrayLength(out arrayLength, arrayObject); if (lengthErrorCode == Error.None && arrayLength == firstIndex) { values = new Value[0]; return Error.None; } } byte[] packet = new byte[HeaderSize + ObjectIdSize + (2 * sizeof(int))]; int id = GetMessageId(); SerializeHeader(packet, id, ArrayReferenceCommand.GetValues); WriteObjectId(packet, HeaderSize, arrayObject); WriteInt32(packet, HeaderSize + ObjectIdSize, firstIndex); WriteInt32(packet, HeaderSize + ObjectIdSize + sizeof(int), length); byte[] response = SendPacket(id, packet); Error errorCode = ReadErrorCode(response); if (errorCode != Error.None) { values = null; return errorCode; } int offset = HeaderSize; // "arrayregion" Tag tag = (Tag)ReadByte(response, ref offset); int count = ReadInt32(response, ref offset); values = new Value[count]; for (int i = 0; i < count; i++) { switch (tag) { case Tag.Byte: case Tag.Char: case Tag.Float: case Tag.Double: case Tag.Int: case Tag.Long: case Tag.Short: case Tag.Boolean: values[i] = ReadUntaggedValue(response, ref offset, tag); break; case Tag.Array: case Tag.Object: case Tag.String: case Tag.Thread: case Tag.ThreadGroup: case Tag.ClassLoader: case Tag.ClassObject: values[i] = ReadValue(response, ref offset); break; case Tag.Invalid: case Tag.Void: default: throw new InvalidOperationException(); } } return Error.None; }
public Error GetArrayLength(out int arrayLength, ArrayId arrayObject) { byte[] packet = new byte[HeaderSize + ObjectIdSize]; int id = GetMessageId(); SerializeHeader(packet, id, ArrayReferenceCommand.Length); WriteObjectId(packet, HeaderSize, arrayObject); byte[] response = SendPacket(id, packet); Error errorCode = ReadErrorCode(response); if (errorCode != Error.None) { arrayLength = 0; return errorCode; } int offset = HeaderSize; arrayLength = ReadInt32(response, ref offset); return Error.None; }
internal ArrayReference(VirtualMachine virtualMachine, ArrayId arrayId, IReferenceType arrayType) : base(virtualMachine, arrayId, arrayType) { Contract.Requires(virtualMachine != null); }
public Error GetArrayValues(ArrayId arrayObject, int firstIndex, int length, out Value[] values) { values = null; try { JniEnvironment nativeEnvironment; JvmtiEnvironment environment; jvmtiError error = GetEnvironment(out environment, out nativeEnvironment); if (error != jvmtiError.None) return GetStandardError(error); using (LocalObjectReferenceHolder objectHandle = VirtualMachine.GetLocalReferenceForObject(nativeEnvironment, arrayObject)) { if (!objectHandle.IsAlive) return Error.InvalidObject; Value[] valuesArray = new Value[length]; using (LocalClassReferenceHolder declaringType = new LocalClassReferenceHolder(nativeEnvironment, nativeEnvironment.GetObjectClass(objectHandle.Value))) { string signature; string genericSignature; error = environment.GetClassSignature(declaringType.Value, out signature, out genericSignature); if (error != jvmtiError.None) return GetStandardError(error); // the array element type signature starts after the '[' Contract.Assert(signature[0] == '['); switch (signature[1]) { case 'Z': { bool[] buffer = new bool[length]; nativeEnvironment.GetBooleanArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'B': { byte[] buffer = new byte[length]; nativeEnvironment.GetByteArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'C': { char[] buffer = new char[length]; nativeEnvironment.GetCharArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'D': { double[] buffer = new double[length]; nativeEnvironment.GetDoubleArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'F': { float[] buffer = new float[length]; nativeEnvironment.GetFloatArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'I': { int[] buffer = new int[length]; nativeEnvironment.GetIntArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'J': { long[] buffer = new long[length]; nativeEnvironment.GetLongArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'S': { short[] buffer = new short[length]; nativeEnvironment.GetShortArrayRegion(objectHandle.Value, firstIndex, length, buffer); for (int i = 0; i < length; i++) valuesArray[i] = (Value)buffer[i]; break; } case 'V': return Error.InvalidFieldid; case '[': case 'L': { for (int i = 0; i < length; i++) { jobject value = nativeEnvironment.GetObjectArrayElement(objectHandle.Value, firstIndex + i); valuesArray[i] = (Value)VirtualMachine.TrackLocalObjectReference(value, environment, nativeEnvironment, true); } break; } default: throw new FormatException(); } } values = valuesArray; return Error.None; } } catch (Exception) { return Error.Internal; } }
public Error GetArrayLength(ArrayId arrayObject, out int arrayLength) { arrayLength = 0; JniEnvironment nativeEnvironment; JvmtiEnvironment environment; jvmtiError error = GetEnvironment(out environment, out nativeEnvironment); if (error != jvmtiError.None) return GetStandardError(error); using (var arrayHandle = VirtualMachine.GetLocalReferenceForObject(nativeEnvironment, arrayObject)) { if (!arrayHandle.IsAlive) return Error.InvalidObject; arrayLength = nativeEnvironment.GetArrayLength(arrayHandle.Value); return Error.None; } }
internal ArrayReference GetMirrorOf(ArrayId array) { if (array == default(ArrayId)) return null; return new ArrayReference(this, array); }