EnglishРусский  

   ..

   arr.c

   arr.h

   arrdata.c

   arrdata.h

   buf.c

   buf.h

   crc.c

   crc.h

   file.c

   file.h

   hash.c

   hash.h

   memory.c

   memory.h

   mix.c

   mix.h

   msg.c

   msg.h

   msglist.c

   msglist.g

   msglist.h

   number.c

   number.h

   str.c

   str.h

   types.h

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: msg 18.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov
 13 *
 14 * Summary: Message functions.
 15 *
 16 ******************************************************************************/
 17 
 18 #include "../os/user/defines.h"
 19 #include "../genteeapi/gentee.h"
 20 #include "msg.h"
 21 #include "../compiler/lexem.h"
 22 
 23 #ifndef RUNTIME
 24    #include <setjmp.h> 
 25    extern jmp_buf stack_state;
 26 #endif
 27 
 28 uint _time;  
 29 
 30 /*-----------------------------------------------------------------------------
 31 *
 32 * ID: msg 23.10.06 0.0.A.
 33 * 
 34 * Summary: Show an error or information message
 35 *
 36 -----------------------------------------------------------------------------*/
 37 
 38 uint CDECLCALL msg( uint code, ... )
 39 {
 40    va_list args;
 41    msginfo minfo;
 42    plexem  plex;
 43 
 44    mem_zero( &minfo, sizeof( msginfo ));
 45    minfo.flag = code & 0xFFFF0000;
 46    minfo.code = code & 0xFFFF;
 47 
 48    va_start( args, code );
 49 
 50    if ( code & MSG_STR )
 51       minfo.namepar = str_ptr(( pstr )va_arg( args, int ));
 52    if ( code & MSG_POS || code & MSG_LEXEM )
 53       plex = ( plexem )va_arg( args, int );
 54    if ( code & MSG_VALSTR )
 55       minfo.namepar = ( pubyte )va_arg( args, int );
 56    if ( code & MSG_VALUE )
 57       minfo.uintpar = ( uint )va_arg( args, int );
 58 
 59 #ifndef RUNTIME
 60    if ( code & MSG_LEXNAME )
 61    {
 62       minfo.namepar = 0;
 63       switch ( plex->type )
 64       {
 65          case LEXEM_OPER: 
 66             minfo.namepar = ( pubyte )&plex->oper.name;
 67             break;
 68          case LEXEM_NAME: 
 69          case LEXEM_MACRO: 
 70             minfo.namepar = ( pubyte )lexem_getname( plex );
 71             break;
 72       }
 73       minfo.flag |= MSG_STR;
 74    }
 75 #endif
 76 //   for ( i = 0; i < 8; i++ )
 77 //      pars[i] = ( uint )va_arg( args, int );
 78    va_end( args );  
 79 
 80    if ( _compile && _compile->cur )
 81    {
 82       // Лишнее ???
 83       if ( _compile->cur->src->use > _pvm->pos )
 84          minfo.line = str_pos2line( _compile->cur->src, _pvm->pos, &minfo.pos );
 85       if ( minfo.flag & MSG_POS )
 86       {
 87          minfo.line = str_pos2line( _compile->cur->src, ( uint )plex, &minfo.pos );
 88       }
 89       if ( minfo.flag & MSG_LEXEM )
 90          minfo.line = str_pos2line( _compile->cur->src, plex->pos, &minfo.pos );
 91       minfo.filename = str_ptr( _compile->cur->filename ); 
 92       minfo.line++;
 93       minfo.pos++;
 94    }
 95    minfo.pattern = msgtext[ minfo.code ];
 96 
 97    if ( _gentee.message )
 98       _gentee.message( &minfo );
 99 
100    if ( minfo.flag & MSG_EXIT )
101    {
102       if ( _compile )
103          os_dirsetcur( _compile->curdir );
104       if ( !_compile || _compile->flag & CMPL_THREAD )
105          os_exitthread( 0 );
106 #ifndef RUNTIME
107       else
108 //         os_exitthread( 0 );
109          longjmp( stack_state, -1 );
110 #endif
111    }
112    return 1;	
113 }
114 
115 /*-----------------------------------------------------------------------------
116 *
117 * ID: print 26.12.06 0.0.A.
118 * 
119 * Summary: Print function for debugging
120 *
121 -----------------------------------------------------------------------------*/
122 
123 void  CDECLCALL print( pubyte output, ... ) 
124 {
125    va_list args;
126    uint    len;
127    ubyte   ok[ 512 ];
128 
129    va_start( args, output );
130    len = vsprintf( ok, output, args );
131    va_end( args );
132    _gentee.print( ok, len );
133 //   os_print( ok, len );
134 }
135 
136 uint STDCALL message( pmsginfo minfo )
137 {
138    uint      temp, time;
139    uint      line = 0, pos = 0;
140 
141    if ( minfo->flag & MSG_EXIT )
142    {
143       print( _compile ? "Compile error [ 0x%X %i ]: " :
144             "Run-time error [ 0x%X %i ]: ", minfo->code, minfo->code ); 
145       if ( minfo->line )
146          print( "%s\r\n[ Line: %i Pos: %i ] ", minfo->filename, 
147                  minfo->line, minfo->pos ); 
148    }
149    else 
150       if ( _gentee.flags & G_SILENT )
151          return 0;
152 
153    if ( minfo->flag & MSG_VALSTR )
154       print( minfo->pattern, minfo->uintpar, minfo->uintpar, minfo->namepar ); 
155    else
156       if ( minfo->flag & MSG_VALVAL )
157          print( minfo->pattern, minfo->uintpar, minfo->uintpar ); 
158       else
159          if ( minfo->flag & MSG_STR )
160             print( minfo->pattern, minfo->namepar ); 
161          else
162             if ( minfo->flag & MSG_VALUE )
163                print( minfo->pattern, minfo->uintpar ); 
164             else
165                print( minfo->pattern );
166    print( "\r\n" );
167 
168    switch ( minfo->code )
169    {
170       case MStart:
171          _time = os_time();
172          break;
173       case MEnd:
174          time = os_time() - _time;
175          temp = time % 60000;
176          print( "Summary Time: %i:%i:%i\r\n", 
177                   time / 60000, temp / 1000, temp % 1000 );
178          break;
179    }
180 //   if ( !( _gentee.flags & G_SILENT ) || minfo->flag & MSG_EXIT )
181 //       str_output( minfo->result );
182 
183    if ( minfo->flag & MSG_EXIT )
184    {
185       print( "\r\nPress any key...\r\n" );
186       os_getchar();
187    }
188    return 0;
189 }
190 
Редактировать