private void Compile() { MacroCompiler compiler = new MacroCompiler(this); SimpleMacroCompilerSource asset = new SimpleMacroCompilerSource(m_Asset.text); MacroCompilerResult result = compiler.Compile(asset); m_Bank = result.Bank; foreach (var unknown in result.UnrecognizedMacros) { Debug.LogWarning("Unknown macro " + unknown); } foreach (var unknown in result.UnrecognizedMacroIds) { Debug.LogWarning("Unknown macro id " + unknown); } foreach (var exported in result.MacroNames) { Debug.Log("Exported macro " + exported); } Debug.Log("Reused strings: " + result.ReusedStrings); }
/// <summary> /// Initializes a new instance of the <see cref="Parser"/> class. /// </summary> /// <param name="compiler">The <see cref="MacroCompiler"/> to use for compiling macros.</param> public Parser(MacroCompiler compiler) { this.compiler = compiler; }
private void ProcessInternalMacro(InternalClass klass, MacroStatement node) { Type macroType = new MacroCompiler(Context).Compile(klass); if (null == macroType) { Errors.Add(CompilerErrorFactory.AstMacroMustBeExternal(node, klass.FullName)); return; } ProcessMacro(macroType, node); }
private void ProcessInternalMacro(InternalClass klass, MacroStatement node) { TypeDefinition macroDefinition = klass.TypeDefinition; if (MacroDefinitionContainsMacroApplication(macroDefinition, node)) { ProcessingError(CompilerErrorFactory.InvalidMacro(node, klass.FullName)); return; } bool firstTry = ! MacroCompiler.AlreadyCompiled(macroDefinition); Type macroType = new MacroCompiler(Context).Compile(macroDefinition); if (null == macroType) { if (firstTry) { ProcessingError(CompilerErrorFactory.AstMacroMustBeExternal(node, klass.FullName)); } else { RemoveCurrentNode(); } return; } ProcessMacro(macroType, node); }