Removed WriteSymbolTable and WriteStringTable.

This commit is contained in:
arookas 2015-12-27 23:10:11 -05:00
parent 80c4c94b28
commit 61e0b220b4

View file

@ -29,11 +29,19 @@ namespace arookas
int ofs = 0; int ofs = 0;
foreach (var sym in this) foreach (var sym in this)
{ {
ofs += sym.WriteSymbolTable(writer, ofs); writer.WriteS32((int)sym.Type);
writer.WriteS32(ofs);
writer.Write32(sym.Data);
// runtime fields
writer.WriteS32(0);
writer.WriteS32(0);
ofs += writer.Encoding.GetByteCount(sym.Name) + 1; // include null terminator
} }
foreach (var sym in this) foreach (var sym in this)
{ {
sym.WriteStringTable(writer); writer.WriteString(sym.Name, aBinaryStringFormat.NullTerminated);
} }
} }
@ -55,23 +63,6 @@ namespace arookas
} }
public abstract void Compile(sunContext context); public abstract void Compile(sunContext context);
public virtual int WriteSymbolTable(aBinaryWriter writer, int ofs)
{
writer.WriteS32((int)Type);
writer.WriteS32(ofs);
writer.Write32(Data);
// runtime fields
writer.WriteS32(0);
writer.WriteS32(0);
return writer.Encoding.GetByteCount(Name) + 1; // include null terminator
}
public virtual void WriteStringTable(aBinaryWriter writer)
{
writer.WriteString(Name, aBinaryStringFormat.NullTerminated);
}
} }
abstract class sunCallableSymbol : sunSymbol abstract class sunCallableSymbol : sunSymbol
@ -229,8 +220,6 @@ namespace arookas
public int Display { get; private set; } public int Display { get; private set; }
public int Index { get; private set; } public int Index { get; private set; }
string TableName { get { return String.Format("varsym_{0}_{1}", Display, Index); } }
// symbol table // symbol table
public override sunSymbolType Type { get { return sunSymbolType.Variable; } } public override sunSymbolType Type { get { return sunSymbolType.Variable; } }
public override uint Data { get { return (uint)Index; } } public override uint Data { get { return (uint)Index; } }
@ -258,15 +247,6 @@ namespace arookas
{ {
context.Text.DecVariable(Display, Index); context.Text.DecVariable(Display, Index);
} }
public override int WriteSymbolTable(aBinaryWriter writer, int ofs)
{
base.WriteSymbolTable(writer, ofs);
return writer.Encoding.GetByteCount(TableName) + 1; // include null terminator
}
public override void WriteStringTable(aBinaryWriter writer)
{
writer.WriteString(TableName, aBinaryStringFormat.NullTerminated);
}
} }
class sunConstantSymbol : sunStorableSymbol class sunConstantSymbol : sunStorableSymbol