/// <summary> /// Processes the CompilationUnit cu immediately /// </summary> /// <param name="cu"></param> public void ProcessSynchronous(CompilationUnit cu) { DoProcess(cu); }
/// <summary> /// The main processing function for the database /// </summary> /// <param name="cu"></param> private void DoProcess(CompilationUnit cu) { lock (this) { // Gather all the scripts that use this lua file var scripts = FindScripts(cu.SourceKey); foreach (LuatScript script in scripts) { ((StatusImpl)Status).Action = string.Format("Dropping stale symbols from '{0}'", script.Name); if (null != script.CU) { // Remove any table variables that were declared in the old compilation unit Drop(script); } ((StatusImpl)Status).Action = string.Format("Adding symbols for {0} ('{1}')", script.Name, Path.GetFileName(cu.SourceKey)); script.CU = cu; // Gather up all the expressions and statements and add them to the pending process lists foreach (LuatAstNodeBase node in Helpers.Traversal<IAstNode>(cu, n => n.ChildNodes)) { var expression = node as Expression; if (expression != null) AddUnresolvedExpression(script, expression); var statement = node as Statement; if (statement != null) AddUnresolvedStatement(script, statement); } } } // Resolve all the symbols DoResolve(); // Process all the warnings DoProcessWarnings(); // Done ((StatusImpl)Status).Finish(); }
/// <summary> /// Queues the processing of the CompilationUnit cu /// </summary> /// <param name="cu"></param> public void Process(CompilationUnit cu) { m_taskQueue.AddTask(() => DoProcess(cu), TaskQueue.Thread.Worker); }
/// <summary> /// Matches a <c>CompilationUnit</c> non-terminal. /// </summary> /// <returns><c>true</c> if the <c>CompilationUnit</c> was matched successfully; otherwise, <c>false</c>.</returns> /// <remarks> /// The non-terminal can start with: <c>Do</c>, <c>While</c>, <c>Repeat</c>, <c>If</c>, <c>For</c>, <c>Local</c>, <c>Function</c>, <c>Return</c>, <c>Break</c>, <c>OpenParenthesis</c>, <c>OpenCurlyBrace</c>, <c>Identifier</c>, <c>TripleDot</c>, <c>Nil</c>, <c>False</c>, <c>True</c>, <c>Number</c>, <c>Subtraction</c>, <c>Not</c>, <c>Hash</c>, <c>String</c>. /// </remarks> protected virtual bool MatchCompilationUnit() { compilationUnit = new CompilationUnit(); compilationUnit.StartOffset = 0; BlockStatement block; if (!this.MatchCUBlock(out block)) return false; compilationUnit.Block = block; compilationUnit.EndOffset = this.LookAheadToken.EndOffset; return true; }