Example #1
0
//---------------------------------------------------------------------------
uchar out_index(ushort index, fmt_t mode, color_t ntag, uchar as_index)
{
  if ( as_index ) {
    if(   !(idpflags & (IDM_BADIDXSTR | IDM_OUTASM))   // no store in file
       || !is_valid_string_index(index)) return(putShort(index));
    ntag = COLOR_ERROR;
    mode = fmt_string;
  }
  return(OutUtf8(index, mode, ntag));
}
Example #2
0
//----------------------------------------------------------------------
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);
}
Example #3
0
//--------------------------------------------------------------------------
uchar out_alt_ind(uint32 val)
{
  if ( (ushort)val) return(OutUtf8((ushort)val, fmt_fullname, COLOR_IMPNAME) );
  return(putShort((ushort)(val >> 16)));
}
//----------------------------------------------------------------------
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;
}