mirror of
https://github.com/arabine/open-story-teller.git
synced 2025-12-06 17:09:06 +01:00
Multiple compiler and node fixes
This commit is contained in:
parent
07849e3e69
commit
d14935dd53
6 changed files with 33 additions and 4 deletions
|
|
@ -548,8 +548,9 @@ private:
|
||||||
m_functionCallParamIndex++;
|
m_functionCallParamIndex++;
|
||||||
} else {
|
} else {
|
||||||
// C'est pour un syscall (Print, etc.) → empiler sur la stack
|
// C'est pour un syscall (Print, etc.) → empiler sur la stack
|
||||||
std::string paramReg = LoadOperand(instr->GetDest(), "r0");
|
// std::string paramReg = LoadOperand(instr->GetDest(), "r0");
|
||||||
m_assembly << " push " << paramReg << "\n";
|
// m_assembly << " push " << paramReg << "\n";
|
||||||
|
m_printParams.push_back(instr->GetDest());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -430,6 +430,8 @@ private:
|
||||||
|
|
||||||
std::shared_ptr<FunctionContext> m_currentFunction;
|
std::shared_ptr<FunctionContext> m_currentFunction;
|
||||||
|
|
||||||
|
bool m_insideLoop = false;
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// HELPERS
|
// HELPERS
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
@ -683,6 +685,12 @@ private:
|
||||||
|
|
||||||
// Génération pour FunctionExitNode
|
// Génération pour FunctionExitNode
|
||||||
std::shared_ptr<TACOperand> GenerateFunctionExitNode(std::shared_ptr<ASTNode> node) {
|
std::shared_ptr<TACOperand> GenerateFunctionExitNode(std::shared_ptr<ASTNode> node) {
|
||||||
|
|
||||||
|
if (m_insideLoop) {
|
||||||
|
std::cout << " Skipping FunctionExitNode (inside loop)\n";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto* exitNode = node->GetAs<FunctionExitNode>();
|
auto* exitNode = node->GetAs<FunctionExitNode>();
|
||||||
if (!exitNode) return nullptr;
|
if (!exitNode) return nullptr;
|
||||||
|
|
||||||
|
|
@ -709,7 +717,7 @@ private:
|
||||||
nullptr
|
nullptr
|
||||||
));
|
));
|
||||||
|
|
||||||
std::cout << " Return value: " << returnValue.name << "\n";
|
std::cout << " Return value: " << returnValue.name << "\n";
|
||||||
}
|
}
|
||||||
portIndex++;
|
portIndex++;
|
||||||
}
|
}
|
||||||
|
|
@ -911,8 +919,10 @@ private:
|
||||||
// === 5. CORPS DE LA BOUCLE - CORRECTION ===
|
// === 5. CORPS DE LA BOUCLE - CORRECTION ===
|
||||||
// Générer toute la chaîne d'exécution (pas juste le premier enfant)
|
// Générer toute la chaîne d'exécution (pas juste le premier enfant)
|
||||||
if (node->GetChild(0)) {
|
if (node->GetChild(0)) {
|
||||||
|
m_insideLoop = true; // ← Marquer qu'on est dans une boucle
|
||||||
std::cout << " Generating loop body execution chain...\n";
|
std::cout << " Generating loop body execution chain...\n";
|
||||||
GenerateExecutionChain(node->GetChild(0));
|
GenerateExecutionChain(node->GetChild(0));
|
||||||
|
m_insideLoop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// === 6. LABEL loop_continue (pour Continue) ===
|
// === 6. LABEL loop_continue (pour Continue) ===
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,14 @@ public:
|
||||||
: BaseNode(type, typeName, BaseNode::Behavior::BEHAVIOR_DATA)
|
: BaseNode(type, typeName, BaseNode::Behavior::BEHAVIOR_DATA)
|
||||||
, m_operationType(OperationType::ADD)
|
, m_operationType(OperationType::ADD)
|
||||||
{
|
{
|
||||||
Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize() override {
|
void Initialize() override {
|
||||||
// Define input ports based on operator type
|
// Define input ports based on operator type
|
||||||
|
nlohmann::json j = GetInternalData();
|
||||||
|
std::string typeName = JsonReader::get<std::string>(j, "operation_type", "Equal to");
|
||||||
|
m_operationType = TypeNameToOperationType(typeName);
|
||||||
UpdatePorts();
|
UpdatePorts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,6 +85,7 @@ public:
|
||||||
void SetOperationType(OperationType type) {
|
void SetOperationType(OperationType type) {
|
||||||
m_operationType = type;
|
m_operationType = type;
|
||||||
UpdatePorts();
|
UpdatePorts();
|
||||||
|
SetInternalData({"operation_type", OperatorTypeName(m_operationType)});
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationType GetOperationType() const {
|
OperationType GetOperationType() const {
|
||||||
|
|
@ -135,4 +139,15 @@ private:
|
||||||
}
|
}
|
||||||
return OperationType::ADD; // Default to ADD if not found
|
return OperationType::ADD; // Default to ADD if not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OperationType TypeNameToOperationType(const std::string& str) const {
|
||||||
|
auto symbolMap = GetOperators();
|
||||||
|
|
||||||
|
for (const auto& pair : symbolMap) {
|
||||||
|
if (pair.second.name == str) {
|
||||||
|
return pair.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OperationType::ADD; // Default to ADD if not found
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ BranchNodeWidget::BranchNodeWidget(IStoryManager &manager, std::shared_ptr<BaseN
|
||||||
: BaseNodeWidget(manager, node)
|
: BaseNodeWidget(manager, node)
|
||||||
{
|
{
|
||||||
m_branchNode = std::dynamic_pointer_cast<BranchNode>(node);
|
m_branchNode = std::dynamic_pointer_cast<BranchNode>(node);
|
||||||
|
SetTitle("Branch");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchNodeWidget::Initialize()
|
void BranchNodeWidget::Initialize()
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ ForLoopNodeWidget::ForLoopNodeWidget(IStoryManager &manager, std::shared_ptr<Bas
|
||||||
: BaseNodeWidget(manager, base)
|
: BaseNodeWidget(manager, base)
|
||||||
{
|
{
|
||||||
m_forLoopNode = std::dynamic_pointer_cast<ForLoopNode>(base);
|
m_forLoopNode = std::dynamic_pointer_cast<ForLoopNode>(base);
|
||||||
|
SetTitle("For loop");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForLoopNodeWidget::Draw()
|
void ForLoopNodeWidget::Draw()
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ OperatorNodeWidget::OperatorNodeWidget(IStoryManager &manager, std::shared_ptr<B
|
||||||
, m_manager(manager)
|
, m_manager(manager)
|
||||||
{
|
{
|
||||||
m_opNode = std::dynamic_pointer_cast<OperatorNode>(node);
|
m_opNode = std::dynamic_pointer_cast<OperatorNode>(node);
|
||||||
|
SetTitle("Operator");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OperatorNodeWidget::Initialize()
|
void OperatorNodeWidget::Initialize()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue