Esempio n. 1
0
 private static void ValidateEntryPoint(CodeGenerator generator, RppOptions options, Diagnostic diagnostic)
 {
     if (options.Library == false && !generator.HasMain())
     {
         diagnostic.Error(101, "Program doesn't contain a valid entry point");
     }
 }
Esempio n. 2
0
        private static int RunAndReturnExitCode(RppOptions options)
        {
            Diagnostic diagnostic = new Diagnostic();
            RppCompiler.CompileAndSave(options, diagnostic);

            diagnostic.Report();

            if (diagnostic.Errors.Any())
            {
                return 1;
            }

            return 0;
        }
Esempio n. 3
0
        public static void CompileAndSave(RppOptions options, Diagnostic diagnostic)
        {
            string outFileName = GetOutputFileName(options);

            Assembly stdlib = null;
            if (!options.Nostdlib)
            {
                stdlib = FindStdlib();
            }

            CodeGenerator generator = Compile(program => Parse(options.InputFiles, program), diagnostic, stdlib, outFileName);
            if (generator != null)
            {
                ValidateEntryPoint(generator, options, diagnostic);
                if (!diagnostic.Errors.Any())
                {
                    generator.Save(options.Library ? ApplicationType.Library : ApplicationType.Application);
                }
            }
        }
Esempio n. 4
0
 private static string GenerateOutputFileName(RppOptions options)
 {
     string ext = options.Library ? ".dll" : ".exe";
     string firstFile = options.InputFiles.First();
     return Path.GetFileNameWithoutExtension(firstFile) + ext;
 }
Esempio n. 5
0
 private static string GetOutputFileName(RppOptions options)
 {
     return !string.IsNullOrEmpty(options.Out) ? options.Out : GenerateOutputFileName(options);
 }