From 8f683d16a3a8a32f2d662118b8186cf6abd759cc Mon Sep 17 00:00:00 2001 From: arookas Date: Sun, 31 Jan 2016 14:57:08 -0500 Subject: [PATCH] Moved system symbols to their own function --- ssc/context.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ssc/context.cs b/ssc/context.cs index 8b1f9fa..9f7d1aa 100644 --- a/ssc/context.cs +++ b/ssc/context.cs @@ -61,6 +61,7 @@ namespace arookas { mWriter = new aBinaryWriter(output, Endianness.Big, Encoding.GetEncoding(932)); Text = new sunWriter(mWriter); mWriter.PushAnchor(); + AddSystemSymbols(); WriteHeader(); // dummy header @@ -68,17 +69,6 @@ namespace arookas { mTextOffset = (uint)mWriter.Position; mWriter.PushAnchor(); // match code offsets and writer offsets - // add system builtins - Yield = AddSystemBuiltin("yield"); - Exit = AddSystemBuiltin("exit"); - Lock = AddSystemBuiltin("lock"); - Unlock = AddSystemBuiltin("unlock"); - Int = AddSystemBuiltin("int"); - Float = AddSystemBuiltin("float"); - Typeof = AddSystemBuiltin("typeof"); - - // add system variables - Switch = AddSystemVariable("$switch"); // storage for switch statements } public void Close() { if (!mOpen) { @@ -233,6 +223,20 @@ namespace arookas { return null; } + // system symbols + void AddSystemSymbols() { + // add system builtins + Yield = AddSystemBuiltin("yield"); + Exit = AddSystemBuiltin("exit"); + Lock = AddSystemBuiltin("lock"); + Unlock = AddSystemBuiltin("unlock"); + Int = AddSystemBuiltin("int"); + Float = AddSystemBuiltin("float"); + Typeof = AddSystemBuiltin("typeof"); + + // add system variables + Switch = AddSystemVariable("$switch"); // storage for switch statements + } sunCallableSymbol AddSystemBuiltin(string name) { var symbol = new sunBuiltinSymbol(name, SymbolTable.Count); SymbolTable.Add(symbol);