summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-05-15 12:22:51 -0400
committerAdrian Thurston <thurston@complang.org>2015-05-15 12:22:51 -0400
commitc98d2e9b47091c12deb747e111f7f1cd05a1f937 (patch)
tree5decdd801287425e2b27c285422e8c9da3b15415 /src
parentb05674c0aa0a63ae984fc8f8204bdb09d5e1dd9e (diff)
downloadcolm-c98d2e9b47091c12deb747e111f7f1cd05a1f937.tar.gz
naming convention improvements
Diffstat (limited to 'src')
-rw-r--r--src/bytecode.c310
-rw-r--r--src/bytecode.h20
-rw-r--r--src/codevect.c29
-rw-r--r--src/compiler.cc8
-rw-r--r--src/compiler.h6
-rw-r--r--src/ctinput.cc61
-rw-r--r--src/declare.cc2
-rw-r--r--src/fsmcodegen.cc4
-rw-r--r--src/fsmexec.cc2
-rw-r--r--src/input.c122
-rw-r--r--src/input.h72
-rw-r--r--src/iter.c6
-rw-r--r--src/list.c4
-rw-r--r--src/map.c4
-rw-r--r--src/parsetree.h52
-rw-r--r--src/pdabuild.cc2
-rw-r--r--src/pdacodegen.cc12
-rw-r--r--src/pdacodegen.h4
-rw-r--r--src/pdarun.c84
-rw-r--r--src/pdarun.h75
-rw-r--r--src/program.h6
-rw-r--r--src/string.c18
-rw-r--r--src/struct.h13
-rw-r--r--src/synthesis.cc10
-rw-r--r--src/tree.c20
-rw-r--r--src/tree.h27
26 files changed, 482 insertions, 491 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index e391b33a..7075f3bb 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -54,19 +54,19 @@ Tree **host_call( Program *prg, long code, Tree **sp );
} while(0)
#define read_half( i ) do { \
- i = ((Word) *instr++); \
- i |= ((Word) *instr++) << 8; \
+ i = ((word_t) *instr++); \
+ i |= ((word_t) *instr++) << 8; \
} while(0)
/* There are better ways. */
#if SIZEOF_LONG == 4
#define read_type( type, i ) do { \
- Word w; \
- w = ((Word) *instr++); \
- w |= ((Word) *instr++) << 8; \
- w |= ((Word) *instr++) << 16; \
- w |= ((Word) *instr++) << 24; \
+ word_t w; \
+ w = ((word_t) *instr++); \
+ w |= ((word_t) *instr++) << 8; \
+ w |= ((word_t) *instr++) << 16; \
+ w |= ((word_t) *instr++) << 24; \
i = (type) w; \
} while(0)
@@ -82,15 +82,15 @@ Tree **host_call( Program *prg, long code, Tree **sp );
#else
#define read_type( type, i ) do { \
- Word _w; \
- _w = ((Word) *instr++); \
- _w |= ((Word) *instr++) << 8; \
- _w |= ((Word) *instr++) << 16; \
- _w |= ((Word) *instr++) << 24; \
- _w |= ((Word) *instr++) << 32; \
- _w |= ((Word) *instr++) << 40; \
- _w |= ((Word) *instr++) << 48; \
- _w |= ((Word) *instr++) << 56; \
+ word_t _w; \
+ _w = ((word_t) *instr++); \
+ _w |= ((word_t) *instr++) << 8; \
+ _w |= ((word_t) *instr++) << 16; \
+ _w |= ((word_t) *instr++) << 24; \
+ _w |= ((word_t) *instr++) << 32; \
+ _w |= ((word_t) *instr++) << 40; \
+ _w |= ((word_t) *instr++) << 48; \
+ _w |= ((word_t) *instr++) << 56; \
i = (type) _w; \
} while(0)
@@ -110,15 +110,15 @@ Tree **host_call( Program *prg, long code, Tree **sp );
#define read_tree( i ) read_type( Tree*, i )
#define read_parser( i ) read_type( Parser*, i )
-#define read_word( i ) read_type( Word, i )
+#define read_word( i ) read_type( word_t, i )
#define read_stream( i ) read_type( Stream*, i )
-#define read_word_p( i, p ) read_type_p( Word, i, p )
+#define read_word_p( i, p ) read_type_p( word_t, i, p )
#define consume_byte() instr += 1
#define consume_half() instr += 2
-static void rcode_downref( Program *prg, Tree **sp, Code *instr );
+static void rcode_downref( Program *prg, Tree **sp, code_t *instr );
void colm_parser_set_context( Program *prg, Tree **sp, Parser *parser, Struct *val )
{
@@ -141,10 +141,10 @@ static Head *tree_to_str( Program *prg, Tree **sp, Tree *tree, int trim )
return ret;
}
-static Word stream_append_tree( Program *prg, Tree **sp, Stream *dest, Tree *input )
+static word_t stream_append_tree( Program *prg, Tree **sp, Stream *dest, Tree *input )
{
long length = 0;
- StreamImpl *impl = streamToImpl( dest );
+ struct stream_impl *impl = streamToImpl( dest );
if ( input->id == LEL_ID_STR ) {
/* Collect the tree data. */
@@ -169,18 +169,18 @@ static Word stream_append_tree( Program *prg, Tree **sp, Stream *dest, Tree *inp
return length;
}
-static Word stream_append_stream( Program *prg, Tree **sp, Stream *dest, Tree *stream )
+static word_t stream_append_stream( Program *prg, Tree **sp, Stream *dest, Tree *stream )
{
long length = 0;
- StreamImpl *impl = streamToImpl( dest );
+ struct stream_impl *impl = streamToImpl( dest );
impl->funcs->appendStream( impl, stream );
return length;
}
static void stream_undo_append( Program *prg, Tree **sp,
- StreamImpl *is, Tree *input, long length )
+ struct stream_impl *is, Tree *input, long length )
{
if ( input->id == LEL_ID_STR )
is->funcs->undoAppendData( is, length );
@@ -192,7 +192,7 @@ static void stream_undo_append( Program *prg, Tree **sp,
}
}
-static void stream_undo_append_stream( Program *prg, Tree **sp, StreamImpl *is,
+static void stream_undo_append_stream( Program *prg, Tree **sp, struct stream_impl *is,
Tree *input, long length )
{
is->funcs->undoAppendStream( is );
@@ -202,20 +202,20 @@ static Tree *stream_pull_bc( Program *prg, Tree **sp, struct pda_run *pdaRun,
Stream *stream, Tree *length )
{
long len = ((long)length);
- StreamImpl *impl = streamToImpl( stream );
+ struct stream_impl *impl = streamToImpl( stream );
Head *tokdata = colm_stream_pull( prg, sp, pdaRun, impl, len );
return constructString( prg, tokdata );
}
static void undo_pull( Program *prg, Stream *stream, Tree *str )
{
- StreamImpl *impl = streamToImpl( stream );
+ struct stream_impl *impl = streamToImpl( stream );
const char *data = stringData( ( (Str*)str )->value );
long length = stringLength( ( (Str*)str )->value );
undoStreamPull( impl, data, length );
}
-static long stream_push( Program *prg, Tree **sp, StreamImpl *in, Tree *tree, int ignore )
+static long stream_push( Program *prg, Tree **sp, struct stream_impl *in, Tree *tree, int ignore )
{
if ( tree->id == LEL_ID_STR ) {
/* This should become a compile error. If it's text, it's up to the
@@ -227,7 +227,7 @@ static long stream_push( Program *prg, Tree **sp, StreamImpl *in, Tree *tree, in
initStrCollect( &collect );
printTreeCollect( prg, sp, &collect, tree, false );
- streamPushText( in, collect.data, collect.length );
+ colm_stream_push_text( in, collect.data, collect.length );
long length = collect.length;
strCollectDestroy( &collect );
@@ -235,20 +235,20 @@ static long stream_push( Program *prg, Tree **sp, StreamImpl *in, Tree *tree, in
}
else if ( tree->id == LEL_ID_PTR ) {
treeUpref( tree );
- streamPushStream( in, tree );
+ colm_stream_push_stream( in, tree );
return -1;
}
else {
treeUpref( tree );
- streamPushTree( in, tree, ignore );
+ colm_stream_push_tree( in, tree, ignore );
return -1;
}
}
static long stream_push_stream( Program *prg, Tree **sp,
- StreamImpl *in, Stream *stream )
+ struct stream_impl *in, Stream *stream )
{
- streamPushStream( in, (Tree*)stream );
+ colm_stream_push_stream( in, (Tree*)stream );
return -1;
}
@@ -325,7 +325,7 @@ static Tree *construct_arg0( Program *prg, int argc, const char **argv )
{
Tree *arg0 = 0;
if ( argc > 0 ) {
- Head *head = stringAllocPointer( prg, argv[0], strlen(argv[0]) );
+ Head *head = colm_string_alloc_pointer( prg, argv[0], strlen(argv[0]) );
arg0 = constructString( prg, head );
treeUpref( arg0 );
}
@@ -337,7 +337,7 @@ static List *construct_argv( Program *prg, int argc, const char **argv )
List *list = (List*)colm_construct_generic( prg, prg->rtd->argvGenericId );
int i;
for ( i = 1; i < argc; i++ ) {
- Head *head = stringAllocPointer( prg, argv[i], strlen(argv[i]) );
+ Head *head = colm_string_alloc_pointer( prg, argv[i], strlen(argv[i]) );
Tree *arg = constructString( prg, head );
treeUpref( arg );
@@ -359,8 +359,8 @@ void colm_rcode_downref_all( Program *prg, Tree **sp, struct rt_code_vect *rev )
{
while ( rev->tabLen > 0 ) {
/* Read the length */
- Code *prcode = rev->data + rev->tabLen - SIZEOF_WORD;
- Word len;
+ code_t *prcode = rev->data + rev->tabLen - SIZEOF_WORD;
+ word_t len;
read_word_p( len, prcode );
/* Find the start of block. */
@@ -375,7 +375,7 @@ void colm_rcode_downref_all( Program *prg, Tree **sp, struct rt_code_vect *rev )
}
}
-void colm_execute( Program *prg, Execution *exec, Code *code )
+void colm_execute( Program *prg, Execution *exec, code_t *code )
{
Tree **sp = prg->stackRoot;
@@ -395,7 +395,7 @@ void colm_execute( Program *prg, Execution *exec, Code *code )
exec->framePtr = vm_ptop();
vm_pushn( fi->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fi->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fi->frameSize );
/* Execution loop. */
sp = colm_execute_code( prg, exec, sp, code );
@@ -425,11 +425,11 @@ Tree *colm_run_func( struct colm_program *prg, int frameId,
Tree **sp = prg->stackRoot;
struct frame_info *fi = &prg->rtd->frameInfo[frameId];
- Code *code = fi->codeWC;
+ code_t *code = fi->codeWC;
vm_pushn( paramCount );
execution.callArgs = vm_ptop();
- memset( vm_ptop(), 0, sizeof(Word) * paramCount );
+ memset( vm_ptop(), 0, sizeof(word_t) * paramCount );
int p;
for ( p = 0; p < paramCount; p++ ) {
@@ -437,7 +437,7 @@ Tree *colm_run_func( struct colm_program *prg, int frameId,
((Value*)execution.callArgs)[p] = 0;
}
else {
- Head *head = stringAllocPointer( prg, params[p], strlen(params[p]) );
+ Head *head = colm_string_alloc_pointer( prg, params[p], strlen(params[p]) );
Tree *tree = constructString( prg, head );
treeUpref( tree );
((Tree**)execution.callArgs)[p] = tree;
@@ -458,7 +458,7 @@ Tree *colm_run_func( struct colm_program *prg, int frameId,
execution.framePtr = vm_ptop();
vm_pushn( fi->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fi->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fi->frameSize );
/* Execution loop. */
sp = colm_execute_code( prg, &execution, sp, code );
@@ -498,7 +498,7 @@ int colm_make_reverse_code( struct pda_run *pdaRun )
/* Go backwards, group by group, through the reverse code. Push each group
* to the global reverse code stack. */
- Code *p = rcodeCollect->data + rcodeCollect->tabLen;
+ code_t *p = rcodeCollect->data + rcodeCollect->tabLen;
while ( p != rcodeCollect->data ) {
p--;
long len = *p;
@@ -540,29 +540,29 @@ static void rcode_unit_start( Execution *exec )
exec->rcodeUnitLen = 0;
}
-static void rcode_code( Execution *exec, const Code code )
+static void rcode_code( Execution *exec, const code_t code )
{
append_code_val( &exec->parser->pdaRun->rcodeCollect, code );
exec->rcodeUnitLen += SIZEOF_CODE;
}
-static void rcodeHalf( Execution *exec, const Half half )
+static void rcodeHalf( Execution *exec, const half_t half )
{
append_half( &exec->parser->pdaRun->rcodeCollect, half );
exec->rcodeUnitLen += SIZEOF_HALF;
}
-static void rcode_word( Execution *exec, const Word word )
+static void rcode_word( Execution *exec, const word_t word )
{
append_word( &exec->parser->pdaRun->rcodeCollect, word );
exec->rcodeUnitLen += SIZEOF_WORD;
}
-Code *colm_pop_reverse_code( struct rt_code_vect *allRev )
+code_t *colm_pop_reverse_code( struct rt_code_vect *allRev )
{
/* Read the length */
- Code *prcode = allRev->data + allRev->tabLen - SIZEOF_WORD;
- Word len;
+ code_t *prcode = allRev->data + allRev->tabLen - SIZEOF_WORD;
+ word_t len;
read_word_p( len, prcode );
/* Find the start of block. */
@@ -574,12 +574,12 @@ Code *colm_pop_reverse_code( struct rt_code_vect *allRev )
return prcode;
}
-Tree **colm_execute_code( Program *prg, Execution *exec, Tree **sp, Code *instr )
+Tree **colm_execute_code( Program *prg, Execution *exec, Tree **sp, code_t *instr )
{
/* When we exit we are going to verify that we did not eat up any stack
* space. */
Tree **root = sp;
- Code c;
+ code_t c;
again:
c = *instr++;
@@ -610,9 +610,9 @@ again:
}
case IN_LOAD_WORD: {
debug( prg, REALM_BYTECODE, "IN_LOAD_WORD\n" );
- Word w;
+ word_t w;
read_word( w );
- vm_push_type( Word, w );
+ vm_push_type( word_t, w );
break;
}
case IN_LOAD_TRUE: {
@@ -628,7 +628,7 @@ again:
break;
}
case IN_LOAD_INT: {
- Word i;
+ word_t i;
read_word( i );
debug( prg, REALM_BYTECODE, "IN_LOAD_INT %d\n", i );
@@ -638,7 +638,7 @@ again:
break;
}
case IN_LOAD_STR: {
- Word offset;
+ word_t offset;
read_word( offset );
debug( prg, REALM_BYTECODE, "IN_LOAD_STR %d\n", offset );
@@ -674,7 +674,7 @@ again:
for ( i = n-1; i >= 0; i-- )
arg[i] = vm_pop_tree();
Stream *stream = vm_pop_stream();
- StreamImpl *si = streamToImpl( stream );
+ struct stream_impl *si = streamToImpl( stream );
for ( i = 0; i < n; i++ ) {
if ( si->file != 0 )
@@ -771,7 +771,7 @@ again:
/* Set up the reverse instruction. */
rcode_unit_start( exec );
rcode_code( exec, IN_LOAD_INPUT_BKT );
- rcode_word( exec, (Word)exec->parser->input );
+ rcode_word( exec, (word_t)exec->parser->input );
break;
}
case IN_LOAD_INPUT_WC: {
@@ -858,7 +858,7 @@ again:
break;
}
case IN_INIT_RHS_EL: {
- Half position;
+ half_t position;
short field;
read_half( position );
read_half( field );
@@ -1147,7 +1147,7 @@ again:
/* Set up the reverse instruction. */
rcode_code( exec, IN_SET_FIELD_TREE_BKT );
rcodeHalf( exec, field );
- rcode_word( exec, (Word)prev );
+ rcode_word( exec, (word_t)prev );
rcode_unit_term( exec );
break;
}
@@ -1323,7 +1323,7 @@ again:
/* Set up the reverse instruction. */
rcode_code( exec, IN_SET_STRUCT_BKT );
rcodeHalf( exec, field );
- rcode_word( exec, (Word)prev );
+ rcode_word( exec, (word_t)prev );
rcode_unit_term( exec );
break;
}
@@ -1381,7 +1381,7 @@ again:
rcode_code( exec, IN_SET_STRUCT_VAL_BKT );
rcodeHalf( exec, field );
- rcode_word( exec, (Word)prev );
+ rcode_word( exec, (word_t)prev );
rcode_unit_term( exec );
break;
}
@@ -1803,8 +1803,8 @@ again:
case IN_DUP_VAL: {
debug( prg, REALM_BYTECODE, "IN_DUP_VAL\n" );
- Word val = (Word)vm_top();
- vm_push_type( Word, val );
+ word_t val = (word_t)vm_top();
+ vm_push_type( word_t, val );
break;
}
case IN_DUP_TREE: {
@@ -1817,8 +1817,8 @@ again:
}
case IN_TRITER_FROM_REF: {
short field;
- Half argSize;
- Half searchTypeId;
+ half_t argSize;
+ half_t searchTypeId;
read_half( field );
read_half( argSize );
read_half( searchTypeId );
@@ -1851,8 +1851,8 @@ again:
}
case IN_REV_TRITER_FROM_REF: {
short field;
- Half argSize;
- Half searchTypeId;
+ half_t argSize;
+ half_t searchTypeId;
read_half( field );
read_half( argSize );
read_half( searchTypeId );
@@ -1892,7 +1892,7 @@ again:
break;
}
case IN_TREE_SEARCH: {
- Word id;
+ word_t id;
read_word( id );
debug( prg, REALM_BYTECODE, "IN_TREE_SEARCH\n" );
@@ -2005,8 +2005,8 @@ again:
}
case IN_GEN_ITER_FROM_REF: {
short field;
- Half argSize;
- Half genericId;
+ half_t argSize;
+ half_t genericId;
read_half( field );
read_half( argSize );
read_half( genericId );
@@ -2086,7 +2086,7 @@ again:
break;
}
case IN_MATCH: {
- Half patternId;
+ half_t patternId;
read_half( patternId );
debug( prg, REALM_BYTECODE, "IN_MATCH\n" );
@@ -2148,15 +2148,15 @@ again:
Tree *input = vm_pop_tree();
Parser *parser = vm_pop_parser();
- Word len = stream_append_tree( prg, sp, parser->input, input );
+ word_t len = stream_append_tree( prg, sp, parser->input, input );
vm_push_parser( parser );
rcode_unit_start( exec );
rcode_code( exec, IN_PARSE_APPEND_BKT );
- rcode_word( exec, (Word) parser );
- rcode_word( exec, (Word) input );
- rcode_word( exec, (Word) len );
+ rcode_word( exec, (word_t) parser );
+ rcode_word( exec, (word_t) input );
+ rcode_word( exec, (word_t) len );
rcode_unit_term( exec );
break;
}
@@ -2164,14 +2164,14 @@ again:
case IN_PARSE_APPEND_BKT: {
Tree *pptr;
Tree *input;
- Word len;
+ word_t len;
read_tree( pptr );
read_tree( input );
read_word( len );
debug( prg, REALM_BYTECODE, "IN_PARSE_APPEND_BKT\n" );
- StreamImpl *si = streamToImpl( ((Parser*)pptr)->input );
+ struct stream_impl *si = streamToImpl( ((Parser*)pptr)->input );
stream_undo_append( prg, sp, si, input, len );
treeDownref( prg, sp, input );
@@ -2195,15 +2195,15 @@ again:
Tree *input = vm_pop_tree();
Parser *parser = vm_pop_parser();
- Word len = stream_append_stream( prg, sp, parser->input, input );
+ word_t len = stream_append_stream( prg, sp, parser->input, input );
vm_push_parser( parser );
rcode_unit_start( exec );
rcode_code( exec, IN_PARSE_APPEND_STREAM_BKT );
- rcode_word( exec, (Word) parser );
- rcode_word( exec, (Word) input );
- rcode_word( exec, (Word) len );
+ rcode_word( exec, (word_t) parser );
+ rcode_word( exec, (word_t) input );
+ rcode_word( exec, (word_t) len );
rcode_unit_term( exec );
break;
}
@@ -2211,14 +2211,14 @@ again:
case IN_PARSE_APPEND_STREAM_BKT: {
Tree *pptr;
Tree *input;
- Word len;
+ word_t len;
read_tree( pptr );
read_tree( input );
read_word( len );
debug( prg, REALM_BYTECODE, "IN_PARSE_APPEND_STREAM_BKT\n" );
- StreamImpl *si = streamToImpl( ((Parser*)pptr)->input );
+ struct stream_impl *si = streamToImpl( ((Parser*)pptr)->input );
stream_undo_append_stream( prg, sp, si, input, len );
treeDownref( prg, sp, input );
@@ -2229,7 +2229,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_INPUT_CLOSE_WC\n" );
Stream *stream = vm_pop_stream();
- StreamImpl *si = stream->impl;
+ struct stream_impl *si = stream->impl;
if ( si->file != 0 ) {
fclose( si->file );
@@ -2283,8 +2283,8 @@ again:
debug( prg, REALM_BYTECODE, "IN_PARSE_INIT_BKT\n" );
Parser *parser;
- Word pcr;
- Word steps;
+ word_t pcr;
+ word_t steps;
read_parser( parser );
read_word( pcr );
@@ -2317,8 +2317,8 @@ again:
/* Return location one instruction back. Depends on the size of of
* the frag/finish. */
- Code *returnTo = instr - ( SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF );
- vm_push_type( Code*, returnTo );
+ code_t *returnTo = instr - ( SIZEOF_CODE + SIZEOF_CODE + SIZEOF_HALF );
+ vm_push_type( code_t*, returnTo );
exec->framePtr = 0;
exec->iframePtr = 0;
@@ -2333,7 +2333,7 @@ again:
exec->framePtr = vm_ptop();
vm_pushn( fi->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fi->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fi->frameSize );
}
break;
}
@@ -2355,7 +2355,7 @@ again:
vm_popn( fi->frameSize );
}
- instr = vm_pop_type(Code*);
+ instr = vm_pop_type(code_t*);
exec->frameId = vm_pop_type(long);
exec->iframePtr = vm_pop_type(Tree**);
exec->framePtr = vm_pop_type(Tree**);
@@ -2374,7 +2374,7 @@ again:
}
case IN_PARSE_FRAG_WC: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WC %hd\n", stopId );
@@ -2407,7 +2407,7 @@ again:
}
case IN_PARSE_FRAG_WV: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WV %hd\n", stopId );
@@ -2436,8 +2436,8 @@ again:
rcode_unit_start( exec );
rcode_code( exec, IN_PARSE_INIT_BKT );
- rcode_word( exec, (Word) parser );
- rcode_word( exec, (Word) PCR_START );
+ rcode_word( exec, (word_t) parser );
+ rcode_word( exec, (word_t) PCR_START );
rcode_word( exec, steps );
rcode_code( exec, IN_PARSE_FRAG_BKT );
rcodeHalf( exec, 0 );
@@ -2451,7 +2451,7 @@ again:
}
case IN_PARSE_FRAG_BKT: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT %hd\n", stopId );
@@ -2475,7 +2475,7 @@ again:
}
case IN_PARSE_FINISH_WC: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WC %hd\n", stopId );
@@ -2511,7 +2511,7 @@ again:
}
case IN_PARSE_FINISH_WV: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WV %hd\n", stopId );
@@ -2541,8 +2541,8 @@ again:
rcode_unit_start( exec );
rcode_code( exec, IN_PARSE_INIT_BKT );
- rcode_word( exec, (Word)parser );
- rcode_word( exec, (Word)PCR_START );
+ rcode_word( exec, (word_t)parser );
+ rcode_word( exec, (word_t)PCR_START );
rcode_word( exec, steps );
rcode_code( exec, IN_PARSE_FINISH_BKT );
rcodeHalf( exec, 0 );
@@ -2557,7 +2557,7 @@ again:
}
case IN_PARSE_FINISH_BKT: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_BKT %hd\n", stopId );
@@ -2579,7 +2579,7 @@ again:
exec->pcr = vm_pop_type(long);
exec->parser = vm_pop_parser();
- StreamImpl *si = streamToImpl( parser->input );
+ struct stream_impl *si = streamToImpl( parser->input );
si->funcs->unsetEof( si );
break;
}
@@ -2597,7 +2597,7 @@ again:
/* Single unit. */
treeUpref( string );
rcode_code( exec, IN_INPUT_PULL_BKT );
- rcode_word( exec, (Word) string );
+ rcode_word( exec, (word_t) string );
rcode_unit_term( exec );
//treeDownref( prg, sp, len );
@@ -2662,13 +2662,13 @@ again:
break;
}
case IN_INPUT_PUSH_BKT: {
- Word len;
+ word_t len;
read_word( len );
debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_BKT %d\n", len );
Stream *input = vm_pop_stream();
- undoStreamPush( prg, sp, streamToImpl( input ), len );
+ colm_undo_stream_push( prg, sp, streamToImpl( input ), len );
break;
}
case IN_INPUT_PUSH_STREAM_WV: {
@@ -2686,17 +2686,17 @@ again:
break;
}
case IN_INPUT_PUSH_STREAM_BKT: {
- Word len;
+ word_t len;
read_word( len );
debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_STREAM_BKT %d\n", len );
Stream *input = vm_pop_stream();
- undoStreamPush( prg, sp, streamToImpl( input ), len );
+ colm_undo_stream_push( prg, sp, streamToImpl( input ), len );
break;
}
case IN_CONS_GENERIC: {
- Half genericId;
+ half_t genericId;
read_half( genericId );
debug( prg, REALM_BYTECODE, "IN_CONS_GENERIC %hd\n", genericId );
@@ -2706,7 +2706,7 @@ again:
break;
}
case IN_CONS_OBJECT: {
- Half langElId;
+ half_t langElId;
read_half( langElId );
debug( prg, REALM_BYTECODE, "IN_CONS_OBJECT %hd\n", langElId );
@@ -2716,7 +2716,7 @@ again:
break;
}
case IN_CONSTRUCT: {
- Half patternId;
+ half_t patternId;
read_half( patternId );
debug( prg, REALM_BYTECODE, "IN_CONSTRUCT\n" );
@@ -2741,7 +2741,7 @@ again:
break;
}
case IN_CONSTRUCT_TERM: {
- Half tokenId;
+ half_t tokenId;
read_half( tokenId );
debug( prg, REALM_BYTECODE, "IN_CONSTRUCT_TERM\n" );
@@ -2789,7 +2789,7 @@ again:
break;
}
case IN_TREE_CAST: {
- Half langElId;
+ half_t langElId;
read_half( langElId );
debug( prg, REALM_BYTECODE, "IN_TREE_CAST %hd\n", langElId );
@@ -2810,11 +2810,11 @@ again:
/* This is an initial global load. Need to reverse execute it. */
rcode_unit_start( exec );
rcode_code( exec, IN_PTR_ACCESS_BKT );
- rcode_word( exec, (Word) ptr );
+ rcode_word( exec, (word_t) ptr );
break;
}
case IN_PTR_ACCESS_BKT: {
- Word p;
+ word_t p;
read_word( p );
debug( prg, REALM_BYTECODE, "IN_PTR_ACCESS_BKT\n" );
@@ -2972,7 +2972,7 @@ again:
/* Set up reverse code. Needs no args. */
rcode_code( exec, IN_SET_TOKEN_DATA_BKT );
- rcode_word( exec, (Word)oldval );
+ rcode_word( exec, (word_t)oldval );
rcode_unit_term( exec );
treeDownref( prg, sp, tree );
@@ -2982,7 +2982,7 @@ again:
case IN_SET_TOKEN_DATA_BKT: {
debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT \n" );
- Word oldval;
+ word_t oldval;
read_word( oldval );
Tree *tree = vm_pop_tree();
@@ -3278,8 +3278,8 @@ again:
}
case IN_STASH_ARG: {
- Half pos;
- Half size;
+ half_t pos;
+ half_t size;
read_half( pos );
read_half( size );
@@ -3296,7 +3296,7 @@ again:
}
case IN_PREP_ARGS: {
- Half size;
+ half_t size;
read_half( size );
debug( prg, REALM_BYTECODE, "IN_PREP_ARGS %hd\n", size );
@@ -3304,12 +3304,12 @@ again:
vm_push_type( Tree**, exec->callArgs );
vm_pushn( size );
exec->callArgs = vm_ptop();
- memset( vm_ptop(), 0, sizeof(Word) * size );
+ memset( vm_ptop(), 0, sizeof(word_t) * size );
break;
}
case IN_CLEAR_ARGS: {
- Half size;
+ half_t size;
read_half( size );
debug( prg, REALM_BYTECODE, "IN_CLEAR_ARGS %hd\n", size );
@@ -3320,7 +3320,7 @@ again:
}
case IN_HOST: {
- Half funcId;
+ half_t funcId;
read_half( funcId );
debug( prg, REALM_BYTECODE, "IN_HOST %hd\n", funcId );
@@ -3329,7 +3329,7 @@ again:
break;
}
case IN_CALL_WV: {
- Half funcId;
+ half_t funcId;
read_half( funcId );
struct function_info *fi = &prg->rtd->functionInfo[funcId];
@@ -3341,7 +3341,7 @@ again:
vm_push_type( Tree**, exec->callArgs );
vm_push_value( 0 ); /* Return value. */
- vm_push_type( Code*, instr );
+ vm_push_type( code_t*, instr );
vm_push_type( Tree**, exec->framePtr );
vm_push_type( long, exec->frameId );
@@ -3350,11 +3350,11 @@ again:
exec->framePtr = vm_ptop();
vm_pushn( fr->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fr->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fr->frameSize );
break;
}
case IN_CALL_WC: {
- Half funcId;
+ half_t funcId;
read_half( funcId );
struct function_info *fi = &prg->rtd->functionInfo[funcId];
@@ -3366,7 +3366,7 @@ again:
vm_push_type( Tree**, exec->callArgs );
vm_push_value( 0 ); /* Return value. */
- vm_push_type( Code*, instr );
+ vm_push_type( code_t*, instr );
vm_push_type( Tree**, exec->framePtr );
vm_push_type( long, exec->frameId );
@@ -3375,7 +3375,7 @@ again:
exec->framePtr = vm_ptop();
vm_pushn( fr->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fr->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fr->frameSize );
break;
}
case IN_YIELD: {
@@ -3397,7 +3397,7 @@ again:
uiter->frame = exec->framePtr;
/* Restore the instruction and frame pointer. */
- instr = (Code*) vm_local_iframe(IFR_RIN);
+ instr = (code_t*) vm_local_iframe(IFR_RIN);
exec->framePtr = (Tree**) vm_local_iframe(IFR_RFR);
exec->iframePtr = (Tree**) vm_local_iframe(IFR_RIF);
@@ -3410,7 +3410,7 @@ again:
}
case IN_UITER_CREATE_WV: {
short field;
- Half funcId, searchId;
+ half_t funcId, searchId;
read_half( field );
read_half( funcId );
read_half( searchId );
@@ -3419,7 +3419,7 @@ again:
struct function_info *fi = prg->rtd->functionInfo + funcId;
- vm_contiguous( (sizeof(UserIter) / sizeof(Word)) + FR_AA + fi->frameSize );
+ vm_contiguous( (sizeof(UserIter) / sizeof(word_t)) + FR_AA + fi->frameSize );
UserIter *uiter = colm_uiter_create( prg, &sp, fi, searchId );
vm_set_local(exec, field, (SW) uiter);
@@ -3432,20 +3432,20 @@ again:
vm_push_type( Tree**, exec->callArgs );
vm_push_value( 0 );
- vm_push_type( Code*, 0 ); /* Return instruction pointer, */
+ vm_push_type( code_t*, 0 ); /* Return instruction pointer, */
vm_push_type( Tree**, exec->iframePtr ); /* Return iframe. */
vm_push_type( Tree**, exec->framePtr ); /* Return frame. */
uiter->frame = vm_ptop();
vm_pushn( fi->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fi->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fi->frameSize );
uiterInit( prg, sp, uiter, fi, true );
break;
}
case IN_UITER_CREATE_WC: {
short field;
- Half funcId, searchId;
+ half_t funcId, searchId;
read_half( field );
read_half( funcId );
read_half( searchId );
@@ -3454,7 +3454,7 @@ again:
struct function_info *fi = prg->rtd->functionInfo + funcId;
- vm_contiguous( (sizeof(UserIter) / sizeof(Word)) + FR_AA + fi->frameSize );
+ vm_contiguous( (sizeof(UserIter) / sizeof(word_t)) + FR_AA + fi->frameSize );
UserIter *uiter = colm_uiter_create( prg, &sp, fi, searchId );
vm_set_local(exec, field, (SW) uiter);
@@ -3467,13 +3467,13 @@ again:
vm_push_type( Tree**, exec->callArgs );
vm_push_value( 0 );
- vm_push_type( Code*, 0 ); /* Return instruction pointer, */
+ vm_push_type( code_t*, 0 ); /* Return instruction pointer, */
vm_push_type( Tree**, exec->iframePtr ); /* Return iframe. */
vm_push_type( Tree**, exec->framePtr ); /* Return frame. */
uiter->frame = vm_ptop();
vm_pushn( fi->frameSize );
- memset( vm_ptop(), 0, sizeof(Word) * fi->frameSize );
+ memset( vm_ptop(), 0, sizeof(word_t) * fi->frameSize );
uiterInit( prg, sp, uiter, fi, false );
break;
@@ -3507,7 +3507,7 @@ again:
exec->frameId = vm_pop_type(long);
exec->framePtr = vm_pop_type(Tree**);
- instr = vm_pop_type(Code*);
+ instr = vm_pop_type(code_t*);
exec->retVal = vm_pop_tree();
vm_pop_value();
//vm_popn( fi->argSize );
@@ -3633,7 +3633,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_STR_ATOI\n" );
Str *str = vm_pop_string();
- Word res = strAtoi( str->value );
+ word_t res = strAtoi( str->value );
Value integer = res;
vm_push_value( integer );
treeDownref( prg, sp, (Tree*)str );
@@ -3643,7 +3643,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_STR_ATOO\n" );
Str *str = vm_pop_string();
- Word res = strAtoo( str->value );
+ word_t res = strAtoo( str->value );
Value integer = res;
vm_push_value( integer );
treeDownref( prg, sp, (Tree*)str );
@@ -3653,7 +3653,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_STR_UORD8\n" );
Str *str = vm_pop_string();
- Word res = strUord8( str->value );
+ word_t res = strUord8( str->value );
Value integer = res;
vm_push_value( integer );
treeDownref( prg, sp, (Tree*)str );
@@ -3663,7 +3663,7 @@ again:
debug( prg, REALM_BYTECODE, "IN_STR_UORD16\n" );
Str *str = vm_pop_string();
- Word res = strUord16( str->value );
+ word_t res = strUord16( str->value );
Value integer = res;
vm_push_value( integer );
treeDownref( prg, sp, (Tree*)str );
@@ -3718,7 +3718,7 @@ again:
break;
}
case IN_LOAD_ARG0: {
- Half field;
+ half_t field;
read_half( field );
debug( prg, REALM_BYTECODE, "IN_LOAD_ARG0 %lu\n", field );
@@ -3730,7 +3730,7 @@ again:
break;
}
case IN_LOAD_ARGV: {
- Half field;
+ half_t field;
read_half( field );
debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV %lu\n", field );
@@ -3867,7 +3867,7 @@ again:
rcode_code( exec, IN_FN );
rcode_code( exec, IN_LIST_POP_TAIL_BKT );
rcodeHalf( exec, genId );
- rcode_word( exec, (Word)s );
+ rcode_word( exec, (word_t)s );
rcode_unit_term( exec );
break;
}
@@ -3921,7 +3921,7 @@ again:
rcode_code( exec, IN_FN );
rcode_code( exec, IN_LIST_POP_HEAD_BKT );
rcodeHalf( exec, genId );
- rcode_word( exec, (Word)s );
+ rcode_word( exec, (word_t)s );
rcode_unit_term( exec );
break;
}
@@ -3998,7 +3998,7 @@ again:
rcode_code( exec, IN_MAP_INSERT_BKT );
rcodeHalf( exec, genId );
rcode_code( exec, inserted != 0 ? 1 : 0 );
- rcode_word( exec, (Word)mapEl );
+ rcode_word( exec, (word_t)mapEl );
rcode_unit_term( exec );
break;
}
@@ -4006,7 +4006,7 @@ again:
case IN_MAP_INSERT_BKT: {
short genId;
uchar inserted;
- Word wmapEl;
+ word_t wmapEl;
read_half( genId );
read_byte( inserted );
@@ -4053,8 +4053,8 @@ again:
/* Reverse instruction. */
rcode_code( exec, IN_FN );
rcode_code( exec, IN_MAP_DETACH_BKT );
- rcode_word( exec, (Word)pair.key );
- rcode_word( exec, (Word)pair.val );
+ rcode_word( exec, (word_t)pair.key );
+ rcode_word( exec, (word_t)pair.val );
rcode_unit_term( exec );
treeDownref( prg, sp, obj );
@@ -4223,7 +4223,7 @@ again:
/* Call layout. */
exec->frameId = vm_pop_type(long);
exec->framePtr = vm_pop_type(Tree**);
- instr = vm_pop_type(Code*);
+ instr = vm_pop_type(code_t*);
Tree *retVal = vm_pop_tree();
vm_pop_value();
@@ -4277,7 +4277,7 @@ out:
/*
* Deleteing rcode required downreffing any trees held by it.
*/
-static void rcode_downref( Program *prg, Tree **sp, Code *instr )
+static void rcode_downref( Program *prg, Tree **sp, code_t *instr )
{
again:
switch ( *instr++ ) {
@@ -4316,7 +4316,7 @@ again:
}
case IN_PARSE_FRAG_BKT: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
break;
@@ -4326,7 +4326,7 @@ again:
break;
}
case IN_PARSE_FINISH_BKT: {
- Half stopId;
+ half_t stopId;
read_half( stopId );
debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_BKT\n" );
break;
@@ -4440,7 +4440,7 @@ again:
break;
}
case IN_SET_TOKEN_DATA_BKT: {
- Word oldval;
+ word_t oldval;
read_word( oldval );
debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT\n" );
diff --git a/src/bytecode.h b/src/bytecode.h
index 6b4aa885..c0d874bb 100644
--- a/src/bytecode.h
+++ b/src/bytecode.h
@@ -572,7 +572,7 @@ typedef Tree **StackPtr;
* serial representation. */
#define SIZEOF_CODE 1
#define SIZEOF_HALF 2
-#define SIZEOF_WORD sizeof(Word)
+#define SIZEOF_WORD sizeof(word_t)
typedef struct colm_execution
{
@@ -632,19 +632,19 @@ Head *stringCopy( struct colm_program *prg, Head *head );
void stringFree( struct colm_program *prg, Head *head );
void stringShorten( Head *tokdata, long newlen );
Head *concatStr( Head *s1, Head *s2 );
-Word strAtoi( Head *str );
-Word strAtoo( Head *str );
-Word strUord16( Head *head );
-Word strUord8( Head *head );
-Word cmpString( Head *s1, Head *s2 );
+word_t strAtoi( Head *str );
+word_t strAtoo( Head *str );
+word_t strUord16( Head *head );
+word_t strUord8( Head *head );
+word_t cmpString( Head *s1, Head *s2 );
Head *stringToUpper( Head *s );
Head *stringToLower( Head *s );
Head *stringSprintf( Program *prg, Str *format, long integer );
Head *makeLiteral( struct colm_program *prg, long litoffset );
-Head *intToStr( struct colm_program *prg, Word i );
+Head *intToStr( struct colm_program *prg, word_t i );
-void colm_execute( struct colm_program *prg, Execution *exec, Code *code );
+void colm_execute( struct colm_program *prg, Execution *exec, code_t *code );
void reductionExecution( Execution *exec, Tree **sp );
void generationExecution( Execution *exec, Tree **sp );
void reverseExecution( Execution *exec, Tree **sp, struct rt_code_vect *allRev );
@@ -663,8 +663,8 @@ void splitRef( struct colm_program *prg, Tree ***sp, Ref *fromRef );
void allocGlobal( struct colm_program *prg );
Tree **colm_execute_code( struct colm_program *prg,
- Execution *exec, Tree **sp, Code *instr );
-Code *colm_pop_reverse_code( struct rt_code_vect *allRev );
+ Execution *exec, Tree **sp, code_t *instr );
+code_t *colm_pop_reverse_code( struct rt_code_vect *allRev );
#ifdef __cplusplus
}
diff --git a/src/codevect.c b/src/codevect.c
index eb30388c..1b037977 100644
--- a/src/codevect.c
+++ b/src/codevect.c
@@ -56,13 +56,13 @@ static void upResize( struct rt_code_vect *vect, long len )
vect->allocLen = newLen;
if ( vect->data != 0 ) {
/* Table exists already, resize it up. */
- vect->data = (Code*) realloc( vect->data, sizeof(Code) * newLen );
+ vect->data = (code_t*) realloc( vect->data, sizeof(code_t) * newLen );
//if ( vect->data == 0 )
// throw std::bad_alloc();
}
else {
/* Create the data. */
- vect->data = (Code*) malloc( sizeof(Code) * newLen );
+ vect->data = (code_t*) malloc( sizeof(code_t) * newLen );
//if ( vect->data == 0 )
// throw std::bad_alloc();
}
@@ -86,7 +86,7 @@ static void downResize( struct rt_code_vect *vect, long len)
}
else {
/* Not shrinking to size zero, realloc it to the smaller size. */
- vect->data = (Code*) realloc( vect->data, sizeof(Code) * newLen );
+ vect->data = (code_t*) realloc( vect->data, sizeof(code_t) * newLen );
//if ( vect->data == 0 )
// throw std::bad_alloc();
}
@@ -94,7 +94,7 @@ static void downResize( struct rt_code_vect *vect, long len)
}
-void rtCodeVectEmpty( struct rt_code_vect *vect )
+void colm_rt_code_vect_empty( struct rt_code_vect *vect )
{
if ( vect->data != 0 ) {
/* Free the data space. */
@@ -104,10 +104,11 @@ void rtCodeVectEmpty( struct rt_code_vect *vect )
}
}
-void rtCodeVectReplace( struct rt_code_vect *vect, long pos, const Code *val, long len )
+void colm_rt_code_vect_replace( struct rt_code_vect *vect, long pos,
+ const code_t *val, long len )
{
long endPos, i;
- //Code *item;
+ //code_t *item;
/* If we are given a negative position to replace at then
* treat it as a position relative to the length. */
@@ -125,7 +126,7 @@ void rtCodeVectReplace( struct rt_code_vect *vect, long pos, const Code *val, lo
/* Delete any objects we need to delete. */
//item = vect->data + pos;
//for ( i = pos; i < vect->tabLen; i++, item++ )
- // item->~Code();
+ // item->~code_t();
/* We are extending the vector, set the new data length. */
vect->tabLen = endPos;
@@ -134,20 +135,20 @@ void rtCodeVectReplace( struct rt_code_vect *vect, long pos, const Code *val, lo
/* Delete any objects we need to delete. */
//item = vect->data + pos;
//for ( i = pos; i < endPos; i++, item++ )
- // item->~Code();
+ // item->~code_t();
}
/* Copy data in using copy constructor. */
- Code *dst = vect->data + pos;
- const Code *src = val;
+ code_t *dst = vect->data + pos;
+ const code_t *src = val;
for ( i = 0; i < len; i++, dst++, src++ )
*dst = *src;
}
-void rtCodeVectRemove( struct rt_code_vect *vect, long pos, long len )
+void colm_rt_code_vect_remove( struct rt_code_vect *vect, long pos, long len )
{
long newLen, lenToSlideOver, endPos;
- Code *dst;//, *item;
+ code_t *dst;//, *item;
/* If we are given a negative position to remove at then
* treat it as a position relative to the length. */
@@ -166,12 +167,12 @@ void rtCodeVectRemove( struct rt_code_vect *vect, long pos, long len )
/* Call Destructors. */
//item = dst;
//for ( long i = 0; i < len; i += 1, item += 1 )
- // item->~Code();
+ // item->~code_t();
/* Shift data over if necessary. */
lenToSlideOver = vect->tabLen - endPos;
if ( len > 0 && lenToSlideOver > 0 )
- memmove(dst, dst + len, sizeof(Code)*lenToSlideOver);
+ memmove(dst, dst + len, sizeof(code_t)*lenToSlideOver);
/* Shrink the data if necessary. */
downResize( vect, newLen );
diff --git a/src/compiler.cc b/src/compiler.cc
index a87c2149..e2fcdca7 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -979,9 +979,9 @@ void Compiler::initEmptyScanners()
}
pda_run *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc,
- int parserId, StreamImpl *sourceStream )
+ int parserId, struct stream_impl *sourceStream )
{
- StreamImpl *in = colm_impl_new_generic( "<internal>" );
+ struct stream_impl *in = colm_impl_new_generic( "<internal>" );
struct pda_run *pdaRun = new pda_run;
colm_pda_init( prg, pdaRun, pdaTables, parserId, 0, false, 0 );
@@ -1024,13 +1024,13 @@ void Compiler::parsePatterns()
for ( ConsList::Iter cons = replList; cons.lte(); cons++ ) {
if ( cons->langEl != 0 ) {
- StreamImpl *in = colm_impl_new_cons( "<internal>", cons );
+ struct stream_impl *in = colm_impl_new_cons( "<internal>", cons );
cons->pdaRun = parsePattern( prg, sp, cons->loc, cons->langEl->parserId, in );
}
}
for ( PatList::Iter pat = patternList; pat.lte(); pat++ ) {
- StreamImpl *in = colm_impl_new_pat( "<internal>", pat );
+ struct stream_impl *in = colm_impl_new_pat( "<internal>", pat );
pat->pdaRun = parsePattern( prg, sp, pat->loc, pat->langEl->parserId, in );
}
diff --git a/src/compiler.h b/src/compiler.h
index f8f190b3..e4d1fca1 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -91,7 +91,7 @@ struct Production;
/* A pointer to this is in struct pda_run, but it's specification is not known by the
* runtime code. The runtime functions that access it are defined in
* ctinput.cpp and stubbed in fsmcodegen.cpp */
-struct Bindings
+struct bindings
: public Vector<ParseTree*>
{};
@@ -736,7 +736,7 @@ struct Compiler
void prepGrammar();
struct pda_run *parsePattern( Program *prg, Tree **sp, const InputLoc &loc,
- int parserId, StreamImpl *sourceStream );
+ int parserId, struct stream_impl *sourceStream );
void parsePatterns();
void collectParserEls( LangElSet &parserEls );
@@ -789,7 +789,7 @@ struct Compiler
int argvOffset();
int arg0Offset();
void makeDefaultIterators();
- void addLengthField( ObjectDef *objDef, Code getLength );
+ void addLengthField( ObjectDef *objDef, code_t getLength );
ObjectDef *findObject( const String &name );
void resolveListElementOf( ObjectDef *container, ObjectDef *obj, ElementOf *elof );
void resolveMapElementOf( ObjectDef *container, ObjectDef *obj, ElementOf *elof );
diff --git a/src/ctinput.cc b/src/ctinput.cc
index be856a9f..01b6aeb0 100644
--- a/src/ctinput.cc
+++ b/src/ctinput.cc
@@ -38,17 +38,18 @@ extern StreamFuncs replFuncs;
* Pattern
*/
-StreamImpl *colm_impl_new_pat( const char *name, Pattern *pattern )
+struct stream_impl *colm_impl_new_pat( const char *name, Pattern *pattern )
{
- StreamImpl *ss = (StreamImpl*)malloc(sizeof(StreamImpl));
- memset( ss, 0, sizeof(StreamImpl) );
+ struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
+ memset( ss, 0, sizeof(struct stream_impl) );
ss->pattern = pattern;
ss->patItem = pattern->list->head;
ss->funcs = &patternFuncs;
return ss;
}
-LangEl *inputStreamPatternGetLangEl( StreamImpl *ss, long *bindId, char **data, long *length )
+LangEl *inputStreamPatternGetLangEl( struct stream_impl *ss, long *bindId,
+ char **data, long *length )
{
LangEl *klangEl = ss->patItem->prodEl->langEl;
*bindId = ss->patItem->bindId;
@@ -60,7 +61,8 @@ LangEl *inputStreamPatternGetLangEl( StreamImpl *ss, long *bindId, char **data,
return klangEl;
}
-int inputStreamPatternGetParseBlock( StreamImpl *ss, int skip, char **pdp, int *copied )
+int inputStreamPatternGetParseBlock( struct stream_impl *ss, int skip,
+ char **pdp, int *copied )
{
*copied = 0;
@@ -107,7 +109,7 @@ int inputStreamPatternGetParseBlock( StreamImpl *ss, int skip, char **pdp, int *
return INPUT_DATA;
}
-int inputStreamPatternGetData( StreamImpl *ss, char *dest, int length )
+int inputStreamPatternGetData( struct stream_impl *ss, char *dest, int length )
{
int copied = 0;
@@ -144,7 +146,7 @@ int inputStreamPatternGetData( StreamImpl *ss, char *dest, int length )
return copied;
}
-void inputStreamPatternBackup( StreamImpl *ss )
+void inputStreamPatternBackup( struct stream_impl *ss )
{
if ( ss->patItem == 0 )
ss->patItem = ss->pattern->list->tail;
@@ -152,7 +154,7 @@ void inputStreamPatternBackup( StreamImpl *ss )
ss->patItem = ss->patItem->prev;
}
-void inputStreamPatternPushBackBuf( StreamImpl *ss, RunBuf *runBuf )
+void inputStreamPatternPushBackBuf( struct stream_impl *ss, RunBuf *runBuf )
{
char *data = runBuf->data + runBuf->offset;
long length = runBuf->length;
@@ -173,13 +175,13 @@ void inputStreamPatternPushBackBuf( StreamImpl *ss, RunBuf *runBuf )
assert( memcmp( &ss->patItem->data[ss->offset], data, length ) == 0 );
}
-void inputStreamPatternUndoConsumeLangEl( StreamImpl *ss )
+void inputStreamPatternUndoConsumeLangEl( struct stream_impl *ss )
{
inputStreamPatternBackup( ss );
ss->offset = ss->patItem->data.length();
}
-int inputStreamPatternConsumeData( Program *prg, Tree **sp, StreamImpl *ss, int length, Location *loc )
+int inputStreamPatternConsumeData( Program *prg, Tree **sp, struct stream_impl *ss, int length, Location *loc )
{
//debug( REALM_INPUT, "consuming %ld bytes\n", length );
@@ -213,7 +215,7 @@ int inputStreamPatternConsumeData( Program *prg, Tree **sp, StreamImpl *ss, int
return consumed;
}
-int inputStreamPatternUndoConsumeData( StreamImpl *ss, const char *data, int length )
+int inputStreamPatternUndoConsumeData( struct stream_impl *ss, const char *data, int length )
{
ss->offset -= length;
return length;
@@ -236,17 +238,17 @@ StreamFuncs patternFuncs =
* Constructor
*/
-StreamImpl *colm_impl_new_cons( const char *name, Constructor *constructor )
+struct stream_impl *colm_impl_new_cons( const char *name, Constructor *constructor )
{
- StreamImpl *ss = (StreamImpl*)malloc(sizeof(StreamImpl));
- memset( ss, 0, sizeof(StreamImpl) );
+ struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
+ memset( ss, 0, sizeof(struct stream_impl) );
ss->constructor = constructor;
ss->consItem = constructor->list->head;
ss->funcs = &replFuncs;
return ss;
}
-LangEl *inputStreamConsGetLangEl( StreamImpl *ss, long *bindId, char **data, long *length )
+LangEl *inputStreamConsGetLangEl( struct stream_impl *ss, long *bindId, char **data, long *length )
{
LangEl *klangEl = ss->consItem->type == ConsItem::ExprType ?
ss->consItem->langEl : ss->consItem->prodEl->langEl;
@@ -272,7 +274,7 @@ LangEl *inputStreamConsGetLangEl( StreamImpl *ss, long *bindId, char **data, lon
return klangEl;
}
-int inputStreamConsGetParseBlock( StreamImpl *ss,
+int inputStreamConsGetParseBlock( struct stream_impl *ss,
int skip, char **pdp, int *copied )
{
*copied = 0;
@@ -320,7 +322,7 @@ int inputStreamConsGetParseBlock( StreamImpl *ss,
return INPUT_DATA;
}
-int inputStreamConsGetData( StreamImpl *ss, char *dest, int length )
+int inputStreamConsGetData( struct stream_impl *ss, char *dest, int length )
{
int copied = 0;
@@ -357,7 +359,7 @@ int inputStreamConsGetData( StreamImpl *ss, char *dest, int length )
return copied;
}
-void inputStreamConsBackup( StreamImpl *ss )
+void inputStreamConsBackup( struct stream_impl *ss )
{
if ( ss->consItem == 0 )
ss->consItem = ss->constructor->list->tail;
@@ -365,7 +367,7 @@ void inputStreamConsBackup( StreamImpl *ss )
ss->consItem = ss->consItem->prev;
}
-void inputStreamConsPushBackBuf( StreamImpl *ss, RunBuf *runBuf )
+void inputStreamConsPushBackBuf( struct stream_impl *ss, RunBuf *runBuf )
{
char *data = runBuf->data + runBuf->offset;
long length = runBuf->length;
@@ -390,14 +392,14 @@ void inputStreamConsPushBackBuf( StreamImpl *ss, RunBuf *runBuf )
assert( memcmp( &ss->consItem->data[ss->offset], data, length ) == 0 );
}
-void inputStreamConsUndoConsumeLangEl( StreamImpl *ss )
+void inputStreamConsUndoConsumeLangEl( struct stream_impl *ss )
{
inputStreamConsBackup( ss );
ss->offset = ss->consItem->data.length();
}
int inputStreamConsConsumeData( Program *prg, Tree **sp,
- StreamImpl *ss, int length, Location *loc )
+ struct stream_impl *ss, int length, Location *loc )
{
int consumed = 0;
@@ -429,7 +431,7 @@ int inputStreamConsConsumeData( Program *prg, Tree **sp,
return consumed;
}
-int inputStreamConsUndoConsumeData( StreamImpl *ss, const char *data, int length )
+int inputStreamConsUndoConsumeData( struct stream_impl *ss, const char *data, int length )
{
ss->offset -= length;
return length;
@@ -447,8 +449,14 @@ StreamFuncs replFuncs =
&inputStreamConsUndoConsumeLangEl,
};
+void pushBinding( pda_run *pdaRun, ParseTree *parseTree )
+{
+ /* If the item is bound then store it in the bindings array. */
+ pdaRun->bindings->push( parseTree );
+}
+
extern "C" void internalSendNamedLangEl( Program *prg, Tree **sp,
- pda_run *pdaRun, StreamImpl *is )
+ struct pda_run *pdaRun, struct stream_impl *is )
{
/* All three set by consumeLangEl. */
long bindId;
@@ -482,15 +490,10 @@ extern "C" void internalSendNamedLangEl( Program *prg, Tree **sp,
extern "C" void internalInitBindings( pda_run *pdaRun )
{
/* Bindings are indexed at 1. Need a no-binding. */
- pdaRun->bindings = new Bindings;
+ pdaRun->bindings = new bindings;
pdaRun->bindings->push(0);
}
-void pushBinding( pda_run *pdaRun, ParseTree *parseTree )
-{
- /* If the item is bound then store it in the bindings array. */
- pdaRun->bindings->push( parseTree );
-}
extern "C" void internalPopBinding( pda_run *pdaRun, ParseTree *parseTree )
{
diff --git a/src/declare.cc b/src/declare.cc
index 7f38a643..2179c7e8 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -891,7 +891,7 @@ ObjectField *Compiler::makeLineEl()
/* Add a constant length field to the object.
* Opcode supplied by the caller. */
-void Compiler::addLengthField( ObjectDef *objDef, Code getLength )
+void Compiler::addLengthField( ObjectDef *objDef, code_t getLength )
{
/* Create the "length" field. */
TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
diff --git a/src/fsmcodegen.cc b/src/fsmcodegen.cc
index 10d8ef91..e7d44cb3 100644
--- a/src/fsmcodegen.cc
+++ b/src/fsmcodegen.cc
@@ -848,7 +848,7 @@ void FsmCodeGen::writeExec()
setLabelsNeeded();
out <<
- "static void fsm_execute( struct pda_run *pdaRun, StreamImpl *inputStream )\n"
+ "static void fsm_execute( struct pda_run *pdaRun, struct stream_impl *inputStream )\n"
"{\n"
" " << BLOCK_START() << " = pdaRun->p;\n"
"/*_resume:*/\n";
@@ -901,7 +901,7 @@ void FsmCodeGen::writeCode()
* should use the preprocessor to make these go away. */
out <<
"static void sendNamedLangEl( struct colm_program *prg, Tree **tree,\n"
- " struct pda_run *pdaRun, StreamImpl *inputStream ) { }\n"
+ " struct pda_run *pdaRun, struct stream_impl *inputStream ) { }\n"
"static void initBindings( struct pda_run *pdaRun ) {}\n"
"static void popBinding( struct pda_run *pdaRun, ParseTree *tree ) {}\n"
"\n"
diff --git a/src/fsmexec.cc b/src/fsmexec.cc
index f1e257c3..6d06eba7 100644
--- a/src/fsmexec.cc
+++ b/src/fsmexec.cc
@@ -92,7 +92,7 @@ void execAction( struct pda_run *pdaRun, GenAction *genAction )
pdaRun->mark[genAction->markId-1] = pdaRun->p;
}
-extern "C" void internalFsmExecute( struct pda_run *pdaRun, StreamImpl *inputStream )
+extern "C" void internalFsmExecute( struct pda_run *pdaRun, struct stream_impl *inputStream )
{
int _klen;
unsigned int _trans;
diff --git a/src/input.c b/src/input.c
index a8b50446..348329e9 100644
--- a/src/input.c
+++ b/src/input.c
@@ -53,8 +53,8 @@ extern struct StreamFuncs fileFuncs;
extern struct StreamFuncs fdFuncs;
extern struct StreamFuncs streamFuncs;
-void clearSourceStream( struct colm_program *prg,
- Tree **sp, StreamImpl *sourceStream )
+void colm_clear_source_stream( struct colm_program *prg,
+ Tree **sp, struct stream_impl *sourceStream )
{
RunBuf *buf = sourceStream->queue;
while ( buf != 0 ) {
@@ -81,7 +81,7 @@ void clearSourceStream( struct colm_program *prg,
void colm_stream_destroy( Program *prg, Tree **sp, Struct *s )
{
Stream *stream = (Stream*) s;
- clearSourceStream( prg, sp, stream->impl );
+ colm_clear_source_stream( prg, sp, stream->impl );
if ( stream->impl->file != 0 )
fclose( stream->impl->file );
@@ -93,7 +93,7 @@ void colm_stream_destroy( Program *prg, Tree **sp, Struct *s )
/* Keep the position up to date after consuming text. */
-void updatePosition( StreamImpl *is, const char *data, long length )
+void updatePosition( struct stream_impl *is, const char *data, long length )
{
int i;
for ( i = 0; i < length; i++ ) {
@@ -109,7 +109,7 @@ void updatePosition( StreamImpl *is, const char *data, long length )
}
/* Keep the position up to date after sending back text. */
-void undoPosition( StreamImpl *is, const char *data, long length )
+void undoPosition( struct stream_impl *is, const char *data, long length )
{
/* FIXME: this needs to fetch the position information from the parsed
* token and restore based on that.. */
@@ -123,7 +123,7 @@ void undoPosition( StreamImpl *is, const char *data, long length )
}
-static RunBuf *sourceStreamPopHead( StreamImpl *ss )
+static RunBuf *sourceStreamPopHead( struct stream_impl *ss )
{
RunBuf *ret = ss->queue;
ss->queue = ss->queue->next;
@@ -134,7 +134,7 @@ static RunBuf *sourceStreamPopHead( StreamImpl *ss )
return ret;
}
-static void sourceStreamAppend( StreamImpl *ss, RunBuf *runBuf )
+static void sourceStreamAppend( struct stream_impl *ss, RunBuf *runBuf )
{
if ( ss->queue == 0 ) {
runBuf->prev = runBuf->next = 0;
@@ -148,7 +148,7 @@ static void sourceStreamAppend( StreamImpl *ss, RunBuf *runBuf )
}
}
-static void sourceStreamPrepend( StreamImpl *ss, RunBuf *runBuf )
+static void sourceStreamPrepend( struct stream_impl *ss, RunBuf *runBuf )
{
if ( ss->queue == 0 ) {
runBuf->prev = runBuf->next = 0;
@@ -166,7 +166,7 @@ static void sourceStreamPrepend( StreamImpl *ss, RunBuf *runBuf )
* Base run-time input streams.
*/
-int fdGetParseBlock( StreamImpl *ss, int skip, char **pdp, int *copied )
+int fdGetParseBlock( struct stream_impl *ss, int skip, char **pdp, int *copied )
{
int ret = 0;
*copied = 0;
@@ -225,7 +225,7 @@ int fdGetParseBlock( StreamImpl *ss, int skip, char **pdp, int *copied )
return ret;
}
-int fdGetData( StreamImpl *ss, char *dest, int length )
+int fdGetData( struct stream_impl *ss, char *dest, int length )
{
int copied = 0;
@@ -268,7 +268,7 @@ int fdGetData( StreamImpl *ss, char *dest, int length )
return copied;
}
-int fdConsumeData( Program *prg, Tree **sp, StreamImpl *ss, int length, Location *loc )
+int fdConsumeData( Program *prg, Tree **sp, struct stream_impl *ss, int length, Location *loc )
{
int consumed = 0;
@@ -314,7 +314,7 @@ int fdConsumeData( Program *prg, Tree **sp, StreamImpl *ss, int length, Location
return consumed;
}
-int fdUndoConsumeData( StreamImpl *ss, const char *data, int length )
+int fdUndoConsumeData( struct stream_impl *ss, const char *data, int length )
{
RunBuf *newBuf = newRunBuf();
newBuf->length = length;
@@ -330,7 +330,7 @@ int fdUndoConsumeData( StreamImpl *ss, const char *data, int length )
* File
*/
-int fileGetDataSource( StreamImpl *ss, char *dest, int length )
+int fileGetDataSource( struct stream_impl *ss, char *dest, int length )
{
//debug( REALM_INPUT, "inputStreamFileGetDataSource length = %ld\n", length );
size_t res = fread( dest, 1, length, ss->file );
@@ -346,7 +346,7 @@ void initFileFuncs()
* FD
*/
-int fdGetDataSource( StreamImpl *ss, char *dest, int length )
+int fdGetDataSource( struct stream_impl *ss, char *dest, int length )
{
if ( ss->eof )
return 0;
@@ -362,9 +362,9 @@ int fdGetDataSource( StreamImpl *ss, char *dest, int length )
* StreamImpl struct, this wraps the list of input streams.
*/
-void initStreamImpl( StreamImpl *is, const char *name )
+void initStreamImpl( struct stream_impl *is, const char *name )
{
- memset( is, 0, sizeof(StreamImpl) );
+ memset( is, 0, sizeof(struct stream_impl) );
is->name = name;
is->line = 1;
@@ -372,7 +372,7 @@ void initStreamImpl( StreamImpl *is, const char *name )
is->byte = 0;
}
-void clearStreamImpl( struct colm_program *prg, Tree **sp, StreamImpl *inputStream )
+void colm_clear_stream_impl( struct colm_program *prg, Tree **sp, struct stream_impl *inputStream )
{
RunBuf *buf = inputStream->queue;
while ( buf != 0 ) {
@@ -397,7 +397,7 @@ void clearStreamImpl( struct colm_program *prg, Tree **sp, StreamImpl *inputStre
inputStream->queue = 0;
}
-static void inputStreamPrepend( StreamImpl *is, RunBuf *runBuf )
+static void inputStreamPrepend( struct stream_impl *is, RunBuf *runBuf )
{
if ( is->queue == 0 ) {
runBuf->prev = runBuf->next = 0;
@@ -411,7 +411,7 @@ static void inputStreamPrepend( StreamImpl *is, RunBuf *runBuf )
}
}
-static RunBuf *inputStreamPopHead( StreamImpl *is )
+static RunBuf *inputStreamPopHead( struct stream_impl *is )
{
RunBuf *ret = is->queue;
is->queue = is->queue->next;
@@ -422,7 +422,7 @@ static RunBuf *inputStreamPopHead( StreamImpl *is )
return ret;
}
-static void inputStreamAppend( StreamImpl *is, RunBuf *runBuf )
+static void inputStreamAppend( struct stream_impl *is, RunBuf *runBuf )
{
if ( is->queue == 0 ) {
runBuf->prev = runBuf->next = 0;
@@ -436,7 +436,7 @@ static void inputStreamAppend( StreamImpl *is, RunBuf *runBuf )
}
}
-static RunBuf *inputStreamPopTail( StreamImpl *is )
+static RunBuf *inputStreamPopTail( struct stream_impl *is )
{
RunBuf *ret = is->queueTail;
is->queueTail = is->queueTail->prev;
@@ -447,23 +447,23 @@ static RunBuf *inputStreamPopTail( StreamImpl *is )
return ret;
}
-static int isSourceStream( StreamImpl *is )
+static int isSourceStream( struct stream_impl *is )
{
if ( is->queue != 0 && is->queue->type == RunBufSourceType )
return true;
return false;
}
-static void _setEof( StreamImpl *is )
+static void _setEof( struct stream_impl *is )
{
//debug( REALM_INPUT, "setting EOF in input stream\n" );
is->eof = true;
}
-static void _unsetEof( StreamImpl *is )
+static void _unsetEof( struct stream_impl *is )
{
if ( isSourceStream( is ) ) {
- StreamImpl *si = streamToImpl( (Stream*)is->queue->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)is->queue->tree );
si->eof = false;
}
else {
@@ -471,7 +471,7 @@ static void _unsetEof( StreamImpl *is )
}
}
-static int _getParseBlock( StreamImpl *is, int skip, char **pdp, int *copied )
+static int _getParseBlock( struct stream_impl *is, int skip, char **pdp, int *copied )
{
int ret = 0;
*copied = 0;
@@ -486,7 +486,7 @@ static int _getParseBlock( StreamImpl *is, int skip, char **pdp, int *copied )
}
if ( buf->type == RunBufSourceType ) {
- StreamImpl *si = streamToImpl( (Stream*)buf->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)buf->tree );
int type = si->funcs->getParseBlock( si, skip, pdp, copied );
// if ( type == INPUT_EOD && !si->eosSent ) {
@@ -570,7 +570,7 @@ static int _getParseBlock( StreamImpl *is, int skip, char **pdp, int *copied )
return ret;
}
-static int _getData( StreamImpl *is, char *dest, int length )
+static int _getData( struct stream_impl *is, char *dest, int length )
{
int copied = 0;
@@ -583,7 +583,7 @@ static int _getData( StreamImpl *is, char *dest, int length )
}
if ( buf->type == RunBufSourceType ) {
- StreamImpl *si = streamToImpl( (Stream*)buf->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)buf->tree );
int glen = si->funcs->getData( si, dest+copied, length );
if ( glen == 0 ) {
@@ -626,7 +626,7 @@ static int _getData( StreamImpl *is, char *dest, int length )
return copied;
}
-static int _consumeData( Program *prg, Tree **sp, StreamImpl *is,
+static int _consumeData( Program *prg, Tree **sp, struct stream_impl *is,
int length, Location *loc )
{
//debug( REALM_INPUT, "consuming %d bytes\n", length );
@@ -641,7 +641,7 @@ static int _consumeData( Program *prg, Tree **sp, StreamImpl *is,
break;
if ( buf->type == RunBufSourceType ) {
- StreamImpl *si = streamToImpl( (Stream*)buf->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)buf->tree );
int slen = si->funcs->consumeData( prg, sp, si, length, loc );
//debug( REALM_INPUT, " got %d bytes from source\n", slen );
@@ -681,12 +681,12 @@ static int _consumeData( Program *prg, Tree **sp, StreamImpl *is,
return consumed;
}
-static int _undoConsumeData( StreamImpl *is, const char *data, int length )
+static int _undoConsumeData( struct stream_impl *is, const char *data, int length )
{
//debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
if ( is->consumed == 0 && isSourceStream( is ) ) {
- StreamImpl *si = streamToImpl( (Stream*)is->queue->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)is->queue->tree );
int len = si->funcs->undoConsumeData( si, data, length );
return len;
}
@@ -701,7 +701,7 @@ static int _undoConsumeData( StreamImpl *is, const char *data, int length )
}
}
-static Tree *_consumeTree( StreamImpl *is )
+static Tree *_consumeTree( struct stream_impl *is )
{
while ( is->queue != 0 && is->queue->type == RunBufDataType &&
is->queue->offset == is->queue->length )
@@ -724,7 +724,7 @@ static Tree *_consumeTree( StreamImpl *is )
return 0;
}
-static void _undoConsumeTree( StreamImpl *is, Tree *tree, int ignore )
+static void _undoConsumeTree( struct stream_impl *is, Tree *tree, int ignore )
{
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
@@ -735,11 +735,11 @@ static void _undoConsumeTree( StreamImpl *is, Tree *tree, int ignore )
inputStreamPrepend( is, newBuf );
}
-static struct LangEl *_consumeLangEl( StreamImpl *is, long *bindId,
+static struct LangEl *_consumeLangEl( struct stream_impl *is, long *bindId,
char **data, long *length )
{
if ( isSourceStream( is ) ) {
- StreamImpl *si = streamToImpl( (Stream*)is->queue->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)is->queue->tree );
return si->funcs->consumeLangEl( si, bindId, data, length );
}
else {
@@ -747,10 +747,10 @@ static struct LangEl *_consumeLangEl( StreamImpl *is, long *bindId,
}
}
-static void _undoConsumeLangEl( StreamImpl *is )
+static void _undoConsumeLangEl( struct stream_impl *is )
{
if ( isSourceStream( is ) ) {
- StreamImpl *si = streamToImpl( (Stream*)is->queue->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)is->queue->tree );
return si->funcs->undoConsumeLangEl( si );
}
else {
@@ -758,7 +758,7 @@ static void _undoConsumeLangEl( StreamImpl *is )
}
}
-static void _prependData( StreamImpl *is, const char *data, long length )
+static void _prependData( struct stream_impl *is, const char *data, long length )
{
if ( isSourceStream( is ) &&
streamToImpl((Stream*)is->queue->tree)->funcs == &streamFuncs )
@@ -779,7 +779,7 @@ static void _prependData( StreamImpl *is, const char *data, long length )
}
}
-static void _prependTree( StreamImpl *is, Tree *tree, int ignore )
+static void _prependTree( struct stream_impl *is, Tree *tree, int ignore )
{
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
@@ -790,7 +790,7 @@ static void _prependTree( StreamImpl *is, Tree *tree, int ignore )
inputStreamPrepend( is, newBuf );
}
-static void _prependStream( StreamImpl *in, struct colm_tree *tree )
+static void _prependStream( struct stream_impl *in, struct colm_tree *tree )
{
/* Create a new buffer for the data. This is the easy implementation.
* Something better is needed here. It puts a max on the amount of
@@ -801,7 +801,7 @@ static void _prependStream( StreamImpl *in, struct colm_tree *tree )
inputStreamPrepend( in, newBuf );
}
-static int _undoPrependData( StreamImpl *is, int length )
+static int _undoPrependData( struct stream_impl *is, int length )
{
//debug( REALM_INPUT, "consuming %d bytes\n", length );
@@ -815,7 +815,7 @@ static int _undoPrependData( StreamImpl *is, int length )
break;
if ( buf->type == RunBufSourceType ) {
- StreamImpl *si = streamToImpl( (Stream*)buf->tree );
+ struct stream_impl *si = streamToImpl( (Stream*)buf->tree );
int slen = si->funcs->undoPrependData( si, length );
consumed += slen;
@@ -847,7 +847,7 @@ static int _undoPrependData( StreamImpl *is, int length )
return consumed;
}
-static Tree *_undoPrependTree( StreamImpl *is )
+static Tree *_undoPrependTree( struct stream_impl *is )
{
while ( is->queue != 0 && is->queue->type == RunBufDataType &&
is->queue->offset == is->queue->length )
@@ -870,7 +870,7 @@ static Tree *_undoPrependTree( StreamImpl *is )
return 0;
}
-static void _appendData( StreamImpl *is, const char *data, long len )
+static void _appendData( struct stream_impl *is, const char *data, long len )
{
while ( len > 0 ) {
RunBuf *ad = newRunBuf();
@@ -888,7 +888,7 @@ static void _appendData( StreamImpl *is, const char *data, long len )
}
}
-static Tree *_undoAppendData( StreamImpl *is, int length )
+static Tree *_undoAppendData( struct stream_impl *is, int length )
{
int consumed = 0;
@@ -925,7 +925,7 @@ static Tree *_undoAppendData( StreamImpl *is, int length )
return 0;
}
-static void _appendTree( StreamImpl *is, Tree *tree )
+static void _appendTree( struct stream_impl *is, Tree *tree )
{
RunBuf *ad = newRunBuf();
@@ -936,7 +936,7 @@ static void _appendTree( StreamImpl *is, Tree *tree )
ad->length = 0;
}
-static void _appendStream( StreamImpl *in, struct colm_tree *tree )
+static void _appendStream( struct stream_impl *in, struct colm_tree *tree )
{
RunBuf *ad = newRunBuf();
@@ -947,7 +947,7 @@ static void _appendStream( StreamImpl *in, struct colm_tree *tree )
ad->length = 0;
}
-static Tree *_undoAppendTree( StreamImpl *is )
+static Tree *_undoAppendTree( struct stream_impl *is )
{
RunBuf *runBuf = inputStreamPopTail( is );
Tree *tree = runBuf->tree;
@@ -955,7 +955,7 @@ static Tree *_undoAppendTree( StreamImpl *is )
return tree;
}
-static Tree *_undoAppendStream( StreamImpl *is )
+static Tree *_undoAppendStream( struct stream_impl *is )
{
RunBuf *runBuf = inputStreamPopTail( is );
Tree *tree = runBuf->tree;
@@ -1009,9 +1009,9 @@ struct StreamFuncs fileFuncs =
};
-StreamImpl *colm_impl_new_file( const char *name, FILE *file )
+struct stream_impl *colm_impl_new_file( const char *name, FILE *file )
{
- StreamImpl *ss = (StreamImpl*)malloc(sizeof(StreamImpl));
+ struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
initStreamImpl( ss, name );
ss->funcs = &fileFuncs;
@@ -1020,9 +1020,9 @@ StreamImpl *colm_impl_new_file( const char *name, FILE *file )
return ss;
}
-StreamImpl *colm_impl_new_fd( const char *name, long fd )
+struct stream_impl *colm_impl_new_fd( const char *name, long fd )
{
- StreamImpl *ss = (StreamImpl*)malloc(sizeof(StreamImpl));
+ struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
initStreamImpl( ss, name );
ss->funcs = &fdFuncs;
@@ -1031,9 +1031,9 @@ StreamImpl *colm_impl_new_fd( const char *name, long fd )
return ss;
}
-StreamImpl *colm_impl_new_generic( const char *name )
+struct stream_impl *colm_impl_new_generic( const char *name )
{
- StreamImpl *ss = (StreamImpl*)malloc(sizeof(StreamImpl));
+ struct stream_impl *ss = (struct stream_impl*)malloc(sizeof(struct stream_impl));
initStreamImpl( ss, name );
ss->funcs = &streamFuncs;
@@ -1053,7 +1053,7 @@ Stream *colm_stream_new_struct( Program *prg )
Stream *colm_stream_open_fd( Program *prg, char *name, long fd )
{
- StreamImpl *impl = colm_impl_new_fd( name, fd );
+ struct stream_impl *impl = colm_impl_new_fd( name, fd );
struct colm_stream *s = colm_stream_new_struct( prg );
s->impl = impl;
@@ -1093,19 +1093,19 @@ Stream *colm_stream_open_file( Program *prg, Tree *name, Tree *mode )
Stream *colm_stream_new( Program *prg )
{
- StreamImpl *impl = colm_impl_new_generic( "<internal>" );
+ struct stream_impl *impl = colm_impl_new_generic( "<internal>" );
struct colm_stream *stream = colm_stream_new_struct( prg );
stream->impl = impl;
return stream;
}
-StreamImpl *colm_stream_impl( struct colm_struct *s )
+struct stream_impl *colm_stream_impl( struct colm_struct *s )
{
return ((Stream*)s)->impl;
}
-StreamImpl *streamToImpl( Stream *ptr )
+struct stream_impl *streamToImpl( Stream *ptr )
{
return ptr->impl;
}
diff --git a/src/input.h b/src/input.h
index 095a643c..be1b1bf5 100644
--- a/src/input.h
+++ b/src/input.h
@@ -51,6 +51,8 @@ struct colm_location;
struct colm_program;
struct colm_struct;
+struct stream_impl;
+
enum RunBufType {
RunBufDataType = 0,
RunBufTokenType,
@@ -70,50 +72,50 @@ typedef struct _RunBuf
RunBuf *newRunBuf();
-typedef struct _StreamImpl StreamImpl;
-
struct StreamFuncs
{
- int (*getParseBlock)( StreamImpl *ss, int skip, char **pdp, int *copied );
+ int (*getParseBlock)( struct stream_impl *ss, int skip, char **pdp, int *copied );
- int (*getData)( StreamImpl *ss, char *dest, int length );
+ int (*getData)( struct stream_impl *ss, char *dest, int length );
- int (*consumeData)( struct colm_program *prg, struct colm_tree **sp, StreamImpl *ss,
- int length, struct colm_location *loc );
- int (*undoConsumeData)( StreamImpl *ss, const char *data, int length );
+ int (*consumeData)( struct colm_program *prg, struct colm_tree **sp,
+ struct stream_impl *ss, int length, struct colm_location *loc );
+ int (*undoConsumeData)( struct stream_impl *ss, const char *data, int length );
- struct colm_tree *(*consumeTree)( StreamImpl *ss );
- void (*undoConsumeTree)( StreamImpl *ss, struct colm_tree *tree, int ignore );
+ struct colm_tree *(*consumeTree)( struct stream_impl *ss );
+ void (*undoConsumeTree)( struct stream_impl *ss,
+ struct colm_tree *tree, int ignore );
/* Language elments (compile-time). */
- struct LangEl *(*consumeLangEl)( StreamImpl *ss, long *bindId, char **data, long *length );
- void (*undoConsumeLangEl)( StreamImpl *ss );
+ struct LangEl *(*consumeLangEl)( struct stream_impl *ss,
+ long *bindId, char **data, long *length );
+ void (*undoConsumeLangEl)( struct stream_impl *ss );
/* Private implmentation for some shared get data functions. */
- int (*getDataSource)( StreamImpl *ss, char *dest, int length );
+ int (*getDataSource)( struct stream_impl *ss, char *dest, int length );
- void (*setEof)( StreamImpl *is );
- void (*unsetEof)( StreamImpl *is );
+ void (*setEof)( struct stream_impl *is );
+ void (*unsetEof)( struct stream_impl *is );
/* Prepending to a stream. */
- void (*prependData)( StreamImpl *in, const char *data, long len );
- void (*prependTree)( StreamImpl *is, struct colm_tree *tree, int ignore );
- void (*prependStream)( StreamImpl *in, struct colm_tree *tree );
- int (*undoPrependData)( StreamImpl *is, int length );
- struct colm_tree *(*undoPrependTree)( StreamImpl *is );
- struct colm_tree *(*undoPrependStream)( StreamImpl *in );
+ void (*prependData)( struct stream_impl *in, const char *data, long len );
+ void (*prependTree)( struct stream_impl *is, struct colm_tree *tree, int ignore );
+ void (*prependStream)( struct stream_impl *in, struct colm_tree *tree );
+ int (*undoPrependData)( struct stream_impl *is, int length );
+ struct colm_tree *(*undoPrependTree)( struct stream_impl *is );
+ struct colm_tree *(*undoPrependStream)( struct stream_impl *in );
/* Appending to a stream. */
- void (*appendData)( StreamImpl *in, const char *data, long len );
- void (*appendTree)( StreamImpl *in, struct colm_tree *tree );
- void (*appendStream)( StreamImpl *in, struct colm_tree *tree );
- struct colm_tree *(*undoAppendData)( StreamImpl *in, int length );
- struct colm_tree *(*undoAppendTree)( StreamImpl *in );
- struct colm_tree *(*undoAppendStream)( StreamImpl *in );
+ void (*appendData)( struct stream_impl *in, const char *data, long len );
+ void (*appendTree)( struct stream_impl *in, struct colm_tree *tree );
+ void (*appendStream)( struct stream_impl *in, struct colm_tree *tree );
+ struct colm_tree *(*undoAppendData)( struct stream_impl *in, int length );
+ struct colm_tree *(*undoAppendTree)( struct stream_impl *in );
+ struct colm_tree *(*undoAppendStream)( struct stream_impl *in );
};
/* List of source streams. Enables streams to be pushed/popped. */
-struct _StreamImpl
+struct stream_impl
{
struct StreamFuncs *funcs;
@@ -144,16 +146,16 @@ struct _StreamImpl
int consumed;
};
-StreamImpl *colm_impl_new_pat( const char *name, struct Pattern *pattern );
-StreamImpl *colm_impl_new_cons( const char *name, struct Constructor *constructor );
-StreamImpl *colm_impl_new_file( const char *name, FILE *file );
-StreamImpl *colm_impl_new_fd( const char *name, long fd );
-StreamImpl *colm_impl_new_generic( const char *name );
+struct stream_impl *colm_impl_new_pat( const char *name, struct Pattern *pattern );
+struct stream_impl *colm_impl_new_cons( const char *name, struct Constructor *constructor );
+struct stream_impl *colm_impl_new_file( const char *name, FILE *file );
+struct stream_impl *colm_impl_new_fd( const char *name, long fd );
+struct stream_impl *colm_impl_new_generic( const char *name );
-void updatePosition( StreamImpl *inputStream, const char *data, long length );
-void undoPosition( StreamImpl *inputStream, const char *data, long length );
+void updatePosition( struct stream_impl *inputStream, const char *data, long length );
+void undoPosition( struct stream_impl *inputStream, const char *data, long length );
-StreamImpl *colm_stream_impl( struct colm_struct *s );
+struct stream_impl *colm_stream_impl( struct colm_struct *s );
#ifdef __cplusplus
}
diff --git a/src/iter.c b/src/iter.c
index d63b092e..ddb5ba6c 100644
--- a/src/iter.c
+++ b/src/iter.c
@@ -195,7 +195,7 @@ UserIter *colm_uiter_create( Program *prg, Tree ***psp, struct function_info *fi
{
Tree **sp = *psp;
- vm_pushn( sizeof(UserIter) / sizeof(Word) );
+ vm_pushn( sizeof(UserIter) / sizeof(word_t) );
void *mem = vm_ptop();
UserIter *uiter = mem;
@@ -264,7 +264,7 @@ void colm_uiter_destroy( Program *prg, Tree ***psp, UserIter *uiter )
assert( uiter->yieldSize == curStackSize );
vm_popn( uiter->yieldSize );
- vm_popn( sizeof(UserIter) / sizeof(Word) );
+ vm_popn( sizeof(UserIter) / sizeof(word_t) );
uiter->type = 0;
@@ -285,7 +285,7 @@ void colm_uiter_unwind( Program *prg, Tree ***psp, UserIter *uiter )
long argSize = uiter->argSize;
vm_popn( uiter->yieldSize );
- vm_popn( sizeof(UserIter) / sizeof(Word) );
+ vm_popn( sizeof(UserIter) / sizeof(word_t) );
/* The IN_PREP_ARGS stack data. */
vm_popn( argSize );
diff --git a/src/list.c b/src/list.c
index 010bc10f..eafb6851 100644
--- a/src/list.c
+++ b/src/list.c
@@ -209,7 +209,7 @@ List *colm_list_new( struct colm_program *prg )
}
struct colm_struct *colm_list_get( struct colm_program *prg,
- List *list, Word genId, Word field )
+ List *list, word_t genId, word_t field )
{
struct generic_info *gi = &prg->rtd->genericInfo[genId];
ListEl *result = 0;
@@ -231,7 +231,7 @@ struct colm_struct *colm_list_get( struct colm_program *prg,
}
struct colm_struct *colm_list_el_get( struct colm_program *prg,
- ListEl *listEl, Word genId, Word field )
+ ListEl *listEl, word_t genId, word_t field )
{
struct generic_info *gi = &prg->rtd->genericInfo[genId];
ListEl *result = 0;
diff --git a/src/map.c b/src/map.c
index 0cff7a7e..6e768991 100644
--- a/src/map.c
+++ b/src/map.c
@@ -29,7 +29,7 @@
#define false 0
struct colm_struct *colm_map_el_get( struct colm_program *prg,
- MapEl *mapEl, Word genId, Word field )
+ MapEl *mapEl, word_t genId, word_t field )
{
struct generic_info *gi = &prg->rtd->genericInfo[genId];
MapEl *result = 0;
@@ -51,7 +51,7 @@ struct colm_struct *colm_map_el_get( struct colm_program *prg,
}
struct colm_struct *colm_map_get( struct colm_program *prg,
- Map *map, Word genId, Word field )
+ Map *map, word_t genId, word_t field )
{
struct generic_info *gi = &prg->rtd->genericInfo[genId];
MapEl *result = 0;
diff --git a/src/parsetree.h b/src/parsetree.h
index 0afb8e90..c820c75f 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -69,16 +69,16 @@ struct IterCall;
/*
* Code Vector
*/
-struct CodeVect : public Vector<Code>
+struct CodeVect : public Vector<code_t>
{
- void appendHalf( Half half )
+ void appendHalf( half_t half )
{
/* not optimal. */
append( half & 0xff );
append( (half>>8) & 0xff );
}
- void appendWord( Word word )
+ void appendWord( word_t word )
{
/* not optimal. */
append( word & 0xff );
@@ -93,21 +93,21 @@ struct CodeVect : public Vector<Code>
#endif
}
- void setHalf( long pos, Half half )
+ void setHalf( long pos, half_t half )
{
/* not optimal. */
data[pos] = half & 0xff;
data[pos+1] = (half>>8) & 0xff;
}
- void insertHalf( long pos, Half half )
+ void insertHalf( long pos, half_t half )
{
/* not optimal. */
insert( pos, half & 0xff );
insert( pos+1, (half>>8) & 0xff );
}
- void insertWord( long pos, Word word )
+ void insertWord( long pos, word_t word )
{
/* not at all optimal. */
insert( pos, word & 0xff );
@@ -123,7 +123,7 @@ struct CodeVect : public Vector<Code>
}
void insertTree( long pos, Tree *tree )
- { insertWord( pos, (Word) tree ); }
+ { insertWord( pos, (word_t) tree ); }
};
@@ -1762,17 +1762,17 @@ struct IterImpl
bool useSearchUT;
bool useGenericId;
- Code inCreateWV;
- Code inCreateWC;
- Code inUnwind;
- Code inDestroy;
- Code inAdvance;
+ code_t inCreateWV;
+ code_t inCreateWC;
+ code_t inUnwind;
+ code_t inDestroy;
+ code_t inAdvance;
- Code inGetCurR;
- Code inGetCurWC;
- Code inSetCurWC;
+ code_t inGetCurR;
+ code_t inGetCurWC;
+ code_t inSetCurWC;
- Code inRefFromCur;
+ code_t inRefFromCur;
};
struct CmpIterDef
@@ -2431,16 +2431,16 @@ struct ObjectField
Vector<RhsVal> rhsVal;
- Code inGetR;
- Code inGetWC;
- Code inGetWV;
- Code inSetWC;
- Code inSetWV;
- Code inGetValR;
- Code inGetValWC;
- Code inGetValWV;
- Code inSetValWC;
- Code inSetValWV;
+ code_t inGetR;
+ code_t inGetWC;
+ code_t inGetWV;
+ code_t inSetWC;
+ code_t inSetWV;
+ code_t inGetValR;
+ code_t inGetValWC;
+ code_t inGetValWV;
+ code_t inSetValWC;
+ code_t inSetValWV;
IterImpl *iterImpl;
diff --git a/src/pdabuild.cc b/src/pdabuild.cc
index 73a69f0a..0bed30ba 100644
--- a/src/pdabuild.cc
+++ b/src/pdabuild.cc
@@ -1728,7 +1728,7 @@ void countNodes( Program *prg, int &count, ParseTree *parseTree, Kid *kid )
}
}
-void fillNodes( Program *prg, int &nextAvail, Bindings *bindings, long &bindId,
+void fillNodes( Program *prg, int &nextAvail, struct bindings *bindings, long &bindId,
struct pat_cons_node *nodes, ParseTree *parseTree, Kid *kid, int ind )
{
if ( kid != 0 ) {
diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc
index 7934c438..18ca5a68 100644
--- a/src/pdacodegen.cc
+++ b/src/pdacodegen.cc
@@ -78,9 +78,9 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables
for ( int i = 0; i < runtimeData->numFrames; i++ ) {
/* FIXME: horrible code cloning going on here. */
if ( runtimeData->frameInfo[i].codeLenWV > 0 ) {
- out << "static Code code_" << i << "_wv[] = {\n\t";
+ out << "static code_t code_" << i << "_wv[] = {\n\t";
- Code *block = runtimeData->frameInfo[i].codeWV;
+ code_t *block = runtimeData->frameInfo[i].codeWV;
for ( int j = 0; j < runtimeData->frameInfo[i].codeLenWV; j++ ) {
out << (unsigned long) block[j];
@@ -94,9 +94,9 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables
}
if ( runtimeData->frameInfo[i].codeLenWC > 0 ) {
- out << "static Code code_" << i << "_wc[] = {\n\t";
+ out << "static code_t code_" << i << "_wc[] = {\n\t";
- Code *block = runtimeData->frameInfo[i].codeWC;
+ code_t *block = runtimeData->frameInfo[i].codeWC;
for ( int j = 0; j < runtimeData->frameInfo[i].codeLenWC; j++ ) {
out << (unsigned long) block[j];
@@ -150,8 +150,8 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables
/*
* Init code.
*/
- out << "static Code " << rootCode() << "[] = {\n\t";
- Code *block = runtimeData->rootCode ;
+ out << "static code_t " << rootCode() << "[] = {\n\t";
+ code_t *block = runtimeData->rootCode ;
for ( int j = 0; j < runtimeData->rootCodeLen; j++ ) {
out << (unsigned int) block[j];
diff --git a/src/pdacodegen.h b/src/pdacodegen.h
index 03eeb358..ac73f6c8 100644
--- a/src/pdacodegen.h
+++ b/src/pdacodegen.h
@@ -96,9 +96,9 @@ struct PdaCodeGen
extern "C"
{
- void internalFsmExecute( struct pda_run *pdaRun, StreamImpl *inputStream );
+ void internalFsmExecute( struct pda_run *pdaRun, struct stream_impl *inputStream );
void internalSendNamedLangEl( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is );
+ struct pda_run *pdaRun, struct stream_impl *is );
void internalInitBindings( struct pda_run *pdaRun );
void internalPopBinding( struct pda_run *pdaRun, ParseTree *parseTree );
}
diff --git a/src/pdarun.c b/src/pdarun.c
index 8caab5a9..6f965866 100644
--- a/src/pdarun.c
+++ b/src/pdarun.c
@@ -41,18 +41,18 @@
#define act_rb 0x2
#define read_word_p( i, p ) do { \
- i = ((Word) p[0]); \
- i |= ((Word) p[1]) << 8; \
- i |= ((Word) p[2]) << 16; \
- i |= ((Word) p[3]) << 24; \
+ i = ((word_t) p[0]); \
+ i |= ((word_t) p[1]) << 8; \
+ i |= ((word_t) p[2]) << 16; \
+ i |= ((word_t) p[3]) << 24; \
} while(0)
#define read_tree_p( i, p ) do { \
- Word w; \
- w = ((Word) p[0]); \
- w |= ((Word) p[1]) << 8; \
- w |= ((Word) p[2]) << 16; \
- w |= ((Word) p[3]) << 24; \
+ word_t w; \
+ w = ((word_t) p[0]); \
+ w |= ((word_t) p[1]) << 8; \
+ w |= ((word_t) p[2]) << 16; \
+ w |= ((word_t) p[3]) << 24; \
i = (Tree*)w; \
} while(0)
@@ -95,7 +95,7 @@ void colm_decrement_steps( struct pda_run *pdaRun )
//debug( prg, REALM_PARSE, "steps down to %ld\n", pdaRun->steps );
}
-Head *colm_stream_pull( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamImpl *is, long length )
+Head *colm_stream_pull( Program *prg, Tree **sp, struct pda_run *pdaRun, struct stream_impl *is, long length )
{
if ( pdaRun != 0 ) {
RunBuf *runBuf = pdaRun->consumeBuf;
@@ -116,7 +116,7 @@ Head *colm_stream_pull( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamI
pdaRun->p = pdaRun->pe = 0;
pdaRun->toklen = 0;
- Head *tokdata = stringAllocPointer( prg, dest, length );
+ Head *tokdata = colm_string_alloc_pointer( prg, dest, length );
tokdata->location = loc;
return tokdata;
@@ -134,29 +134,29 @@ Head *colm_stream_pull( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamI
}
}
-void undoStreamPull( StreamImpl *is, const char *data, long length )
+void undoStreamPull( struct stream_impl *is, const char *data, long length )
{
//debug( REALM_PARSE, "undoing stream pull\n" );
is->funcs->prependData( is, data, length );
}
-void streamPushText( StreamImpl *is, const char *data, long length )
+void colm_stream_push_text( struct stream_impl *is, const char *data, long length )
{
is->funcs->prependData( is, data, length );
}
-void streamPushTree( StreamImpl *is, Tree *tree, int ignore )
+void colm_stream_push_tree( struct stream_impl *is, Tree *tree, int ignore )
{
is->funcs->prependTree( is, tree, ignore );
}
-void streamPushStream( StreamImpl *is, Tree *tree )
+void colm_stream_push_stream( struct stream_impl *is, Tree *tree )
{
is->funcs->prependStream( is, tree );
}
-void undoStreamPush( Program *prg, Tree **sp, StreamImpl *is, long length )
+void colm_undo_stream_push( Program *prg, Tree **sp, struct stream_impl *is, long length )
{
if ( length < 0 ) {
Tree *tree = is->funcs->undoPrependTree( is );
@@ -170,7 +170,7 @@ void undoStreamPush( Program *prg, Tree **sp, StreamImpl *is, long length )
/* Should only be sending back whole tokens/ignores, therefore the send back
* should never cross a buffer boundary. Either we slide back data, or we move to
* a previous buffer and slide back data. */
-static void send_back_text( StreamImpl *is, const char *data, long length )
+static void send_back_text( struct stream_impl *is, const char *data, long length )
{
//debug( REALM_PARSE, "push back of %ld characters\n", length );
@@ -183,7 +183,7 @@ static void send_back_text( StreamImpl *is, const char *data, long length )
is->funcs->undoConsumeData( is, data, length );
}
-static void send_back_tree( StreamImpl *is, Tree *tree )
+static void send_back_tree( struct stream_impl *is, Tree *tree )
{
is->funcs->undoConsumeTree( is, tree, false );
}
@@ -193,7 +193,7 @@ static void send_back_tree( StreamImpl *is, Tree *tree )
* PCR_REVERSE
*/
static void send_back_ignore( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, ParseTree *parseTree )
+ struct pda_run *pdaRun, struct stream_impl *is, ParseTree *parseTree )
{
#ifdef DEBUG
struct lang_el_info *lelInfo = prg->rtd->lelInfo;
@@ -239,7 +239,7 @@ static void reset_token( struct pda_run *pdaRun )
*/
static void send_back( Program *prg, Tree **sp, struct pda_run *pdaRun,
- StreamImpl *is, ParseTree *parseTree )
+ struct stream_impl *is, ParseTree *parseTree )
{
debug( prg, REALM_PARSE, "sending back: %s\n",
prg->rtd->lelInfo[parseTree->id].name );
@@ -348,7 +348,7 @@ static void ignore_tree_art( Program *prg, struct pda_run *pdaRun, Tree *tree )
}
Kid *make_token_with_data( Program *prg, struct pda_run *pdaRun,
- StreamImpl *is, int id, Head *tokdata )
+ struct stream_impl *is, int id, Head *tokdata )
{
/* Make the token object. */
long objectLength = prg->rtd->lelInfo[id].objectLength;
@@ -718,7 +718,7 @@ static void handle_error( Program *prg, Tree **sp, struct pda_run *pdaRun )
}
}
-static Head *extract_match( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamImpl *is )
+static Head *extract_match( Program *prg, Tree **sp, struct pda_run *pdaRun, struct stream_impl *is )
{
long length = pdaRun->toklen;
@@ -743,7 +743,7 @@ static Head *extract_match( Program *prg, Tree **sp, struct pda_run *pdaRun, Str
pdaRun->toklen = 0;
pdaRun->tokstart = 0;
- Head *head = stringAllocPointer( prg, dest, length );
+ Head *head = colm_string_alloc_pointer( prg, dest, length );
head->location = location;
@@ -752,7 +752,7 @@ static Head *extract_match( Program *prg, Tree **sp, struct pda_run *pdaRun, Str
return head;
}
-static Head *peekMatch( Program *prg, struct pda_run *pdaRun, StreamImpl *is )
+static Head *peekMatch( Program *prg, struct pda_run *pdaRun, struct stream_impl *is )
{
long length = pdaRun->toklen;
@@ -770,7 +770,7 @@ static Head *peekMatch( Program *prg, struct pda_run *pdaRun, StreamImpl *is )
pdaRun->p = pdaRun->pe = 0;
pdaRun->toklen = 0;
- Head *head = stringAllocPointer( prg, dest, length );
+ Head *head = colm_string_alloc_pointer( prg, dest, length );
head->location = locationAllocate( prg );
head->location->line = is->line;
@@ -784,7 +784,7 @@ static Head *peekMatch( Program *prg, struct pda_run *pdaRun, StreamImpl *is )
static void send_ignore( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, long id )
+ struct pda_run *pdaRun, struct stream_impl *is, long id )
{
debug( prg, REALM_PARSE, "ignoring: %s\n", prg->rtd->lelInfo[id].name );
@@ -803,7 +803,7 @@ static void send_ignore( Program *prg, Tree **sp,
}
static void send_token( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, long id )
+ struct pda_run *pdaRun, struct stream_impl *is, long id )
{
int emptyIgnore = pdaRun->accumIgnore == 0;
@@ -829,7 +829,7 @@ static void send_token( Program *prg, Tree **sp,
set_region( pdaRun, emptyIgnore, parseTree );
}
-static void send_tree( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamImpl *is )
+static void send_tree( Program *prg, Tree **sp, struct pda_run *pdaRun, struct stream_impl *is )
{
Kid *input = kidAllocate( prg );
input->tree = is->funcs->consumeTree( is );
@@ -844,14 +844,14 @@ static void send_tree( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamIm
pdaRun->parseInput = parseTree;
}
-static void send_ignore_tree( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamImpl *is )
+static void send_ignore_tree( Program *prg, Tree **sp, struct pda_run *pdaRun, struct stream_impl *is )
{
Tree *tree = is->funcs->consumeTree( is );
ignore_tree_art( prg, pdaRun, tree );
}
static void send_collect_ignore( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, int id )
+ struct pda_run *pdaRun, struct stream_impl *is, int id )
{
debug( prg, REALM_PARSE, "token: CI\n" );
@@ -894,7 +894,7 @@ static int get_next_pre_region( struct pda_run *pdaRun )
return pdaRun->pda_tables->tokenPreRegions[pdaRun->nextRegionInd];
}
-static void send_eof( Program *prg, Tree **sp, struct pda_run *pdaRun, StreamImpl *is )
+static void send_eof( Program *prg, Tree **sp, struct pda_run *pdaRun, struct stream_impl *is )
{
debug( prg, REALM_PARSE, "token: _EOF\n" );
@@ -983,7 +983,7 @@ static void push_bt_point( Program *prg, struct pda_run *pdaRun )
#define SCAN_LANG_EL -2
#define SCAN_EOF -1
-static long scan_token( Program *prg, struct pda_run *pdaRun, StreamImpl *is )
+static long scan_token( Program *prg, struct pda_run *pdaRun, struct stream_impl *is )
{
if ( pdaRun->triggerUndo )
return SCAN_UNDO;
@@ -1171,8 +1171,8 @@ void colm_pda_clear( Program *prg, Tree **sp, struct pda_run *pdaRun )
pdaRun->parseInput = 0;
colm_rcode_downref_all( prg, sp, &pdaRun->reverseCode );
- rtCodeVectEmpty( &pdaRun->reverseCode );
- rtCodeVectEmpty( &pdaRun->rcodeCollect );
+ colm_rt_code_vect_empty( &pdaRun->reverseCode );
+ colm_rt_code_vect_empty( &pdaRun->rcodeCollect );
treeDownref( prg, sp, pdaRun->parseErrorText );
}
@@ -1266,9 +1266,9 @@ static int been_committed( ParseTree *parseTree )
return parseTree->flags & PF_COMMITTED;
}
-static Code *backup_over_rcode( Code *rcode )
+static code_t *backup_over_rcode( code_t *rcode )
{
- Word len;
+ word_t len;
rcode -= SIZEOF_WORD;
read_word_p( len, rcode );
rcode -= len;
@@ -1278,7 +1278,7 @@ static Code *backup_over_rcode( Code *rcode )
/* The top level of the stack is linked right-to-left. Trees underneath are
* linked left-to-right. */
static void commit_kid( Program *prg, struct pda_run *pdaRun, Tree **root,
- ParseTree *lel, Code **rcode, long *causeReduce )
+ ParseTree *lel, code_t **rcode, long *causeReduce )
{
ParseTree *tree = 0;
Tree **sp = root;
@@ -1398,7 +1398,7 @@ static void commit_full( Program *prg, Tree **sp, struct pda_run *pdaRun, long c
debug( prg, REALM_PARSE, "running full commit\n" );
ParseTree *parseTree = pdaRun->stackTop;
- Code *rcode = pdaRun->reverseCode.data + pdaRun->reverseCode.tabLen;
+ code_t *rcode = pdaRun->reverseCode.data + pdaRun->reverseCode.tabLen;
/* The top level of the stack is linked right to left. This is the
* traversal order we need for committing. */
@@ -1424,7 +1424,7 @@ static void commit_full( Program *prg, Tree **sp, struct pda_run *pdaRun, long c
* PCR_REVERSE
*/
static long parse_token( Program *prg, Tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, long entry )
+ struct pda_run *pdaRun, struct stream_impl *is, long entry )
{
int pos;
unsigned int *action;
@@ -1671,7 +1671,7 @@ again:
/* Add the restore instruct. */
append_code_val( &pdaRun->rcodeCollect, IN_RESTORE_LHS );
- append_word( &pdaRun->rcodeCollect, (Word)pdaRun->parsed );
+ append_word( &pdaRun->rcodeCollect, (word_t)pdaRun->parsed );
append_code_val( &pdaRun->rcodeCollect, SIZEOF_CODE + SIZEOF_WORD );
}
else {
@@ -1993,7 +1993,7 @@ _out:
*/
long colm_parse_loop( Program *prg, Tree **sp, struct pda_run *pdaRun,
- StreamImpl *is, long entry )
+ struct stream_impl *is, long entry )
{
struct lang_el_info *lelInfo = prg->rtd->lelInfo;
@@ -2266,7 +2266,7 @@ long colm_parse_frag( Program *prg, Tree **sp, struct pda_run *pdaRun,
long colm_parse_finish( Tree **result, Program *prg, Tree **sp,
struct pda_run *pdaRun, Stream *input , int revertOn, long entry )
{
- StreamImpl *si;
+ struct stream_impl *si;
/* COROUTINE */
switch ( entry ) {
diff --git a/src/pdarun.h b/src/pdarun.h
index 39c809fe..ae170267 100644
--- a/src/pdarun.h
+++ b/src/pdarun.h
@@ -69,7 +69,7 @@ struct fsm_tables
long numActionSwitch;
};
-void undoStreamPull( StreamImpl *inputStream, const char *data, long length );
+void undoStreamPull( struct stream_impl *inputStream, const char *data, long length );
#if SIZEOF_LONG != 4 && SIZEOF_LONG != 8
#error "SIZEOF_LONG contained an unexpected value"
@@ -79,7 +79,7 @@ struct colm_execution;
struct rt_code_vect
{
- Code *data;
+ code_t *data;
long tabLen;
long allocLen;
@@ -188,9 +188,9 @@ struct local_info
struct frame_info
{
const char *name;
- Code *codeWV;
+ code_t *codeWV;
long codeLenWV;
- Code *codeWC;
+ code_t *codeWC;
long codeLenWC;
struct local_info *locals;
long localsLen;
@@ -306,7 +306,7 @@ struct pda_run
Kid *btPoint;
- struct Bindings *bindings;
+ struct bindings *bindings;
int revertOn;
@@ -350,7 +350,7 @@ struct pda_run
int reject;
/* Instruction pointer to use when we stop parsing and execute code. */
- Code *code;
+ code_t *code;
int rcBlockCount;
@@ -364,35 +364,36 @@ void colm_pda_init( struct colm_program *prg, struct pda_run *pdaRun,
void colm_pda_clear( struct colm_program *prg, struct colm_tree **sp,
struct pda_run *pdaRun );
-void rtCodeVectReplace( struct rt_code_vect *vect, long pos, const Code *val, long len );
-void rtCodeVectEmpty( struct rt_code_vect *vect );
-void rtCodeVectRemove( struct rt_code_vect *vect, long pos, long len );
+void colm_rt_code_vect_replace( struct rt_code_vect *vect, long pos,
+ const code_t *val, long len );
+void colm_rt_code_vect_empty( struct rt_code_vect *vect );
+void colm_rt_code_vect_remove( struct rt_code_vect *vect, long pos, long len );
void initRtCodeVect( struct rt_code_vect *codeVect );
-inline static void append_code_val( struct rt_code_vect *vect, const Code val );
-inline static void append_code_vect( struct rt_code_vect *vect, const Code *val, long len );
-inline static void append_half( struct rt_code_vect *vect, Half half );
-inline static void append_word( struct rt_code_vect *vect, Word word );
+inline static void append_code_val( struct rt_code_vect *vect, const code_t val );
+inline static void append_code_vect( struct rt_code_vect *vect, const code_t *val, long len );
+inline static void append_half( struct rt_code_vect *vect, half_t half );
+inline static void append_word( struct rt_code_vect *vect, word_t word );
-inline static void append_code_vect( struct rt_code_vect *vect, const Code *val, long len )
+inline static void append_code_vect( struct rt_code_vect *vect, const code_t *val, long len )
{
- rtCodeVectReplace( vect, vect->tabLen, val, len );
+ colm_rt_code_vect_replace( vect, vect->tabLen, val, len );
}
-inline static void append_code_val( struct rt_code_vect *vect, const Code val )
+inline static void append_code_val( struct rt_code_vect *vect, const code_t val )
{
- rtCodeVectReplace( vect, vect->tabLen, &val, 1 );
+ colm_rt_code_vect_replace( vect, vect->tabLen, &val, 1 );
}
-inline static void append_half( struct rt_code_vect *vect, Half half )
+inline static void append_half( struct rt_code_vect *vect, half_t half )
{
/* not optimal. */
append_code_val( vect, half & 0xff );
append_code_val( vect, (half>>8) & 0xff );
}
-inline static void append_word( struct rt_code_vect *vect, Word word )
+inline static void append_word( struct rt_code_vect *vect, word_t word )
{
/* not optimal. */
append_code_val( vect, word & 0xff );
@@ -410,18 +411,8 @@ inline static void append_word( struct rt_code_vect *vect, Word word )
void colm_increment_steps( struct pda_run *pdaRun );
void colm_decrement_steps( struct pda_run *pdaRun );
-void clearStreamImpl( struct colm_program *prg, Tree **sp, StreamImpl *inputStream );
-void initSourceStream( StreamImpl *in );
-void clearSourceStream( struct colm_program *prg, Tree **sp, StreamImpl *sourceStream );
-
-
-void clearContext( struct pda_run *pdaRun, Tree **sp );
-void runCommit( struct pda_run *pdaRun );
-void pdaRunMatch( struct pda_run *pdaRun, Kid *tree, Kid *pattern );
-
-/* Offset can be used to look at the next nextRegionInd. */
-int pdaRunGetNextRegion( struct pda_run *pdaRun, int offset );
-int pdaRunGetNextPreRegion( struct pda_run *pdaRun );
+void colm_clear_stream_impl( struct colm_program *prg, Tree **sp, struct stream_impl *inputStream );
+void colm_clear_source_stream( struct colm_program *prg, Tree **sp, struct stream_impl *sourceStream );
#define PCR_START 1
#define PCR_DONE 2
@@ -431,24 +422,20 @@ int pdaRunGetNextPreRegion( struct pda_run *pdaRun );
#define PCR_REVERSE 6
Head *colm_stream_pull( struct colm_program *prg, struct colm_tree **sp,
- struct pda_run *pdaRun, StreamImpl *is, long length );
-Head *stringAllocPointer( struct colm_program *prg, const char *data, long length );
+ struct pda_run *pdaRun, struct stream_impl *is, long length );
+Head *colm_string_alloc_pointer( struct colm_program *prg, const char *data, long length );
-void streamPushText( StreamImpl *inputStream, const char *data, long length );
-void streamPushTree( StreamImpl *inputStream, Tree *tree, int ignore );
-void streamPushStream( StreamImpl *inputStream, Tree *tree );
-void undoStreamPush( struct colm_program *prg, Tree **sp,
- StreamImpl *inputStream, long length );
-void undoStreamAppend( struct colm_program *prg, Tree **sp,
- StreamImpl *inputStream, struct colm_tree *tree, long length );
+void colm_stream_push_text( struct stream_impl *inputStream, const char *data, long length );
+void colm_stream_push_tree( struct stream_impl *inputStream, Tree *tree, int ignore );
+void colm_stream_push_stream( struct stream_impl *inputStream, Tree *tree );
+void colm_undo_stream_push( struct colm_program *prg, Tree **sp,
+ struct stream_impl *inputStream, long length );
Kid *make_token_with_data( struct colm_program *prg, struct pda_run *pdaRun,
- StreamImpl *inputStream, int id, Head *tokdata );
-
-void pushBinding( struct pda_run *pdaRun, ParseTree *parseTree );
+ struct stream_impl *inputStream, int id, Head *tokdata );
long colm_parse_loop( struct colm_program *prg, Tree **sp, struct pda_run *pdaRun,
- StreamImpl *inputStream, long entry );
+ struct stream_impl *inputStream, long entry );
long colm_parse_frag( struct colm_program *prg, Tree **sp, struct pda_run *pdaRun,
Stream *input, long stopId, long entry );
diff --git a/src/program.h b/src/program.h
index b24ad7e3..a6e9afed 100644
--- a/src/program.h
+++ b/src/program.h
@@ -46,7 +46,7 @@ struct colm_sections
struct region_info *regionInfo;
long numRegions;
- Code *rootCode;
+ code_t *rootCode;
long rootCodeLen;
long rootFrameId;
@@ -94,9 +94,9 @@ struct colm_sections
long globalId;
long argvElId;
- void (*fsm_execute)( struct pda_run *pdaRun, struct _StreamImpl *inputStream );
+ void (*fsm_execute)( struct pda_run *pdaRun, struct stream_impl *inputStream );
void (*sendNamedLangEl)( struct colm_program *prg, Tree **tree,
- struct pda_run *pdaRun, struct _StreamImpl *inputStream );
+ struct pda_run *pdaRun, struct stream_impl *inputStream );
void (*initBindings)( struct pda_run *pdaRun );
void (*popBinding)( struct pda_run *pdaRun, ParseTree *tree );
diff --git a/src/string.c b/src/string.c
index 0c69d1b2..ef184357 100644
--- a/src/string.c
+++ b/src/string.c
@@ -66,7 +66,7 @@ Head *stringCopy( Program *prg, Head *head )
if ( (char*)(head+1) == head->data )
result = stringAllocFull( prg, head->data, head->length );
else
- result = stringAllocPointer( prg, head->data, head->length );
+ result = colm_string_alloc_pointer( prg, head->data, head->length );
if ( head->location != 0 ) {
result->location = locationAllocate( prg );
@@ -143,7 +143,7 @@ Head *stringAllocFull( Program *prg, const char *data, long length )
}
/* Create from a c-style string. */
-Head *stringAllocPointer( Program *prg, const char *data, long length )
+Head *colm_string_alloc_pointer( Program *prg, const char *data, long length )
{
/* Find the length and allocate the space for the shared string. */
Head *head = headAllocate( prg );
@@ -204,7 +204,7 @@ Head *stringToLower( Head *s )
/* Compare two strings. If identical returns 1, otherwise 0. */
-Word cmpString( Head *s1, Head *s2 )
+word_t cmpString( Head *s1, Head *s2 )
{
if ( s1->length < s2->length )
return -1;
@@ -217,7 +217,7 @@ Word cmpString( Head *s1, Head *s2 )
}
}
-Word strAtoi( Head *str )
+word_t strAtoi( Head *str )
{
/* FIXME: need to implement this by hand. There is no null terminator. */
char *nulled = (char*)malloc( str->length + 1 );
@@ -228,7 +228,7 @@ Word strAtoi( Head *str )
return res;
}
-Word strAtoo( Head *str )
+word_t strAtoo( Head *str )
{
/* FIXME: need to implement this by hand. There is no null terminator. */
char *nulled = (char*)malloc( str->length + 1 );
@@ -239,14 +239,14 @@ Word strAtoo( Head *str )
return res;
}
-Head *intToStr( Program *prg, Word i )
+Head *intToStr( Program *prg, word_t i )
{
char data[20];
sprintf( data, "%ld", i );
return stringAllocFull( prg, data, strlen(data) );
}
-Word strUord16( Head *head )
+word_t strUord16( Head *head )
{
uchar *data = (uchar*)(head->data);
ulong res;
@@ -255,7 +255,7 @@ Word strUord16( Head *head )
return res;
}
-Word strUord8( Head *head )
+word_t strUord8( Head *head )
{
uchar *data = (uchar*)(head->data);
ulong res = (ulong)data[0];
@@ -264,7 +264,7 @@ Word strUord8( Head *head )
Head *makeLiteral( Program *prg, long offset )
{
- return stringAllocPointer( prg,
+ return colm_string_alloc_pointer( prg,
prg->rtd->litdata[offset],
prg->rtd->litlen[offset] );
}
diff --git a/src/struct.h b/src/struct.h
index 44e94eba..a4296b19 100644
--- a/src/struct.h
+++ b/src/struct.h
@@ -5,9 +5,6 @@
extern "C" {
#endif
-
-typedef struct _StreamImpl StreamImpl;
-
typedef void (*colm_destructor_t)( struct colm_program *prg,
Tree **sp, struct colm_struct *s );
@@ -49,7 +46,7 @@ typedef struct colm_stream
void *buffer[8];
- StreamImpl *impl;
+ struct stream_impl *impl;
} Stream;
#define COLM_LIST_EL_SIZE 2
@@ -134,18 +131,18 @@ Stream *colm_stream_new_struct( struct colm_program *prg );
List *colm_list_new( struct colm_program *prg );
struct colm_struct *colm_list_get( struct colm_program *prg, List *list,
- Word genId, Word field );
+ word_t genId, word_t field );
struct colm_struct *colm_list_el_get( struct colm_program *prg,
- ListEl *listEl, Word genId, Word field );
+ ListEl *listEl, word_t genId, word_t field );
ListEl *colm_list_detach_head( List *list );
ListEl *colm_list_detach_tail( List *list );
long colm_list_length( List *list );
Map *colm_map_new( struct colm_program *prg );
struct colm_struct *colm_map_el_get( struct colm_program *prg,
- MapEl *mapEl, Word genId, Word field );
+ MapEl *mapEl, word_t genId, word_t field );
struct colm_struct *colm_map_get( struct colm_program *prg, Map *map,
- Word genId, Word field );
+ word_t genId, word_t field );
struct colm_struct *colm_construct_generic( struct colm_program *prg, long genericId );
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 32fc91f5..2e61396d 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -298,16 +298,16 @@ long sizeOfField( UniqueType *fieldUT )
case IterDef::Child:
case IterDef::Repeat:
case IterDef::RevRepeat:
- size = sizeof(TreeIter) / sizeof(Word);
+ size = sizeof(TreeIter) / sizeof(word_t);
break;
case IterDef::RevChild:
- size = sizeof(RevTreeIter) / sizeof(Word);
+ size = sizeof(RevTreeIter) / sizeof(word_t);
break;
case IterDef::Map:
case IterDef::List:
- size = sizeof(GenericIter) / sizeof(Word);
+ size = sizeof(GenericIter) / sizeof(word_t);
break;
case IterDef::User:
@@ -2357,7 +2357,7 @@ void LangStmt::compileWhile( Compiler *pd, CodeVect &code ) const
/* Jump past the while block if false. Note that we don't have the
* distance yet. */
long jumpFalse = code.length();
- Half jinstr = eut->tree() ? IN_JMP_FALSE_TREE : IN_JMP_FALSE_VAL;
+ half_t jinstr = eut->tree() ? IN_JMP_FALSE_TREE : IN_JMP_FALSE_VAL;
code.append( jinstr );
code.appendHalf( 0 );
@@ -2464,7 +2464,7 @@ void LangStmt::compile( Compiler *pd, CodeVect &code ) const
/* Jump past the if block if false. We don't know the distance
* yet so store the location of the jump. */
jumpFalse = code.length();
- Half jinstr = eut->tree() ? IN_JMP_FALSE_TREE : IN_JMP_FALSE_VAL;
+ half_t jinstr = eut->tree() ? IN_JMP_FALSE_TREE : IN_JMP_FALSE_VAL;
code.append( jinstr );
code.appendHalf( 0 );
diff --git a/src/tree.c b/src/tree.c
index 16157fe8..f3b3b456 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -193,7 +193,7 @@ Value colm_get_pointer_val( Tree *ptr )
}
-Tree *constructTerm( Program *prg, Word id, Head *tokdata )
+Tree *constructTerm( Program *prg, word_t id, Head *tokdata )
{
struct lang_el_info *lelInfo = prg->rtd->lelInfo;
@@ -217,7 +217,7 @@ static Kid *constructIgnoreList( Program *prg, long ignoreInd )
Kid *first = 0, *last = 0;
while ( ignoreInd >= 0 ) {
- Head *ignoreData = stringAllocPointer( prg, nodes[ignoreInd].data,
+ Head *ignoreData = colm_string_alloc_pointer( prg, nodes[ignoreInd].data,
nodes[ignoreInd].length );
Tree *ignTree = treeAllocate( prg );
@@ -487,7 +487,7 @@ Tree *constructTree( Program *prg, Kid *kid, Tree **bindings, long pat )
tree->id = nodes[pat].id;
tree->refs = 1;
tree->tokdata = nodes[pat].length == 0 ? 0 :
- stringAllocPointer( prg,
+ colm_string_alloc_pointer( prg,
nodes[pat].data, nodes[pat].length );
tree->prod_num = nodes[pat].prodNum;
@@ -538,7 +538,7 @@ Tree *constructTree( Program *prg, Kid *kid, Tree **bindings, long pat )
attr->id = nodes[ci].id;
attr->refs = 1;
attr->tokdata = nodes[ci].length == 0 ? 0 :
- stringAllocPointer( prg,
+ colm_string_alloc_pointer( prg,
nodes[ci].data, nodes[ci].length );
colm_tree_set_attr( tree, ca->offset, attr );
@@ -1173,17 +1173,17 @@ void colm_tree_set_field( Program *prg, Tree *tree, long field, Tree *value )
colm_tree_set_attr( tree, field, value );
}
-Tree *colm_tree_get_field( Tree *tree, Word field )
+Tree *colm_tree_get_field( Tree *tree, word_t field )
{
return colm_get_attr( tree, field );
}
-Kid *getFieldKid( Tree *tree, Word field )
+Kid *getFieldKid( Tree *tree, word_t field )
{
return getAttrKid( tree, field );
}
-Tree *getFieldSplit( Program *prg, Tree *tree, Word field )
+Tree *getFieldSplit( Program *prg, Tree *tree, word_t field )
{
Tree *val = colm_get_attr( tree, field );
Tree *split = splitTree( prg, val );
@@ -1366,7 +1366,7 @@ void splitRef( Program *prg, Tree ***psp, Ref *fromRef )
}
}
-Tree *setListMem( List *list, Half field, Tree *value )
+Tree *setListMem( List *list, half_t field, Tree *value )
{
if ( value != 0 )
assert( value->refs >= 1 );
@@ -1465,7 +1465,7 @@ Tree *listRemoveHead( Program *prg, List *list )
return 0;
}
-Tree *getParserMem( Parser *parser, Word field )
+Tree *getParserMem( Parser *parser, word_t field )
{
Tree *result = 0;
switch ( field ) {
@@ -1486,7 +1486,7 @@ Tree *getParserMem( Parser *parser, Word field )
return result;
}
-Tree *getListMemSplit( Program *prg, List *list, Word field )
+Tree *getListMemSplit( Program *prg, List *list, word_t field )
{
Tree *sv = 0;
switch ( field ) {
diff --git a/src/tree.h b/src/tree.h
index 299a9f4a..5256064d 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -31,10 +31,11 @@ extern "C" {
#include <colm/input.h>
#include <colm/internal.h>
-typedef unsigned char Code;
-typedef unsigned long Word;
-typedef unsigned long Half;
-struct Bindings;
+typedef unsigned char code_t;
+typedef unsigned long word_t;
+typedef unsigned long half_t;
+
+struct bindings;
struct function_info;
typedef struct colm_stream Stream;
@@ -215,7 +216,7 @@ typedef struct _UserIter
long yieldSize;
long rootSize;
- Code *resume;
+ code_t *resume;
Tree **frame;
long searchId;
} UserIter;
@@ -241,7 +242,7 @@ Kid *treeExtractChild( struct colm_program *prg, Tree *tree );
Kid *reverseKidList( Kid *kid );
Tree *colm_construct_pointer( struct colm_program *prg, colm_value_t value );
-Tree *constructTerm( struct colm_program *prg, Word id, Head *tokdata );
+Tree *constructTerm( struct colm_program *prg, word_t id, Head *tokdata );
Tree *constructTree( struct colm_program *prg, Kid *kid,
Tree **bindings, long pat );
Tree *constructObject( struct colm_program *prg, Kid *kid,
@@ -260,8 +261,8 @@ Tree *copyTree( struct colm_program *prg, Tree *tree,
Kid *oldNextDown, Kid **newNextDown );
colm_value_t colm_get_pointer_val( Tree *pointer );
-Tree *colm_tree_get_field( Tree *tree, Word field );
-Tree *getFieldSplit( struct colm_program *prg, Tree *tree, Word field );
+Tree *colm_tree_get_field( Tree *tree, word_t field );
+Tree *getFieldSplit( struct colm_program *prg, Tree *tree, word_t field );
Tree *getRhsEl( struct colm_program *prg, Tree *lhs, long position );
Kid *getRhsElKid( struct colm_program *prg, Tree *lhs, long position );
void colm_tree_set_field( struct colm_program *prg, Tree *tree, long field, Tree *value );
@@ -277,19 +278,19 @@ int matchPattern( Tree **bindings, struct colm_program *prg,
Tree *treeIterDerefCur( TreeIter *iter );
/* For making references of attributes. */
-Kid *getFieldKid( Tree *tree, Word field );
+Kid *getFieldKid( Tree *tree, word_t field );
Tree *copyRealTree( struct colm_program *prg, Tree *tree,
Kid *oldNextDown, Kid **newNextDown );
void splitIterCur( struct colm_program *prg, Tree ***psp, TreeIter *iter );
-Tree *setListMem( List *list, Half field, Tree *value );
+Tree *setListMem( List *list, half_t field, Tree *value );
void listPushTail( struct colm_program *prg, List *list, Tree *val );
void listPushHead( struct colm_program *prg, List *list, Tree *val );
Tree *listRemoveEnd( struct colm_program *prg, List *list );
Tree *listRemoveHead( struct colm_program *prg, List *list );
-Tree *getListMemSplit( struct colm_program *prg, List *list, Word field );
-Tree *getParserMem( Parser *parser, Word field );
+Tree *getListMemSplit( struct colm_program *prg, List *list, word_t field );
+Tree *getParserMem( Parser *parser, word_t field );
Tree *treeIterAdvance( struct colm_program *prg, Tree ***psp, TreeIter *iter );
Tree *treeIterNextChild( struct colm_program *prg, Tree ***psp, TreeIter *iter );
@@ -341,7 +342,7 @@ void colm_uiter_destroy( struct colm_program *prg, Tree ***psp, UserIter *uiter
void colm_uiter_unwind( struct colm_program *prg, Tree ***psp, UserIter *uiter );
Tree *castTree( struct colm_program *prg, int langElId, Tree *tree );
-StreamImpl *streamToImpl( Stream *ptr );
+struct stream_impl *streamToImpl( Stream *ptr );
void colm_init_list_iter( GenericIter *listIter, Tree **stackRoot,
long argSize, long rootSize, const Ref *rootRef, int genericId );