Add simple return type deduction
This commit is contained in:
parent
ab49281b0d
commit
c926456560
|
@ -71,7 +71,7 @@ inline BitVector::BitVector(int size, unsigned char * data)
|
|||
else
|
||||
bits = nullptr;
|
||||
|
||||
if (size)
|
||||
if (size > 0)
|
||||
{
|
||||
memcpy(bits, data, (size + 7) / 8);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ inline BitVector::BitVector(int size, bool set)
|
|||
else
|
||||
bits = NULL;
|
||||
|
||||
if (size)
|
||||
if (size > 0)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
|
|
|
@ -1067,7 +1067,7 @@ bool Compiler::BuildLZO(const char* targetPath)
|
|||
|
||||
CompilationUnit* cunit;
|
||||
|
||||
char data[65536];
|
||||
char * data = new char[65536];
|
||||
int n = 0;
|
||||
|
||||
while (mErrors->mErrorCount == 0 && (cunit = mCompilationUnits->PendingUnit()))
|
||||
|
@ -1110,14 +1110,20 @@ bool Compiler::BuildLZO(const char* targetPath)
|
|||
{
|
||||
int done = fwrite(data, 1, n, file);
|
||||
fclose(file);
|
||||
delete[] data;
|
||||
return done == n;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] data;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] data;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool Compiler::WriteOutputFile(const char* targetPath, DiskImage * d64)
|
||||
|
|
|
@ -882,7 +882,7 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
|||
}
|
||||
|
||||
Declaration::Declaration(const Location& loc, DecType type)
|
||||
: mLocation(loc), mEndLocation(loc), mType(type), mScope(nullptr), mData(nullptr), mIdent(nullptr), mQualIdent(nullptr),
|
||||
: 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),
|
||||
mBase(nullptr), mParams(nullptr), mValue(nullptr), mNext(nullptr), mPrev(nullptr),
|
||||
mConst(nullptr), mMutable(nullptr),
|
||||
|
|
|
@ -250,7 +250,7 @@ bool DiskImage::WriteFile(const char* fname, bool compressed)
|
|||
|
||||
if (OpenFile(dname))
|
||||
{
|
||||
uint8 buffer[65536], cbuffer[65536];
|
||||
uint8 * buffer = new uint8[65536], * cbuffer = new uint8[65536];
|
||||
int size = fread(buffer, 1, 65536, file);
|
||||
int csize = 0;
|
||||
|
||||
|
@ -311,6 +311,9 @@ bool DiskImage::WriteFile(const char* fname, bool compressed)
|
|||
else
|
||||
WriteBytes(buffer, size);
|
||||
CloseFile();
|
||||
|
||||
delete[] buffer;
|
||||
delete[] cbuffer;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
|
|
@ -245,7 +245,7 @@ class InterVariable
|
|||
{
|
||||
public:
|
||||
bool mUsed, mAliased, mTemp;
|
||||
int mIndex, mSize, mOffset, mAddr, mTempIndex;
|
||||
int mIndex, mSize, mOffset, mTempIndex;
|
||||
int mNumReferences;
|
||||
const Ident * mIdent;
|
||||
LinkerObject * mLinkerObject;
|
||||
|
|
|
@ -22386,8 +22386,8 @@ bool NativeCodeBasicBlock::PatchCrossBlock16BitFlood(const NativeCodeBasicBlock*
|
|||
|
||||
mPatchExit = true;
|
||||
|
||||
mExitRequiredRegs |= sreg;
|
||||
mExitRequiredRegs |= sreg + 1;
|
||||
mExitRequiredRegs += sreg;
|
||||
mExitRequiredRegs += sreg + 1;
|
||||
|
||||
if (mTrueJump && mTrueJump->PatchCrossBlock16BitFlood(block, sreg, dreg, 0))
|
||||
changed = true;
|
||||
|
|
|
@ -120,6 +120,8 @@ NumberSet& NumberSet::operator=(const NumberSet& set)
|
|||
|
||||
NumberSet& NumberSet::operator&=(const NumberSet& set)
|
||||
{
|
||||
assert(dwsize == set.dwsize);
|
||||
|
||||
int size = dwsize;
|
||||
const uint32* sbits = set.bits;
|
||||
uint32* dbits = bits;
|
||||
|
@ -132,6 +134,8 @@ NumberSet& NumberSet::operator&=(const NumberSet& set)
|
|||
|
||||
NumberSet& NumberSet::operator|=(const NumberSet& set)
|
||||
{
|
||||
assert(dwsize == set.dwsize);
|
||||
|
||||
int size = dwsize;
|
||||
const uint32* sbits = set.bits;
|
||||
uint32* dbits = bits;
|
||||
|
@ -144,6 +148,8 @@ NumberSet& NumberSet::operator|=(const NumberSet& set)
|
|||
|
||||
NumberSet& NumberSet::operator-=(const NumberSet& set)
|
||||
{
|
||||
assert(dwsize == set.dwsize);
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < dwsize; i++)
|
||||
|
@ -154,6 +160,8 @@ NumberSet& NumberSet::operator-=(const NumberSet& set)
|
|||
|
||||
bool NumberSet::operator<=(const NumberSet& set) const
|
||||
{
|
||||
assert(dwsize == set.dwsize);
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < dwsize; i++)
|
||||
|
|
|
@ -20,6 +20,7 @@ Parser::Parser(Errors* errors, Scanner* scanner, CompilationUnits* compilationUn
|
|||
mCompilerOptionSP = 0;
|
||||
mThisPointer = nullptr;
|
||||
mFunction = nullptr;
|
||||
mFunctionType = nullptr;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
mCharMap[i] = i;
|
||||
|
@ -7110,7 +7111,7 @@ Expression* Parser::ParseFunction(Declaration * dec)
|
|||
if (dec->mFlags & DTF_FUNC_THIS)
|
||||
mThisPointer = dec->mParams;
|
||||
|
||||
mReturnType = dec->mBase;
|
||||
mFunctionType = dec;
|
||||
|
||||
DeclarationScope* oscope = mScope;
|
||||
while (mScope->mLevel == SLEVEL_CLASS)
|
||||
|
@ -7508,10 +7509,16 @@ Expression* Parser::ParseStatement(void)
|
|||
if (mScanner->mToken != TK_SEMICOLON)
|
||||
{
|
||||
exp->mLeft = ParseRExpression();
|
||||
if (mReturnType)
|
||||
exp->mLeft = CoerceExpression(exp->mLeft, mReturnType);
|
||||
if (mFunctionType && mFunctionType->mBase)
|
||||
{
|
||||
if (mFunctionType->mBase->mType == DT_TYPE_AUTO)
|
||||
{
|
||||
mFunctionType->mBase = exp->mLeft->mDecType;
|
||||
}
|
||||
exp->mLeft = CoerceExpression(exp->mLeft, mFunctionType->mBase);
|
||||
}
|
||||
exp->mLeft = CleanupExpression(exp->mLeft);
|
||||
if (exp->mLeft->mType == EX_CONSTRUCT && mReturnType && mReturnType->mType == DT_TYPE_STRUCT)
|
||||
if (exp->mLeft->mType == EX_CONSTRUCT && mFunctionType && mFunctionType->mBase && mFunctionType->mBase->mType == DT_TYPE_STRUCT)
|
||||
{
|
||||
Expression* cexp = exp->mLeft->mLeft->mLeft;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
DeclarationScope * mGlobals, * mScope, * mTemplateScope;
|
||||
int mLocalIndex;
|
||||
CompilationUnits * mCompilationUnits;
|
||||
Declaration * mThisPointer, * mReturnType, * mFunction;
|
||||
Declaration * mThisPointer, * mFunctionType, * mFunction;
|
||||
|
||||
LinkerSection * mCodeSection, * mDataSection, * mBSSection;
|
||||
|
||||
|
|
|
@ -1277,6 +1277,7 @@ void Scanner::NextRawToken(void)
|
|||
{
|
||||
int n = 0;
|
||||
char tkprep[128];
|
||||
tkprep[0] = 0;
|
||||
|
||||
while (NextChar() && IsAlpha(mTokenChar))
|
||||
{
|
||||
|
@ -1371,6 +1372,8 @@ void Scanner::NextRawToken(void)
|
|||
{
|
||||
int n = 0;
|
||||
char tkident[256];
|
||||
tkident[0] = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (IsIdentChar(mTokenChar))
|
||||
|
|
Loading…
Reference in New Issue