EnglishРусский  

   ..

   compiler.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

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

source\lib\compiler\compiler.g
  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2004-2008, 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 * Author: Alexey Krivonogov ( gentee )
 11 *
 12 ******************************************************************************/
 13 
 14 define
 15 {
 16    GSET_TEMPDIR  = 0x0001  // Specify the custom temporary directory
 17    GSET_PRINT    = 0x0002  // Specify the custom print function
 18    GSET_MESSAGE  = 0x0003  // Specify the custom message function
 19    GSET_EXPORT   = 0x0004  // Specify the custom export function
 20    GSET_ARGS     = 0x0005  // Specify the command-line arguments
 21    GSET_FLAG     = 0x0006  // Specify flags 
 22    GSET_DEBUG    = 0x0007  // Specify the custom debug function
 23    GSET_GETCH    = 0x0008  // Specify the custom getch function
 24 
 25    CMPL_SRC    = 0x0001   // If compileinfo.input is Gentee source
 26    CMPL_NORUN  = 0x0002   // Don't run after compiling
 27    CMPL_GE     = 0x0004   // Create GE file
 28    CMPL_DEFARG = 0x0008   // Define arguments
 29    CMPL_LINE   = 0x0010   // Proceed #! at the first string
 30    CMPL_DEBUG  = 0x0020   // Compilation with the debug information
 31    CMPL_THREAD = 0x0040   // Compilation in the thread
 32    CMPL_NOWAIT = 0x0080   // Do not wait for the end of the compilation. /
 33                           // Use with CMPL_THREAD only.
 34    CMPL_OPTIMIZE = 0x0100 // Optimize the output GE file
 35    CMPL_NOCLEAR  = 0x0200 // Do not clear existing objects in the virtual /
 36                           // machine.
 37    CMPL_ASM      = 0x0400 // Convert bytecode to assembler
 38 
 39    OPTI_DEFINE   = 0x0001   // Delete 'define' objects.
 40    OPTI_NAME     = 0x0002   // Delete names of objects.
 41    OPTI_AVOID    = 0x0004   // Delete no used objects.
 42    OPTI_MAIN     = 0x0008   // Leave only one main function with OPTI_AVOID.
 43 
 44    G_CONSOLE = 0x0001   // Console application.
 45    G_SILENT  = 0x0002   // Don't display any service messages.
 46    G_CHARPRN = 0x0004   // Print Windows characters.
 47    G_ASM     = 0x0008   // Run-time converting a bytecode to assembler.
 48    G_TMPRAND = 0x0010   // Random name of t temporary directory.
 49 }
 50 
 51 type optimize
 52 {
 53    uint     flag     // Flags of the optimization. $$[optiflags]
 54    uint     nameson  // Don't delete names with the following wildcards /
 55                      // divided by 0 if OPTI_NAME specified
 56    uint     avoidon  // Don't delete objects with the following wildcards /
 57                      // divided by 0 if OPTI_AVOID specified
 58 }
 59 
 60 type compileinfo
 61 {
 62    uint    input      // Gentee source or filename 
 63    uint    flag       // Compile flags
 64    uint    includes   // folders for searching files  name 0 name 00
 65    uint    libs       // include files  name 0 name 00
 66    uint    defargs    // define arguments  name 0 name 00
 67    uint    output     // Ouput filename for GE
 68    uint    hthread    // The result handle of the thread if you specified    /
 69                       // CMPL_THREAD | CMPL_NOWAIT. 
 70    uint    result     // Result of the program if it was executed.
 71    optimize opti      // Optimize structure. It is used if flag CMPL_OPTIMIZE /
 72                       // is defined.
 73 }
 74 
 75 type gcompileinfo
 76 {
 77    str     input      // Gentee source or filename 
 78    uint    flag       // Compile flags
 79    arrstr  includes   // folders for searching files  name 0 name 00
 80    arrstr  libs       // include files  name 0 name 00
 81    arrstr  defargs    // define arguments  name 0 name 00
 82    arrstr  args       // Command line arguments
 83    str     output     // Ouput filename for GE or EXE
 84    uint    hthread    // The result handle of the thread if you specified    /
 85                       // CMPL_THREAD | CMPL_NOWAIT. 
 86    uint    result     // Result of the program if it was executed.
 87    uint    optiflag   // Flags of the optimization. $$[optiflags]
 88    arrstr  nameson    // Don't delete names with the following wildcards /
 89                       // if OPTI_NAME specified
 90    arrstr  avoidon    // Don't delete objects with the following wildcards /
 91                       // divided by 0 if OPTI_AVOID specified
 92 }
 93 
 94 func uint compile_arrs( arrstr input, buf output )
 95 {
 96    uint i
 97    
 98    output.clear()
 99    if *input
100    {
101       fornum i, *input
102       { 
103          output.append( input[ i ].ptr(), *input[ i ] + 1 )
104       }
105    }
106    output += ubyte( 0 )
107    return 1
108 }
109 
110 func  compile_file( gcompileinfo gcinfo )
111 {
112    compileinfo  cmpl
113    buf          includes libs defargs nameson args avoidon
114    
115    cmpl.input = gcinfo.input.ptr()
116    cmpl.flag = gcinfo.flag//$CMPL_NORUN | $CMPL_GE
117    
118    compile_arrs( gcinfo.includes, includes ) 
119    cmpl.includes = includes.ptr()
120    
121    compile_arrs( gcinfo.libs, libs ) 
122    cmpl.libs = libs.ptr()
123    
124    compile_arrs( gcinfo.defargs, defargs ) 
125    cmpl.defargs = defargs.ptr()
126 
127    compile_arrs( gcinfo.args, args ) 
128    gentee_set( $GSET_ARGS, args.ptr())
129    
130    cmpl.output = gcinfo.output.ptr()
131    
132    cmpl.opti.flag = gcinfo.optiflag
133    compile_arrs( gcinfo.nameson, nameson ) 
134    cmpl.opti.nameson = nameson.ptr()
135 
136    compile_arrs( gcinfo.avoidon, avoidon ) 
137    cmpl.opti.avoidon = avoidon.ptr()
138    
139    gentee_compile( &cmpl )      
140 }
141 
142 
Редактировать