public ScriptBlock(TJS owner, string name, int lineoffset, string script, ScriptLineData linedata) { // a class for managing the script block // 以下の4つは实行时にいるかな、名前以外はエラー発生时に必要になるだけだろうけど。 mOwner = owner; mName = name; mLineOffset = lineoffset; mScript = script; mLineData = linedata; mOwner.AddScriptBlock(this); }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> /// <exception cref="Kirikiri.Tjs2.CompileException"></exception> /// <exception cref="Kirikiri.Tjs2.TJSException"></exception> public virtual void Parse(string script, bool isexpr, bool resultneeded) { mCompileErrorCount = 0; mLexicalAnalyzer = new LexicalAnalyzer(this, script, isexpr, resultneeded); mLineData = new ScriptLineData(script, mLineOffset); Program(); mLexicalAnalyzer = null; if (mCompileErrorCount > 0) { throw new TJSScriptError(mFirstError, this, mFirstErrorPos); } }
public virtual void Compact() { if (TJS.IsLowMemory) { mScript = null; mLineData = null; int count = mInterCodeObjectList.Count; for (int i = 0; i < count; i++) { InterCodeObject v = mInterCodeObjectList[i].Get(); if (v != null) { v.Compact(); } } } }
public virtual void LexTest(string script) { Compiler compiler = new Compiler(this); int token = 0; int token1; ScriptLineData lineData = new ScriptLineData(script, 0); Lexer lexer = new Lexer(compiler, script, false, false); LexicalAnalyzer lex = new LexicalAnalyzer(compiler, script, false, false); try { do { token = lexer.GetNext(); token1 = lex.GetNext(); if (token1 != token) { int oleline = lineData.GetSrcPosToLine(lexer.GetCurrentPosition()); int newline = lineData.GetSrcPosToLine(lex.GetCurrentPosition()); System.Console.Out.Write("error line:" + oleline + ", " + newline + "\n"); } int v1 = lexer.GetValue(); int v2 = lex.GetValue(); if (v1 != v2) { int oleline = lineData.GetSrcPosToLine(lexer.GetCurrentPosition()); int newline = lineData.GetSrcPosToLine(lex.GetCurrentPosition()); System.Console.Out.Write("error line:" + oleline + ", " + newline + "\n"); } if (v1 != 0) { object o1 = lexer.GetValue(v1).ToJavaObject(); object o2 = lex.GetValue(v2).ToJavaObject(); if (!o1.Equals(o2)) { int oleline = lineData.GetSrcPosToLine(lexer.GetCurrentPosition()); int newline = lineData.GetSrcPosToLine(lex.GetCurrentPosition()); System.Console.Out.Write("o1:" + o1.ToString() + ", o2" + o2.ToString() + "\n"); System.Console.Out.Write("error line:" + oleline + ", " + newline + "\n"); } } } while (token != 0); } catch (CompileException) { } long start = Runtime.CurrentTimeMillis(); lexer = new Lexer(compiler, script, false, false); try { do { token = lexer.GetNext(); lexer.GetValue(); } while (token != 0); } catch (CompileException) { } long time = Runtime.CurrentTimeMillis() - start; System.Console.Out.Write("old lex : " + time + "ms\n"); start = Runtime.CurrentTimeMillis(); lex = new LexicalAnalyzer(compiler, script, false, false); try { do { token = lex.GetNext(); lex.GetValue(); } while (token != 0); } catch (CompileException) { } time = Runtime.CurrentTimeMillis() - start; System.Console.Out.Write("new lex : " + time + "ms\n"); }