/// <summary> /// Compiles the AST. /// </summary> public IodineModule Compile() { // Analyze the AST symbolTable = new SemanticAnalyzer().Analyze(root); // Create the module var module = new IodineModule(); // Create the context var context = new CompilerContext( symbolTable: symbolTable, module: module, emitter: module.Initializer ); // Push the context haystack.Push(context); // Compile the AST root.Visit(this); // Resolve the initializer module.Initializer.Resolve(); // Pop the context haystack.Pop(); // Return the module return(module); }
/// <summary> /// Initializes a new instance of the <see cref="T:XenonCore.CompilerContext"/> class. /// </summary> /// <param name="symbolTable">Symbol table.</param> /// <param name="module">Module.</param> /// <param name="emitter">Emitter.</param> /// <param name="isWithinClass">Modification flag.</param> public CompilerContext( SymbolTable symbolTable, IodineModule module, Emitter emitter, bool isWithinClass = false ) { // Assign required arguments SymbolTable = symbolTable; Module = module; Emitter = emitter; // Assign optional arguments IsWithinClass = isWithinClass; }