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: define 18.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov ( gentee )
 13 *
 14 * Summary: define command
 15 *
 16 ******************************************************************************/
 17 
 18 #include "../genteeapi/gentee.h"
 19 #include "define.h"
 20 #include "macro.h"
 21 #include "bcodes.h"
 22 
 23 /*-----------------------------------------------------------------------------
 24 *
 25 * ID: define 22.11.06 0.0.A.
 26 * 
 27 * Summary: define command
 28 *
 29 -----------------------------------------------------------------------------*/
 30 /******************************************************************************
 31 *
 32 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
 33 * This file is part of the Gentee open source project - http://www.gentee.com. 
 34 * 
 35 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 36 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 37 * ACCEPTANCE OF THE AGREEMENT.
 38 *
 39 * ID: type 18.10.06 0.0.A.
 40 *
 41 * Author: Alexey Krivonogov ( gentee )
 42 *
 43 * Summary: type command and fucntions
 44 *
 45 ******************************************************************************/
 46 
 47 #include "../genteeapi/gentee.h"
 48 #include "type.h"
 49 //#include "bcodes.h"
 50 
 51 /*-----------------------------------------------------------------------------
 52 *
 53 * ID: type_fieldname 22.11.06 0.0.A.
 54 * 
 55 * Summary: Find the name of the type
 56 *
 57 -----------------------------------------------------------------------------*/
 58 
 59 pvartype STDCALL type_fieldname( uint idtype, pubyte name )
 60 {
 61    povmtype ptype = ( povmtype )PCMD( idtype );
 62    uint     i;
 63    pvartype ret;
 64    
 65    if ( ptype->inherit )
 66    {
 67       if ( ret = type_fieldname( ptype->inherit, name ))
 68          return ret; 
 69    }
 70 //   if ( type->vmobj.flag & GHTY_PROTECTED )
 71 //      return NULL;
 72 //   Обнулять имена полей после окончания файла если есть такой флаг.  
 73 
 74    ret = ptype->children;
 75    for ( i = 0; i < ptype->count; i++ )
 76    {
 77       if ( ret->name && mem_iseqzero( ret->name, name ))
 78          return ret;
 79       ret++;
 80    }
 81    return NULL;
 82 }
 83 
 84 /*-----------------------------------------------------------------------------
 85 *
 86 * ID: type_field 22.11.06 0.0.A.
 87 * 
 88 * Summary: Find the name of the type
 89 *
 90 -----------------------------------------------------------------------------*/
 91 
 92 pvartype STDCALL type_field( plexem plex, uint idtype )
 93 {
 94    pvartype   ret;
 95    ubyte      name[ 128 ];
 96    pubyte     tname = lexem_getname( plex );
 97 
 98    ret = type_fieldname( idtype, tname );
 99    if ( !ret )
100    {
101       // Ищем property get и set
102       sprintf( name, "@%s", tname );
103       if ( !hash_find( &_vm.objname, name ))
104          msg( MNofield | MSG_LEXNAMEERR, plex );
105    }
106    return ret;
107 }
108 
109 /*-----------------------------------------------------------------------------
110 *
111 * ID: type 22.11.06 0.0.A.
112 * 
113 * Summary: type command
114 *
115 -----------------------------------------------------------------------------*/
116 
117 plexem  STDCALL type( plexem plex )
118 {
119    bcflag  bcf;
120    plexem  namelex;
121    pubyte  pout, curname;
122    uint    off_count, count = 0, i, inherit = 0;
123    s_descid  field;
124    uint      iflag;
125    buf       fields;
126 
127    buf_init( &fields );
128    namelex = lexem_next( plex, LEXNEXT_IGNLINE | LEXNEXT_NAME );
129 
130 //   if ( bc_getid( namelex ))
131 //      msg( MRedefine | MSG_LEXNAMEERR, namelex );
132    _vm.pos = namelex->pos;
133    plex = bc_flag( lexem_next( namelex, LEXNEXT_IGNLINE ), BFLAG_TYPE, &bcf );
134 
135    out_init( OVM_TYPE, GHCOM_NAME | bcf.value, lexem_getname( namelex ));
136 
137    if ( bcf.value & GHTY_INHERIT )
138    {
139       inherit = bcf.inherit.idtype;
140 
141       if ( inherit < TBuf || inherit == TReserved  )
142          msg( MInherit | MSG_LEXERR, namelex );
143       out_adduint( inherit );
144    }
145    if ( bcf.value & GHTY_INDEX )
146    {
147       out_adduint( bcf.index.idtype );
148       out_adduint( bcf.index.oftype );
149    }
150    off_count = out_adduint( 0 );
151 
152    plex = lexem_next( plex, LEXNEXT_IGNLINE | LEXNEXT_LCURLY );
153    
154    if ( inherit )
155    {
156       // Added as the first field
157       count = 1;
158       out_adduint( inherit );
159       out_addubyte( 0 );
160       buf_appendch( &fields, 0 );
161    }
162    field.flgdesc = DESCID_TYPE;
163 
164    field.idtype = 0;
165    while ( 1 )
166    {
167       plex = desc_nextidvar( plex, &field );
168       if ( !field.idtype )
169          break;
170 
171       iflag = VAR_NAME;
172       if ( field.oftype ) 
173          iflag |= VAR_OFTYPE;
174 
175       if ( field.msr ) 
176          iflag |= VAR_DIM;
177       
178       // Проверка на переопределение полей
179       curname = buf_ptr( &fields );
180       for ( i = 0; i < count; i++ )
181       {
182          if ( mem_iseqzero( curname, field.name ))
183             msg( MRefield | MSG_LEXNAMEERR, field.lex );
184          curname += mem_len( curname ) + 1;
185       }
186       buf_append( &fields, field.name, mem_len( field.name ) + 1 );
187 //      print("Name=%s flag=%x\n", field.name, iflag );
188       count++;
189       out_addvar( &field, iflag, NULL );
190    }
191    if ( !lexem_isys( plex, LSYS_RCURLY ))
192       msg( MExptype | MSG_LEXERR, plex );
193 
194    out_setuint( off_count, count );
195 
196    pout = out_finish();
197    load_type( &pout );
198    buf_delete( &fields );
199    return plex;
200 }
201 
202 /*-----------------------------------------------------------------------------
203 *
204 * ID: type_protect  22.11.06 0.0.A.
205 * 
206 * Summary: Clear names of the type
207 *
208 -----------------------------------------------------------------------------*/
209 
210 void  STDCALL type_protect( povmtype ptype )
211 {
212    uint  i;
213 
214    for ( i = 0; i < ptype->count; i++ )
215    {
216       ptype->children[ i ].name = NULL;
217       ptype->children[ i ].flag &= ~VAR_NAME;
218    }
219 }
220