Added a name-label stack.
Not like it really needs to be a stack, but just in case.
This commit is contained in:
parent
a7da66f9a9
commit
75be2d41c1
1 changed files with 17 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
using arookas.IO.Binary;
|
using arookas.IO.Binary;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -9,6 +10,7 @@ namespace arookas {
|
||||||
bool mOpen;
|
bool mOpen;
|
||||||
aBinaryWriter mWriter;
|
aBinaryWriter mWriter;
|
||||||
uint mTextOffset, mDataOffset, mSymbolOffset;
|
uint mTextOffset, mDataOffset, mSymbolOffset;
|
||||||
|
Stack<sunNameLabel> mNameStack;
|
||||||
|
|
||||||
public sunWriter Text { get; private set; }
|
public sunWriter Text { get; private set; }
|
||||||
public sunDataTable DataTable { get; private set; }
|
public sunDataTable DataTable { get; private set; }
|
||||||
|
@ -22,6 +24,7 @@ namespace arookas {
|
||||||
SymbolTable = new sunSymbolTable();
|
SymbolTable = new sunSymbolTable();
|
||||||
Scopes = new sunScopeStack();
|
Scopes = new sunScopeStack();
|
||||||
Loops = new sunLoopStack();
|
Loops = new sunLoopStack();
|
||||||
|
mNameStack = new Stack<sunNameLabel>(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// open/close
|
// open/close
|
||||||
|
@ -41,6 +44,7 @@ namespace arookas {
|
||||||
SymbolTable.Clear();
|
SymbolTable.Clear();
|
||||||
Scopes.Clear();
|
Scopes.Clear();
|
||||||
Loops.Clear();
|
Loops.Clear();
|
||||||
|
mNameStack.Clear();
|
||||||
ImportResolver = importResolver;
|
ImportResolver = importResolver;
|
||||||
mWriter = new aBinaryWriter(output, Endianness.Big, Encoding.GetEncoding(932));
|
mWriter = new aBinaryWriter(output, Endianness.Big, Encoding.GetEncoding(932));
|
||||||
Text = new sunWriter(mWriter);
|
Text = new sunWriter(mWriter);
|
||||||
|
@ -215,6 +219,19 @@ namespace arookas {
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PushNameLabel(sunNameLabel label) {
|
||||||
|
if (label == null) {
|
||||||
|
throw new ArgumentNullException("label");
|
||||||
|
}
|
||||||
|
mNameStack.Push(label);
|
||||||
|
}
|
||||||
|
public sunNameLabel PopNameLabel() {
|
||||||
|
if (mNameStack.Count > 0) {
|
||||||
|
return mNameStack.Pop();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
void WriteHeader() {
|
void WriteHeader() {
|
||||||
mWriter.WriteString("SPCB");
|
mWriter.WriteString("SPCB");
|
||||||
mWriter.Write32(mTextOffset);
|
mWriter.Write32(mTextOffset);
|
||||||
|
|
Loading…
Reference in a new issue