Skip to content

Commit

Permalink
Correct translation of bottom-up hierarchical references
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
  • Loading branch information
mballance committed Jul 3, 2024
1 parent 33eea62 commit 3ca706e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
14 changes: 9 additions & 5 deletions src/TaskBuildExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ void TaskBuildExpr::visitExprRefPathContext(ast::IExprRefPathContext *i) {
}

if (i->getHier_id()->getElems().size() > 1) {
DEBUG("Building out result of mkRootFieldRef");
DEBUG("Building out result of mkRootFieldRef(idx=%d size=%d)",
root_ref.second, i->getHier_id()->getElems().size());
m_expr = buildRefExpr(
root_ref.first,
i,
Expand Down Expand Up @@ -861,10 +862,13 @@ vsc::dm::ITypeExpr *TaskBuildExpr::buildRefExpr(
ast::IExprRefPathContext *i,
int32_t idx,
ast::IScopeChild *ast_scope) {
DEBUG_ENTER("buildRefExpr idx=%d offset=%d", idx, i->getHier_id()->getElems().at(idx)->getTarget());
DEBUG_ENTER("buildRefExpr idx=%d offset=%d",
idx,
i->getHier_id()->getElems().at(idx)->getTarget());

// Build this expression level
ast::IExprMemberPathElem *elem = i->getHier_id()->getElems().at(idx).get();
DEBUG("elem: %s", elem->getId()->getId().c_str());

vsc::dm::ITypeExpr *expr = 0;

Expand Down Expand Up @@ -926,7 +930,7 @@ vsc::dm::ITypeExpr *TaskBuildExpr::buildRefExpr(

// if (idx > 1) {
std::string ast_scope_name = (ast_scope)?zsp::parser::TaskGetName().get(ast_scope, true):"<initial>";
std::string ast_scope_name_n = zsp::parser::TaskGetName().get(res.target, true);
std::string ast_scope_name_n = (res.target)?zsp::parser::TaskGetName().get(res.target, true):"<unknown>";
DEBUG("SubField: scope=%s target=%d super=%d new_scope=%s",
ast_scope_name.c_str(),
elem->getTarget(),
Expand All @@ -940,8 +944,8 @@ vsc::dm::ITypeExpr *TaskBuildExpr::buildRefExpr(
res.index);

DEBUG("Source ast_scope: %s ; next_ast_scope: %s",
zsp::parser::TaskGetName().get(ast_scope).c_str(),
zsp::parser::TaskGetName().get(res.target).c_str());
(ast_scope)?zsp::parser::TaskGetName().get(ast_scope).c_str():"<unknown>",
(res.target)?zsp::parser::TaskGetName().get(res.target).c_str():"<unknown>");
ast_scope = res.target;

if (elem->getSubscript()) {
Expand Down
21 changes: 17 additions & 4 deletions src/TaskCalculateFieldOffset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ void TaskCalculateFieldOffset::visitDataTypeUserDefined(ast::IDataTypeUserDefine
}

void TaskCalculateFieldOffset::visitField(ast::IField *i) {
DEBUG_ENTER("visitField");
m_field_cnt++;
DEBUG_ENTER("visitField %s super_idx=%d super_depth=%d m_field_idx=%d m_field_cnt=%d",
i->getName()->getId().c_str(), m_super_idx, m_super_depth, m_field_idx, m_field_cnt);
if (!m_depth) {
i->getType()->accept(m_this);
} else {
m_field_cnt++;
}
DEBUG_LEAVE("visitField");
}

Expand All @@ -87,13 +92,21 @@ void TaskCalculateFieldOffset::visitFieldCompRef(ast::IFieldCompRef *i) {

void TaskCalculateFieldOffset::visitFieldRef(ast::IFieldRef *i) {
DEBUG_ENTER("visitFieldFieldRef");
m_field_cnt++;
if (!m_depth) {
i->getType()->accept(m_this);
} else {
m_field_cnt++;
}
DEBUG_LEAVE("visitFieldFieldRef");
}

void TaskCalculateFieldOffset::visitFieldClaim(ast::IFieldClaim *i) {
DEBUG_ENTER("visitFieldFieldClaim");
m_field_cnt++;
if (!m_depth) {
i->getType()->accept(m_this);
} else {
m_field_cnt++;
}
DEBUG_LEAVE("visitFieldFieldClaim");
}

Expand Down

0 comments on commit 3ca706e

Please sign in to comment.