public virtual IDebugVariable[] GetChildren(DebugVariableLinkCollection collection, IDebugVariable parent) { // Get the array. if (parent.Value is CsvArray array) { // Get the values. IDebugVariable[] children = new IDebugVariable[array.Values.Length]; for (int i = 0; i < children.Length; i++) { children[i] = GetChildDebugVariable(collection, array.Values[i], "[" + i + "]"); collection.Add(children[i]); } // Done return(children); } // Get the vector. else if (parent.Value is CsvVector vector) { var x = GetChildDebugVariable(collection, new CsvNumber(vector.Value.X), "X"); var y = GetChildDebugVariable(collection, new CsvNumber(vector.Value.Y), "Y"); var z = GetChildDebugVariable(collection, new CsvNumber(vector.Value.Z), "Z"); collection.Add(x); collection.Add(y); collection.Add(z); return(new IDebugVariable[] { x, y, z }); } return(new LinkableDebugVariable[0]); }
/// <summary>Evaluates an expression.</summary> public EvaluateResponse Evaluate(EvaluateArgs args) { if (args.context == "clipboard") { return new EvaluateResponse() { result = ClipboardEvaluation[args.expression] } } ; string[] path = args.expression.Split('.'); // Get the first variable. IDebugVariable current = Variables.FirstOrDefault(v => v.IsRoot && v.Name == path[0]); if (current == null) { return(EvaluateResponse.Empty); } // Get the rest of the path. for (int i = 1; i < path.Length; i++) { current = current.Resolver.GetChildren(this, current).FirstOrDefault(v => v.Name == path[i]); if (current == null) { return(EvaluateResponse.Empty); } } return(current.Resolver.GetEvaluation(this, current)); }
public DBPVariable GetVariable(DebugVariableLinkCollection collection, IDebugVariable debugVariable) { // Return null if there is no value. if (debugVariable.Value == null) { return(null); } // Create the variable. DBPVariable variable = GetProtocolVariable(debugVariable); // Add the clipboard value copy. variable.evaluateName = collection.AddClipboardKey(debugVariable.Name, debugVariable.Value.AsOSTWExpression()); // If the value is an array, assign a reference. if (debugVariable.Value is CsvArray array) { variable.indexedVariables = array.Values.Length; variable.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable); } // If the value is a vector, assign a reference. else if (debugVariable.Value is CsvVector vector) { variable.namedVariables = 3; // X, Y, and Z. variable.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable); } return(variable); }
public EvaluateResponse GetEvaluation(DebugVariableLinkCollection collection, IDebugVariable debugVariable) { // Return null if there is no value. if (debugVariable.Value == null) { return(EvaluateResponse.Empty); } // Create the evaluation response. EvaluateResponse response = new EvaluateResponse(collection, debugVariable); // Array if (debugVariable.Value is CsvArray array) { response.indexedVariables = array.Values.Length; response.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable); } // Vector else if (debugVariable.Value is CsvVector) { response.namedVariables = 3; response.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable); } return(response); }
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); }
public DBPVariable(IDebugVariable variable, string typeString = null) { name = variable.Name; type = variable.Type; value = variable.Value.ToString(); if (typeString != null) { value += " {" + typeString + "}"; } }
public EvaluateResponse GetEvaluation(DebugVariableLinkCollection collection, IDebugVariable debugVariable) { // Return null if there is no value. if (debugVariable.Value == null) { return(EvaluateResponse.Empty); } // Create the evaluation response. IDebugVariable.ApplyReference(collection, debugVariable); EvaluateResponse response = new EvaluateResponse(collection, debugVariable); response.namedVariables = Class.ObjectVariables.Count; return(response); }
public DBPVariable GetVariable(DebugVariableLinkCollection collection, IDebugVariable debugVariable) { // Return null if there is no value. if (debugVariable.Value == null) { return(null); } // Create the variable. DBPVariable variable = new DBPVariable(debugVariable, Class.Name); variable.namedVariables = Class.ObjectVariables.Count; variable.variablesReference = IDebugVariable.ApplyReference(collection, debugVariable); return(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); }
public void Add(IDebugVariable variable) { Variables.Add(variable); }
protected override DBPVariable GetProtocolVariable(IDebugVariable variable) => new DBPVariable(variable, _arrayOfTypeName + "[]");
protected virtual DBPVariable GetProtocolVariable(IDebugVariable variable) => new DBPVariable(variable);
public EvaluateResponse(DebugVariableLinkCollection collection, IDebugVariable variable) { type = variable.Type; result = variable.Value.ToString(); collection.References.TryGetValue(variable, out variablesReference); }
public DBPVariable(IDebugVariable variable) { name = variable.Name; type = variable.Type; value = variable.Value.ToString(); }