Exemplo n.º 1
0
        // 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;
        }
Exemplo n.º 2
0
 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');
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
 public static Object bgl_close_input_port( input_port p )
 {
     p.close();
     return p;
 }
Exemplo n.º 5
0
 public static int RGC_START_MATCH( input_port p )
 {
     return (p.forward= p.matchstart= p.matchstop);
 }
Exemplo n.º 6
0
        public static bool rgc_fill_buffer( input_port p )
        {
            --p.forward;
            if (p.eof)
               return false;

            return p.rgc_fill_buffer();
        }
Exemplo n.º 7
0
        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 );
        }
Exemplo n.º 8
0
        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 );
        }
Exemplo n.º 9
0
 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 );
      }
 }
Exemplo n.º 10
0
        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');
        }
Exemplo n.º 11
0
 public static bool rgc_buffer_eof_p( input_port p )
 {
     return ((p.buffer[p.forward] == 0) && (p.forward+1 == p.bufpos));
 }
Exemplo n.º 12
0
 public static bool RGC_BUFFER_EMPTY( input_port p )
 {
     return (p.forward == p.bufpos);
 }
Exemplo n.º 13
0
 public static byte RGC_BUFFER_CHARACTER( input_port p )
 {
     return p.buffer[p.matchstart];
 }
Exemplo n.º 14
0
 public static int RGC_BUFFER_BYTE_REF( input_port p, int offset )
 {
     return (int)p.buffer[p.matchstart + offset];
 }
Exemplo n.º 15
0
 public static int RGC_BUFFER_BYTE( input_port p )
 {
     return (int)p.buffer[p.matchstart];
 }
Exemplo n.º 16
0
 public static int RGC_BUFFER_POSITION( input_port p )
 {
     return (p.forward - p.matchstart);
 }
Exemplo n.º 17
0
 public static byte[] rgc_buffer_substring( input_port p, int o, int e )
 {
     return c_substring( p.buffer, p.matchstart + o, p.matchstart + e );
 }
Exemplo n.º 18
0
 public static int rgc_buffer_fixnum( input_port p )
 {
     return parseint( p.buffer, p.matchstart, p.matchstop, 10 );
 }
Exemplo n.º 19
0
        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;
        }
Exemplo n.º 20
0
 public static double rgc_buffer_flonum( input_port p )
 {
     return Double.Parse( newstring( c_substring( p.buffer, p.matchstart, p.matchstop ) ) );
 }
Exemplo n.º 21
0
        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 );
        }
Exemplo n.º 22
0
 public static int RGC_BUFFER_GET_CHAR( input_port p )
 {
     return (p.buffer[p.forward++] & 0xFF);
 }
Exemplo n.º 23
0
 public static int RGC_SET_FILEPOS( input_port p )
 {
     return (p.filepos+= (p.matchstop - p.matchstart));
 }
Exemplo n.º 24
0
        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;
        }
Exemplo n.º 25
0
 public static int RGC_STOP_MATCH( input_port p )
 {
     return (p.matchstop= p.forward);
 }
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 27
0
 public static void setCurrentInputPort( bgldynamic env, input_port  o )
 {
     env.current_input_port= o;
 }
Exemplo n.º 28
0
 public static Object rgc_buffer_integer(input_port p)
 {
     return parseinteger(p.buffer, p.matchstart, p.matchstop, 10);
 }
Exemplo n.º 29
0
        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;
        }
Exemplo n.º 30
0
 public static int RGC_BUFFER_LENGTH( input_port p )
 {
     return (p.matchstop - p.matchstart);
 }