Merge remote-tracking branch 'refs/remotes/origin/dev'
This commit is contained in:
commit
33fb3886de
6 changed files with 58 additions and 92 deletions
|
@ -1,16 +0,0 @@
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("SSC")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("SSC")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
[assembly: Guid("1e643680-49e4-44b9-be23-6df4ce5017db")]
|
|
||||||
[assembly: AssemblyVersion("0.1.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
|
|
@ -1,6 +1,7 @@
|
||||||
# ssc
|
# ssc
|
||||||
|
|
||||||
![SunScript ST3 syntax preview](http://i.imgur.com/YHChKwd.png)
|
![SunScript ST3 syntax preview](http://i.imgur.com/YHChKwd.png)
|
||||||
|
> Preview of [the standard library](stdlib/talk.sun) in Sublime Text 3 using the included [syntax script](sunscript.sublime-syntax).
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
|
@ -50,8 +51,8 @@ All dependencies must be placed in the _lib-dir_ folder (see below), unless stat
|
||||||
|[arookas library](https://github.com/arookas/arookas)|Preferably, the library should be built in the same configuration as _ssc_ (e.g. debug, release).|
|
|[arookas library](https://github.com/arookas/arookas)|Preferably, the library should be built in the same configuration as _ssc_ (e.g. debug, release).|
|
||||||
|[Grammatica 1.6](http://grammatica.percederberg.net/)|Already included in the repository.|
|
|[Grammatica 1.6](http://grammatica.percederberg.net/)|Already included in the repository.|
|
||||||
|
|
||||||
_**Note:** A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation.
|
> A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation.
|
||||||
For more information, see Grammatica's official [installation documentation](http://grammatica.percederberg.net/doc/release/install.html)._
|
> For more information, see Grammatica's official [installation documentation](http://grammatica.percederberg.net/doc/release/install.html).
|
||||||
|
|
||||||
### premake
|
### premake
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("sbdump")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("arookas")]
|
|
||||||
[assembly: AssemblyProduct("sbdump")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015 arookas")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
[assembly: Guid("e2610ef0-cb2d-4f90-a18a-a2e7db316202")]
|
|
||||||
[assembly: AssemblyVersion("0.1.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
|
|
@ -9,10 +9,10 @@ namespace arookas {
|
||||||
static CommandLineSettings sSettings;
|
static CommandLineSettings sSettings;
|
||||||
static aBinaryReader sReader;
|
static aBinaryReader sReader;
|
||||||
static TextWriter sWriter;
|
static TextWriter sWriter;
|
||||||
static uint sTextOffset, sDataOffset, sDynsymOffset;
|
static uint sTextOffset, sDataOffset, sSymOffset;
|
||||||
static int sDataCount, sDynsymCount, sBssCount;
|
static int sDataCount, sSymCount, sVarCount;
|
||||||
|
|
||||||
const string cTitle = "sbdump v0.1 arookas";
|
const string cTitle = "sbdump arookas";
|
||||||
static readonly string[] sSymbolTypes = { "builtin", "function", "var", };
|
static readonly string[] sSymbolTypes = { "builtin", "function", "var", };
|
||||||
static readonly string[] sCommandNames = {
|
static readonly string[] sCommandNames = {
|
||||||
"int", "flt", "str", "adr", "var", "nop", "inc", "dec",
|
"int", "flt", "str", "adr", "var", "nop", "inc", "dec",
|
||||||
|
@ -44,11 +44,11 @@ namespace arookas {
|
||||||
if (sSettings.OutputData) {
|
if (sSettings.OutputData) {
|
||||||
WriteData();
|
WriteData();
|
||||||
}
|
}
|
||||||
if (sSettings.OutputDynsym) {
|
if (sSettings.OutputSym) {
|
||||||
WriteDynsym();
|
WriteSym();
|
||||||
}
|
}
|
||||||
if (sSettings.OutputBss) {
|
if (sSettings.OutputVars) {
|
||||||
WriteBss();
|
WriteVars();
|
||||||
}
|
}
|
||||||
Console.WriteLine("Closing output file...");
|
Console.WriteLine("Closing output file...");
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,9 @@ namespace arookas {
|
||||||
sTextOffset = sReader.Read32();
|
sTextOffset = sReader.Read32();
|
||||||
sDataOffset = sReader.Read32();
|
sDataOffset = sReader.Read32();
|
||||||
sDataCount = sReader.ReadS32();
|
sDataCount = sReader.ReadS32();
|
||||||
sDynsymOffset = sReader.Read32();
|
sSymOffset = sReader.Read32();
|
||||||
sDynsymCount = sReader.ReadS32();
|
sSymCount = sReader.ReadS32();
|
||||||
sBssCount = sReader.ReadS32();
|
sVarCount = sReader.ReadS32();
|
||||||
}
|
}
|
||||||
static void WriteHeader() {
|
static void WriteHeader() {
|
||||||
Console.WriteLine("Outputting header...");
|
Console.WriteLine("Outputting header...");
|
||||||
|
@ -98,17 +98,17 @@ namespace arookas {
|
||||||
sWriter.WriteLine("# .text offset : {0:X8}", sTextOffset);
|
sWriter.WriteLine("# .text offset : {0:X8}", sTextOffset);
|
||||||
sWriter.WriteLine("# .data offset : {0:X8}", sDataOffset);
|
sWriter.WriteLine("# .data offset : {0:X8}", sDataOffset);
|
||||||
sWriter.WriteLine("# .data count : {0}", sDataCount);
|
sWriter.WriteLine("# .data count : {0}", sDataCount);
|
||||||
sWriter.WriteLine("# .dynsym offset : {0:X8}", sDynsymOffset);
|
sWriter.WriteLine("# .sym offset : {0:X8}", sSymOffset);
|
||||||
sWriter.WriteLine("# .dynsym count : {0}", sDynsymCount);
|
sWriter.WriteLine("# .sym count : {0}", sSymCount);
|
||||||
sWriter.WriteLine("# .bss count : {0}", sBssCount);
|
sWriter.WriteLine("# var count : {0}", sVarCount);
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
}
|
}
|
||||||
static void WriteText() {
|
static void WriteText() {
|
||||||
Console.WriteLine("Outputting .text...");
|
Console.WriteLine("Outputting .text...");
|
||||||
sWriter.WriteLine(".text");
|
sWriter.WriteLine(".text");
|
||||||
WriteText(0u);
|
WriteText(0u);
|
||||||
var symbols = new Symbol[sDynsymCount];
|
var symbols = new Symbol[sSymCount];
|
||||||
for (var i = 0; i < sDynsymCount; ++i) {
|
for (var i = 0; i < sSymCount; ++i) {
|
||||||
symbols[i] = FetchSymbol(i);
|
symbols[i] = FetchSymbol(i);
|
||||||
}
|
}
|
||||||
foreach (var symbol in symbols.Where(i => i.Type == SymbolType.Function).OrderBy(i => i.Data)) {
|
foreach (var symbol in symbols.Where(i => i.Type == SymbolType.Function).OrderBy(i => i.Data)) {
|
||||||
|
@ -120,10 +120,12 @@ namespace arookas {
|
||||||
byte command;
|
byte command;
|
||||||
sReader.Keep();
|
sReader.Keep();
|
||||||
sReader.Goto(sTextOffset + ofs);
|
sReader.Goto(sTextOffset + ofs);
|
||||||
|
var maxofs = 0u;
|
||||||
do {
|
do {
|
||||||
var pos = sReader.Position - sTextOffset;
|
var pos = sReader.Position - sTextOffset;
|
||||||
command = sReader.Read8();
|
command = sReader.Read8();
|
||||||
sWriter.Write(" {0:X8} {1}", pos, sCommandNames[command]);
|
sWriter.Write(" {0:X8} {1}", pos, sCommandNames[command]);
|
||||||
|
var nextofs = 0u;
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 0x00: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
case 0x00: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
||||||
case 0x01: sWriter.Write(" {0}", sReader.ReadF32()); break;
|
case 0x01: sWriter.Write(" {0}", sReader.ReadF32()); break;
|
||||||
|
@ -157,12 +159,14 @@ namespace arookas {
|
||||||
case 0x1D: sWriter.Write(" {0}, {1}", FetchSymbolName(FetchSymbol(sReader.ReadS32())), sReader.ReadS32()); break;
|
case 0x1D: sWriter.Write(" {0}, {1}", FetchSymbolName(FetchSymbol(sReader.ReadS32())), sReader.ReadS32()); break;
|
||||||
case 0x1E: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
case 0x1E: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
||||||
case 0x1F: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
case 0x1F: sWriter.Write(" {0}", sReader.ReadS32()); break;
|
||||||
case 0x22: WriteJmp(ofs); break;
|
case 0x22: nextofs = WriteJmp(ofs); break;
|
||||||
case 0x23: WriteJmp(ofs); break;
|
case 0x23: nextofs = WriteJmp(ofs); break;
|
||||||
}
|
}
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
|
if (nextofs > maxofs) {
|
||||||
} while (command != 0x21 && command != 0x27);
|
maxofs = nextofs;
|
||||||
|
}
|
||||||
|
} while (!IsReturnCommand(command) || sReader.Position <= sTextOffset + maxofs);
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
sReader.Back();
|
sReader.Back();
|
||||||
}
|
}
|
||||||
|
@ -191,34 +195,34 @@ namespace arookas {
|
||||||
Console.WriteLine("Outputting .data...");
|
Console.WriteLine("Outputting .data...");
|
||||||
sWriter.WriteLine(".data");
|
sWriter.WriteLine(".data");
|
||||||
sReader.Goto(sDataOffset);
|
sReader.Goto(sDataOffset);
|
||||||
for (int i = 0; i < sDataCount; ++i) {
|
for (var i = 0; i < sDataCount; ++i) {
|
||||||
var ofs = sReader.Read32();
|
var ofs = sReader.Read32();
|
||||||
var data = FetchDataValue(ofs);
|
var data = FetchDataValue(ofs);
|
||||||
sWriter.WriteLine(" .string \"{0}\"", data);
|
sWriter.WriteLine(" .string \"{0}\"", data);
|
||||||
}
|
}
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
}
|
}
|
||||||
static void WriteDynsym() {
|
static void WriteSym() {
|
||||||
Console.WriteLine("Outputting .dynsym...");
|
Console.WriteLine("Outputting .sym...");
|
||||||
sWriter.WriteLine(".dynsym");
|
sWriter.WriteLine(".sym");
|
||||||
sReader.Goto(sDynsymOffset);
|
sReader.Goto(sSymOffset);
|
||||||
for (int i = 0; i < sDynsymCount; ++i) {
|
for (var i = 0; i < sSymCount; ++i) {
|
||||||
var symbol = new Symbol(sReader);
|
var symbol = new Symbol(sReader);
|
||||||
var name = FetchSymbolName(symbol);
|
var name = FetchSymbolName(symbol);
|
||||||
sWriter.WriteLine(" .{0} {1}", sSymbolTypes[(int)symbol.Type], name);
|
sWriter.WriteLine(" .{0} {1}", sSymbolTypes[(int)symbol.Type], name);
|
||||||
}
|
}
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
}
|
}
|
||||||
static void WriteBss() {
|
static void WriteVars() {
|
||||||
Console.WriteLine("Outputting .bss...");
|
Console.WriteLine("Outputting variables...");
|
||||||
sWriter.WriteLine(".bss");
|
sWriter.WriteLine("# variables:");
|
||||||
for (int i = 0; i < sBssCount; ++i) {
|
for (var i = 0; i < sVarCount; ++i) {
|
||||||
var symbol = FetchSymbol(j => j.Type == SymbolType.Variable && j.Data == i);
|
var symbol = FetchSymbol(j => j.Type == SymbolType.Variable && j.Data == i);
|
||||||
if (symbol != null) {
|
if (symbol != null) {
|
||||||
sWriter.WriteLine(" .var {0}", FetchSymbolName(symbol));
|
sWriter.WriteLine("# {0}", FetchSymbolName(symbol));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sWriter.WriteLine(" .var");
|
sWriter.WriteLine("# (NULL)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sWriter.WriteLine();
|
sWriter.WriteLine();
|
||||||
|
@ -233,7 +237,7 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
static string FetchDataValue(int i) {
|
static string FetchDataValue(int i) {
|
||||||
if (i < 0 || i >= sDataCount) {
|
if (i < 0 || i >= sDataCount) {
|
||||||
return "null";
|
return "(NULL)";
|
||||||
}
|
}
|
||||||
return FetchDataValue(FetchData(i));
|
return FetchDataValue(FetchData(i));
|
||||||
}
|
}
|
||||||
|
@ -246,7 +250,7 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
static Symbol FetchSymbol(int i) {
|
static Symbol FetchSymbol(int i) {
|
||||||
sReader.Keep();
|
sReader.Keep();
|
||||||
sReader.Goto(sDynsymOffset + (20 * i));
|
sReader.Goto(sSymOffset + (20 * i));
|
||||||
var symbol = new Symbol(sReader);
|
var symbol = new Symbol(sReader);
|
||||||
sReader.Back();
|
sReader.Back();
|
||||||
return symbol;
|
return symbol;
|
||||||
|
@ -257,8 +261,8 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
Symbol found = null;
|
Symbol found = null;
|
||||||
sReader.Keep();
|
sReader.Keep();
|
||||||
sReader.Goto(sDynsymOffset);
|
sReader.Goto(sSymOffset);
|
||||||
for (int i = 0; i < sDynsymCount; ++i) {
|
for (var i = 0; i < sSymCount; ++i) {
|
||||||
var symbol = new Symbol(sReader);
|
var symbol = new Symbol(sReader);
|
||||||
if (predicate(symbol)) {
|
if (predicate(symbol)) {
|
||||||
found = symbol;
|
found = symbol;
|
||||||
|
@ -270,10 +274,18 @@ namespace arookas {
|
||||||
}
|
}
|
||||||
static string FetchSymbolName(Symbol symbol) {
|
static string FetchSymbolName(Symbol symbol) {
|
||||||
sReader.Keep();
|
sReader.Keep();
|
||||||
sReader.Goto(sDynsymOffset + (20 * sDynsymCount) + symbol.StringOffset);
|
sReader.Goto(sSymOffset + (20 * sSymCount) + symbol.StringOffset);
|
||||||
var name = sReader.ReadString<aZSTR>();
|
var name = sReader.ReadString<aZSTR>();
|
||||||
sReader.Back();
|
sReader.Back();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsReturnCommand(byte cmd) {
|
||||||
|
return (
|
||||||
|
cmd == 0x20 || // ret
|
||||||
|
cmd == 0x21 || // ret0
|
||||||
|
cmd == 0x27 // end
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,15 @@ using System.IO;
|
||||||
namespace arookas {
|
namespace arookas {
|
||||||
class CommandLineSettings {
|
class CommandLineSettings {
|
||||||
string mInput, mOutput;
|
string mInput, mOutput;
|
||||||
bool mOutputHeader, mOutputText, mOutputData, mOutputDynsym, mOutputBss;
|
bool mOutputHeader, mOutputText, mOutputData, mOutputSym, mOutputVars;
|
||||||
|
|
||||||
public string Input { get { return mInput; } }
|
public string Input { get { return mInput; } }
|
||||||
public string Output { get { return mOutput; } }
|
public string Output { get { return mOutput; } }
|
||||||
public bool OutputHeader { get { return mOutputHeader; } }
|
public bool OutputHeader { get { return mOutputHeader; } }
|
||||||
public bool OutputText { get { return mOutputText; } }
|
public bool OutputText { get { return mOutputText; } }
|
||||||
public bool OutputData { get { return mOutputData; } }
|
public bool OutputData { get { return mOutputData; } }
|
||||||
public bool OutputDynsym { get { return mOutputDynsym; } }
|
public bool OutputSym { get { return mOutputSym; } }
|
||||||
public bool OutputBss { get { return mOutputBss; } }
|
public bool OutputVars { get { return mOutputVars; } }
|
||||||
|
|
||||||
public CommandLineSettings(aCommandLine cmd) {
|
public CommandLineSettings(aCommandLine cmd) {
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
|
@ -28,10 +28,10 @@ namespace arookas {
|
||||||
case "-t": mOutputText = false; continue;
|
case "-t": mOutputText = false; continue;
|
||||||
case "-D": mOutputData = true; continue;
|
case "-D": mOutputData = true; continue;
|
||||||
case "-d": mOutputData = false; continue;
|
case "-d": mOutputData = false; continue;
|
||||||
case "-S": mOutputDynsym = true; continue;
|
case "-S": mOutputSym = true; continue;
|
||||||
case "-s": mOutputDynsym = false; continue;
|
case "-s": mOutputSym = false; continue;
|
||||||
case "-B": mOutputBss = true; continue;
|
case "-V": mOutputVars = true; continue;
|
||||||
case "-b": mOutputBss = false; continue;
|
case "-v": mOutputVars = false; continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mInput == null) {
|
if (mInput == null) {
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("ssc")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("ssc")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015 arookas")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
[assembly: Guid("5413c8e1-aefa-43bc-9fe5-c95f221da8c5")]
|
|
||||||
[assembly: AssemblyVersion("0.1.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
|
Loading…
Reference in a new issue