コード例 #1
0
        public IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent)
        {
            // The class reference of the parent variable.
            int reference = (int)((CsvNumber)parent.Value).Value;

            IDebugVariable[] variables = new IDebugVariable[Class.ObjectVariables.Count];
            for (int i = 0; i < variables.Length; i++)
            {
                CsvPart value = new CsvNull();

                // Get the related object variable array.
                var objectVariableArray = collection.ActionStream.Variables.FirstOrDefault(v => v.Name == ClassData.ObjectVariableTag + i);
                if (objectVariableArray != null && objectVariableArray.Value is Csv.CsvArray csvArray)
                {
                    value = csvArray.Values[reference];
                }

                variables[i] = new ChildDebugVariable(
                    // Child variable resolver
                    Class.ObjectVariables[i].Variable.Type()?.DebugVariableResolver ?? new DefaultResolver(),
                    // Value
                    value,
                    // Name
                    Class.ObjectVariables[i].Variable.Name,
                    // Type
                    Class.ObjectVariables[i].Variable.Type()?.GetName() ?? "define"
                    );
                collection.Add(variables[i]);
            }

            return(variables);
        }
コード例 #2
0
        public void Apply(DebuggerActionSetResult actionStream)
        {
            ActionStream = actionStream;

            // Reset the variables list.
            Variables = new List <IDebugVariable>(LinkableVariables);

            // Reset the references.
            References.Clear();
            _currentReference = 0;

            // Add scope references.
            References.Add(_variablesScope, GetReference());
            References.Add(_rawScope, GetReference());
            _rawScope.Variables.Clear();

            foreach (LinkableDebugVariable variable in LinkableVariables)
            {
                // Reset the obtained variable.
                variable.ResetStreamVariable();

                // Make sure the set matches.
                if (variable.Variable.IsGlobal == (actionStream.Set == DebuggerActionStreamSet.Global))
                {
                    // Get the related variable
                    foreach (var debuggerVariable in actionStream.Variables)
                    {
                        if (debuggerVariable.Name == variable.Variable.Name)
                        {
                            variable.SetStreamVariable(debuggerVariable);
                            break;
                        }
                    }
                }
            }

            // Raw variables
            foreach (var value in actionStream.Variables)
            {
                var variable = new ChildDebugVariable(new DefaultResolver(), value.Value, value.Name, null);
                Add(variable);
                _rawScope.Variables.Add(variable);
            }
        }
        public IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent)
        {
            // Use the default resolver if the value is not a number.
            if (parent.Value is CsvNumber == false)
            {
                return(new DefaultResolver().GetChildren(collection, parent));
            }

            // The class reference of the parent variable.
            int reference = (int)((CsvNumber)parent.Value).Value;

            IDebugVariable[] variables = new IDebugVariable[Class.Variables.Length];
            for (int i = 0; i < variables.Length; i++)
            {
                CsvPart value = new CsvNull();

                // Get the related object variable array.
                var objectVariableArray = collection.ActionStream.Variables.FirstOrDefault(v => v.Name == ClassData.ObjectVariableTag + i);
                if (objectVariableArray != null && objectVariableArray.Value is Csv.CsvArray csvArray && reference < csvArray.Values.Length)
                {
                    value = csvArray.Values[reference];
                }

                var type = Class.Variables[i].CodeType.GetCodeType(_deltinScript);

                variables[i] = new ChildDebugVariable(
                    // Child variable resolver
                    type.DebugVariableResolver ?? new DefaultResolver(),
                    // Value
                    value,
                    // Name
                    Class.Variables[i].Name,
                    // Type
                    type.GetName()
                    );
                collection.Add(variables[i]);
            }

            return(variables);
        }