Exemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the AssemblyEditorViewModel. This is the view model associated
        /// with the editing of all assembly files, and contains a list of individual assembly file view models.
        /// </summary>
        /// <param name="viewId">The ID of the parent view. Used to make active view requests.</param>
        /// <param name="msgMgr">The message manager used to send messages to other views.</param>
        public AssemblyEditorViewModel(int viewId, MessageManager msgMgr) :
            base(msgMgr)
        {
            m_ViewId         = viewId;
            m_Disassembler   = new DisassemblyManager();
            m_OpenViewModels = new ObservableCollection <AssemblyFileViewModel>();

            m_Assembler               = new RiscVAssembler();
            m_AssembleFileCmd         = new RelayCommand <AssemblyCommandParams>(param => AssembleFile(param), false);
            m_NewFileCmd              = new RelayCommand(() => CreateNewFile(), true);
            m_OpenFileCmd             = new RelayCommand <string>((fileName) => OpenFile(fileName), true);
            m_SaveFileCmd             = new RelayCommand <string>((fileName) => SaveFile(fileName), true);
            m_CloseFileCmd            = new RelayCommand <int>(param => CloseFile(param), false);
            m_DisassembleAndImportCmd = new RelayCommand <string>(param => DisassembleAndImportFile(param), true);
            m_ChangeActiveIdxCmd      = new RelayCommand <int>(param => ActiveFileIndex = param, true);
            m_OpenPreferencesCmd      = new RelayCommand(
                () =>
            {
                BroadcastMessage(new BasicMessage(MessageType.ShowOptionsRequest));
            },
                true
                );

            CreateNewFile();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs the assembler with the provided set of arguments.
        /// </summary>
        /// <param name="options">The options provided by the user.</param>
        private static int RunAssembler(AssemblerOptions options)
        {
            ILogger logger      = null;
            string  logFileName = options.LogFile;

            if (!string.IsNullOrEmpty(logFileName) && !string.IsNullOrWhiteSpace(logFileName))
            {
                logger = new HybridLogger(logFileName.Trim());
            }
            else
            {
                logger = new ConsoleLogger();
            }

            RiscVAssembler assembler = new RiscVAssembler();

            try
            {
                assembler.Assemble(options, logger);
                if (options.RunAfterAssembly)
                {
                    string inputFile = options.InputFileNames.ElementAt(0);
                    // get the file name with no extension, in case we want intermediate files,
                    // or for our output.
                    string fileNameNoExtension = inputFile;
                    if (inputFile.Contains("."))
                    {
                        fileNameNoExtension = inputFile.Substring(0, inputFile.LastIndexOf('.'));
                    }

                    //TODO: this will def need to change if we implement more filetypes.
                    string outputFile = fileNameNoExtension + ".jef";

                    var runtimeOps = new InterpreterOptions(outputFile);
                    RunInterpreter(runtimeOps);
                }
            }
            catch (Exception)
            {
            }

            return(0);
        }
Exemplo n.º 3
0
        public bool AssembleFile(RiscVAssembler assembler, string outputFilePath)
        {
            Logger.ClearLogCommand.Execute(null);
            var options = new AssemblerOptions(new[] { FilePath }, new[] { outputFilePath });

            // clear any errors beforehand.
            FileErrors.Clear();
            AssemblerResult result = assembler.AssembleFile(FilePath, outputFilePath, Logger.Logger, options);

            if (!result.OperationSuccessful)
            {
                foreach (AssemblyException ex in result.UserErrors)
                {
                    FileErrors.Add(ex);
                }
            }

            return(result.OperationSuccessful);
        }