Minor cleanup
Now it constructs the context and parser only once.
This commit is contained in:
parent
9373c59c44
commit
8e093a98c7
1 changed files with 11 additions and 7 deletions
|
@ -7,6 +7,7 @@ namespace arookas {
|
|||
sunContext mContext;
|
||||
sunBinary mBinary;
|
||||
sunImportResolver mResolver;
|
||||
sunParser mParser;
|
||||
|
||||
internal sunContext Context {
|
||||
get { return mContext; }
|
||||
|
@ -18,6 +19,11 @@ namespace arookas {
|
|||
get { return mResolver; }
|
||||
}
|
||||
|
||||
public sunCompiler() {
|
||||
mContext = new sunContext();
|
||||
mParser = new sunParser();
|
||||
}
|
||||
|
||||
public sunCompilerResults Compile(string name, Stream output) {
|
||||
return Compile(name, output, sunImportResolver.Default);
|
||||
}
|
||||
|
@ -35,7 +41,7 @@ namespace arookas {
|
|||
var timer = Stopwatch.StartNew();
|
||||
try {
|
||||
mResolver = resolver;
|
||||
mContext = new sunContext();
|
||||
mContext.Clear();
|
||||
using (mBinary = new sunBinary(output)) {
|
||||
var result = Import(name);
|
||||
if (result != sunImportResult.Loaded) {
|
||||
|
@ -74,16 +80,14 @@ namespace arookas {
|
|||
throw new ArgumentNullException("name");
|
||||
}
|
||||
sunScriptFile file;
|
||||
var result = ImportResolver.ResolveImport(name, out file);
|
||||
var result = mResolver.ResolveImport(name, out file);
|
||||
if (result == sunImportResult.Loaded) {
|
||||
try {
|
||||
ImportResolver.EnterFile(file);
|
||||
mResolver.EnterFile(file);
|
||||
mContext.PushLocal();
|
||||
var parser = new sunParser();
|
||||
var tree = parser.Parse(file);
|
||||
tree.Compile(this);
|
||||
mParser.Parse(file).Compile(this);
|
||||
mContext.PopLocal();
|
||||
ImportResolver.ExitFile(file);
|
||||
mResolver.ExitFile(file);
|
||||
}
|
||||
finally {
|
||||
file.Dispose();
|
||||
|
|
Loading…
Add table
Reference in a new issue