1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/*
** The implementation of the TH core. This file contains the parser, and
** the implementation of the interface in th.h.
*/
#include "th.h"
#include <string.h>
#include <assert.h>
typedef struct Th_Command Th_Command;
typedef struct Th_Frame Th_Frame;
typedef struct Th_Variable Th_Variable;
/*
** Interpreter structure.
|
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/*
** The implementation of the TH core. This file contains the parser, and
** the implementation of the interface in th.h.
*/
#include "th.h"
#include <string.h>
#include <assert.h>
#include <stdio.h> /* FILE class */
typedef struct Th_Command Th_Command;
typedef struct Th_Frame Th_Frame;
typedef struct Th_Variable Th_Variable;
/*
** Interpreter structure.
|
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
|
}
void Th_Free(Th_Interp *pInterp, void *z){
if( z ){
pInterp->pVtab->xFree(z);
}
}
/*
** Install a new th1 command.
**
** If a command of the same name already exists, it is deleted automatically.
*/
int Th_CreateCommand(
Th_Interp *interp,
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
|
}
void Th_Free(Th_Interp *pInterp, void *z){
if( z ){
pInterp->pVtab->xFree(z);
}
}
int Th_Vtab_output( Th_Vtab *vTab, char const * zData, int nData ){
if(!vTab->out.f){
return -1;
}else if(!vTab->out.enabled){
return 0;
}else{
return vTab->out.f( zData, nData, vTab->out.pState );
}
}
int Th_output( Th_Interp *pInterp, char const * zData, int nData ){
return Th_Vtab_output( pInterp->pVtab, zData, nData );
}
int Th_output_f_FILE( char const * zData, int nData, void * pState ){
FILE * dest = pState ? (FILE*)pState : stdout;
int rc = (int)fwrite(zData, 1, nData, dest);
fflush(dest);
return rc;
}
/*
** Install a new th1 command.
**
** If a command of the same name already exists, it is deleted automatically.
*/
int Th_CreateCommand(
Th_Interp *interp,
|