当前位置: 首页>>代码示例>>C#>>正文


C# InstructionNode.IsBranch方法代码示例

本文整理汇总了C#中InstructionNode.IsBranch方法的典型用法代码示例。如果您正苦于以下问题:C# InstructionNode.IsBranch方法的具体用法?C# InstructionNode.IsBranch怎么用?C# InstructionNode.IsBranch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InstructionNode的用法示例。


在下文中一共展示了InstructionNode.IsBranch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProgramInfo


//.........这里部分代码省略.........

                    // add label to table, and see if there was anything after the label
                    m_label_table.Add(lab_to_add, lines_of_actual_code);

                    // set the current line to everything after the label and continue
                    current_line = match.Groups[2].Value.Trim();

                    // if this is a label by itself, continue.
                    if (current_line == "" || current_line[0] == ';')
                    {
                        continue;
                    }
                }

                match = opcode_operand_comment_splitter.Match(current_line);
                if (match.Success)
                {
                    string opcode = match.Groups[1].Value;

                    // make sure the opcode exists
                    Program.Instruction inst;
                    if (!cheat_sheet.LookupInstruction(opcode, out inst))
                    {
                        ErrorInvalidOpcode(line_num, opcode);
                        return;
                    }

                    InstructionNode dependency_node = new InstructionNode(opcode, inst);
                    dependency_node.m_original_inst_num = m_original_program.Count;
                    m_original_program.Add(dependency_node);
                    ++m_instruction_cnt[inst.m_pipeline == Program.Pipe.EVEN? 0 : 1];

                    // dont allow jumps in the middle of the code. Todo: check branch target as well
                    if (dependency_node.IsBranch(cheat_sheet) && line_num < lines.Length - 1)
                    {
                        ErrorInvalidBranchSlot(line_num);
                        return;
                    }
                    else if (dependency_node.IsBranch(cheat_sheet) == false && line_num == lines.Length - 1)
                    {
                        ErrorLastInstructionNotBranch(line_num);
                        return;
                    }

                    // don't do anything for opcodes that dont require operands
                    int num_expected_operands = inst.GetNumExpectedOperands();
                    if (num_expected_operands > 0)
                    {
                        // group 2 must be opcodes. If it starts with a semicolon, we are missing the proper operands
                        if (match.Groups[2].Value.Length < 1 || match.Groups[2].Value[0] == ';' || match.Groups[2].Value == "")
                        {
                            ErrorNoOperands(line_num, opcode, num_expected_operands);
                            return;
                        }

                        // now the real work begins.  Verify the operands are what they should be
                        string operands_match = match.Groups[2].Value;
                        string[] operands = operands_match.Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                        // wrong number of operands
                        if (operands.Length != num_expected_operands)
                        {
                            ErrorWrongNumOperands(line_num, opcode, num_expected_operands, operands.Length);
                            return;
                        }
开发者ID:okonomiyonda,项目名称:TREMBLE,代码行数:66,代码来源:ProgramInfo.cs


注:本文中的InstructionNode.IsBranch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。