Fix reference return from inlined function into inline parameter
This commit is contained in:
parent
500cce511f
commit
5b961c031c
|
@ -23498,7 +23498,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "test");
|
CheckFunc = !strcmp(mIdent->mString, "dijkstra");
|
||||||
CheckCase = false;
|
CheckCase = false;
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
|
@ -1652,6 +1652,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateInline(Declaration* pro
|
||||||
else if (vr.mType->IsReference() && !(pdec && pdec->mBase->IsReference()))
|
else if (vr.mType->IsReference() && !(pdec && pdec->mBase->IsReference()))
|
||||||
{
|
{
|
||||||
vr.mReference++;
|
vr.mReference++;
|
||||||
|
vr.mType = vr.mType->mBase;
|
||||||
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
vr = Dereference(proc, texp, block, inlineMapper, vr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1993,7 +1993,49 @@ Expression* Parser::ParseVarInitExpression(Expression* vexp, bool inner)
|
||||||
Expression* nexp = ParseVarInitExpression(qexp, true);
|
Expression* nexp = ParseVarInitExpression(qexp, true);
|
||||||
if (nexp->mType != EX_INITIALIZATION || nexp->mRight->mType != EX_CONSTANT)
|
if (nexp->mType != EX_INITIALIZATION || nexp->mRight->mType != EX_CONSTANT)
|
||||||
isconst = false;
|
isconst = false;
|
||||||
exp = nexp->ListAppend(exp);
|
if (nexp->mRight->mType == EX_PACK)
|
||||||
|
{
|
||||||
|
ConsumeToken(TK_ELLIPSIS);
|
||||||
|
Declaration* pdec = nexp->mRight->mDecValue->mParams;
|
||||||
|
nexp->mRight = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||||
|
nexp->mRight->mDecType = pdec->mBase;
|
||||||
|
nexp->mRight->mDecValue = pdec;
|
||||||
|
exp = nexp->ListAppend(exp);
|
||||||
|
|
||||||
|
pdec = pdec->mNext;
|
||||||
|
while (pdec)
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
|
||||||
|
if (index > mindex)
|
||||||
|
mindex = index;
|
||||||
|
if (index < size)
|
||||||
|
fset += index;
|
||||||
|
|
||||||
|
Expression* qexp = new Expression(mScanner->mLocation, EX_INDEX);
|
||||||
|
qexp->mLeft = vexp;
|
||||||
|
qexp->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
|
||||||
|
qexp->mRight->mDecType = TheUnsignedIntTypeDeclaration;
|
||||||
|
qexp->mRight->mDecValue = new Declaration(mScanner->mLocation, DT_CONST_INTEGER);
|
||||||
|
qexp->mRight->mDecValue->mSize = 2;
|
||||||
|
qexp->mRight->mDecValue->mInteger = index;
|
||||||
|
qexp->mRight->mDecValue->mBase = TheUnsignedIntTypeDeclaration;
|
||||||
|
qexp->mDecType = dtype->mBase;
|
||||||
|
|
||||||
|
nexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
||||||
|
nexp->mToken = TK_ASSIGN;
|
||||||
|
nexp->mLeft = qexp;
|
||||||
|
nexp->mRight = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||||
|
nexp->mRight->mDecType = pdec->mBase;
|
||||||
|
nexp->mRight->mDecValue = pdec;
|
||||||
|
nexp->mDecType = dtype->mBase;
|
||||||
|
|
||||||
|
exp = nexp->ListAppend(exp);
|
||||||
|
pdec = pdec->mNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
exp = nexp->ListAppend(exp);
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
@ -2575,6 +2617,10 @@ Expression* Parser::BuildMemberInitializer(Expression* vexp)
|
||||||
|
|
||||||
return fexp;
|
return fexp;
|
||||||
}
|
}
|
||||||
|
else if (mScanner->mToken == TK_OPEN_BRACE)
|
||||||
|
{
|
||||||
|
return ParseVarInitExpression(vexp);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Expression* nexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
Expression* nexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
||||||
|
@ -7407,6 +7453,8 @@ int Parser::OverloadDistance(Declaration* fdec, Expression* pexp)
|
||||||
return NOOVERLOAD;
|
return NOOVERLOAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ptype->mType == DT_TYPE_POINTER && etype->mType == DT_TYPE_POINTER && ptype->mBase->IsSame(etype->mBase))
|
||||||
|
;
|
||||||
else if (ptype->mType == DT_TYPE_POINTER && (etype->mType == DT_TYPE_ARRAY || etype->mType == DT_TYPE_POINTER) && ptype->mBase->IsSameMutable(etype->mBase))
|
else if (ptype->mType == DT_TYPE_POINTER && (etype->mType == DT_TYPE_ARRAY || etype->mType == DT_TYPE_POINTER) && ptype->mBase->IsSameMutable(etype->mBase))
|
||||||
dist += 2;
|
dist += 2;
|
||||||
else if (ptype->mType == DT_TYPE_POINTER && etype->mType == DT_TYPE_FUNCTION && ptype->mBase->IsSame(etype))
|
else if (ptype->mType == DT_TYPE_POINTER && etype->mType == DT_TYPE_FUNCTION && ptype->mBase->IsSame(etype))
|
||||||
|
@ -10272,6 +10320,29 @@ Expression* Parser::ParseStatement(void)
|
||||||
cexp->mDecType = containerExp->mDecType->BuildPointer(mScanner->mLocation);
|
cexp->mDecType = containerExp->mDecType->BuildPointer(mScanner->mLocation);
|
||||||
cexp->mLeft = containerExp;
|
cexp->mLeft = containerExp;
|
||||||
|
|
||||||
|
Expression* cbegin = new Expression(mScanner->mLocation, EX_CALL);
|
||||||
|
cbegin->mDecType = fbegin->mBase->mBase;
|
||||||
|
cbegin->mLeft = new Expression(mScanner->mLocation, EX_CONSTANT);
|
||||||
|
cbegin->mLeft->mDecType = fbegin->mBase;
|
||||||
|
cbegin->mLeft->mDecValue = fbegin;
|
||||||
|
cbegin->mRight = cexp;
|
||||||
|
|
||||||
|
Expression* cend = new Expression(mScanner->mLocation, EX_CALL);
|
||||||
|
cend->mDecType = fend->mBase->mBase;
|
||||||
|
cend->mLeft = new Expression(mScanner->mLocation, EX_CONSTANT);
|
||||||
|
cend->mLeft->mDecType = fend->mBase;
|
||||||
|
cend->mLeft->mDecValue = fend;
|
||||||
|
cend->mRight = cexp;
|
||||||
|
|
||||||
|
ResolveOverloadCall(cbegin);
|
||||||
|
ResolveOverloadCall(cend);
|
||||||
|
|
||||||
|
fbegin = cbegin->mLeft->mDecValue;
|
||||||
|
fend = cend->mLeft->mDecValue;
|
||||||
|
|
||||||
|
cbegin->mDecType = fbegin->mBase->mBase;
|
||||||
|
cend->mDecType = fend->mBase->mBase;
|
||||||
|
|
||||||
Declaration* iterVarDec = new Declaration(mScanner->mLocation, DT_VARIABLE);
|
Declaration* iterVarDec = new Declaration(mScanner->mLocation, DT_VARIABLE);
|
||||||
iterVarDec->mBase = fbegin->mBase->mBase->NonRefBase();
|
iterVarDec->mBase = fbegin->mBase->mBase->NonRefBase();
|
||||||
iterVarDec->mVarIndex = mLocalIndex++;
|
iterVarDec->mVarIndex = mLocalIndex++;
|
||||||
|
@ -10292,24 +10363,14 @@ Expression* Parser::ParseStatement(void)
|
||||||
initExp->mLeft->mLeft = new Expression(mScanner->mLocation, EX_VARIABLE);
|
initExp->mLeft->mLeft = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||||
initExp->mLeft->mLeft->mDecType = iterVarDec->mBase;
|
initExp->mLeft->mLeft->mDecType = iterVarDec->mBase;
|
||||||
initExp->mLeft->mLeft->mDecValue = iterVarDec;
|
initExp->mLeft->mLeft->mDecValue = iterVarDec;
|
||||||
initExp->mLeft->mRight = new Expression(mScanner->mLocation, EX_CALL);
|
initExp->mLeft->mRight = cbegin;
|
||||||
initExp->mLeft->mRight->mDecType = fbegin->mBase->mBase;
|
|
||||||
initExp->mLeft->mRight->mLeft = new Expression(mScanner->mLocation, EX_CONSTANT);
|
|
||||||
initExp->mLeft->mRight->mLeft->mDecType = fbegin->mBase;
|
|
||||||
initExp->mLeft->mRight->mLeft->mDecValue = fbegin;
|
|
||||||
initExp->mLeft->mRight->mRight = cexp;
|
|
||||||
|
|
||||||
initExp->mRight = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
initExp->mRight = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
||||||
initExp->mRight->mToken = TK_ASSIGN;
|
initExp->mRight->mToken = TK_ASSIGN;
|
||||||
initExp->mRight->mLeft = new Expression(mScanner->mLocation, EX_VARIABLE);
|
initExp->mRight->mLeft = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||||
initExp->mRight->mLeft->mDecType = endVarDec->mBase;
|
initExp->mRight->mLeft->mDecType = endVarDec->mBase;
|
||||||
initExp->mRight->mLeft->mDecValue = endVarDec;
|
initExp->mRight->mLeft->mDecValue = endVarDec;
|
||||||
initExp->mRight->mRight = new Expression(mScanner->mLocation, EX_CALL);
|
initExp->mRight->mRight = cend;
|
||||||
initExp->mRight->mRight->mDecType = fend->mBase->mBase;
|
|
||||||
initExp->mRight->mRight->mLeft = new Expression(mScanner->mLocation, EX_CONSTANT);
|
|
||||||
initExp->mRight->mRight->mLeft->mDecType = fend->mBase;
|
|
||||||
initExp->mRight->mRight->mLeft->mDecValue = fend;
|
|
||||||
initExp->mRight->mRight->mRight = cexp;
|
|
||||||
|
|
||||||
iterateExp = new Expression(mScanner->mLocation, EX_PREINCDEC);
|
iterateExp = new Expression(mScanner->mLocation, EX_PREINCDEC);
|
||||||
iterateExp->mToken = TK_INC;
|
iterateExp->mToken = TK_INC;
|
||||||
|
@ -11796,8 +11857,29 @@ void Parser::ParseTemplateDeclarationBody(Declaration * tdec, Declaration * pthi
|
||||||
|
|
||||||
if (ConsumeTokenIf(TK_COLON))
|
if (ConsumeTokenIf(TK_COLON))
|
||||||
{
|
{
|
||||||
while (mScanner->mToken != TK_OPEN_BRACE)
|
do {
|
||||||
mScanner->NextToken();
|
ConsumeToken(TK_IDENT);
|
||||||
|
if (ConsumeTokenIf(TK_OPEN_PARENTHESIS))
|
||||||
|
{
|
||||||
|
while (mScanner->mToken != TK_OPEN_PARENTHESIS)
|
||||||
|
mScanner->NextToken();
|
||||||
|
mScanner->NextToken();
|
||||||
|
}
|
||||||
|
else if (ConsumeTokenIf(TK_OPEN_BRACE))
|
||||||
|
{
|
||||||
|
int qdepth = 1;
|
||||||
|
while (qdepth)
|
||||||
|
{
|
||||||
|
if (ConsumeTokenIf(TK_OPEN_BRACE))
|
||||||
|
qdepth++;
|
||||||
|
else if (ConsumeTokenIf(TK_CLOSE_BRACE))
|
||||||
|
qdepth--;
|
||||||
|
else
|
||||||
|
mScanner->NextToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (ConsumeTokenIf(TK_COMMA));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue