Skip to content

Commit

Permalink
Correction de GrBytecode.prettify qui affiche mal les fonctions stati…
Browse files Browse the repository at this point in the history
…ques
  • Loading branch information
Enalye committed Feb 25, 2024
1 parent 4f140a0 commit 6b6f2bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/grimoire/assembly/bytecode.d
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ final class GrBytecode {
outSignature ~= grUnmangle(type);
}

line ~= grGetPrettyFunction(primitive.name, inSignature, outSignature);
line ~= grGetPrettyFunctionBasic(primitive.name, inSignature, outSignature);
}
else {
line ~= to!string(index);
Expand Down
30 changes: 30 additions & 0 deletions source/grimoire/compiler/pretty.d
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,36 @@ string grGetPrettyFunctionCall(const string name, const GrType[] inSignature) {
return result;
}

/// Enjolive une fonction.
string grGetPrettyFunctionBasic(const string name, const GrType[] inSignature, const GrType[] outSignature) {
string result;
GrType[] signature = inSignature.dup;

result = name;

result ~= "(";

int i;
foreach (type; signature) {
result ~= grGetPrettyType(type);
if ((i + 2) <= signature.length)
result ~= ", ";
i++;
}
result ~= ")";
if (outSignature.length)
result ~= "(";
foreach (type; outSignature) {
result ~= grGetPrettyType(type);
if ((i + 2) <= outSignature.length)
result ~= ", ";
i++;
}
if (outSignature.length)
result ~= ")";
return result;
}

/// Enjolive une fonction.
string grGetPrettyFunction(const string name, const GrType[] inSignature, const GrType[] outSignature) {
import std.string : indexOf;
Expand Down

0 comments on commit 6b6f2bc

Please sign in to comment.