Added full data/symbol table information to results
I felt this is better than having 5 count properties.
This commit is contained in:
parent
5de905e9e5
commit
306cb5f5fd
3 changed files with 54 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace arookas
|
||||
|
@ -22,11 +23,11 @@ namespace arookas
|
|||
var results = compiler.Compile(inputFile, output);
|
||||
if (results.Success) {
|
||||
Message("Finished compiling in {0:F2}ms.\n", results.CompileTime.TotalMilliseconds);
|
||||
Message(" Data count: {0}\n", results.DataCount);
|
||||
Message("Symbol count: {0}\n", results.SymbolCount);
|
||||
Message(" - builtins: {0}\n", results.BuiltinCount);
|
||||
Message(" - functions: {0}\n", results.FunctionCount);
|
||||
Message(" - variables: {0}\n", results.VariableCount);
|
||||
Message(" Data count: {0}\n", results.Data.Length);
|
||||
Message("Symbol count: {0}\n", results.Symbols.Length);
|
||||
Message(" - builtins: {0}\n", results.Symbols.Count(i => i.Type == sunSymbolType.Builtin));
|
||||
Message(" - functions: {0}\n", results.Symbols.Count(i => i.Type == sunSymbolType.Function));
|
||||
Message(" - variables: {0}\n", results.Symbols.Count(i => i.Type == sunSymbolType.Variable));
|
||||
}
|
||||
else {
|
||||
if (results.Error is sunSourceException) {
|
||||
|
|
|
@ -30,11 +30,8 @@ Use the various properties on this type to gather the information of the compila
|
|||
|`Success`|Whether the script was compiled successfully. If not, the `Error` property will be non-`null`.|
|
||||
|`Error`|The fatal error which occured during compilation. If compilation was successful, this will be `null`.|
|
||||
|`CompileTime`|The time it took to compile, measured as a `TimeSpan` instance.|
|
||||
|`DataCount`|The total number of data-table entries created.|
|
||||
|`SymbolCount`|The total number of symbols (builtins, functions, and variables) created.|
|
||||
|`BuiltinCount`|The total number of builtin symbols created.|
|
||||
|`FunctionCount`|The total number of function symbols created.|
|
||||
|`VariableCount`|The total number of global-scope variable symbols created.|
|
||||
|`Data`|An array containing the data-table entries.|
|
||||
|`Symbols`|An array containing the symbol-table entries.|
|
||||
|
||||
If the error is of the type `sunSourceException`, you can cast and retrieve the script name, line, and column of the error.
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace arookas {
|
||||
public class sunCompiler {
|
||||
|
@ -63,11 +64,8 @@ namespace arookas {
|
|||
mBinary.EndSymbol();
|
||||
mBinary.Close();
|
||||
|
||||
results.DataCount = mContext.DataTable.Count;
|
||||
results.SymbolCount = mContext.SymbolTable.Count;
|
||||
results.BuiltinCount = mContext.SymbolTable.GetCount<sunBuiltinSymbol>();
|
||||
results.FunctionCount = mContext.SymbolTable.GetCount<sunFunctionSymbol>();
|
||||
results.VariableCount = mContext.SymbolTable.GetCount<sunVariableSymbol>();
|
||||
results.Data = mContext.DataTable.ToArray();
|
||||
results.Symbols = mContext.SymbolTable.Select(i => new sunSymbolInfo(i.Type, i.Name)).ToArray();
|
||||
}
|
||||
catch (sunCompilerException ex) {
|
||||
results.Error = ex;
|
||||
|
@ -168,17 +166,50 @@ namespace arookas {
|
|||
}
|
||||
|
||||
public class sunCompilerResults {
|
||||
// success
|
||||
public bool Success { get { return Error == null; } }
|
||||
public sunCompilerException Error { get; internal set; }
|
||||
sunCompilerException mError;
|
||||
TimeSpan mTime;
|
||||
string[] mData;
|
||||
sunSymbolInfo[] mSymbols;
|
||||
|
||||
// statistics
|
||||
public int DataCount { get; internal set; }
|
||||
public int SymbolCount { get; internal set; }
|
||||
public int BuiltinCount { get; internal set; }
|
||||
public int FunctionCount { get; internal set; }
|
||||
public int VariableCount { get; internal set; }
|
||||
public bool Success {
|
||||
get { return mError == null; }
|
||||
}
|
||||
|
||||
public TimeSpan CompileTime { get; internal set; }
|
||||
public sunCompilerException Error {
|
||||
get { return mError; }
|
||||
internal set { mError = value; }
|
||||
}
|
||||
public TimeSpan CompileTime {
|
||||
get { return mTime; }
|
||||
internal set { mTime = value; }
|
||||
}
|
||||
public string[] Data {
|
||||
get { return mData; }
|
||||
internal set { mData = value; }
|
||||
}
|
||||
public sunSymbolInfo[] Symbols {
|
||||
get { return mSymbols; }
|
||||
internal set { mSymbols = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public class sunSymbolInfo {
|
||||
sunSymbolType mType;
|
||||
string mName;
|
||||
|
||||
public sunSymbolType Type {
|
||||
get { return mType; }
|
||||
}
|
||||
public string Name {
|
||||
get { return mName; }
|
||||
}
|
||||
|
||||
internal sunSymbolInfo(sunSymbolType type, string name) {
|
||||
if (name == null) {
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
mType = type;
|
||||
mName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue