
/*
//////////////////////////////////////////////////////
//////                misc2.c                     //////
//////////////////////////////////////////////////////
*/


/*
/////////////////////////////
//
// Author: Gayatri Krishnan
// Assignment # 8
// Internet Applications
// 
/////////////////////////////
*/


/*
////
// include files
////
*/

#include "common.h"

/* 
 ** Function    : read_methods()
 ** Description : Outputs Methods
 */ 
void read_methods(int totalm)
{
  int status;
  int  method_counter, attribute_count;
  
  /*&&&&&&&&&&Reading Methods&&&&&&&&&&*/
  
  for(method_counter=0; method_counter < totalm; method_counter++)
    {
      status = read_bytes(4);
      if (status==-1) exit(0);
      /* Method Name */
       printf("--------------------------------------------------------------------\n");
      printf("\nMethod : %s() \n", cPool[((byte[2] <<8) | byte[3])].str);
      
      /**********AttributeCount**********/
      status = read_bytes(4);
      if (status==-1) exit(0);
      attribute_count=(byte[2]<<8)| byte[3];
      if (attribute_count > 0)
	read_attributes(attribute_count);
    }

}

/* 
 ** Function    : isSpecial()
 ** Description : Checks if the opcode is one from the array list 
 */ 
int isSpecial() {
  int ret_val = -1;
  int count;
  
  char spl_str[20][29] = {
    {"ifeq"},
    {"ifnull"},
    {"iflt"},
    {"ifle"},
    {"ifne"},
    {"ifgt"},
    {"ifge"},
    {"ifnonull"},
    {"if_icmpeq"},
    {"if_icmpne"},
    {"if_icmplt"},
    {"if_icmpgt"},
    {"if_icmple"},
    {"if_icmpge"},
    {"if_acmpeq"},
    {"if_acmpne"},
    {"jsr"},
    {"jsr_w"},
    {"goto"},
    {"goto_w"}
  };

  for (count =0; count < 20; count++) {
    if(! strcmp (gotoNif->op_name, spl_str[count])){
      ret_val = 1;
      break;
    }
  }
  return ret_val;
} /* isSpecial() */
