示例#1
0
    DisassemblerContext::TermDefinitionList* DisassemblerContext::term_definition_list(const ValuePtr<>& term) {
#if PSI_DEBUG
      switch (term->term_type()) {
      case term_global_variable:
      case term_function:
      case term_block:
      case term_phi:
      case term_parameter_placeholder:
      case term_function_parameter:
        PSI_FAIL("term type should not go in definition lists");
        
      default:
        break;
      }
#endif

      // Should this term be named?
      ValuePtr<Block> block;
      ValuePtr<Function> function;
      if (Value *source = term->disassembler_source()) {
        switch (source->term_type()) {
        case term_global_variable:
        case term_function:
        case term_recursive:
          return &m_global_definitions;

        case term_block: block.reset(value_cast<Block>(source)); break;
        case term_phi: block = value_cast<Phi>(source)->block(); break;
        case term_instruction: block = value_cast<Instruction>(source)->block(); break;

        case term_parameter_placeholder: return NULL;

        case term_function_parameter:
          function = value_cast<FunctionParameter>(source)->function();
          block = function->blocks().front();
          break;

        default: PSI_FAIL("unexpected source term type");
        }
      }

      if (m_in_function_mode || (!block && !function))
        return &m_global_definitions;
      
      if (block)
        return &m_local_definitions[block];
      
      return NULL;
    }