예제 #1
0
//-----------------------------------------------------------------------
//----------------------------------------------------------------------
// some utilities (size of npool)
//----------------------------------------------------------------------
// visible for converter only
char *convert_clsname(char *buf)
{
  if ( jasmin() )
    for(register char *p = buf; (p = strchr(p, j_clspath_dlm)) != NULL; p++)
      *p = j_field_dlm;

  return(buf);
}
예제 #2
0
파일: oututil.cpp 프로젝트: nealey/vera
//--------------------------------------------------------------------------
void idaapi footer(void)
{
  if ( !jasmin()) block_end(0 );
}
예제 #3
0
파일: oututil.cpp 프로젝트: nealey/vera
bool idaapi outop(op_t& x)
{
  uchar warn = 0;

  switch ( x.type ) {
    case o_near:
      if ( x.ref ) ++warn;
      else {
        if ( outName(cmd.ea + x.offb, x.n, curSeg.startEA, x.addr, &warn) ) break;
        if ( warn ) goto badop;
      }
      if ( putVal(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_32, warn) ) break;
      //PASS THRU
    case o_void:
badop:
      return(false);

    case o_imm:
      if ( x.ref == 2 ) ++warn;
      if ( putVal(x, OOFW_IMM | OOF_NUMBER | (x.ref ? OOFS_NOSIGN : OOF_SIGNED ),
                warn)) break;
      goto badop;

    case o_mem:
      if ( jasmin() ) goto putVarNum;
      if ( x.ref ) {
putAddr:
        ++warn;
      } else {
        if ( outName(cmd.ea + x.offb, x.n, curSeg.DataBase, x.addr, &warn) ) break;
        if ( warn ) goto badop;
      }
putVarNum:
      if ( putVal(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_16, warn) ) break;
      goto badop;

    case o_cpool:
      if ( !x.cp_ind) OUT_KEYWORD("NULL" );
      else {
        if ( x.ref ) goto putAddr;
        if ( !OutConstant(x) ) goto badop;
      }
      break;

    case o_array:
      if ( !x.ref ) {
        int i = (uchar)x.cp_type - (T_BOOLEAN-1); // -1 - correct tp_decl
        if ( i < 0 || i > T_LONG - (T_BOOLEAN-1) || chkOutKeyword(tp_decl[i].str, tp_decl[i].size) )
          goto badop;
      } else {
        static const char tt_bogust[] = "BOGUST_TYPE-";

        if ( !checkLine(sizeof(tt_bogust) + 2) ) goto badop;
        out_tagon(COLOR_ERROR);
        outcnt += out_snprintf("%c%s%u", WARN_SYM, tt_bogust, (uchar)x.cp_type);
        out_tagoff(COLOR_ERROR);
      }
      break;

    default:
      warning("out: %a: bad optype %d", cmd.ip, x.type);
      break;
  }
  return(true);
}
예제 #4
0
파일: oututil.cpp 프로젝트: nealey/vera
//----------------------------------------------------------------------
uchar OutConstant(op_t& x, uchar impdsc)
{
  register uchar    savetype = x.dtyp;
  register fmt_t    fmt = fmt_dscr;
  register color_t  ntag;

  switch ( (uchar)x.cp_type ) {
    default:
      warning("OC: bad constant type %u", (uchar)x.cp_type);
      break;

    case CONSTANT_Long:
      x.dtyp = dt_qword;
      goto outNum;
    case CONSTANT_Double:
      x.dtyp = dt_double;
      goto outNum;
    case CONSTANT_Integer:
      x.dtyp = dt_dword;
      goto outNum;
    case CONSTANT_Float:
      x.dtyp = dt_float;
outNum:
      if ( putVal(x, OOF_NUMBER | OOF_SIGNED | OOFW_IMM, 0) ) break;
badconst:
      return(0);

    case CONSTANT_String:
      if ( OutUtf8(x._name, fmt_string, COLOR_STRING) ) goto badconst;
      break;

    case CONSTANT_Class:
#ifdef __BORLANDC__
#if ( fmt_cast+1) != fmt_classname || (fmt_classname+1 ) != fmt_fullname
#error
#endif
#endif
      if ( OutUtf8(x._name, (fmt_t )x.addr_shorts.high,
                 (   (fmt_t)x.addr_shorts.high < fmt_cast
                  || (fmt_t)x.addr_shorts.high > fmt_fullname) ?
                 COLOR_KEYWORD : (cmd.xtrn_ip == 0xFFFF ? COLOR_DNAME :
                                                          COLOR_IMPNAME)))
                                                                goto badconst;
      break;

    case CONSTANT_InterfaceMethodref:
    case CONSTANT_Methodref:
        fmt = fmt_retdscr;
    case CONSTANT_Fieldref:
#ifdef VIEW_WITHOUT_TYPE
        if ( impdsc )
#endif
          if ( !jasmin() && OutUtf8(x._dscr, fmt, COLOR_KEYWORD) ) goto badconst;
        out_tagon(ntag = (x._class == curClass.This.Dscr) ? COLOR_DNAME :
                                                            COLOR_IMPNAME);
        if ( jasmin() || (ntag == COLOR_IMPNAME && !impdsc) ) { // other class
          if ( OutUtf8(x._name, fmt_classname) || chkOutDot() ) goto badconst;
        }
        if ( OutUtf8(x._subnam, fmt_name) ) goto badconst; // Field
        out_tagoff(ntag);
        if ( jasmin() ) {
          if ( fmt == fmt_retdscr ) fmt = fmt_signature; // no space at end
          else if ( chkOutSpace() ) goto badconst;
        } else {
          if ( fmt != fmt_retdscr ) break;
          fmt = fmt_paramstr;
        }
        if ( OutUtf8(x._dscr, fmt, COLOR_KEYWORD) ) goto badconst;
        break;
  }
  x.dtyp = savetype;
  return(1);
}
예제 #5
0
파일: oututil.cpp 프로젝트: nealey/vera
//----------------------------------------------------------------------
bool block_close(uint32 off, const char *name)
{
  if ( !jasmin()) return(block_end(off) );
  return(printf_line(off, COLSTR(".end %s", SCOLOR_KEYWORD), name));
}
예제 #6
0
//----------------------------------------------------------------------
uchar OutConstant(op_t& x, uchar impdsc)
{
  uchar savetype = x.dtyp;
  fmt_t fmt = fmt_dscr;
  color_t color;

  switch ( (uchar)x.cp_type )
  {
    default:
      warning("OC: bad constant type %u", (uchar)x.cp_type);
      break;

    case CONSTANT_Long:
      x.dtyp = dt_qword;
      goto outNum;
    case CONSTANT_Double:
      x.dtyp = dt_double;
      goto outNum;
    case CONSTANT_Integer:
      x.dtyp = dt_dword;
      goto outNum;
    case CONSTANT_Float:
      x.dtyp = dt_float;
outNum:
      if ( putVal(x, OOF_NUMBER | OOF_SIGNED | OOFW_IMM, 0) )
        break;
badconst:
      return 0;

    case CONSTANT_String:
      if ( OutUtf8(x._name, fmt_string, COLOR_STRING) )
        goto badconst;
      break;

    case CONSTANT_Class:
      CASSERT((fmt_cast+1) == fmt_classname && (fmt_classname+1) == fmt_fullname);
      {
        fmt_t f2 = (fmt_t )x.addr_shorts.high;
        color_t c2 = f2 < fmt_cast || f2 > fmt_fullname ? COLOR_KEYWORD
                   : cmd.xtrn_ip == 0xFFFF ? COLOR_DNAME : COLOR_IMPNAME;

        if ( OutUtf8(x._name, f2, c2) )
          goto badconst;
      }
      break;

    case CONSTANT_InterfaceMethodref:
    case CONSTANT_Methodref:
        fmt = fmt_retdscr;
    case CONSTANT_Fieldref:
#ifdef VIEW_WITHOUT_TYPE
        if ( impdsc )
#endif
          if ( !jasmin() && OutUtf8(x._dscr, fmt, COLOR_KEYWORD) )
            goto badconst;
        color = x._class == curClass.This.Dscr ? COLOR_DNAME : COLOR_IMPNAME;
        out_tagon(color);
        if ( jasmin() || (color == COLOR_IMPNAME && !impdsc) ) // other class
        {
          if ( OutUtf8(x._name, fmt_classname) || chkOutDot() )
            goto badconst;
        }
        if ( OutUtf8(x._subnam, fmt_name) )
          goto badconst; // Field
        out_tagoff(color);
        if ( jasmin() )
        {
          if ( fmt == fmt_retdscr )
            fmt = fmt_signature; // no space at end
          else if ( chkOutSpace() )
            goto badconst;
        }
        else
        {
          if ( fmt != fmt_retdscr )
            break;
          fmt = fmt_paramstr;
        }
        if ( OutUtf8(x._dscr, fmt, COLOR_KEYWORD) )
          goto badconst;
        break;
  }
  x.dtyp = savetype;
  return 1;
}