public override object ParseFromStorage(StorageManager storageManager, StorageLocation storageLocation, IJsonRpcClient rpcClient = null) { // Create our result array var results = new VariableValuePair[Members.Length]; // Loop for each result we need to evaluate for (int i = 0; i < Members.Length; i++) { // Define our member's definite storage location (this struct's location + the member's static location). StorageLocation memberLocation = new StorageLocation(storageLocation.SlotKeyInteger + Members[i].StorageLocation.SlotKeyInteger, storageLocation.DataOffset + Members[i].StorageLocation.DataOffset); // Parse our result for our indexed variable. results[i] = new VariableValuePair(Members[i], Members[i].ValueParser.ParseFromStorage(storageManager, memberLocation, rpcClient)); } return(results); }
public override object ParseDereferencedFromMemory(Memory <byte> memory, int offset) { // Create our result array var results = new VariableValuePair[Members.Length]; // Loop for each result we need to evaluate for (int i = 0; i < Members.Length; i++) { // Set our indexed result results[i] = new VariableValuePair(Members[i], Members[i].ValueParser.ParseFromMemory(memory, offset)); // Advance our offset offset += UInt256.SIZE; } return(results); }
public override void Visit(VariableValuePair node) { this.action(node); }
public override void ExplicitVisit(VariableValuePair fragment) { _fragments.Add(fragment); }
void ResolveVariables( List <Variable> variableList, int variablesReference, bool isLocalVariableScope, bool isStateVariableScope, bool isParentVariableScope, int traceIndex, UnderlyingVariableValuePair parentVariableValuePair, MeadowDebugAdapterThreadState threadState) { // Obtain our local variables at this point in execution VariableValuePair[] variablePairs = Array.Empty <VariableValuePair>(); if (isLocalVariableScope) { variablePairs = threadState.ExecutionTraceAnalysis.GetLocalVariables(traceIndex, threadState.RpcClient); } else if (isStateVariableScope) { variablePairs = threadState.ExecutionTraceAnalysis.GetStateVariables(traceIndex, threadState.RpcClient); } else if (isParentVariableScope) { // We're loading sub-variables for a variable. switch (parentVariableValuePair.Variable.GenericType) { case VarGenericType.Struct: { // Cast our to an enumerable type. variablePairs = ((IEnumerable <VariableValuePair>)parentVariableValuePair.Value).ToArray(); break; } case VarGenericType.Array: { // Cast our variable var arrayVariable = ((VarArray)parentVariableValuePair.Variable); // Cast to an object array. var arrayValue = (object[])parentVariableValuePair.Value; // Loop for each element for (int i = 0; i < arrayValue.Length; i++) { // Create an underlying variable value pair for this element var underlyingVariableValuePair = new UnderlyingVariableValuePair(arrayVariable.ElementObject, arrayValue[i]); // Check if this is a nested variable type bool nestedType = IsNestedVariableType(arrayVariable.ElementObject.GenericType); int variablePairReferenceId = 0; if (nestedType) { // Create a new reference id for this variable if it's a nested type. variablePairReferenceId = ReferenceContainer.GetUniqueId(); // Link our reference for any nested types. ReferenceContainer.LinkSubVariableReference(variablesReference, variablePairReferenceId, threadState.ThreadId, underlyingVariableValuePair); } // Obtain the value string for this variable and add it to our list. string variableValueString = GetVariableValueString(underlyingVariableValuePair); variableList.Add(CreateVariable($"[{i}]", variableValueString, variablePairReferenceId, underlyingVariableValuePair.Variable.BaseType)); } break; } case VarGenericType.ByteArrayDynamic: case VarGenericType.ByteArrayFixed: { // Cast our to an enumerable type. var bytes = (Memory <byte>)parentVariableValuePair.Value; for (int i = 0; i < bytes.Length; i++) { variableList.Add(CreateVariable($"[{i}]", bytes.Span[i].ToString(CultureInfo.InvariantCulture), 0, "byte")); } break; } case VarGenericType.Mapping: { // Obtain our mapping's key-value pairs. var mappingKeyValuePairs = (MappingKeyValuePair[])parentVariableValuePair.Value; variablePairs = new VariableValuePair[mappingKeyValuePairs.Length * 2]; // Loop for each key and value pair to add. int variableIndex = 0; for (int i = 0; i < mappingKeyValuePairs.Length; i++) { // Set our key and value in our variable value pair enumeration. variablePairs[variableIndex++] = mappingKeyValuePairs[i].Key; variablePairs[variableIndex++] = mappingKeyValuePairs[i].Value; } break; } } } // Loop for each local variables foreach (VariableValuePair variablePair in variablePairs) { // Create an underlying variable value pair for this pair. var underlyingVariableValuePair = new UnderlyingVariableValuePair(variablePair); // Check if this is a nested variable type bool nestedType = IsNestedVariableType(variablePair.Variable.GenericType); int variablePairReferenceId = 0; if (nestedType) { // Create a new reference id for this variable if it's a nested type. variablePairReferenceId = ReferenceContainer.GetUniqueId(); // Link our reference for any nested types. ReferenceContainer.LinkSubVariableReference(variablesReference, variablePairReferenceId, threadState.ThreadId, underlyingVariableValuePair); } // Obtain the value string for this variable and add it to our list. string variableValueString = GetVariableValueString(underlyingVariableValuePair); variableList.Add(CreateVariable(variablePair.Variable.Name, variableValueString, variablePairReferenceId, variablePair.Variable.BaseType)); } }