fixed privates resizing

This commit is contained in:
ALEXks
2024-03-30 19:29:13 +03:00
parent d589a372a0
commit d0fa88eea2
3 changed files with 30 additions and 19 deletions

View File

@@ -276,11 +276,10 @@ static SgExpression* constructExtendedArrayRefTail(SgExpression* oldTail, const
return newTail;
}
static SgExpression* extendArrayRef(const vector<SgSymbol*>& indexes, SgExpression* expressionToExtend,
SgSymbol* newSymbol, const vector<SgExpression*>& lowBounds)
static void extendArrayRef(const vector<SgSymbol*>& indexes, SgExpression*& expressionToExtend,
SgSymbol* newSymbol, const vector<SgExpression*>& lowBounds)
{
SgExpression* newTail = constructExtendedArrayRefTail(expressionToExtend->lhs(), indexes);
SgExpression* oldTail = expressionToExtend->lhs();
if (oldTail == NULL)
{
@@ -305,8 +304,6 @@ static SgExpression* extendArrayRef(const vector<SgSymbol*>& indexes, SgExpressi
expressionToExtend->setLhs(newTail);
expressionToExtend->setSymbol(newSymbol);
}
return expressionToExtend;
}
static bool isAllocatable(SgSymbol* symbol)
@@ -348,14 +345,21 @@ static void setAllocatable(SgStatement *newDecl, SgSymbol *origSymbol)
}
static SgExpression* checkArrayDecl(SgExpression* array, SgSymbol* arraySymbol, SgStatement* checkedDecl)
{
{
if (array->lhs() == NULL)
{
vector<SgStatement*> allDecls;
auto mainDecl = declaratedInStmt(arraySymbol, &allDecls);
if (allDecls.size() < 2)
if (allDecls.size() == 0)
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
if (allDecls.size() == 1)
{
array = findSymbol(arraySymbol, mainDecl->expr(0));
checkNull(array, convertFileName(__FILE__).c_str(), __LINE__);
return array;
}
for (auto& decl : allDecls)
{
if (decl == mainDecl)
@@ -418,7 +422,7 @@ static SgSymbol* alterShrinkArrayDeclaration(SgStatement *declarationStatement,
return newArraySymbol;
}
static void extendArrayRefsInExpr(const vector<SgSymbol*>& indexes, SgExpression* expr,
static void extendArrayRefsInExpr(const vector<SgSymbol*>& indexes, SgExpression*& expr,
SgSymbol* arraySymbol, SgSymbol* newArraySymbol,
const vector<SgExpression*>& lowBounds, int line)
{
@@ -438,19 +442,20 @@ static void extendArrayRefsInExpr(const vector<SgSymbol*>& indexes, SgExpression
}
}
extendArrayRefsInExpr(indexes, expr->lhs(), arraySymbol, newArraySymbol, lowBounds, line);
extendArrayRefsInExpr(indexes, expr->rhs(), arraySymbol, newArraySymbol, lowBounds, line);
SgExpression* left = expr->lhs();
extendArrayRefsInExpr(indexes, left, arraySymbol, newArraySymbol, lowBounds, line);
if (left != expr->lhs())
expr->setLhs(left);
SgExpression* right = expr->rhs();
extendArrayRefsInExpr(indexes, right, arraySymbol, newArraySymbol, lowBounds, line);
if (right != expr->rhs())
expr->setRhs(right);
if (isArrayRef(expr) && isEqSymbols(arraySymbol, expr->symbol()))
extendArrayRef(indexes, expr, newArraySymbol, lowBounds);
else if (expr->variant() == VAR_REF && isEqSymbols(arraySymbol, expr->symbol()))
{
SgExpression* extended = extendArrayRef(indexes, expr, newArraySymbol, lowBounds);
expr->setSymbol(extended->symbol());
expr->setLhs(extended->lhs());
expr->setRhs(extended->rhs());
}
extendArrayRef(indexes, expr, newArraySymbol, lowBounds);
}
}
@@ -474,7 +479,12 @@ static void extendArrayRefs(const vector<SgSymbol*> &indexes, SgStatement *st, S
}
if (st->expr(i))
extendArrayRefsInExpr(indexes, st->expr(i), arraySymbol, newArraySymbol, lowBounds, st->lineNumber());
{
SgExpression* ex = st->expr(i);
extendArrayRefsInExpr(indexes, ex, arraySymbol, newArraySymbol, lowBounds, st->lineNumber());
if (ex != st->expr(i))
st->setExpression(i, ex);
}
}
}

View File

@@ -19,6 +19,7 @@
#include <locale>
#include <algorithm>
#include <thread>
#include <cstdint>
#include "utils.h"
#include "errors.h"

View File

@@ -1,3 +1,3 @@
#pragma once
#define VERSION_SPF "2298"
#define VERSION_SPF "2298"