Skip to content

Commit

Permalink
fix missing constants in stack checker
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Jan 29, 2025
1 parent 8176d2e commit 10ff6d9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 1 addition & 3 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,7 @@ int main(string[] args) {
if (!noStackCheck) stackChecker.Evaluate(nodes);
}
catch (StackCheckerError) {
if (stackCheckerFunctions) {
stackChecker.DumpFunctions();
}
stderr.writeln("Error occured during stack checker stage");
return 1;
}

Expand Down
1 change: 0 additions & 1 deletion source/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class CompilerBackend {
}

NewConst(format("%s.sizeOf", node.name), offset);
writeln(node.name);
types ~= Type(node.name, offset, true, entries);
}

Expand Down
23 changes: 23 additions & 0 deletions source/stackCheck.d
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,26 @@ class StackChecker {
foreach (ref member ; structure) {
identifiers ~= format("%s.%s", node.name, member);
}

identifiers ~= format("%s.sizeOf", node.name);
}

void EvaluateEnum(EnumNode node) {
identifiers ~= format("%s.sizeOf", node.name);
identifiers ~= format("%s.min", node.name);
identifiers ~= format("%s.max", node.name);

foreach (ref value ; node.names) {
identifiers ~= format("%s.%s", node.name, value);
}
}

void EvaluateUnion(UnionNode node) {
identifiers ~= format("%s.sizeOf", node.name);
}

void EvaluateAlias(AliasNode node) {
identifiers ~= format("%s.sizeOf", node.to);
}

void EvaluateUnsafe(UnsafeNode node) {
Expand Down Expand Up @@ -437,6 +457,9 @@ class StackChecker {
case NodeType.Set: Pop(node, 1); break;
case NodeType.TryCatch: EvaluateTryCatch(cast(TryCatchNode) node); break;
case NodeType.Struct: EvaluateStruct(cast(StructNode) node); break;
case NodeType.Enum: EvaluateEnum(cast(EnumNode) node); break;
case NodeType.Union: EvaluateUnion(cast(UnionNode) node); break;
case NodeType.Alias: EvaluateAlias(cast(AliasNode) node); break;
case NodeType.Unsafe: EvaluateUnsafe(cast(UnsafeNode) node); break;
default: break;
}
Expand Down

0 comments on commit 10ff6d9

Please sign in to comment.