// constructor public bgldynamic() { exitd_top= new exit(); exitd_val = new pair( new pair(unspecified._unspecified, unspecified._unspecified), unspecified._unspecified ); error_handler= nil._nil; uncaught_exception_handler= nil._nil; mvalues_number= 1; current_input_port= new input_console_port( foreign.default_io_bufsiz ); current_output_port= new output_stream_port( Console.OpenStandardOutput() ); // !!!!! to check current_error_port= new output_stream_port( Console.OpenStandardError() ); // !!!!! to check error_handler= bigloo.nil._nil; }
public static bool rgc_buffer_bol_p( input_port p ) { if (p.matchstart > 0) return (p.buffer[p.matchstart - 1] == '\n'); else return (p.lastchar == (byte)'\n'); }
private static void rgc_buffer_reserve_space(input_port p, int amount) { int bufsize = p.bufsiz; int bufpos = p.bufpos; int matchstop = p.matchstop; if ( matchstop >= amount ) return; if ( (matchstop + (bufsize - (bufpos-1))) >= amount ) { // shift the buffer to the right int diff = amount - matchstop; bcopy( p.buffer, matchstop, p.buffer, amount, bufpos-1 - matchstop); p.bufpos += diff; p.matchstop += diff; } else { p.rgc_double_buffer(); rgc_buffer_reserve_space(p, amount); } }
public static Object bgl_close_input_port( input_port p ) { p.close(); return p; }
public static int RGC_START_MATCH( input_port p ) { return (p.forward= p.matchstart= p.matchstop); }
public static bool rgc_fill_buffer( input_port p ) { --p.forward; if (p.eof) return false; return p.rgc_fill_buffer(); }
public static keyword rgc_buffer_upcase_keyword( input_port p ) { int start = p.matchstart; int stop = p.matchstop; int n = stop - start - 1; byte[] name = new byte[n]; if( p.buffer[start] == ':' ) start++; for ( int i = 0 ; i < n ; ++i, ++start ) name[i] = (byte)toupper( p.buffer[start] & 0xFF ); return keyword.make_keyword( name ); }
public static symbol rgc_buffer_subsymbol( input_port p, int o, int e ) { int start = p.matchstart + o; int stop = p.matchstop + e; int n = stop - start; byte[] name = new byte[n]; for ( int i= 0 ; i < n ; ++i, ++start ) name[i]= (byte)(p.buffer[start] & 0xFF); return symbol.make_symbol( name ); }
public static byte[] rgc_buffer_escape_substring( input_port p, int o, int e, bool strict ) { if( strict ) { return bgl_escape_scheme_string( p.buffer, p.matchstart + o, p.matchstart + e ); } else { return bgl_escape_C_string( p.buffer, p.matchstart + o, p.matchstart + e ); } }
public static bool rgc_buffer_eol_p( input_port p ) { int c = RGC_BUFFER_GET_CHAR( p ); if (c == 0) { if(!RGC_BUFFER_EMPTY( p )) { --p.forward; return false; } if (rgc_fill_buffer( p )) return rgc_buffer_eol_p( p ); return false; } --p.forward; return (c == (byte)'\n'); }
public static bool rgc_buffer_eof_p( input_port p ) { return ((p.buffer[p.forward] == 0) && (p.forward+1 == p.bufpos)); }
public static bool RGC_BUFFER_EMPTY( input_port p ) { return (p.forward == p.bufpos); }
public static byte RGC_BUFFER_CHARACTER( input_port p ) { return p.buffer[p.matchstart]; }
public static int RGC_BUFFER_BYTE_REF( input_port p, int offset ) { return (int)p.buffer[p.matchstart + offset]; }
public static int RGC_BUFFER_BYTE( input_port p ) { return (int)p.buffer[p.matchstart]; }
public static int RGC_BUFFER_POSITION( input_port p ) { return (p.forward - p.matchstart); }
public static byte[] rgc_buffer_substring( input_port p, int o, int e ) { return c_substring( p.buffer, p.matchstart + o, p.matchstart + e ); }
public static int rgc_buffer_fixnum( input_port p ) { return parseint( p.buffer, p.matchstart, p.matchstop, 10 ); }
public static int rgc_buffer_unget_char( input_port p, int c ) { p.filepos--; if (0 < p.matchstop) --p.matchstop; else { p.buffer[0]= (byte)c; if (p.bufpos == 0) { p.bufpos= 1; p.buffer[1]= (byte)'\0'; } } return c; }
public static double rgc_buffer_flonum( input_port p ) { return Double.Parse( newstring( c_substring( p.buffer, p.matchstart, p.matchstop ) ) ); }
public static symbol rgc_buffer_upcase_symbol( input_port p ) { int start= p.matchstart; int stop= p.matchstop; int n= stop - start; byte[] name= new byte[n]; for ( int i= 0 ; i < n ; ++i, ++start ) name[i]= (byte)toupper( p.buffer[start] & 0xFF ); return symbol.make_symbol( name ); }
public static int RGC_BUFFER_GET_CHAR( input_port p ) { return (p.buffer[p.forward++] & 0xFF); }
public static int RGC_SET_FILEPOS( input_port p ) { return (p.filepos+= (p.matchstop - p.matchstart)); }
public static bool rgc_buffer_insert_char(input_port p, int c) { rgc_buffer_reserve_space(p, 1); int matchstop = p.matchstop; p.buffer[matchstop - 1] = (byte) c; if ( p.filepos > 0 ) p.filepos--; else p.filepos = 0; p.matchstop--; p.forward = p.matchstop; p.matchstart = p.matchstop; return true; }
public static int RGC_STOP_MATCH( input_port p ) { return (p.matchstop= p.forward); }
public static bool rgc_buffer_insert_substring(input_port p, byte[] s, int from, int to) { if ( from < 0 ) return false; if ( to > s.Length ) return false; if ( p.bufsiz == 2) return false; // unbuffered port if ( CLOSED_RGC_BUFFER( p )) return false; if ( from >= to ) return true; int len = to - from; rgc_buffer_reserve_space(p, len); int matchstop = p.matchstop; bcopy(s, from, p.buffer, (matchstop - len), len); if ( p.filepos >= len ) p.filepos -= len; else p.filepos = 0; p.matchstop -= len; p.forward = p.matchstop; p.matchstart = p.matchstop; return true; }
public static void setCurrentInputPort( bgldynamic env, input_port o ) { env.current_input_port= o; }
public static Object rgc_buffer_integer(input_port p) { return parseinteger(p.buffer, p.matchstart, p.matchstop, 10); }
private static int rgc_do_blit( input_port p, byte[] s, int o, int l ) { RGC_START_MATCH( p ); while ( ((p.bufpos - p.matchstart) <= l) && !p.eof) { // MS fix 6 Juillet 2005 int fsize = (p.bufsiz - p.bufpos); p.forward= p.bufpos; rgc_fill_buffer( p ); // less characters are available if( (p.bufpos - p.forward) < fsize ) break; } if ((p.bufpos - p.matchstart) <= l) l= (p.bufpos - p.matchstart - 1); p.forward= p.matchstart + l; RGC_STOP_MATCH( p ); RGC_SET_FILEPOS( p ); bcopy( p.buffer, p.matchstart, s, o, l ); return l; }
public static int RGC_BUFFER_LENGTH( input_port p ) { return (p.matchstop - p.matchstart); }