Add iostream library
This commit is contained in:
parent
bbf2bd5b6a
commit
bd6db60802
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,238 @@
|
|||
#ifndef OPP_IOSTREAM_H
|
||||
#define OPP_IOSTREAM_H
|
||||
|
||||
#include <opp/string.h>
|
||||
|
||||
class ios
|
||||
{
|
||||
public:
|
||||
|
||||
ios(void);
|
||||
virtual ~ios(void);
|
||||
|
||||
char fill() const;
|
||||
char fill(char cillch);
|
||||
|
||||
char width() const;
|
||||
char width(char wide);
|
||||
|
||||
char precision() const;
|
||||
char precision(char prec);
|
||||
|
||||
enum fmtflags
|
||||
{
|
||||
boolalpha = 0x0001,
|
||||
dec = 0x0002,
|
||||
fixed = 0x0004,
|
||||
hex = 0x0008,
|
||||
internal = 0x0010,
|
||||
left = 0x0020,
|
||||
oct = 0x0040,
|
||||
right = 0x0080,
|
||||
scientific = 0x0100,
|
||||
showbase = 0x0200,
|
||||
showpoint = 0x0400,
|
||||
showpos = 0x0800,
|
||||
skipws = 0x1000,
|
||||
unitbuf = 0x2000,
|
||||
uppercase = 0x3000,
|
||||
|
||||
adjustfield = 0x00b0,
|
||||
basefield = 0x004a,
|
||||
floatfield = 0x0104
|
||||
};
|
||||
|
||||
enum statebits
|
||||
{
|
||||
goodbit = 0,
|
||||
badbit = 1,
|
||||
eofbit = 2,
|
||||
failbit = 4,
|
||||
};
|
||||
|
||||
fmtflags flags(void) const;
|
||||
fmtflags flags(fmtflags f);
|
||||
|
||||
fmtflags setf(fmtflags f);
|
||||
fmtflags setf(fmtflags f, fmtflags m);
|
||||
fmtflags unsetf(fmtflags f);
|
||||
|
||||
bool good(void) const;
|
||||
bool eof(void) const;
|
||||
bool fail(void) const;
|
||||
bool bad(void) const;
|
||||
|
||||
bool operator!(void) const;
|
||||
operator bool(void);
|
||||
|
||||
statebits rdstate(void) const;
|
||||
void clear(void);
|
||||
|
||||
protected:
|
||||
fmtflags mFlags;
|
||||
statebits mState;
|
||||
char mWidth;
|
||||
char mPrecision;
|
||||
char mFill;
|
||||
};
|
||||
|
||||
class ostream;
|
||||
|
||||
typedef ostream & (* manip)(ostream &);
|
||||
|
||||
class ostream : public ios
|
||||
{
|
||||
public:
|
||||
ostream(void);
|
||||
|
||||
ostream & put(char c);
|
||||
ostream & write(const char * s, int n);
|
||||
|
||||
ostream & operator<<(bool val);
|
||||
ostream & operator<<(int val);
|
||||
ostream & operator<<(unsigned val);
|
||||
ostream & operator<<(long val);
|
||||
ostream & operator<<(unsigned long val);
|
||||
ostream & operator<<(float val);
|
||||
|
||||
ostream & operator<<(const char * p);
|
||||
ostream & operator<<(const string & s);
|
||||
|
||||
ostream & operator<<(manip m);
|
||||
protected:
|
||||
void putnum(const char * buffer, char prefix, char size);
|
||||
void numput(unsigned n, char sign);
|
||||
void numput(unsigned long n, char sign);
|
||||
|
||||
virtual void bput(char ch);
|
||||
};
|
||||
|
||||
class istream : public ios
|
||||
{
|
||||
public:
|
||||
char get(void);
|
||||
istream & get(char & c);
|
||||
istream & get(char * s, char size);
|
||||
istream & get(char * s, char size, char delim);
|
||||
istream & getline(char * s, char size);
|
||||
istream & getline(char * s, char size, char delim);
|
||||
istream & ignore(char size);
|
||||
istream & ignore(char size, char delim);
|
||||
istream & putback(char c);
|
||||
istream & unget(void);
|
||||
|
||||
istream & operator>>(bool & val);
|
||||
istream & operator>>(int & val);
|
||||
istream & operator>>(unsigned & val);
|
||||
istream & operator>>(long & val);
|
||||
istream & operator>>(unsigned long & val);
|
||||
istream & operator>>(float & val);
|
||||
|
||||
istream & operator>>(char * p);
|
||||
|
||||
istream(void);
|
||||
protected:
|
||||
char mBuffer[32];
|
||||
char mBufferPos, mBufferFill;
|
||||
|
||||
virtual void refill(void);
|
||||
|
||||
unsigned getnum(void);
|
||||
unsigned long getnuml(void);
|
||||
float getnumf(void);
|
||||
|
||||
void doskipws(void);
|
||||
};
|
||||
|
||||
class costream : public ostream
|
||||
{
|
||||
public:
|
||||
costream(void);
|
||||
|
||||
protected:
|
||||
void bput(char ch);
|
||||
};
|
||||
|
||||
class cistream : public istream
|
||||
{
|
||||
public:
|
||||
cistream(void);
|
||||
|
||||
protected:
|
||||
void refill(void);
|
||||
};
|
||||
|
||||
class ostringstream : public ostream
|
||||
{
|
||||
public:
|
||||
ostringstream(void);
|
||||
~ostringstream(void);
|
||||
|
||||
string str(void) const;
|
||||
void str(const string & str);
|
||||
protected:
|
||||
void bput(char ch);
|
||||
|
||||
char * mBuffer;
|
||||
char mBFill, mBSize;
|
||||
};
|
||||
|
||||
class istringstream : public istream
|
||||
{
|
||||
public:
|
||||
istringstream(const string & str);
|
||||
~istringstream(void);
|
||||
|
||||
string str(void) const;
|
||||
void str(const string & str);
|
||||
protected:
|
||||
virtual void refill(void);
|
||||
|
||||
string mString;
|
||||
char mSPos;
|
||||
};
|
||||
|
||||
ostream & endl(ostream & os);
|
||||
|
||||
struct iosetf {
|
||||
ios::fmtflags flags;
|
||||
iosetf(ios::fmtflags flags_) : flags(flags_) {}
|
||||
};
|
||||
|
||||
ostream & operator<<(ostream & os, const iosetf & s);
|
||||
|
||||
iosetf setf(ios::fmtflags flags);
|
||||
|
||||
struct iosetw {
|
||||
char width;
|
||||
iosetw(char width_) : width(width_) {}
|
||||
};
|
||||
|
||||
iosetw setw(char width);
|
||||
|
||||
ostream & operator<<(ostream & os, const iosetw & s);
|
||||
|
||||
struct iosetprecision {
|
||||
char precision;
|
||||
iosetprecision(char precision_) : precision(precision_) {}
|
||||
};
|
||||
|
||||
iosetprecision setprecision(char precision);
|
||||
|
||||
ostream & operator<<(ostream & os, const iosetprecision & s);
|
||||
|
||||
|
||||
struct iosetfill {
|
||||
char fill;
|
||||
iosetfill(char fill_) : fill(fill_) {}
|
||||
};
|
||||
|
||||
iosetfill setfill(char fill);
|
||||
|
||||
ostream & operator<<(ostream & os, const iosetfill & s);
|
||||
|
||||
|
||||
|
||||
#pragma compile("iostream.cpp");
|
||||
|
||||
#endif
|
|
@ -1284,7 +1284,18 @@ bool Declaration::IsSame(const Declaration* dec) const
|
|||
else if (mType == DT_TYPE_ENUM)
|
||||
return mIdent == dec->mIdent;
|
||||
else if (mType == DT_TYPE_POINTER || mType == DT_TYPE_ARRAY)
|
||||
return this->Stride() == dec->Stride() && mBase->IsSame(dec->mBase);
|
||||
{
|
||||
if (mBase->mType == DT_TYPE_STRUCT && dec->mBase->mType == DT_TYPE_STRUCT)
|
||||
{
|
||||
if (mBase->mQualIdent == dec->mBase->mQualIdent &&
|
||||
(mBase->mFlags & (DTF_CONST | DTF_VOLATILE)) == (dec->mBase->mFlags & (DTF_CONST | DTF_VOLATILE)))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return this->Stride() == dec->Stride() && mBase->IsSame(dec->mBase);
|
||||
}
|
||||
else if (mType == DT_TYPE_REFERENCE)
|
||||
return mBase->IsSame(dec->mBase);
|
||||
else if (mType == DT_TYPE_STRUCT)
|
||||
|
|
|
@ -478,6 +478,9 @@ bool NativeCodeInstruction::IsUsedResultInstructions(NumberSet& requiredTemps)
|
|||
if (mType == ASMIT_RTS)
|
||||
{
|
||||
#if 1
|
||||
if (mFlags & NCIF_USE_CPU_REG_A)
|
||||
requiredTemps += CPU_REG_A;
|
||||
|
||||
if (mFlags & NCIF_LOWER)
|
||||
{
|
||||
requiredTemps += BC_REG_ACCU;
|
||||
|
@ -4189,6 +4192,12 @@ void NativeCodeInstruction::FilterRegUsage(NumberSet& requiredTemps, NumberSet&
|
|||
if (mType == ASMIT_RTS)
|
||||
{
|
||||
#if 1
|
||||
if (mFlags & NCIF_USE_CPU_REG_A)
|
||||
{
|
||||
if (!providedTemps[CPU_REG_A])
|
||||
requiredTemps += CPU_REG_A;
|
||||
}
|
||||
|
||||
if (mFlags & NCIF_LOWER)
|
||||
{
|
||||
if (!providedTemps[BC_REG_ACCU + 0]) requiredTemps += BC_REG_ACCU + 0;
|
||||
|
@ -15800,7 +15809,7 @@ bool NativeCodeBasicBlock::CrossBlockStoreLoadBypass(NativeCodeProcedure* proc)
|
|||
{
|
||||
mVisited = true;
|
||||
|
||||
if (mTrueJump && !mFalseJump && mIns.Size() > 0 && mTrueJump->mIns.Size() > 0)
|
||||
if (mTrueJump && mTrueJump->mTrueJump && !mFalseJump && mIns.Size() > 0 && mTrueJump->mIns.Size() > 0)
|
||||
{
|
||||
int sz = mIns.Size();
|
||||
|
||||
|
@ -40463,7 +40472,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
|
|||
#if 1
|
||||
if (mExitBlock->mIns[0].mFlags == NCIF_LOWER)
|
||||
{
|
||||
mExitBlock->mIns[0].mFlags = 0;
|
||||
mExitBlock->mIns[0].mFlags = NCIF_USE_CPU_REG_A;
|
||||
mExitBlock->mIns.Insert(0, NativeCodeInstruction(nullptr, ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_ACCU));
|
||||
mExitBlock->mExitRegA = true;
|
||||
proc->mLinkerObject->mFlags |= LOBJF_RET_REG_A;
|
||||
|
|
|
@ -207,6 +207,8 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
|||
Declaration* mlast = nullptr;
|
||||
for (;;)
|
||||
{
|
||||
do {} while (ConsumeTokenIf(TK_SEMICOLON));
|
||||
|
||||
if (ConsumeTokenIf(TK_PUBLIC))
|
||||
{
|
||||
flags &= ~(DTF_PRIVATE | DTF_PROTECTED);
|
||||
|
@ -252,9 +254,6 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
|||
if (mCompilerOptions & COPT_NATIVE)
|
||||
mdec->mFlags |= DTF_NATIVE;
|
||||
|
||||
if (!(mdec->mFlags & DTF_DEFINED))
|
||||
ConsumeToken(TK_SEMICOLON);
|
||||
|
||||
AddMemberFunction(dec, mdec);
|
||||
}
|
||||
else if ((mCompilerOptions & COPT_CPLUSPLUS) && mdec->mType == DT_ANON)
|
||||
|
@ -329,14 +328,7 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
|||
}
|
||||
else
|
||||
{
|
||||
Declaration* mdec = dec->mParams;
|
||||
while (mdec)
|
||||
{
|
||||
mdec->mOffset++;
|
||||
mdec = mdec->mNext;
|
||||
}
|
||||
vdec->mOffset = 0;
|
||||
dec->mSize++;
|
||||
}
|
||||
|
||||
vdec->mDefaultConstructor = new Declaration(dec->mLocation, DT_CONST_INTEGER);
|
||||
|
@ -349,8 +341,19 @@ Declaration* Parser::ParseStructDeclaration(uint64 flags, DecType dt)
|
|||
vdec->mIdent = dec->mIdent;
|
||||
vdec->mQualIdent = dec->mQualIdent;
|
||||
mCompilationUnits->mVTableScope->Insert(vdec->mQualIdent, vdec);
|
||||
}
|
||||
|
||||
dec->mVTable = vdec;
|
||||
dec->mVTable = vdec;
|
||||
|
||||
if (!dec->mBase)
|
||||
{
|
||||
Declaration* mdec = dec->mParams;
|
||||
while (mdec)
|
||||
{
|
||||
mdec->mOffset++;
|
||||
mdec = mdec->mNext;
|
||||
}
|
||||
dec->mSize++;
|
||||
}
|
||||
|
||||
dec->mScope->Iterate([=](const Ident* ident, Declaration* mdec)
|
||||
|
@ -3636,7 +3639,11 @@ Declaration* Parser::ParseDeclaration(Declaration * pdec, bool variable, bool ex
|
|||
if (pdec)
|
||||
{
|
||||
if (!ndec->mBase->IsSame(pdec->mBase))
|
||||
{
|
||||
ndec->mBase->IsSameParams(pdec->mBase);
|
||||
ndec->mBase->IsSame(pdec->mBase);
|
||||
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function declaration differs", ndec->mIdent);
|
||||
}
|
||||
else if (ndec->mFlags & ~pdec->mFlags & (DTF_HWINTERRUPT | DTF_INTERRUPT | DTF_FASTCALL | DTF_NATIVE))
|
||||
mErrors->Error(ndec->mLocation, EERR_DECLARATION_DIFFERS, "Function call type declaration differs", ndec->mIdent);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue