Fix template function included multiple ways
This commit is contained in:
parent
da9b8f2a42
commit
e9afd5e284
|
@ -1407,6 +1407,18 @@ Declaration* Declaration::ToMutableType(void)
|
|||
return mMutable;
|
||||
}
|
||||
|
||||
bool Declaration::IsSameTemplate(const Declaration* dec) const
|
||||
{
|
||||
if (this == dec)
|
||||
return true;
|
||||
if (this->mType != mType)
|
||||
return false;
|
||||
|
||||
if (mType == DT_CONST_FUNCTION)
|
||||
return mBase->IsSame(dec->mBase);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Declaration::IsSubType(const Declaration* dec) const
|
||||
{
|
||||
|
@ -1731,6 +1743,10 @@ bool Declaration::IsSame(const Declaration* dec) const
|
|||
|
||||
return true;
|
||||
}
|
||||
else if (mType == DT_TYPE_TEMPLATE)
|
||||
{
|
||||
return mIdent == dec->mIdent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -287,6 +287,7 @@ public:
|
|||
|
||||
bool IsTemplateSame(const Declaration* dec, const Declaration* tdec) const;
|
||||
bool IsTemplateSameParams(const Declaration* dec, const Declaration* tdec) const;
|
||||
bool IsSameTemplate(const Declaration* dec) const;
|
||||
|
||||
bool IsIntegerType(void) const;
|
||||
bool IsNumericType(void) const;
|
||||
|
|
|
@ -1297,6 +1297,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
|||
InterInstruction* psins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||
psins->mDst.mType = IT_POINTER;
|
||||
psins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||
psins->mDst.mOperandSize = 2;
|
||||
psins->mConst.mType = IT_POINTER;
|
||||
psins->mConst.mVarIndex = 0;
|
||||
psins->mConst.mIntConst = 0;
|
||||
|
@ -1321,6 +1322,7 @@ void InterCodeGenerator::CopyStruct(InterCodeProcedure* proc, Expression* exp, I
|
|||
InterInstruction* plins = new InterInstruction(exp->mLocation, IC_CONSTANT);
|
||||
plins->mDst.mType = IT_POINTER;
|
||||
plins->mDst.mTemp = proc->AddTemporary(IT_POINTER);
|
||||
plins->mDst.mOperandSize = 2;
|
||||
plins->mConst.mType = IT_POINTER;
|
||||
plins->mConst.mVarIndex = 2;
|
||||
plins->mConst.mIntConst = 0;
|
||||
|
|
|
@ -7812,8 +7812,18 @@ void Parser::ParseTemplateDeclaration(void)
|
|||
Declaration* pdec = mCompilationUnits->mScope->Insert(tdec->mQualIdent, tdec->mBase);
|
||||
if (pdec)
|
||||
{
|
||||
tdec->mBase->mNext = pdec->mNext;
|
||||
pdec->mNext = tdec->mBase;
|
||||
Declaration* ppdec = pdec;
|
||||
while (pdec && !pdec->IsSameTemplate(tdec->mBase))
|
||||
{
|
||||
ppdec = pdec;
|
||||
pdec = pdec->mNext;
|
||||
}
|
||||
|
||||
if (!pdec)
|
||||
{
|
||||
ppdec->mNext = tdec->mBase;
|
||||
tdec->mBase->mNext = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue