Implemented new and delete operators

This commit is contained in:
drmortalwombat 2023-07-02 16:34:17 +02:00
parent 291ff890e6
commit 7f6cf654f6
6 changed files with 251 additions and 98 deletions

View File

@ -136,16 +136,19 @@ void test_member_assign(void)
int main(void) int main(void)
{ {
#if 0
test_local_init(); test_local_init();
test_member_init(); test_member_init();
#endif
test_member_array_init(); test_member_array_init();
#if 0
test_local_copy(); test_local_copy();
test_member_copy(); test_member_copy();
test_local_assign(); test_local_assign();
test_member_assign(); test_member_assign();
#endif
return 0; return 0;
} }

View File

@ -54,7 +54,6 @@ long sieve(long size)
int main(void) int main(void)
{ {
testmuli(0, 0, 0); testmuli(0, 0, 0);
testmuli(1, 0, 0); testmuli(1, 0, 0);
testmuli(0, 1, 0); testmuli(0, 1, 0);
@ -111,7 +110,6 @@ int main(void)
assert(sieve(200) == 47); assert(sieve(200) == 47);
assert(sieve(1000) == 169); assert(sieve(1000) == 169);
long a = 0, b = 0; long a = 0, b = 0;
for(long i=0; i<10000; i++) for(long i=0; i<10000; i++)
{ {

View File

@ -4115,7 +4115,6 @@ cmpne:
void HeapStart, HeapEnd; void HeapStart, HeapEnd;
bool HeapInit;
struct Heap { struct Heap {
Heap * next, * end; Heap * next, * end;
@ -4138,22 +4137,18 @@ __asm malloc
// check if heap is initialized // check if heap is initialized
lda HeapInit lda HeapNode + 2
bne hasHeap bne hasHeap
// initialize heap // initialize heap
lda #$ff
sta HeapInit
// set next pointer to null // set next pointer to null
lda #0 lda #0
sta HeapStart + 0 sta HeapStart + 0
sta HeapStart + 1 sta HeapStart + 1
// set size of dummy node to null // set size of dummy node to null
sta HeapNode + 2 inc HeapNode + 2
sta HeapNode + 3
// set next pointer of dummy node to first free heap block // set next pointer of dummy node to first free heap block
lda #<HeapStart lda #<HeapStart

View File

@ -3351,11 +3351,15 @@ bool InterInstruction::PropagateConstTemps(const GrowingInstructionPtrArray& cte
{ {
InterType t = mSrc[i].mType; InterType t = mSrc[i].mType;
InterInstruction* ains = ctemps[mSrc[i].mTemp]; InterInstruction* ains = ctemps[mSrc[i].mTemp];
if (t != IT_POINTER || ains->mConst.mMemory == IM_ABSOLUTE)
{
mSrc[i] = ains->mConst; mSrc[i] = ains->mConst;
mSrc[i].mType = t; mSrc[i].mType = t;
changed = true; changed = true;
} }
} }
}
if (changed) if (changed)
{ {
@ -14167,6 +14171,7 @@ bool InterCodeBasicBlock::PeepholeReplaceOptimization(const GrowingVariableArray
{ {
mInstructions[i + 1]->mSrc[0].mTemp = mInstructions[i + 0]->mSrc[1].mTemp; mInstructions[i + 1]->mSrc[0].mTemp = mInstructions[i + 0]->mSrc[1].mTemp;
mInstructions[i + 1]->mSrc[0].mIntConst += mInstructions[i + 0]->mSrc[0].mIntConst; mInstructions[i + 1]->mSrc[0].mIntConst += mInstructions[i + 0]->mSrc[0].mIntConst;
mInstructions[i + 1]->mSrc[0].mFinal = mInstructions[i + 0]->mSrc[1].mFinal;
mInstructions[i + 0]->mCode = IC_NONE; mInstructions[i + 0]->mCode = IC_NONE;
mInstructions[i + 0]->mNumOperands = 0; mInstructions[i + 0]->mNumOperands = 0;
changed = true; changed = true;

View File

@ -4406,8 +4406,8 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
{ {
InterCodeProcedure* proc = new InterCodeProcedure(mod, dec->mLocation, dec->mQualIdent, mLinker->AddObject(dec->mLocation, dec->mQualIdent, dec->mSection, LOT_BYTE_CODE)); InterCodeProcedure* proc = new InterCodeProcedure(mod, dec->mLocation, dec->mQualIdent, mLinker->AddObject(dec->mLocation, dec->mQualIdent, dec->mSection, LOT_BYTE_CODE));
#if 1 #if 0
if (proc->mIdent && !strcmp(proc->mIdent->mString, "test")) if (proc->mIdent && !strcmp(proc->mIdent->mString, "main"))
exp->Dump(0); exp->Dump(0);
#endif #endif
#if 0 #if 0

View File

@ -1388,9 +1388,13 @@ void Parser::PrependMemberConstructor(Declaration* pthis, Declaration* cfunc)
dexp->mLeft = cexp; dexp->mLeft = cexp;
dexp->mRight = new Expression(mScanner->mLocation, EX_LIST); dexp->mRight = new Expression(mScanner->mLocation, EX_LIST);
dexp->mRight->mLeft = qexp; dexp->mRight->mLeft = qexp;
dexp->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT); dexp->mRight->mRight = new Expression(mScanner->mLocation, EX_BINARY);
dexp->mRight->mRight->mDecType = ncdec->mBase; dexp->mRight->mRight->mToken = TK_ADD;
dexp->mRight->mRight->mDecValue = ncdec; dexp->mRight->mRight->mLeft = qexp;
dexp->mRight->mRight->mDecType = qexp->mDecType;
dexp->mRight->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
dexp->mRight->mRight->mRight->mDecType = ncdec->mBase;
dexp->mRight->mRight->mRight->mDecValue = ncdec;
} }
Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE); Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE);
@ -1993,17 +1997,18 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
ctdec->mBase = TheVoidTypeDeclaration; ctdec->mBase = TheVoidTypeDeclaration;
ctdec->mFlags |= DTF_DEFINED; ctdec->mFlags |= DTF_DEFINED;
Declaration* vthis = pthis->Clone();
vthis->mFlags &= ~DTF_CONST;
Declaration* adec = new Declaration(mScanner->mLocation, DT_ARGUMENT); Declaration* adec = new Declaration(mScanner->mLocation, DT_ARGUMENT);
adec->mVarIndex = 0; adec->mVarIndex = 0;
adec->mOffset = 0; adec->mOffset = 0;
adec->mBase = TheUnsignedIntTypeDeclaration; adec->mBase = pthis;
adec->mSize = adec->mBase->mSize; adec->mSize = adec->mBase->mSize;
adec->mIdent = adec->mQualIdent = Ident::Unique("n"); adec->mIdent = adec->mQualIdent = Ident::Unique("end");
ctdec->mParams = adec; ctdec->mParams = adec;
Declaration* vthis = pthis->Clone();
vthis->mFlags &= ~DTF_CONST;
PrependThisArgument(ctdec, vthis); PrependThisArgument(ctdec, vthis);
Declaration* cdec = new Declaration(ctdec->mLocation, DT_CONST_FUNCTION); Declaration* cdec = new Declaration(ctdec->mLocation, DT_CONST_FUNCTION);
@ -2034,17 +2039,13 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
pexp->mDecValue = ctdec->mParams; pexp->mDecValue = ctdec->mParams;
Expression* aexp = new Expression(mScanner->mLocation, EX_VARIABLE); Expression* aexp = new Expression(mScanner->mLocation, EX_VARIABLE);
aexp->mDecType = TheUnsignedIntTypeDeclaration; aexp->mDecType = pthis;
aexp->mDecValue = adec; aexp->mDecValue = adec;
Expression* iexp = new Expression(mScanner->mLocation, EX_POSTINCDEC); Expression* iexp = new Expression(mScanner->mLocation, EX_POSTINCDEC);
iexp->mToken = TK_INC; iexp->mToken = TK_INC;
iexp->mLeft = pexp; iexp->mLeft = pexp;
Expression* dexp = new Expression(mScanner->mLocation, EX_POSTINCDEC);
dexp->mToken = TK_DEC;
dexp->mLeft = aexp;
Expression* fexp = new Expression(mScanner->mLocation, EX_CONSTANT); Expression* fexp = new Expression(mScanner->mLocation, EX_CONSTANT);
fexp->mDecValue = pthis->mBase->mDefaultConstructor; fexp->mDecValue = pthis->mBase->mDefaultConstructor;
fexp->mDecType = fexp->mDecValue->mBase; fexp->mDecType = fexp->mDecValue->mBase;
@ -2054,10 +2055,12 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
cexp->mRight = iexp; cexp->mRight = iexp;
Expression * wexp = new Expression(mScanner->mLocation, EX_WHILE); Expression * wexp = new Expression(mScanner->mLocation, EX_WHILE);
wexp->mLeft = aexp; wexp->mLeft = new Expression(mScanner->mLocation, EX_RELATIONAL);
wexp->mRight = new Expression(mScanner->mLocation, EX_SEQUENCE); wexp->mLeft->mToken = TK_NOT_EQUAL;
wexp->mRight->mLeft = cexp; wexp->mLeft->mLeft = pexp;
wexp->mRight->mRight = dexp; wexp->mLeft->mRight = aexp;
wexp->mLeft->mDecType = TheBoolTypeDeclaration;
wexp->mRight = cexp;
cdec->mValue = wexp; cdec->mValue = wexp;
} }
@ -2070,17 +2073,18 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
ctdec->mBase = TheVoidTypeDeclaration; ctdec->mBase = TheVoidTypeDeclaration;
ctdec->mFlags |= DTF_DEFINED; ctdec->mFlags |= DTF_DEFINED;
Declaration* vthis = pthis->Clone();
vthis->mFlags &= ~DTF_CONST;
Declaration* adec = new Declaration(mScanner->mLocation, DT_ARGUMENT); Declaration* adec = new Declaration(mScanner->mLocation, DT_ARGUMENT);
adec->mVarIndex = 0; adec->mVarIndex = 0;
adec->mOffset = 0; adec->mOffset = 0;
adec->mBase = TheUnsignedIntTypeDeclaration; adec->mBase = pthis;
adec->mSize = adec->mBase->mSize; adec->mSize = adec->mBase->mSize;
adec->mIdent = adec->mQualIdent = Ident::Unique("n"); adec->mIdent = adec->mQualIdent = Ident::Unique("end");
ctdec->mParams = adec; ctdec->mParams = adec;
Declaration* vthis = pthis->Clone();
vthis->mFlags &= ~DTF_CONST;
PrependThisArgument(ctdec, vthis); PrependThisArgument(ctdec, vthis);
Declaration* cdec = new Declaration(ctdec->mLocation, DT_CONST_FUNCTION); Declaration* cdec = new Declaration(ctdec->mLocation, DT_CONST_FUNCTION);
@ -2114,17 +2118,13 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
pexp->mDecValue = ctdec->mParams; pexp->mDecValue = ctdec->mParams;
Expression* aexp = new Expression(mScanner->mLocation, EX_VARIABLE); Expression* aexp = new Expression(mScanner->mLocation, EX_VARIABLE);
aexp->mDecType = TheUnsignedIntTypeDeclaration; aexp->mDecType = pthis;
aexp->mDecValue = adec; aexp->mDecValue = adec;
Expression* iexp = new Expression(mScanner->mLocation, EX_POSTINCDEC); Expression* iexp = new Expression(mScanner->mLocation, EX_POSTINCDEC);
iexp->mToken = TK_INC; iexp->mToken = TK_INC;
iexp->mLeft = pexp; iexp->mLeft = pexp;
Expression* dexp = new Expression(mScanner->mLocation, EX_POSTINCDEC);
dexp->mToken = TK_DEC;
dexp->mLeft = aexp;
Expression* fexp = new Expression(mScanner->mLocation, EX_CONSTANT); Expression* fexp = new Expression(mScanner->mLocation, EX_CONSTANT);
fexp->mDecValue = pthis->mBase->mDestructor; fexp->mDecValue = pthis->mBase->mDestructor;
fexp->mDecType = fexp->mDecValue->mBase; fexp->mDecType = fexp->mDecValue->mBase;
@ -2134,10 +2134,13 @@ void Parser::AddDefaultConstructors(Declaration* pthis)
cexp->mRight = iexp; cexp->mRight = iexp;
Expression* wexp = new Expression(mScanner->mLocation, EX_WHILE); Expression* wexp = new Expression(mScanner->mLocation, EX_WHILE);
wexp->mLeft = aexp; wexp->mLeft = new Expression(mScanner->mLocation, EX_RELATIONAL);
wexp->mRight = new Expression(mScanner->mLocation, EX_SEQUENCE); wexp->mLeft->mToken = TK_NOT_EQUAL;
wexp->mRight->mLeft = cexp; wexp->mLeft->mLeft = pexp;
wexp->mRight->mRight = dexp; wexp->mLeft->mRight = aexp;
wexp->mLeft->mDecType = TheBoolTypeDeclaration;
wexp->mRight = cexp;
cdec->mValue = wexp; cdec->mValue = wexp;
} }
@ -2419,9 +2422,13 @@ void Parser::AppendMemberDestructor(Declaration* pthis)
dexp->mLeft = cexp; dexp->mLeft = cexp;
dexp->mRight = new Expression(mScanner->mLocation, EX_LIST); dexp->mRight = new Expression(mScanner->mLocation, EX_LIST);
dexp->mRight->mLeft = qexp; dexp->mRight->mLeft = qexp;
dexp->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT); dexp->mRight->mRight = new Expression(mScanner->mLocation, EX_BINARY);
dexp->mRight->mRight->mDecType = ncdec->mBase; dexp->mRight->mRight->mToken = TK_ADD;
dexp->mRight->mRight->mDecValue = ncdec; dexp->mRight->mRight->mLeft = qexp;
dexp->mRight->mRight->mDecType = qexp->mDecType;
dexp->mRight->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
dexp->mRight->mRight->mRight->mDecType = ncdec->mBase;
dexp->mRight->mRight->mRight->mDecValue = ncdec;
} }
Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE); Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE);
@ -3408,9 +3415,16 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
Expression* fexp = new Expression(mScanner->mLocation, EX_CALL); Expression* fexp = new Expression(mScanner->mLocation, EX_CALL);
fexp->mLeft = cexp; fexp->mLeft = cexp;
fexp->mRight = new Expression(mScanner->mLocation, EX_LIST); fexp->mRight = new Expression(mScanner->mLocation, EX_LIST);
fexp->mRight->mLeft = vexp; fexp->mRight->mLeft = vexp;
fexp->mRight->mRight = ncexp; fexp->mRight->mRight = new Expression(mScanner->mLocation, EX_BINARY);
fexp->mRight->mRight->mToken = TK_ADD;
fexp->mRight->mRight->mLeft = vexp;
fexp->mRight->mRight->mDecType = vexp->mDecType;
fexp->mRight->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
fexp->mRight->mRight->mRight->mDecType = ncdec->mBase;
fexp->mRight->mRight->mRight->mDecValue = ncdec;
Expression* dexp = nullptr; Expression* dexp = nullptr;
if (bdec->mDestructor) if (bdec->mDestructor)
@ -3421,9 +3435,7 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
dexp = new Expression(mScanner->mLocation, EX_CALL); dexp = new Expression(mScanner->mLocation, EX_CALL);
dexp->mLeft = cexp; dexp->mLeft = cexp;
dexp->mRight = new Expression(mScanner->mLocation, EX_LIST); dexp->mRight = fexp->mRight;
dexp->mRight->mLeft = vexp;
dexp->mRight->mRight = ncexp;
} }
Expression* nexp = new Expression(mScanner->mLocation, EX_CONSTRUCT); Expression* nexp = new Expression(mScanner->mLocation, EX_CONSTRUCT);
@ -4502,6 +4514,88 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
sexp->mDecValue = sconst; sexp->mDecValue = sconst;
sexp->mDecType = TheUnsignedIntTypeDeclaration; sexp->mDecType = TheUnsignedIntTypeDeclaration;
Declaration* nudec = new Declaration(mScanner->mLocation, DT_CONST_ADDRESS);
nudec->mBase = TheVoidPointerTypeDeclaration;
nudec->mInteger = 0;
Expression* nuexp = new Expression(mScanner->mLocation, EX_CONSTANT);
nuexp->mDecValue = nudec;
nuexp->mDecType = nudec->mBase;
if (ConsumeTokenIf(TK_OPEN_BRACKET))
{
Expression* mexp = new Expression(mScanner->mLocation, EX_BINARY);
mexp->mToken = TK_MUL;
mexp->mLeft = sexp;
mexp->mRight = ParseExpression(false);
mexp->mDecType = TheUnsignedIntTypeDeclaration;
ConsumeToken(TK_CLOSE_BRACKET);
nexp->mLeft = mexp;
nexp->mDecType = dec->BuildPointer(mScanner->mLocation);
if (dec->mVectorConstructor)
{
Declaration* vdec = new Declaration(mScanner->mLocation, DT_VARIABLE);
vdec->mVarIndex = mLocalIndex++;
vdec->mBase = nexp->mDecType;
vdec->mSize = 2;
Expression* vexp = new Expression(mScanner->mLocation, EX_VARIABLE);
vexp->mDecType = vdec->mBase;
vexp->mDecValue = vdec;
Expression* iexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
iexp->mToken = TK_ASSIGN;
iexp->mLeft = vexp;
iexp->mRight = nexp;
iexp->mDecType = nexp->mDecType;
Expression* csexp = new Expression(mScanner->mLocation, EX_TYPECAST);
csexp->mLeft = vexp;
csexp->mDecType = nexp->mDecType->BuildPointer(mScanner->mLocation);
Declaration* mdec = dec->mVectorConstructor;
Expression* pexp = new Expression(mScanner->mLocation, EX_LIST);
pexp->mLeft = vexp;
pexp->mRight = new Expression(mScanner->mLocation, EX_INDEX);
pexp->mRight->mLeft = csexp;
pexp->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
pexp->mRight->mRight->mDecType = TheSignedIntTypeDeclaration;
pexp->mRight->mRight->mDecValue = new Declaration(mScanner->mLocation, DT_CONST_INTEGER);
pexp->mRight->mRight->mDecValue->mBase = TheSignedIntTypeDeclaration;
pexp->mRight->mRight->mDecValue->mInteger = -1;
Expression* cexp = new Expression(mScanner->mLocation, EX_CONSTANT);
cexp->mDecValue = mdec;
cexp->mDecType = cexp->mDecValue->mBase;
Expression* dexp = new Expression(mScanner->mLocation, EX_CALL);
dexp->mLeft = cexp;
dexp->mRight = pexp;
Expression* coexp = nexp = new Expression(mScanner->mLocation, EX_CONDITIONAL);
coexp->mLeft = new Expression(mScanner->mLocation, EX_RELATIONAL);
coexp->mLeft->mDecType = TheBoolTypeDeclaration;
coexp->mLeft->mToken = TK_EQUAL;
coexp->mLeft->mLeft = vexp;
coexp->mLeft->mRight = nuexp;
coexp->mRight = new Expression(mScanner->mLocation, EX_LIST);
coexp->mRight->mLeft = vexp;
coexp->mRight->mRight = new Expression(mScanner->mLocation, EX_SEQUENCE);
coexp->mRight->mRight->mLeft = dexp;
coexp->mRight->mRight->mRight = vexp;
coexp->mDecType = vexp->mDecType;
Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE);
sexp->mLeft = iexp;
sexp->mRight = coexp;
nexp = sexp;
}
}
else
{
nexp->mLeft = sexp; nexp->mLeft = sexp;
nexp->mDecType = dec->BuildPointer(mScanner->mLocation); nexp->mDecType = dec->BuildPointer(mScanner->mLocation);
@ -4523,7 +4617,7 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
iexp->mDecType = nexp->mDecType; iexp->mDecType = nexp->mDecType;
Declaration* mdec = dec->mDefaultConstructor; Declaration* mdec = dec->mDefaultConstructor;
Expression* pexp = iexp; Expression* pexp = vexp;
if (ConsumeTokenIf(TK_OPEN_PARENTHESIS)) if (ConsumeTokenIf(TK_OPEN_PARENTHESIS))
{ {
@ -4536,7 +4630,7 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
ConsumeToken(TK_CLOSE_PARENTHESIS); ConsumeToken(TK_CLOSE_PARENTHESIS);
Expression* lexp = new Expression(mScanner->mLocation, EX_LIST); Expression* lexp = new Expression(mScanner->mLocation, EX_LIST);
lexp->mLeft = iexp; lexp->mLeft = vexp;
lexp->mRight = pexp; lexp->mRight = pexp;
pexp = lexp; pexp = lexp;
} }
@ -4557,14 +4651,45 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
sexp->mLeft = dexp; sexp->mLeft = dexp;
sexp->mRight = vexp; sexp->mRight = vexp;
nexp = sexp; Expression * coexp = nexp = new Expression(mScanner->mLocation, EX_CONDITIONAL);
coexp->mLeft = new Expression(mScanner->mLocation, EX_RELATIONAL);
coexp->mLeft->mDecType = TheBoolTypeDeclaration;
coexp->mLeft->mToken = TK_EQUAL;
coexp->mLeft->mLeft = vexp;
coexp->mLeft->mRight = nuexp;
coexp->mRight = new Expression(mScanner->mLocation, EX_LIST);
coexp->mRight->mLeft = vexp;
coexp->mRight->mRight = new Expression(mScanner->mLocation, EX_SEQUENCE);
coexp->mRight->mRight->mLeft = dexp;
coexp->mRight->mRight->mRight = vexp;
coexp->mDecType = vexp->mDecType;
nexp = new Expression(mScanner->mLocation, EX_SEQUENCE);
nexp->mLeft = iexp;
nexp->mRight = coexp;
}
} }
} }
else if (mScanner->mToken == TK_DELETE) else if (mScanner->mToken == TK_DELETE)
{ {
bool vdelete = false;
mScanner->NextToken();
if (ConsumeTokenIf(TK_OPEN_BRACKET))
{
ConsumeToken(TK_CLOSE_BRACKET);
vdelete = true;
}
Declaration* nudec = new Declaration(mScanner->mLocation, DT_CONST_ADDRESS);
nudec->mBase = TheVoidPointerTypeDeclaration;
nudec->mInteger = 0;
Expression* nuexp = new Expression(mScanner->mLocation, EX_CONSTANT);
nuexp->mDecValue = nudec;
nuexp->mDecType = nudec->mBase;
nexp = new Expression(mScanner->mLocation, EX_PREFIX); nexp = new Expression(mScanner->mLocation, EX_PREFIX);
nexp->mToken = TK_DELETE; nexp->mToken = TK_DELETE;
mScanner->NextToken();
nexp->mLeft = ParsePrefixExpression(false); nexp->mLeft = ParsePrefixExpression(false);
nexp->mDecType = TheVoidTypeDeclaration; nexp->mDecType = TheVoidTypeDeclaration;
if (nexp->mLeft->mDecType->mType == DT_TYPE_POINTER) if (nexp->mLeft->mDecType->mType == DT_TYPE_POINTER)
@ -4588,6 +4713,26 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
iexp->mDecType = nexp->mLeft->mDecType; iexp->mDecType = nexp->mLeft->mDecType;
Declaration* mdec = dec->mDestructor; Declaration* mdec = dec->mDestructor;
Expression* pexp = vexp;
if (vdelete)
{
mdec = dec->mVectorDestructor;
Expression* csexp = new Expression(mScanner->mLocation, EX_TYPECAST);
csexp->mLeft = vexp;
csexp->mDecType = nexp->mLeft->mDecType->BuildPointer(mScanner->mLocation);
pexp = new Expression(mScanner->mLocation, EX_LIST);
pexp->mLeft = vexp;
pexp->mRight = new Expression(mScanner->mLocation, EX_INDEX);
pexp->mRight->mLeft = csexp;
pexp->mRight->mRight = new Expression(mScanner->mLocation, EX_CONSTANT);
pexp->mRight->mRight->mDecType = TheSignedIntTypeDeclaration;
pexp->mRight->mRight->mDecValue = new Declaration(mScanner->mLocation, DT_CONST_INTEGER);
pexp->mRight->mRight->mDecValue->mBase = TheSignedIntTypeDeclaration;
pexp->mRight->mRight->mDecValue->mInteger = -1;
}
Expression* cexp = new Expression(mScanner->mLocation, EX_CONSTANT); Expression* cexp = new Expression(mScanner->mLocation, EX_CONSTANT);
cexp->mDecValue = mdec; cexp->mDecValue = mdec;
@ -4595,13 +4740,20 @@ Expression* Parser::ParsePrefixExpression(bool lhs)
Expression* dexp = new Expression(mScanner->mLocation, EX_CALL); Expression* dexp = new Expression(mScanner->mLocation, EX_CALL);
dexp->mLeft = cexp; dexp->mLeft = cexp;
dexp->mRight = iexp; dexp->mRight = pexp;
Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE); Expression* sexp = new Expression(mScanner->mLocation, EX_SEQUENCE);
sexp->mLeft = iexp;
sexp->mLeft = dexp; sexp->mRight = new Expression(mScanner->mLocation, EX_IF);
sexp->mRight = nexp; sexp->mRight->mLeft = new Expression(mScanner->mLocation, EX_RELATIONAL);
sexp->mRight->mLeft->mDecType = TheBoolTypeDeclaration;
sexp->mRight->mLeft->mToken = TK_NOT_EQUAL;
sexp->mRight->mLeft->mLeft = vexp;
sexp->mRight->mLeft->mRight = nuexp;
sexp->mRight->mRight = new Expression(mScanner->mLocation, EX_LIST);
sexp->mRight->mRight->mLeft = new Expression(mScanner->mLocation, EX_SEQUENCE);
sexp->mRight->mRight->mLeft->mLeft = dexp;
sexp->mRight->mRight->mLeft->mRight = nexp;
nexp->mLeft = iexp; nexp->mLeft = iexp;
nexp = sexp; nexp = sexp;