parser_emit_cbc_push_number (parser_context_t *context_p, /**< context */
                             bool is_negative_number) /**< sign is negative */
{
  uint16_t value = context_p->lit_object.index;
  uint16_t lit_value = PARSER_INVALID_LITERAL_INDEX;

  if (context_p->last_cbc_opcode != PARSER_CBC_UNAVAILABLE)
  {
    if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
    {
      lit_value = context_p->last_cbc.literal_index;
    }
    else
    {
      if (context_p->last_cbc_opcode == CBC_PUSH_TWO_LITERALS)
      {
        context_p->last_cbc_opcode = CBC_PUSH_LITERAL;
        lit_value = context_p->last_cbc.value;
      }
      else if (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS)
      {
        context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS;
        lit_value = context_p->last_cbc.third_literal_index;
      }

      parser_flush_cbc (context_p);
    }
  }

  if (value == 0)
  {
    if (lit_value == PARSER_INVALID_LITERAL_INDEX)
    {
      context_p->last_cbc_opcode = CBC_PUSH_NUMBER_0;
      return;
    }

    context_p->last_cbc_opcode = CBC_PUSH_LITERAL_PUSH_NUMBER_0;
    context_p->last_cbc.literal_index = lit_value;
    return;
  }

  uint16_t opcode;

  if (lit_value == PARSER_INVALID_LITERAL_INDEX)
  {
    opcode = (is_negative_number ? CBC_PUSH_NUMBER_NEG_BYTE
                                 : CBC_PUSH_NUMBER_POS_BYTE);

    JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 1);
  }
  else
  {
    opcode = (is_negative_number ? CBC_PUSH_LITERAL_PUSH_NUMBER_NEG_BYTE
                                 : CBC_PUSH_LITERAL_PUSH_NUMBER_POS_BYTE);
    JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 2);

    context_p->last_cbc.literal_index = lit_value;
  }

  JERRY_ASSERT (value > 0 && value <= CBC_PUSH_NUMBER_BYTE_RANGE_END);

  context_p->last_cbc_opcode = opcode;
  context_p->last_cbc.value = (uint16_t) (value - 1);
} /* parser_emit_cbc_push_number */
parser_emit_cbc_push_number (parser_context_t *context_p,  
                             bool is_negative_number)  
{
  uint16_t value = context_p->lit_object.index;
  uint16_t lit_value = PARSER_INVALID_LITERAL_INDEX;

  if (context_p->last_cbc_opcode != PARSER_CBC_UNAVAILABLE)
  {
    if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
    {
      lit_value = context_p->last_cbc.literal_index;
    }
    else
    {
      if (context_p->last_cbc_opcode == CBC_PUSH_TWO_LITERALS)
      {
        context_p->last_cbc_opcode = CBC_PUSH_LITERAL;
        lit_value = context_p->last_cbc.value;
      }
      else if (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS)
      {
        context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS;
        lit_value = context_p->last_cbc.third_literal_index;
      }

      parser_flush_cbc (context_p);
    }
  }

  if (value == 0)
  {
    if (lit_value == PARSER_INVALID_LITERAL_INDEX)
    {
      context_p->last_cbc_opcode = CBC_PUSH_NUMBER_0;
      return;
    }

    context_p->last_cbc_opcode = CBC_PUSH_LITERAL_PUSH_NUMBER_0;
    context_p->last_cbc.literal_index = lit_value;
    return;
  }

  uint16_t opcode;

  if (lit_value == PARSER_INVALID_LITERAL_INDEX)
  {
    opcode = (is_negative_number ? CBC_PUSH_NUMBER_NEG_BYTE
                                 : CBC_PUSH_NUMBER_POS_BYTE);

    JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 1);
  }
  else
  {
    opcode = (is_negative_number ? CBC_PUSH_LITERAL_PUSH_NUMBER_NEG_BYTE
                                 : CBC_PUSH_LITERAL_PUSH_NUMBER_POS_BYTE);
    JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 2);

    context_p->last_cbc.literal_index = lit_value;
  }

  JERRY_ASSERT (value > 0 && value <= CBC_PUSH_NUMBER_BYTE_RANGE_END);

  context_p->last_cbc_opcode = opcode;
  context_p->last_cbc.value = (uint16_t) (value - 1);
}  