Skip to content

Commit

Permalink
XX
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 Nov 5, 2023
1 parent c93fcb6 commit bbdd8a1
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/TaskCollectDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class TaskCollectDeclarations : public virtual ast::VisitorBase {
private:
void duplicateSymbolDeclError(
ast::IScopeChild *new_sym,
ast::IScopeChild *ex_sym);;;;
ast::IScopeChild *ex_sym);

private:
IMarkerListener *m_listener;
Expand Down
87 changes: 85 additions & 2 deletions src/TaskCompareParamLists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,92 @@ bool TaskCompareParamLists::equal(
const ast::ITemplateParamDeclList *plist1,
const ast::ITemplateParamDeclList *plist2) {
DEBUG_ENTER("equal");
if (plist1->getParams().size() != plist2->getParams().size()) {
DEBUG("Sizes differ: %d vs %d",
plist1->getParams().size(),
plist2->getParams().size());
return false;
}
m_plist1 = plist1;
m_plist2 = plist2;

DEBUG_LEAVE("equal");
return false;

bool ret = true;
ast::ITemplateGenericTypeParamDecl *type_value[2];
ast::ITemplateValueParamDecl *expr_value[2];
for (m_idx=0; m_idx<plist1->getParams().size(); m_idx++) {
for (uint32_t i=0; i<2; i++) {
m_type_value = 0;
m_expr_value = 0;
((i)?plist2:plist1)->getParams().at(m_idx)->accept(m_this);
type_value[i] = m_type_value;
expr_value[i] = m_expr_value;
}

DEBUG("type_value={%p,%p} expr_value={%p,%p}",
type_value[0], type_value[1],
expr_value[0], expr_value[1]);
if ((!type_value[0] != !type_value[1]) || (!expr_value[0] != !expr_value[1])) {
ret = false;
break;
}

// How do we compare?
if (type_value[0]) {
type_value[0]->getDflt()->accept(m_this);
} else if (expr_value[0] && expr_value[0]->getDflt()) {
expr_value[0]->getDflt()->accept(m_this);
} else {
DEBUG("FATAL: didn't hit anything");
ret = false;
break;
}
}

DEBUG_LEAVE("equal %d", ret);
return ret;
}

void TaskCompareParamLists::visitExpr(ast::IExpr *i) {
DEBUG_ENTER("visitExpr");

DEBUG_LEAVE("visitExpr");
}

void TaskCompareParamLists::visitSymbolTypeScope(ast::ISymbolTypeScope *i) {
DEBUG_ENTER("visitSymbolTypeScope");
DEBUG("this=%p other=%p", i, m_type_value);
DEBUG_LEAVE("visitSymbolTypeScope");
}

void TaskCompareParamLists::visitTemplateGenericTypeParamDecl(ast::ITemplateGenericTypeParamDecl *i) {
DEBUG_ENTER("visitTemplateGenericTypeParamDecl");
m_type_value = i;
DEBUG_LEAVE("visitTemplateGenericTypeParamDecl");
}

void TaskCompareParamLists::visitTemplateCategoryTypeParamDecl(ast::ITemplateCategoryTypeParamDecl *i) {
DEBUG_ENTER("visitTemplateCategoryTypeParamDecl");

DEBUG_LEAVE("visitTemplateCategoryTypeParamDecl");
}

void TaskCompareParamLists::visitTemplateValueParamDecl(ast::ITemplateValueParamDecl *i) {
DEBUG_ENTER("visitTemplateValueParamDecl dflt=%p", i->getDflt());
m_expr_value = i;
DEBUG_LEAVE("visitTemplateValueParamDecl");
}

void TaskCompareParamLists::visitTemplateParamTypeValue(ast::ITemplateParamTypeValue *i) {
DEBUG_ENTER("visitTemplateParamTypeValue");

DEBUG_LEAVE("visitTemplateParamTypeValue");
}

void TaskCompareParamLists::visitTemplateParamExprValue(ast::ITemplateParamExprValue *i) {
DEBUG_ENTER("visitTemplateParamExprValue");

DEBUG_LEAVE("visitTemplateParamExprValue");
}

dmgr::IDebug *TaskCompareParamLists::m_dbg = 0;
Expand Down
20 changes: 20 additions & 0 deletions src/TaskCompareParamLists.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,28 @@ class TaskCompareParamLists : public ast::VisitorBase {
const ast::ITemplateParamDeclList *plist1,
const ast::ITemplateParamDeclList *plist2);

virtual void visitExpr(ast::IExpr *i) override;

virtual void visitSymbolTypeScope(ast::ISymbolTypeScope *i) override;

virtual void visitTemplateGenericTypeParamDecl(ast::ITemplateGenericTypeParamDecl *i) override;

virtual void visitTemplateCategoryTypeParamDecl(ast::ITemplateCategoryTypeParamDecl *i) override;

virtual void visitTemplateValueParamDecl(ast::ITemplateValueParamDecl *i) override;

virtual void visitTemplateParamTypeValue(ast::ITemplateParamTypeValue *i) override;

virtual void visitTemplateParamExprValue(ast::ITemplateParamExprValue *i) override;

private:
static dmgr::IDebug *m_dbg;
uint32_t m_idx;
uint32_t m_phase;
ast::ITemplateGenericTypeParamDecl *m_type_value;
ast::ITemplateValueParamDecl *m_expr_value;
const ast::ITemplateParamDeclList *m_plist1;
const ast::ITemplateParamDeclList *m_plist2;

};

Expand Down
2 changes: 1 addition & 1 deletion src/TaskResolveRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void TaskResolveRef::visitSymbolFunctionScope(ast::ISymbolFunctionScope *i) {
}

void TaskResolveRef::visitTypeIdentifier(ast::ITypeIdentifier *i) {
DEBUG_ENTER("visitTypeIdentifier");
DEBUG_ENTER("visitTypeIdentifier %s", i->getElems().at(0)->getId()->getId().c_str());
// Find the first element

ISymbolTableIterator *it = m_symtab_it_s.back().get();
Expand Down
68 changes: 68 additions & 0 deletions src/TaskResolveRootRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ ast::ISymbolRefPath *TaskResolveRootRef::resolve(
return m_ref;
}

void TaskResolveRootRef::visitEnumDecl(ast::IEnumDecl *i) {
DEBUG_ENTER("visitEnumDecl");
for (std::vector<ast::IEnumItemUP>::const_iterator
it=i->getItems().begin();
it!=i->getItems().end(); it++) {
DEBUG("Enum Item: %s", (*it)->getName()->getId().c_str());
if ((*it)->getName()->getId() == m_id->getId()) {
DEBUG("Found!!");
break;
}
}
DEBUG_LEAVE("visitEnumDecl");
}

void TaskResolveRootRef::visitEnumItem(ast::IEnumItem *i) {

}

void TaskResolveRootRef::visitSymbolScope(ast::ISymbolScope *i) {
DEBUG_ENTER("visitSymbolScope id=%s (%s)",
m_id->getId().c_str(), i->getName().c_str());
Expand All @@ -73,13 +91,50 @@ void TaskResolveRootRef::visitSymbolScope(ast::ISymbolScope *i) {

// Now, add in the child element that we just found
m_ref->getPath().push_back({ast::SymbolRefPathElemKind::ElemKind_ChildIdx, it->second});
} else if ((m_ref=searchEnums(i, m_id))) {
// Found in this scope
} else if (m_search_imp && i->getImports() && (m_ref=searchImports(m_id, i->getImports()))) {
// Found in imports
}

DEBUG_LEAVE("visitSymbolScope");
}

void TaskResolveRootRef::visitSymbolEnumScope(ast::ISymbolEnumScope *i) {
DEBUG_ENTER("visitSymbolEnumScope %s (looking for %s)",
i->getName().c_str(),
m_id->getId().c_str());
std::map<std::string, int32_t>::const_iterator it =
i->getSymtab().find(m_id->getId());
if (it != i->getSymtab().end()) {
DEBUG("Found symbol %s", m_id->getId().c_str());
m_ref = m_scope->getScopeSymbolPath();

m_ref->getPath().push_back({
ast::SymbolRefPathElemKind::ElemKind_ParamIdx,
i->getIndex()
});

m_ref->getPath().push_back({
ast::SymbolRefPathElemKind::ElemKind_ParamIdx,
it->second
});
DEBUG("Path");
for (std::vector<ast::SymbolRefPathElem>::const_iterator
it=m_ref->getPath().begin();
it!=m_ref->getPath().end(); it++) {
DEBUG(" Elem: %d", it->idx);
}
fflush(stdout);
}
for (std::vector<ast::IScopeChild *>::const_iterator
it=i->getChildren().begin();
it!=i->getChildren().end(); it++) {
(*it)->accept(m_this);
}
DEBUG_LEAVE("visitSymbolEnumScope %s", i->getName().c_str());
}

void TaskResolveRootRef::visitSymbolExecScope(ast::ISymbolExecScope *i) {
DEBUG_ENTER("visitSymbolExecScope");

Expand Down Expand Up @@ -203,6 +258,19 @@ ast::ISymbolRefPath *TaskResolveRootRef::searchImport(
return ret;
}

ast::ISymbolRefPath *TaskResolveRootRef::searchEnums(
ast::ISymbolScope *i,
const ast::IExprId *id) {
DEBUG_ENTER("searchEnums %s", id->getId().c_str());
for (std::vector<ast::IScopeChild *>::const_iterator
it=i->getChildren().begin();
it!=i->getChildren().end(); it++) {
(*it)->accept(m_this);
}
DEBUG_LEAVE("searchEnums %s", id->getId().c_str());
return 0 /*m_ref*/;
}

dmgr::IDebug *TaskResolveRootRef::m_dbg = 0;

}
Expand Down
10 changes: 10 additions & 0 deletions src/TaskResolveRootRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ class TaskResolveRootRef : public ast::VisitorBase {
const ISymbolTableIterator *scope,
const ast::IExprId *id);

virtual void visitEnumDecl(ast::IEnumDecl *i) override;

virtual void visitEnumItem(ast::IEnumItem *i) override;

virtual void visitSymbolScope(ast::ISymbolScope *i) override;

virtual void visitSymbolEnumScope(ast::ISymbolEnumScope *i) override;

virtual void visitSymbolExecScope(ast::ISymbolExecScope *i) override;

virtual void visitSymbolTypeScope(ast::ISymbolTypeScope *i) override;
Expand All @@ -59,6 +65,10 @@ class TaskResolveRootRef : public ast::VisitorBase {
const ast::IExprId *id,
ast::IPackageImportStmt *imp);

ast::ISymbolRefPath *searchEnums(
ast::ISymbolScope *i,
const ast::IExprId *id);

private:
static dmgr::IDebug *m_dbg;
IMarkerUP m_marker;
Expand Down
13 changes: 11 additions & 2 deletions src/include/zsp/parser/impl/TaskCopyAst.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class TaskCopyAst : public ast::VisitorBase {
virtual void visitExecTargetTemplateParam(ast::IExecTargetTemplateParam *i) { }

virtual void visitConstraintStmt(ast::IConstraintStmt *i) { }

virtual void visitExprRefPathElem(ast::IExprRefPathElem *i) { }

virtual void visitExprStaticRefPath(ast::IExprStaticRefPath *i) {
Expand Down Expand Up @@ -365,7 +365,16 @@ class TaskCopyAst : public ast::VisitorBase {

virtual void visitConstraintScope(ast::IConstraintScope *i) { }

virtual void visitExprRefPathContext(ast::IExprRefPathContext *i) { }
virtual void visitExprRefPathContext(ast::IExprRefPathContext *i) {
ast::IExprRefPathContext *ic = m_factory->mkExprRefPathContext(
copyT<ast::IExprHierarchicalId>(i->getHier_id())
);
ic->setIs_super(i->getIs_super());
if (i->getSlice()) {
ic->setSlice(copyT<ast::IExprBitSlice>(i->getSlice()));
}
m_expr = ic;
}

virtual void visitConstraintStmtExpr(ast::IConstraintStmtExpr *i) {
m_constraint = m_factory->mkConstraintStmtExpr(
Expand Down

0 comments on commit bbdd8a1

Please sign in to comment.