public override object?VisitFile(FileContext context) { var file = New.AstFile(_namespace, _builderContext.CompilerContext.IntrinsicSymbols, context); _builderContext.SetCurrent(file); _builderContext.SetCurrent(file.CodeBlock); _ = base.VisitChildren(context); _builderContext.RevertCurrent(); _builderContext.RevertCurrent(); return(file); }
public AstFile Build(FileContext fileCtx, string moduleName) { // look ahead var modCtx = ToStatementModule(fileCtx); if (modCtx is not null) { moduleName = AstSymbolName.ToCanonical(modCtx.module_name().identifier_module().GetText()); } else { moduleName = AstSymbolName.ToCanonical(moduleName); var mod = _context.CompilerContext.Modules.GetOrAddModule(moduleName); _context.SetCurrent(mod); } var file = BuildFile(fileCtx, moduleName); if (modCtx is null) { // remove the AstModule we added. _context.RevertCurrent(); } var module = _context.CompilerContext.Modules.FindModule <AstModuleImpl>(file.SymbolTable.Name); module !.AddFile(file !); return(file); }