Made symbols write their table entries themselves.

This will allow for overriding the writing code for specific symbol
types.
This commit is contained in:
arookas 2015-12-23 20:17:16 -05:00
parent ac51f19b85
commit 684a8a3197

View file

@ -29,19 +29,11 @@ namespace arookas
int ofs = 0;
foreach (var sym in this)
{
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
ofs += sym.WriteSymbolTable(writer, ofs);
}
foreach (var sym in this)
{
writer.WriteString(sym.Name, aBinaryStringFormat.NullTerminated);
sym.WriteStringTable(writer);
}
}
@ -61,6 +53,23 @@ namespace arookas
{
Name = name;
}
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