diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index dd0ed8d..632aabc 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -979,7 +979,7 @@ Declaration::Declaration(const Location& loc, DecType type) : mLocation(loc), mEndLocation(loc), mType(type), mScope(nullptr), mData(nullptr), mIdent(nullptr), mQualIdent(nullptr), mMangleIdent(nullptr), mSize(0), mOffset(0), mFlags(0), mComplexity(0), mLocalSize(0), mNumVars(0), mBase(nullptr), mParams(nullptr), mParamPack(nullptr), mValue(nullptr), mReturn(nullptr), mNext(nullptr), mPrev(nullptr), - mConst(nullptr), mMutable(nullptr), + mConst(nullptr), mMutable(nullptr), mVolatile(nullptr), mDefaultConstructor(nullptr), mDestructor(nullptr), mCopyConstructor(nullptr), mCopyAssignment(nullptr), mMoveConstructor(nullptr), mMoveAssignment(nullptr), mVectorConstructor(nullptr), mVectorDestructor(nullptr), mVectorCopyConstructor(nullptr), mVectorCopyAssignment(nullptr), mVTable(nullptr), mTemplate(nullptr), mForwardParam(nullptr), mForwardCall(nullptr), @@ -1859,6 +1859,59 @@ Declaration* Declaration::ToStriped(int stripe) return ndec; } +Declaration* Declaration::ToVolatileType(void) +{ + if (mFlags & DTF_VOLATILE) + return this; + + if (!mVolatile) + { + Declaration* ndec = new Declaration(mLocation, mType); + ndec->mSize = mSize; + ndec->mStride = mStride; + ndec->mBase = mBase; + ndec->mFlags = mFlags | DTF_VOLATILE; + ndec->mScope = mScope; + ndec->mParams = mParams; + ndec->mIdent = mIdent; + ndec->mQualIdent = mQualIdent; + ndec->mTemplate = mTemplate; + + if (mType == DT_TYPE_STRUCT) + { + ndec->mScope = new DeclarationScope(nullptr, mScope->mLevel); + Declaration* p = mParams; + Declaration* prev = nullptr; + while (p) + { + Declaration* pnec = p->Clone(); + pnec->mBase = pnec->mBase->ToVolatileType(); + + ndec->mScope->Insert(pnec->mIdent, pnec); + + if (prev) + prev->mNext = pnec; + else + ndec->mParams = pnec; + prev = pnec; + p = p->mNext; + } + } + + ndec->mDestructor = mDestructor; + ndec->mDefaultConstructor = mDefaultConstructor; + ndec->mCopyConstructor = mCopyConstructor; + ndec->mMoveConstructor = mMoveConstructor; + ndec->mVectorConstructor = mVectorConstructor; + ndec->mVectorCopyConstructor = mVectorCopyConstructor; + ndec->mVTable = mVTable; + + mVolatile = ndec; + } + + return mVolatile; +} + Declaration* Declaration::ToConstType(void) { if (mFlags & DTF_CONST) diff --git a/oscar64/Declaration.h b/oscar64/Declaration.h index f4accaa..734a3c0 100644 --- a/oscar64/Declaration.h +++ b/oscar64/Declaration.h @@ -267,7 +267,7 @@ public: Location mLocation, mEndLocation; DecType mType; Token mToken; - Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable; + Declaration * mBase, * mParams, * mParamPack, * mNext, * mPrev, * mConst, * mMutable, * mVolatile; Declaration * mDefaultConstructor, * mDestructor, * mCopyConstructor, * mCopyAssignment, * mMoveConstructor, * mMoveAssignment; Declaration * mVectorConstructor, * mVectorDestructor, * mVectorCopyConstructor, * mVectorCopyAssignment; Declaration * mVTable, * mClass, * mTemplate; @@ -315,6 +315,7 @@ public: Declaration* ToConstType(void); Declaration* ToMutableType(void); + Declaration* ToVolatileType(void); Declaration* ToStriped(int stripe); Declaration* ToStriped(Errors* errors); diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 700f925..8c59050 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -648,6 +648,13 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt, Declaratio mScope = oscope; } + else + { + if ((flags & ~dec->mFlags) == DTF_CONST) + dec = dec->ToConstType(); + else if ((flags & ~dec->mFlags) == DTF_VOLATILE) + dec = dec->ToVolatileType(); + } return dec; } @@ -820,6 +827,8 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl { if ((flags & ~dec->mFlags) == DTF_CONST) dec = dec->ToConstType(); + else if ((flags & ~dec->mFlags) == DTF_VOLATILE) + dec = dec->ToVolatileType(); else if (dec->IsSimpleType() && (flags & ~dec->mFlags)) { Declaration* ndec = new Declaration(dec->mLocation, dec->mType); @@ -832,6 +841,8 @@ Declaration* Parser::ParseBaseTypeDeclaration(uint64 flags, bool qualified, Decl { if ((flags & ~dec->mFlags) == DTF_CONST) dec = dec->ToConstType(); + else if ((flags & ~dec->mFlags) == DTF_VOLATILE) + dec = dec->ToVolatileType(); else { Declaration* ndec = new Declaration(dec->mLocation, dec->mType);