83
compile_name_sub( Expr *expr, BufInfo *buf )
83
compile_name_sub( Expr *expr, VipsBuf *buf )
86
if( !buf_is_empty( buf ) )
87
buf_appends( buf, ", " );
86
if( !vips_buf_is_empty( buf ) )
87
vips_buf_appends( buf, ", " );
88
88
row_qualified_name( expr->row, buf );
95
compile_name( Compile *compile, BufInfo *buf )
95
compile_name( Compile *compile, VipsBuf *buf )
100
buf_appends( buf, "\"" );
100
vips_buf_appends( buf, "\"" );
101
101
symbol_qualified_name( compile->sym, buf );
102
buf_appends( buf, "\"" );
102
vips_buf_appends( buf, "\"" );
104
buf_init_static( &buf2, txt, 256 );
104
vips_buf_init_static( &buf2, txt, 256 );
105
105
slist_map( compile->exprs,
106
106
(SListMapFn) compile_name_sub, &buf2 );
107
if( !buf_is_empty( &buf2 ) )
108
buf_appendf( buf, " (%s)", buf_all( &buf2 ) );
107
if( !vips_buf_is_empty( &buf2 ) )
108
vips_buf_appendf( buf, " (%s)", vips_buf_all( &buf2 ) );
191
191
/* Must be there.
193
assert( g_slist_find( compile->children, child ) &&
193
g_assert( g_slist_find( compile->children, child ) &&
194
194
g_slist_find( child->parents, compile ) );
196
196
compile->children = g_slist_remove( compile->children, child );
210
210
compile_expr_link_break( Compile *compile, Expr *expr )
212
assert( expr->compile == compile );
213
assert( g_slist_find( compile->exprs, expr ) );
212
g_assert( expr->compile == compile );
213
g_assert( g_slist_find( compile->exprs, expr ) );
215
215
expr->compile = NULL;
216
216
compile->exprs = g_slist_remove( compile->exprs, expr );
230
230
compile_expr_link_make( Compile *compile, Expr *expr )
232
assert( !expr->compile );
233
assert( !g_slist_find( compile->exprs, expr ) );
234
assert( compile->sym == expr->sym );
232
g_assert( !expr->compile );
233
g_assert( !g_slist_find( compile->exprs, expr ) );
234
g_assert( compile->sym == expr->sym );
236
236
expr->compile = compile;
237
237
compile->exprs = g_slist_prepend( compile->exprs, expr );
280
280
/* Remove static strings we created.
282
282
slist_map( compile->statics,
283
(SListMapFn) heap_static_string_unref, NULL );
283
(SListMapFn) managed_destroy_nonheap, NULL );
284
284
IM_FREEF( g_slist_free, compile->statics );
303
303
/* If we're being finalized, we must have a ref count of zero, so
304
304
* there shouldn't be any exprs looking at us.
306
assert( !compile->exprs );
306
g_assert( !compile->exprs );
308
308
G_OBJECT_CLASS( parent_class )->finalize( gobject );
312
compile_child_add( iContainer *parent, iContainer *child, int pos )
314
Compile *compile = COMPILE( parent );
315
Symbol *sym = SYMBOL( child );
318
compile->last_sym = sym;
320
ICONTAINER_CLASS( parent_class )->child_add( parent, child, pos );
324
compile_child_remove( iContainer *parent, iContainer *child )
326
Compile *compile = COMPILE( parent );
327
Symbol *sym = SYMBOL( child );
329
if( sym && compile->last_sym == sym )
330
compile->last_sym = NULL;
332
ICONTAINER_CLASS( parent_class )->child_remove( parent, child );
336
312
compile_class_init( CompileClass *class )
338
314
GObjectClass *gobject_class = (GObjectClass *) class;
339
iContainerClass *icontainer_class = (iContainerClass *) class;
341
316
parent_class = g_type_class_peek_parent( class );
343
318
gobject_class->finalize = compile_finalize;
345
icontainer_class->child_add = compile_child_add;
346
icontainer_class->child_remove = compile_child_remove;
348
320
/* Create signals.
827
799
switch( pn->con.type ) {
828
800
case PARSE_CONST_STR:
830
HeapStaticString *string;
832
if( !(string = heap_static_string_new(
833
reduce_context->heap,
802
Managedstring *managedstring;
804
if( !(managedstring = managedstring_find(
805
reduce_context->heap,
834
806
pn->con.val.str )) )
808
MANAGED_REF( managedstring );
836
809
compile->statics = g_slist_prepend( compile->statics,
839
PEPUTP( out, ELEMENT_STATIC, string );
811
PEPUTP( out, ELEMENT_MANAGED, managedstring );
844
815
case PARSE_CONST_CHAR:
845
816
PEPUTP( out, ELEMENT_CHAR, pn->con.val.ch );
1214
1182
hash = INT_TO_HASH( g_str_hash( PEGETTAG( e ) ) );
1217
case ELEMENT_STATIC:
1218
hash = INT_TO_HASH( g_str_hash( PEGETSTATIC( e )->text ) );
1185
case ELEMENT_MANAGED:
1186
if( PEISMANAGEDSTRING( e ) )
1187
hash = INT_TO_HASH( g_str_hash(
1188
PEGETMANAGEDSTRING( e )->string ) );
1221
1191
case ELEMENT_NOVAL:
1222
case ELEMENT_MANAGED:
1227
1196
return( hash );
1313
1282
/* If compound type, something is wrong! Only built by reduce.
1315
assert( hn1->type != TAG_CLASS );
1284
g_assert( hn1->type != TAG_CLASS );
1317
1286
/* In two parts, test tags.
1352
1321
Heap *heap = compile->heap;
1355
1324
#endif /*DEBUG*/
1358
buf_init_static( &buf, txt, 80 );
1327
vips_buf_init_static( &buf, txt, 80 );
1359
1328
graph_node( heap, &buf, hn1, TRUE );
1360
printf( "Found common subexpression: %s\n", buf_all( &buf ) );
1329
printf( "Found common subexpression: %s\n", vips_buf_all( &buf ) );
1361
1330
#endif /*DEBUG*/
1363
1332
#ifdef DEBUG_COMMON
1466
buf_init_static( &buf, txt, 80 );
1435
vips_buf_init_static( &buf, txt, 80 );
1467
1436
graph_node( heap, &buf, hn1, TRUE );
1468
printf( "Found shared code: %s\n", buf_all( &buf ) );
1437
printf( "Found shared code: %s\n", vips_buf_all( &buf ) );
1469
1438
#endif /*DEBUG*/
1471
1440
if( NEWNODE( heap, hn2 ) )
1594
buf_init_static( &buf, txt, 1024 );
1563
vips_buf_init_static( &buf, txt, 1024 );
1595
1564
graph_pelement( compile->heap, &buf, &base, TRUE );
1596
1565
printf( "before var abstraction, compiled \"%s\" to: %s\n",
1597
IOBJECT( compile->sym )->name, buf_all( &buf ) );
1566
IOBJECT( compile->sym )->name, vips_buf_all( &buf ) );
1598
1567
#endif /*DEBUG*/
1600
1569
/* Abstract real parameters.
1623
1592
#ifdef DEBUG_RESULT
1626
1595
char txt[1024];
1628
1597
printf( "compiled \"" );
1629
1598
symbol_name_print( compile->sym );
1630
1599
printf( "\" to: " );
1631
buf_init_static( &buf, txt, 1024 );
1600
vips_buf_init_static( &buf, txt, 1024 );
1632
1601
graph_pelement( compile->heap, &buf, &base, TRUE );
1633
printf( "%s\n", buf_all( &buf ) );
1602
printf( "%s\n", vips_buf_all( &buf ) );
1635
1604
#endif /*DEBUG_RESULT*/
2107
2076
/* Must be a different place.
2109
assert( symbol_get_parent( sym )->expr->compile != dest );
2078
g_assert( symbol_get_parent( sym )->expr->compile != dest );
2111
2080
/* Must not be an existing sym of that name. Or if there is, it has to
2114
assert( !compile_lookup( dest, name ) ||
2083
g_assert( !compile_lookup( dest, name ) ||
2115
2084
compile_lookup( dest, name )->type == SYM_ZOMBIE );
2117
2086
switch( sym->type ) {