Added open/close sanity checks.
This commit is contained in:
parent
a5ec72e1f9
commit
af2a00f225
1 changed files with 11 additions and 0 deletions
|
@ -8,6 +8,7 @@ namespace arookas
|
||||||
{
|
{
|
||||||
class sunContext
|
class sunContext
|
||||||
{
|
{
|
||||||
|
bool mOpen;
|
||||||
aBinaryWriter mWriter;
|
aBinaryWriter mWriter;
|
||||||
uint mTextOffset, mDataOffset, mSymbolOffset;
|
uint mTextOffset, mDataOffset, mSymbolOffset;
|
||||||
int mVarCount;
|
int mVarCount;
|
||||||
|
@ -34,6 +35,10 @@ namespace arookas
|
||||||
}
|
}
|
||||||
public void Open(Stream output, sunImportResolver importResolver)
|
public void Open(Stream output, sunImportResolver importResolver)
|
||||||
{
|
{
|
||||||
|
if (mOpen)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
if (output == null)
|
if (output == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("output");
|
throw new ArgumentNullException("output");
|
||||||
|
@ -42,6 +47,7 @@ namespace arookas
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("importResolver");
|
throw new ArgumentNullException("importResolver");
|
||||||
}
|
}
|
||||||
|
mOpen = true;
|
||||||
DataTable.Clear();
|
DataTable.Clear();
|
||||||
SymbolTable.Clear();
|
SymbolTable.Clear();
|
||||||
Scopes.Clear();
|
Scopes.Clear();
|
||||||
|
@ -70,6 +76,10 @@ namespace arookas
|
||||||
}
|
}
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
|
if (!mOpen)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
mWriter.PopAnchor();
|
mWriter.PopAnchor();
|
||||||
mDataOffset = (uint)mWriter.Position;
|
mDataOffset = (uint)mWriter.Position;
|
||||||
DataTable.Write(mWriter);
|
DataTable.Write(mWriter);
|
||||||
|
@ -77,6 +87,7 @@ namespace arookas
|
||||||
SymbolTable.Write(mWriter);
|
SymbolTable.Write(mWriter);
|
||||||
mWriter.Goto(0);
|
mWriter.Goto(0);
|
||||||
WriteHeader();
|
WriteHeader();
|
||||||
|
mOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// imports/compilation
|
// imports/compilation
|
||||||
|
|
Loading…
Reference in a new issue