Exemplo n.º 1
0
        protected override void ExecuteInternal(AssembleOptions opts, IConfiguration config)
        {
            try
            {
                var content     = _reader.ReadStringContent(opts.FilePath);
                var parser      = new IlParser(content);
                var codeBuilder = parser.Parse();
                var program     = codeBuilder.GetBinaryProgram();

                _writer.WriteFile(opts.FilePath, program);
            }
            catch (CliException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        protected override void ExecuteInternal(FormatOptions opts, IConfiguration config)
        {
            try
            {
                var content     = _reader.ReadStringContent(opts.FilePath);
                var parser      = new IlParser(content);
                var codeBuilder = parser.Parse();
                var program     = codeBuilder.GetIlProgram();
                var code        = CodeFormatter.Format(program, new CodeFormatSettings()
                {
                    InstructionIndentSize = 4
                });

                _writer.WriteFile(opts.FilePath, code);
            }
            catch (CliException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }