1、修复二维数组解析失败问题;

This commit is contained in:
xuhong 2023-12-15 14:22:22 +08:00
parent 9299fe7b96
commit caa5512a25
1 changed files with 27 additions and 5 deletions

View File

@ -9,7 +9,7 @@ const referenceRegexQt = /^(0x[0-9a-fA-F]+)([\<a-zA-Z0-9\,\ \:\*\)\_\(]*)([\>])/
const cppReferenceRegex = /^@0x[0-9a-fA-F]+/;
const nullpointerRegex = /^0x0+\b/;
const charRegex = /^(\d+) ['"]/;
const numberRegex = /^\d+(\.\d+)?(e-\d+)?/;
const numberRegex = /^(-)?\d+(\.\d+)?(e-\d+)?/;
const pointerCombineChar = ".";
const nullTupleRegex = /^(0x[0-9a-fA-F]+)}/;
@ -96,10 +96,15 @@ function writeLogToFile(log, filePath) {
}
}
export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
addToLogQueue("xh++++++++++++++:expandValue=====xxxx1", filePath);
// addToLogQueue(`xh++++++++++++++:expandValue=====xxxx2 ${value}: ${JSON.stringify(extra)}`, filePath);
export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
addToLogQueue("debug.output::expandValue=====xxxx1", filePath);
addToLogQueue(`debug.output::expandValue=====xxxx2 ${value}: ${JSON.stringify(extra)}`, filePath);
let jsonVar = false;
if(value.indexOf("=")!=-1){
jsonVar = true;
}
const parseCString = () => {
value = value.trim();
if (value[0] != '"' && value[0] != '\'')
@ -160,6 +165,9 @@ export function expandValue(variableCreate: Function, value: string, root: strin
//解析字典json
const parseTupleOrList = () => {
addToLogQueue(`debug.output::parseTupleOrList=====xxxx10 ${value}`, filePath);
value = value.trim();
if (value[0] != '{')
return undefined;
@ -184,6 +192,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
const newValPos1 = value.indexOf("{");
const newValPos2 = value.indexOf(",");
let newValPos = newValPos1;
addToLogQueue(`debug.output::parseTupleOrList=====xxxx10 ${value}:${eqPos}: ${newValPos}: ${newValPos2}`, filePath);
if (newValPos2 != -1 && newValPos2 < newValPos1){
newValPos = newValPos2;
@ -237,6 +246,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
};
const parsePrimitive = () => {
addToLogQueue(`debug.output::parsePrimitive=====xxxx20 ${value}`, filePath);
let primitive: any;
let match;
@ -286,18 +296,29 @@ export function expandValue(variableCreate: Function, value: string, root: strin
parseValue = () => {
value = value.trim();
addToLogQueue(`debug.output::parseValue=====xxxx3 ${value}`, filePath);
if (value[0] == '"'){ //解析字符串
return parseCString();
}
else if (value[0] == '{'){ //解析字典
return parseTupleOrList();
}
else if(value.startsWith("std::vector of length")){
addToLogQueue(`debug.output::parseValue=====xxxx4 ${value}`, filePath);
const eqPos = value.indexOf("=");
value = value.substr(eqPos).trim();
addToLogQueue(`debug.output::parseValue=====xxxx5 ${value}`, filePath);
return parseValue();
}
else{
return parsePrimitive();
}
};
parseResult = (pushToStack: boolean = false) => {
addToLogQueue(`debug.output::parseResult=====xxxx30 ${value}`, filePath);
value = value.trim();
const variableMatch = resultRegex.exec(value);
if (!variableMatch)
@ -325,6 +346,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
createValue = (name, val) => {
let ref = 0;
let evaluateName;
addToLogQueue(`debug.output::parseResult=====xxxx40 ${value}`, filePath);
if (typeof val == "object") {
ref = variableCreate(val);
@ -358,7 +380,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
var tmp = value
tmp = tmp.substr(1).trim();
tmp = tmp.trim();
if(tmp[0] == '{'){
if(tmp[0] == '{' && jsonVar == true){
tmp = ",anonymous union = " + tmp;
value = tmp;
}