示例#1
0
        /// <summary>
        /// Compiles the given source into a bank.
        /// </summary>
        /// <param name="inSource">Source for entries.</param>
        /// <param name="inLinks">Optional collection of banks to use when linking.</param>
        public MacroCompilerResult Compile(IMacroCompilerSource inSource, ICollection <MacroBank> inLinks = null)
        {
            ClearOutputState();

            m_LinkedBanks = inLinks;

            if (m_Config != null)
            {
                if (m_Config.RecognizedMacros != null)
                {
                    foreach (var macro in m_Config.RecognizedMacros)
                    {
                        SetMacroKnown(macro);
                    }
                }
            }

            MacroCompilerResult result = new MacroCompilerResult();

            foreach (var kv in inSource.Entries)
            {
                CompileEntry(kv.Key, kv.Value);
            }

            result.Bank = new CompiledMacroBank(m_MacroDictionary, m_StringTable.ToArray());

            result.UnrecognizedMacros   = ToArray(m_UnknownMacros);
            result.UnrecognizedMacroIds = ToArray(m_UnknownMacroHashes);
            result.MacroNames           = ToArray(m_CompiledMacroNames);

            result.MacroCount    = m_MacroDictionary.Count;
            result.StringCount   = m_StringTable.Count;
            result.ReusedStrings = m_StringReuseCounter;

            ClearOutputState();

            return(result);
        }
示例#2
0
 /// <summary>
 /// Asynchronously compiles the given source into a bank.
 /// Each call to MoveNext on the iterator will compile one entry.
 /// </summary>
 /// <param name="inSource">Source for entries.</param>
 /// <param name="outResult">Target for storing compilation results.</param>
 public IEnumerator CompileAsync(IMacroCompilerSource inSource, MacroCompilerResult outResult)
 {
     return(CompileAsync(inSource, null, outResult));
 }