diff --git a/include/opp/vector.h b/include/opp/vector.h index c18c96c..485051e 100644 --- a/include/opp/vector.h +++ b/include/opp/vector.h @@ -21,7 +21,7 @@ public: vector(size_t n) : _data((T*)malloc(n * sizeof(T))), _size(n), _capacity(n) { for(size_t i=0; i::resize(size_t n) else if (n < _capacity) { for(size_t i=_size; i::insert(size_t at, const T & t) { if (_size == _capacity) reserve(_size + 1 + (_size >> 1)); - new (_data + _size)T; + new (_data + _size)T(); for(size_t i=_size; i>at; i--) _data[i] = move(_data[i - 1]); _data[at] = t; @@ -318,7 +318,7 @@ T * vector::insert(T * at, const T & t) at = (T *)(f + unsigned(_data)); } T * dp = _data + _size; - new (dp)T; + new (dp)T(); while (dp != at) { dp--; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 04e9f5f..99c5ead 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -7950,6 +7950,28 @@ Expression* Parser::ParsePostfixExpression(bool lhs) nexp = CheckOperatorOverload(nexp); exp = nexp->ConstantFold(mErrors, mDataSection); } + else if (exp->mDecType->IsSimpleType()) + { + Expression* nexp = new Expression(mScanner->mLocation, EX_CONSTANT); + + if (exp->mDecType->IsIntegerType()) + { + nexp->mDecType = exp->mDecType; + nexp->mDecValue = TheZeroIntegerConstDeclaration; + } + else if (exp->mDecType->mType == DT_TYPE_FLOAT) + { + nexp->mDecType = TheFloatTypeDeclaration; + nexp->mDecValue = TheZeroFloatConstDeclaration; + } + else // Pointer + { + nexp->mDecType = TheNullPointerTypeDeclaration; + nexp->mDecValue = TheNullptrConstDeclaration; + } + + exp = nexp; + } else { Declaration* tdec = new Declaration(mScanner->mLocation, DT_VARIABLE); @@ -8398,13 +8420,49 @@ Expression* Parser::ParseNewOperator(void) nexp = new Expression(mScanner->mLocation, EX_PREFIX); nexp->mToken = TK_BINARY_AND; - nexp->mDecType = nexp->mDecType; + nexp->mDecType = iexp->mDecType; nexp->mLeft = iexp; } else if (pexp) { mErrors->Error(mScanner->mLocation, ERRO_NO_MATCHING_FUNCTION_CALL, "No matching constructor", dec->mIdent); } + else if (nexp->mDecType->IsSimpleType()) + { + Expression* cexp = new Expression(mScanner->mLocation, EX_CONSTANT); + + if (nexp->mDecType->mBase->IsIntegerType()) + { + cexp->mDecType = TheSignedIntTypeDeclaration; + cexp->mDecValue = TheZeroIntegerConstDeclaration; + } + else if (nexp->mDecType->mBase->mType == DT_TYPE_FLOAT) + { + cexp->mDecType = TheFloatTypeDeclaration; + cexp->mDecValue = TheZeroFloatConstDeclaration; + } + else // Pointer + { + cexp->mDecType = TheNullPointerTypeDeclaration; + cexp->mDecValue = TheNullptrConstDeclaration; + } + + Expression* dexp = new Expression(mScanner->mLocation, EX_PREFIX); + dexp->mToken = TK_MUL; + dexp->mLeft = nexp; + dexp->mDecType = nexp->mDecType->mBase; + + Expression* iexp = new Expression(mScanner->mLocation, EX_INITIALIZATION); + iexp->mToken = TK_ASSIGN; + iexp->mLeft = dexp; + iexp->mRight = cexp; + iexp->mDecType = nexp->mDecType; + + nexp = new Expression(mScanner->mLocation, EX_PREFIX); + nexp->mToken = TK_BINARY_AND; + nexp->mDecType = iexp->mDecType; + nexp->mLeft = iexp; + } } }