close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 15 years ago

Last modified 14 years ago

#1029 closed task

API para el intérprete de C y C++ CINT — at Initial Version

Reported by: Víctor de Buen Remiro Owned by: Víctor de Buen Remiro
Priority: highest Milestone: TOL Extensions
Component: Kernel Version: head
Severity: critical Keywords:
Cc:

Description

CINT es un intérprete de C y C++ open source que permite ejecutar código sin tener que compilar ni crear un fichero ejecutable. El resultado es más lento que el código compilado pero aún así es mucho más rápido que TOL y que la mayoría de los intérpretes de lenguajes de alto nivel.

Mediante la API de CINT con C sería posible desde TOL cargar y descargar ficheros con funciones C y C++ y ejecutar sentencias que las usaran. Esta API sería especialmente útil a la hora de programar ciclos ciclos de cálculo largos que en TOL resultan demasiado lentos y que no precisan el uso de los tipos abstractos, sino que pueden expresarse mediante los tipos más simples Real, Text, Date y Matrix

Existen dos funciones para la carga y descarga de funciones en el ámbito global.

 int G__loadfile(const char *file);
/*
        G__loadfile() incrementally loads source file.
*/

 int G__unloadfile(const char *file);
/*
        G__unloadfile()  unloads source file. If any of the func-
       tions  included  in  the  file  is  busy,  G__unloadfile()
       returns error code (-1) and won't unload it.
*/

Existen otras dos funciones para la llamada a código interpretado desde C/C++.

 [anytype] G__calc(char *expression);
/*
        G__calc() evaluates C expression.  It returns the type of
       object  the  argument  expression  returns.  Variables and
       function calls can be used in  the  expression.   Declara-
       tion,  loop  and  conditional statement can not be used in
       the expression.
*/
            int i;
            double a;
            i = G__calc("1+2+3");  // returns int
            a = G__calc("3.14*i");  // returns double

 [anytype] G__exec_tempfile(char *file);
/*
        G__exec_tempfile() opens temporal source file and execute
       it  in  the  current  context.   The tempfile can contain,
       variable   declaration,   struct,union,enum    definition.
       expression,  loop and control statement and cannot contain
       function definition.  G__exec_tempfile() executes a state-
       ment or statement list surrounded by '{' , '}' and returns
       the last evaluated value.
*/
            {    // example of tempfile
                 int i;
                 double ary[100];
                 for(i=0;i<100;i++) ary[i] = i;
            }
/*
       Then in the main program, you can execute above  statement
       by G__exec_tempfile.
*/

Change History (0)

Note: See TracTickets for help on using tickets.