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: global 18.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 * Summary: global 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: global 22.11.06 0.0.A.
26 *
27 * Summary: global command
28 *
29 -----------------------------------------------------------------------------*/
30
31 plexem STDCALL global( plexem plex )
32 {
33 s_descid field;
34 pubyte pout, pdata;
35 uint isize;
36 uint iflag, flag = GHCOM_NAME | ( _compile->cur->priv ? GHRT_PRIVATE : 0 );
37
38 plex = lexem_next( plex, LEXNEXT_IGNLINE );
39
40 field.flgdesc = DESCID_GLOBAL;
41 plex = lexem_next( plex, LEXNEXT_IGNLINE | LEXNEXT_LCURLY );
42
43 field.idtype = 0;
44 while ( 1 )
45 {
46 plex = desc_nextidvar( plex, &field );
47 if ( !field.idtype )
48 break;
49
50 // if ( bc_getid( field.lex ))
51 // msg( MRedefine | MSG_LEXNAMEERR, field.lex );
52 _vm.pos = field.lex->pos;
53
54 out_init( OVM_GLOBAL, flag, field.name );
55 iflag = 0;
56 pdata = 0;
57 if ( field.oftype )
58 iflag |= VAR_OFTYPE;
59
60 if ( field.msr )
61 iflag |= VAR_DIM;
62 if ( field.lexres )
63 {
64 iflag |= VAR_DATA;
65 if ( field.lexres->type == LEXEM_NUMBER )
66 pdata = ( pubyte )&field.lexres->num.vint;
67 else
68 pdata = ( pubyte )lexem_getstr( field.lexres );
69 }
70 out_addvar( &field, iflag, pdata );
71
72 // Reserve space for variable data
73 isize = ((povmtype)PCMD(field.idtype))->size;
74 buf_expand( _compile->pout, isize );
75 _compile->pout->use += isize;
76
77 pout = out_finish();
78 load_global( &pout );
79 }
80 if ( !lexem_isys( plex, LSYS_RCURLY ))
81 msg( MRcurly | MSG_LEXERR, plex );
82
83 return plex;
84 }
85
86
Редактировать