MCPcopy Create free account
hub / github.com/WebFreak001/code-debug / valueOf

Method valueOf

src/backend/mi_parse.ts:80–124  ·  view source on GitHub ↗
(start: any, path: string)

Source from the content-addressed store, hash-verified

78 }
79
80 static valueOf(start: any, path: string): any {
81 if (!start)
82 return undefined;
83 const pathRegex = /^\.?([a-zA-Z_\-][a-zA-Z0-9_\-]*)/;
84 const indexRegex = /^\[(\d+)\](?:$|\.)/;
85 path = path.trim();
86 if (!path)
87 return start;
88 let current = start;
89 do {
90 let target = pathRegex.exec(path);
91 if (target) {
92 path = path.substring(target[0].length);
93 if (current.length && typeof current != "string") {
94 const found = [];
95 for (const element of current) {
96 if (element[0] == target[1]) {
97 found.push(element[1]);
98 }
99 }
100 if (found.length > 1) {
101 current = found;
102 } else if (found.length == 1) {
103 current = found[0];
104 } else return undefined;
105 } else return undefined;
106 } else if (path[0] == '@') {
107 current = [current];
108 path = path.substring(1);
109 } else {
110 target = indexRegex.exec(path);
111 if (target) {
112 path = path.substring(target[0].length);
113 const i = parseInt(target[1]);
114 if (current.length && typeof current != "string" && i >= 0 && i < current.length) {
115 current = current[i];
116 } else if (i == 0) {
117 // empty
118 } else return undefined;
119 } else return undefined;
120 }
121 path = path.trim();
122 } while (path);
123 return current;
124 }
125}
126
127const tokenRegex = /^\d+/;

Callers 12

variablesRequestMethod · 0.80
recordMethod · 0.80
resultMethod · 0.80
expandValueFunction · 0.80
constructorMethod · 0.80
applyChangesMethod · 0.80
getThreadsMethod · 0.80
getStackMethod · 0.80
getStackVariablesMethod · 0.80
getRegisterValuesMethod · 0.80
addToStackMethod · 0.80
mi_parse.test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected