Example #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);
            }
        }
Example #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);
            }
        }