diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index 49d312e..ca49ac9 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -31,6 +31,17 @@ DeclarationScope::~DeclarationScope(void) delete[] mHash; } +DeclarationScope* DeclarationScope::Clone(void) const +{ + DeclarationScope* scope = new DeclarationScope(mParent, mLevel, mName); + for (int i = 0; i < mHashSize; i++) + { + if (mHash[i].mIdent) + scope->Insert(mHash[i].mIdent, mHash[i].mDec); + } + return scope; +} + const Ident* DeclarationScope::Mangle(const Ident* ident) const { if (mName && ident) diff --git a/oscar64/Declaration.h b/oscar64/Declaration.h index 6d6d673..9432ee9 100644 --- a/oscar64/Declaration.h +++ b/oscar64/Declaration.h @@ -166,6 +166,8 @@ public: ScopeLevel mLevel; const Ident * mName; + DeclarationScope* Clone(void) const; + DeclarationScope* mParent; protected: struct Entry diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 3e0e2e7..819c2ee 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -7483,6 +7483,21 @@ int Parser::OverloadDistance(Declaration* fdec, Expression* pexp) { dist += 32; } + else if (ptype->mType == DT_TYPE_STRUCT && etype->mType == DT_TYPE_STRUCT) + { + int ncast = 0; + Declaration* ext = ex->mDecType; + while (ext && !ext->IsConstSame(ptype)) + { + ncast++; + ext = ext->mBase; + } + + if (ext) + dist += 32 * ncast; + else + return NOOVERLOAD; + } else return NOOVERLOAD; @@ -11149,6 +11164,7 @@ Declaration* Parser::ParseTemplateExpansion(Declaration* tmpld, Declaration* exp p->mScanner->Replay(tmpld->mBase->mTokens); tdec = tmpld->mBase->Clone(); + tdec->mScope = tdec->mScope->Clone(); tdec->mScope->mName = expd->mScope->mName; tdec->mScope->mParent = expd->mScope;