EnglishРусский  

   ..

   alias.c

   alias.h

   bcodes.c

   bcodes.h

   body.c

   compile.c

   compile.h

   define.c

   define.h

   desc.c

   expr.c

   extern.c

   for.c

   foreach.c

   func.c

   func.h

   global.c

   global.h

   goto.c

   if.c

   ifdef.c

   ifdef.h

   import.c

   import.h

   include.c

   include.h

   jump.c

   lexem.c

   lexem.h

   macro.c

   macro.h

   operlist.txt

   out.c

   out.h

   subfunc.c

   switch.c

   type.c

   type.h

   vars.c

   while.c

   with.c

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

  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: import 18.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov ( gentee )
 13 *
 14 * Summary: import command
 15 *
 16 ******************************************************************************/
 17 
 18 #include "../genteeapi/gentee.h"
 19 #include "bcodes.h"
 20 #include "compile.h"
 21 #include "../common/file.h"
 22 
 23 /*-----------------------------------------------------------------------------
 24 *
 25 * ID: include 22.11.06 0.0.A.
 26 * 
 27 * Summary: import command
 28 *
 29 -----------------------------------------------------------------------------*/
 30 
 31 plexem  STDCALL import( plexem plex )
 32 {
 33    bcflag bcf; 
 34    uint   funcflags = _compile->cur->priv ? GHRT_PRIVATE : 0;
 35    pubyte pout;
 36    plexem lexname, lexalias;
 37    pstr   filename;
 38    buf    bdata;
 39    pvmobj parent;
 40    uint   ret, parcount, i;
 41    uint   params[64];
 42 
 43    buf_init( &bdata );
 44    plex = lexem_next( plex, LEXNEXT_IGNLINE );
 45    if ( plex->type != LEXEM_STRING )  
 46       msg( MMuststr | MSG_LEXERR, plex );
 47    lexname = plex;
 48    filename = lexem_getstr( lexname );
 49 
 50    plex = bc_flag( lexem_next( plex, LEXNEXT_IGNLINE ), BFLAG_IMPORT, &bcf );
 51  
 52    funcflags |= GHEX_IMPORT | ( bcf.value & GHIMP_CDECL ? GHEX_CDECL : 0 );
 53    out_init( OVM_IMPORT, bcf.value, 0 );
 54 
 55    if ( bcf.value & GHIMP_LINK )
 56    {
 57       // Линкуем dll файл
 58       file2buf( filename, &bdata, lexname->pos );
 59       // Оставляем только имя dll файла
 60       str_getdirfile( filename, 0, filename );
 61 
 62       // проверку на дублирование
 63       if ( !hash_find( &_compile->files, str_ptr( filename )))
 64          hash_create( &_compile->files, str_ptr( filename ));
 65       else
 66          buf_clear( &bdata );
 67    }
 68    out_addname( str_ptr( filename ));
 69    out_adduint( buf_len( &bdata )); 
 70    out_addbuf( &bdata );
 71 
 72    pout = out_finish();
 73    parent = load_import( &pout );
 74 
 75 //   print("IMPORT name=%s size =%i\n", str_ptr( filename ), buf_len( _compile->pout ));
 76    buf_delete( &bdata );
 77 
 78    plex = lexem_next( plex, LEXNEXT_IGNLINE | LEXNEXT_LCURLY );
 79 
 80    while ( 1 )
 81    {
 82       if ( lexem_isys( plex, LSYS_RCURLY ))
 83          break;
 84 
 85       if ( ret = bc_type( plex ))
 86          plex = lexem_next( plex, LEXNEXT_IGNLINE );
 87       
 88       if ( plex->type != LEXEM_NAME )
 89          msg( MExpname | MSG_LEXERR, plex );
 90       lexname = plex;
 91 
 92       plex = lexem_next( plex, LEXNEXT_IGNLINE );
 93       if ( !lexem_isys( plex, LSYS_LBRACK ))
 94          msg( MExpopenbr | MSG_LEXERR, plex );
 95       parcount = 0;
 96 
 97       while ( 1 )
 98       {
 99          plex = lexem_next( plex, LEXNEXT_IGNLINE | LEXNEXT_IGNCOMMA );
100          if ( lexem_isys( plex, LSYS_RBRACK ))
101             break;
102          params[ parcount++ ] = bc_type( plex );
103          if ( !params[ parcount - 1 ] )
104             msg( MExptype | MSG_LEXERR, plex );
105       }
106       plex = lexem_next( plex, 0 );
107       lexalias = NULL;
108       if ( lexem_isys( plex, LSYS_PTR ))
109       {
110          plex = lexem_next( plex, LEXNEXT_IGNLINE );
111          if ( plex->type != LEXEM_NAME )
112             msg( MExpname | MSG_LEXERR, plex );
113          lexalias = plex;
114       }
115       out_init( OVM_EXFUNC, funcflags, 
116                 lexem_getname( lexalias ? lexalias : lexname ));
117       out_adduint( ret );
118       out_addubyte( 0 );      
119       out_adduint( parcount );
120       for ( i = 0; i < parcount; i++ )
121       {
122          out_adduint( params[ i ] );
123          out_addubyte( 0 );      
124       }
125       out_adduint( parent->id );
126       out_addname( lexem_getname( lexname ));
127       pout = out_finish();
128       load_exfunc( &pout, 0 );
129 
130       plex = lexem_next( plex, LEXNEXT_IGNLINE );
131    }
132 
133    return plex;
134 }
135 
136