public Compiler(IAstModuleLoader moduleLoader) { Context = new CompilerContext(moduleLoader); _astBuilder = new AstBuilder(Context); _resolveDefinition = new ResolveDefinition(Context); _checkRules = new CheckRules(Context); }
public static AstFile File(string code, IAstModuleLoader moduleLoader = null) { var file = ParseFile(code); var context = new CompilerContext(moduleLoader ?? new ModuleLoader()); return(BuildFile(file, context)); }
public static AstModuleImpl Module(string code, IAstModuleLoader moduleLoader = null) { var file = ParseFile(code); var context = new CompilerContext(moduleLoader ?? new ModuleLoader()); _ = BuildFile(file, context); return((AstModuleImpl)context.Modules.Modules.First()); }
public static AstFile File(string code, IAstModuleLoader moduleLoader = null) { var compiler = new Compiler(moduleLoader ?? new ModuleLoader()); var errors = compiler.ParseAst("UnitTests", "UnitTests", code); errors.PrintErrors(); errors.Should().BeEmpty(); return(((AstModuleImpl)compiler.Context.Modules.Modules.First()).Files.First()); }
public static EmitCode Run(string code, string testName, IAstModuleLoader moduleLoader = null) { var emit = Emit.Create(code, moduleLoader); emit.SaveAs($@".\{testName}\{testName}.cs"); Console.WriteLine(emit.ToString()); var targetPath = Emit.Build(testName); File.Exists(targetPath).Should().BeTrue(); return(emit); }
public static EmitCode Create(string code, IAstModuleLoader moduleLoader = null) { var compiler = new Compiler(moduleLoader ?? new ModuleLoader()); var errors = compiler.ParseAst("UnitTests", AssemblyName, code); foreach (var err in errors) { Console.WriteLine(err); } errors.Should().BeEmpty(); var module = compiler.Context.Modules.Modules.First(); var emit = new EmitCode(AssemblyName); emit.Visit(module); return(emit); }
public CompilerContext(IAstModuleLoader moduleLoader) { IntrinsicSymbols = CreateIntrinsicSymbols(); Modules = new AstModuleManager(IntrinsicSymbols, moduleLoader); }