/* This file is part of GNU epsilon, a functional language implementation

Copyright (C) 2003 Luca Saiu

GNU epsilon is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2, or (at your
option) any later version.

GNU epsilon is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with epsilon; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */


/* Code for the s_filewc instruction */


/* The argument (in top) is a pair <FILE*, character>: */
FILE* file_star = ((word_t*)top)[0];
char c = (char) (((integer_t*)top)[1]);

/* Write the character into the FILE* in file_star. */
if(fwrite(&c, sizeof(char), 1, (FILE*)file_star) != 1){
  /* an error occourred. */
  {/* To do: look at errno */
    fprintf(stderr, "s_filewc: look at errno %i\n", errno);
    THROW(unimplemented_exception, NULL);
  }
}

/* remove the argument from the stack: */
POP; 
