Exemplo n.º 1
0
/** <!--******************************************************************-->
 *
 * @fn CHKMcast
 *
 * @brief Touched the node and its sons/attributes
 *
 * @param arg_node Cast node to process
 * @param arg_info pointer to info structure
 *
 * @return processed node
 *
 ***************************************************************************/
node *
CHKMcast (node * arg_node, info * arg_info)
{
  DBUG_ENTER ("CHKMcast");
  NODE_ERROR (arg_node) = CHKMTRAV (NODE_ERROR (arg_node), arg_info);
  CAST_L_BRACKET (arg_node) = CHKMTRAV (CAST_L_BRACKET (arg_node), arg_info);
  CAST_TYPE (arg_node) = CHKMTRAV (CAST_TYPE (arg_node), arg_info);
  CAST_R_BRACKET (arg_node) = CHKMTRAV (CAST_R_BRACKET (arg_node), arg_info);
  CAST_EXPR (arg_node) = CHKMTRAV (CAST_EXPR (arg_node), arg_info);
  DBUG_RETURN (arg_node);
}
Exemplo n.º 2
0
/** <!--******************************************************************-->
 *
 * @fn COPYcast
 *
 * @brief Copies the node and its sons/attributes
 *
 * @param arg_node Cast node to process
 * @param arg_info pointer to info structure
 *
 * @return processed node
 *
 ***************************************************************************/
node *
COPYcast (node * arg_node, info * arg_info)
{
  node *result = TBmakeCast (NULL, NULL, NULL, NULL);
  DBUG_ENTER ("COPYcast");
  LUTinsertIntoLutP (INFO_LUT (arg_info), arg_node, result);
  /* Copy sons */
  CAST_L_BRACKET (result) = COPYTRAV (CAST_L_BRACKET (arg_node), arg_info);
  CAST_TYPE (result) = COPYTRAV (CAST_TYPE (arg_node), arg_info);
  CAST_R_BRACKET (result) = COPYTRAV (CAST_R_BRACKET (arg_node), arg_info);
  CAST_EXPR (result) = COPYTRAV (CAST_EXPR (arg_node), arg_info);
  /* Return value */
  DBUG_RETURN (result);
}
Exemplo n.º 3
0
node* CALCCONSTcast(node *arg_node, info *arg_info){
  DBUG_ENTER ("CALCCONSTcast");

  CAST_EXPR( arg_node) = TRAVopt( CAST_EXPR( arg_node), NULL);
  node * ret;
  switch(NODE_TYPE(CAST_EXPR( arg_node))){
  case N_bool:
    switch(CAST_TYPE(arg_node)){
    case VT_bool:
      //no cast needed
      ret = CAST_EXPR( arg_node);
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );
      break;
    case VT_int:
      //FREEcast(arg_node);
      ret = TBmakeInt((int)BOOL_VALUE(CAST_EXPR( arg_node)));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );

      break;
    case VT_float:
      //FREEcast(arg_node);
      ret = TBmakeFloat((float)BOOL_VALUE(CAST_EXPR( arg_node)));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );
      break;
    default:
      DBUG_RETURN(arg_node);

    }

    break;
  case N_int:
    switch(CAST_TYPE(arg_node)){
    case VT_bool:
      ret =TBmakeBool(INT_VALUE(CAST_EXPR( arg_node)));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );
      break;
    case VT_int:
      //no cast needed

      ret = CAST_EXPR( arg_node);
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );


      break;
    case VT_float:

      ret =TBmakeFloat((float)INT_VALUE(CAST_EXPR( arg_node) ));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );

      break;
    default:
      DBUG_RETURN(arg_node);

    }

    break;
  case N_float:
    switch(CAST_TYPE(arg_node)){
    case VT_bool:
      ret =TBmakeBool(FLOAT_VALUE(CAST_EXPR( arg_node)));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );


      break;
    case VT_int:
      ret =TBmakeInt(FLOAT_VALUE(CAST_EXPR( arg_node)));
      FREEdoFreeNode(arg_node);
      DBUG_RETURN(ret );

      break;
    case VT_float:
      //no cast needed
      ret = CAST_EXPR( arg_node);
      FREEdoFreeNode(arg_node);

      DBUG_RETURN(ret );


      break;
    default:
      DBUG_RETURN(arg_node);

    }

    break;
  default:
    DBUG_RETURN(arg_node);

  }


}