Add quotes to attribute names in dbj export

This commit is contained in:
drmortalwombat 2023-03-31 17:51:09 +02:00
parent 0555f3d75d
commit 4a2e417e31
2 changed files with 17 additions and 17 deletions

View File

@ -990,7 +990,7 @@ bool Compiler::WriteDbjFile(const char* filename)
ExpandingArray<Declaration*> types; ExpandingArray<Declaration*> types;
fprintf(file, "\tvariables: [\n"); fprintf(file, "\t\"variables\": [\n");
bool first = true; bool first = true;
for (int i = 0; i < mInterCodeModule->mGlobalVars.Size(); i++) for (int i = 0; i < mInterCodeModule->mGlobalVars.Size(); i++)
{ {
@ -1001,12 +1001,12 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, ",\n"); fprintf(file, ",\n");
first = false; first = false;
fprintf(file, "\t\t{name: \"%s\", start: %d, end: %d, typeid: %d}", v->mIdent->mString, v->mLinkerObject->mAddress, v->mLinkerObject->mAddress + v->mLinkerObject->mSize, types.IndexOrPush(v->mDeclaration->mBase)); fprintf(file, "\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"typeid\": %d}", v->mIdent->mString, v->mLinkerObject->mAddress, v->mLinkerObject->mAddress + v->mLinkerObject->mSize, types.IndexOrPush(v->mDeclaration->mBase));
} }
} }
fprintf(file, "\t],\n"); fprintf(file, "\t],\n");
fprintf(file, "\tfunctions: [\n"); fprintf(file, "\t\"functions\": [\n");
first = true; first = true;
for (int i = 0; i < mInterCodeModule->mProcedures.Size(); i++) for (int i = 0; i < mInterCodeModule->mProcedures.Size(); i++)
{ {
@ -1017,7 +1017,7 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, ",\n"); fprintf(file, ",\n");
first = false; first = false;
fprintf(file, "\t\t{name: \"%s\", start: %d, end: %d, typeid: %d, source: \"%s\", line: %d, lines: [\n", fprintf(file, "\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"typeid\": %d, \"source\": \"%s\", \"line\": %d, \"lines\": [\n",
p->mIdent->mString, p->mLinkerObject->mAddress, p->mLinkerObject->mAddress + p->mLinkerObject->mSize, types.IndexOrPush(p->mDeclaration->mBase), p->mIdent->mString, p->mLinkerObject->mAddress, p->mLinkerObject->mAddress + p->mLinkerObject->mSize, types.IndexOrPush(p->mDeclaration->mBase),
p->mLocation.mFileName, p->mLocation.mLine); p->mLocation.mFileName, p->mLocation.mLine);
@ -1030,7 +1030,7 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, ",\n"); fprintf(file, ",\n");
lfirst = false; lfirst = false;
fprintf(file, "\t\t\t{start: %d, end: %d, source: \"%s\", line: %d}", fprintf(file, "\t\t\t{\"start\": %d, \"end\": %d, \"source\": \"%s\", \"line\": %d}",
lo->mCodeLocations[j].mStart + lo->mAddress, lo->mCodeLocations[j].mStart + lo->mAddress,
lo->mCodeLocations[j].mEnd + lo->mAddress, lo->mCodeLocations[j].mEnd + lo->mAddress,
lo->mCodeLocations[j].mLocation.mFileName, lo->mCodeLocations[j].mLocation.mFileName,
@ -1043,7 +1043,7 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, "\t],\n"); fprintf(file, "\t],\n");
first = true; first = true;
fprintf(file, "\ttypes: [\n"); fprintf(file, "\t\"types\": [\n");
for (int i = 0; i < types.Size(); i++) for (int i = 0; i < types.Size(); i++)
{ {
if (!first) if (!first)
@ -1055,25 +1055,25 @@ bool Compiler::WriteDbjFile(const char* filename)
{ {
case DT_TYPE_INTEGER: case DT_TYPE_INTEGER:
if (dec->mFlags & DTF_SIGNED) if (dec->mFlags & DTF_SIGNED)
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"int\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"int\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
else else
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"uint\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"uint\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
break; break;
case DT_TYPE_FLOAT: case DT_TYPE_FLOAT:
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"float\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"float\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
break; break;
case DT_TYPE_BOOL: case DT_TYPE_BOOL:
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"bool\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"bool\"}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
break; break;
case DT_TYPE_ARRAY: case DT_TYPE_ARRAY:
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"array\", eid: %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize, types.IndexOrPush(dec->mBase)); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"array\", \"eid\": %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize, types.IndexOrPush(dec->mBase));
break; break;
case DT_TYPE_POINTER: case DT_TYPE_POINTER:
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"ptr\", eid: %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize, types.IndexOrPush(dec->mBase)); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"ptr\", eid: %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize, types.IndexOrPush(dec->mBase));
break; break;
case DT_TYPE_STRUCT: case DT_TYPE_STRUCT:
{ {
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d, type: \"struct\", members: [\n", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d, \"type\": \"struct\",\" members\": [\n", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
bool tfirst = true; bool tfirst = true;
Declaration* mdec = dec->mParams; Declaration* mdec = dec->mParams;
while (mdec) while (mdec)
@ -1082,7 +1082,7 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, ",\n"); fprintf(file, ",\n");
tfirst = false; tfirst = false;
fprintf(file, "\t\t\t{name: \"%s\", offset: %d, typeid: %d}", mdec->mIdent->mString, mdec->mOffset, types.IndexOrPush(mdec->mBase)); fprintf(file, "\t\t\t{\"name\": \"%s\", \"offset\": %d, \"typeid\": %d}", mdec->mIdent->mString, mdec->mOffset, types.IndexOrPush(mdec->mBase));
mdec = mdec->mNext; mdec = mdec->mNext;
} }
@ -1090,7 +1090,7 @@ bool Compiler::WriteDbjFile(const char* filename)
} }
break; break;
default: default:
fprintf(file, "\t\t{name: \"%s\", typeid: %d, size: %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize); fprintf(file, "\t\t{\"name\": \"%s\", \"typeid\": %d, \"size\": %d}", dec->mIdent ? dec->mIdent->mString : "", i, dec->mSize);
} }
} }

View File

@ -1094,7 +1094,7 @@ bool Linker::WriteMlbFile(const char* filename, TargetMachine machine)
bool Linker::WriteDbjFile(FILE* file) bool Linker::WriteDbjFile(FILE* file)
{ {
fprintf(file, "\tmemory: ["); fprintf(file, "\t\"memory\": [");
bool first = true; bool first = true;
for (int i = 0; i < mObjects.Size(); i++) for (int i = 0; i < mObjects.Size(); i++)
@ -1109,7 +1109,7 @@ bool Linker::WriteDbjFile(FILE* file)
fprintf(file, ",\n"); fprintf(file, ",\n");
first = false; first = false;
fprintf(file, "\t\t{name: \"%s\", start: %d, end: %d, type: \"%s\", source: \"%s\", line: %d }", fprintf(file, "\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"type\": \"%s\", \"source\": \"%s\", \"line\": %d }",
obj->mIdent->mString, obj->mAddress, obj->mAddress + obj->mSize, LinkerObjectTypeNames[obj->mType], obj->mIdent->mString, obj->mAddress, obj->mAddress + obj->mSize, LinkerObjectTypeNames[obj->mType],
obj->mLocation.mFileName, obj->mLocation.mLine); obj->mLocation.mFileName, obj->mLocation.mLine);
} }