Step 138: type-aware code generation

This commit is contained in:
Bill
2026-02-09 17:35:17 -07:00
parent 4bfaaa6cce
commit dcd44d26ed
6 changed files with 89 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "ProjectionGenerator.h"
#include "../TypeAwareMappings.h"
class CppGenerator : public ProjectionGenerator {
public:
@@ -106,6 +107,13 @@ public:
typeStr = generate(type);
}
auto initializer = variable->getChild("initializer");
if (!type && initializer && initializer->conceptType == "FunctionCall") {
auto* call = static_cast<const FunctionCall*>(initializer);
std::string mapped = mapTypeForFunctionCall("cpp", call->functionName);
if (!mapped.empty()) typeStr = mapped;
}
// Check enclosing function for memory annotations that affect variable types
std::string wrapper = getMemoryTypeWrapper(variable);
if (!wrapper.empty()) {
@@ -113,8 +121,6 @@ public:
} else {
oss << typeStr << " " << variable->name;
}
auto initializer = variable->getChild("initializer");
if (initializer) {
oss << " = " << generate(initializer);
}