87
87
const char *top_str = str ? str : _( "Bad arguments." );
88
88
const char *op_name = op >= 0 ? decode_BinOp( op ) : name;
91
91
char txt[MAX_ERROR_FRAG];
93
93
char txt2[MAX_ERROR_FRAG];
95
95
char txt3[MAX_ERROR_FRAG];
97
buf_init_static( &buf, txt, MAX_ERROR_FRAG );
97
vips_buf_init_static( &buf, txt, MAX_ERROR_FRAG );
98
98
itext_value_ev( rc, &buf, a );
100
buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
100
vips_buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
101
101
itext_value_ev( rc, &buf2, b );
103
buf_init_static( &buf3, txt3, MAX_ERROR_FRAG );
103
vips_buf_init_static( &buf3, txt3, MAX_ERROR_FRAG );
105
105
/* Expands to eg. 'bad args to "+", called from "fred"'
107
buf_appends( &buf3, _( "Called from" ) );
108
buf_appends( &buf3, " " );
107
vips_buf_appends( &buf3, _( "Called from" ) );
108
vips_buf_appends( &buf3, " " );
109
109
compile_name( compile, &buf3 );
123
123
action_nomerror( Reduce *rc, Compile *compile, PElement *a, PElement *b )
128
128
char txt2[MAX_ERROR_FRAG];
130
130
char txt3[MAX_ERROR_FRAG];
132
buf_init_static( &buf, txt, 500 );
133
buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
134
buf_init_static( &buf3, txt3, MAX_ERROR_FRAG );
132
vips_buf_init_static( &buf, txt, 500 );
133
vips_buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
134
vips_buf_init_static( &buf3, txt3, MAX_ERROR_FRAG );
136
136
if( PEISCLASS( a ) )
137
137
symbol_qualified_name( PEGETCLASSCOMPILE( a )->sym, &buf3 );
142
142
else if( PEISCOMPILEREF( a ) )
143
143
symbol_qualified_name( PEGETCOMPILE( a )->sym, &buf3 );
145
buf_appends( &buf3, "<thing>" );
145
vips_buf_appends( &buf3, "<thing>" );
146
146
itext_value_ev( rc, &buf2, b );
147
buf_appendf( &buf, _( "Member \"%s\" not found in class \"%s\"." ),
148
buf_all( &buf2 ), buf_all( &buf3 ) );
149
buf_appendf( &buf, "\n" );
147
vips_buf_appendf( &buf, _( "Member \"%s\" not found in class \"%s\"." ),
148
vips_buf_all( &buf2 ), vips_buf_all( &buf3 ) );
149
vips_buf_appendf( &buf, "\n" );
151
vips_buf_rewind( &buf3 );
152
152
itext_value_ev( rc, &buf3, a );
153
buf_appendf( &buf, " " );
154
buf_appendf( &buf, _( "object = %s" ), buf_all( &buf3 ) );
155
buf_appendf( &buf, "\n" );
157
buf_appendf( &buf, " " );
158
buf_appendf( &buf, _( "tag = %s" ), buf_all( &buf2 ) );
159
buf_appendf( &buf, "\n" );
153
vips_buf_appendf( &buf, " " );
154
vips_buf_appendf( &buf, _( "object = %s" ), vips_buf_all( &buf3 ) );
155
vips_buf_appendf( &buf, "\n" );
157
vips_buf_appendf( &buf, " " );
158
vips_buf_appendf( &buf, _( "tag = %s" ), vips_buf_all( &buf2 ) );
159
vips_buf_appendf( &buf, "\n" );
161
vips_buf_rewind( &buf3 );
162
162
symbol_qualified_name( compile->sym, &buf3 );
163
buf_appendf( &buf, _( "Reference attempted in \"%s\"." ),
165
buf_appendf( &buf, "\n" );
163
vips_buf_appendf( &buf, _( "Reference attempted in \"%s\"." ),
164
vips_buf_all( &buf3 ) );
165
vips_buf_appendf( &buf, "\n" );
167
167
error_top( _( "Member not found." ) );
168
error_sub( "%s", buf_all( &buf ) );
168
error_sub( "%s", vips_buf_all( &buf ) );
169
169
reduce_throw( rc );
178
178
const char *top_str = str ? str : _( "Bad argument." );
179
179
const char *op_name = op >= 0 ? decode_UnOp( op ) : name;
182
182
char txt[MAX_ERROR_FRAG];
184
184
char txt2[MAX_ERROR_FRAG];
186
buf_init_static( &buf, txt, MAX_ERROR_FRAG );
186
vips_buf_init_static( &buf, txt, MAX_ERROR_FRAG );
187
187
itext_value_ev( rc, &buf, a );
189
buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
189
vips_buf_init_static( &buf2, txt2, MAX_ERROR_FRAG );
191
191
/* Expands to eg. 'bad args to "+", called from "fred"'
193
buf_appends( &buf2, _( "Called from" ) );
194
buf_appends( &buf2, " " );
193
vips_buf_appends( &buf2, _( "Called from" ) );
194
vips_buf_appends( &buf2, " " );
195
195
compile_name( compile, &buf2 );
198
198
error_top( "%s", top_str );
199
199
error_sub( _( "Error in unary \"%s\".\n"
200
200
"argument = %s\n%s" ),
201
op_name, buf_all( &buf ), buf_all( &buf2 ) );
201
op_name, vips_buf_all( &buf ), vips_buf_all( &buf2 ) );
202
202
reduce_throw( rc );
325
325
return( link_add( child, expr, TRUE ) );
329
action_proc_dot_tag( PElement *b, char *tag, int n )
332
return( PEGETTAG( b ) );
333
else if( heap_get_string( b, tag, n ) )
328
339
/* Extract field from object. Be careful, a can be equal to out.
332
343
int op, const char *name, PElement *a, PElement *b, PElement *out )
336
348
if( PEISCLASS( a ) ) {
340
if( !class_get_member( a, PEGETTAG( b ), NULL, &c ) )
351
if( (p = action_proc_dot_tag( b, tag, 256 )) ) {
352
if( !class_get_member( a, p, NULL, &c ) )
341
353
action_nomerror( rc, compile, a, b );
343
355
PEPUTPE( out, &c );
349
361
PEPUTPE( out, &c );
351
else if( heap_get_string( b, tag, 256 ) ) {
352
if( !class_get_member( a, tag, NULL, &c ) )
353
action_nomerror( rc, compile, a, b );
358
364
action_boperror( rc, compile,
359
365
_( "Bad right hand side of '.'." ),
370
376
"is not scope" ),
371
377
op, name, a, b );
379
g_assert( sym->expr );
376
child = compile_lookup( sym->expr->compile,
378
else if( heap_get_string( b, tag, 256 ) )
379
child = compile_lookup( sym->expr->compile, tag );
381
if( !(p = action_proc_dot_tag( b, tag, 256 )) )
381
382
action_boperror( rc, compile,
382
383
_( "Bad right hand side of '.'." ),
383
384
op, name, a, b );
385
if( !(child = compile_lookup( sym->expr->compile, p )) )
386
386
action_nomerror( rc, compile, a, b );
388
388
/* Add all exprs which use compile to dynamic link graph.
402
402
PEPUTP( out, ELEMENT_SYMREF, child );
405
else if( PEISMANAGEDGOBJECT( a ) ) {
406
GObject *gobject = PEGETMANAGEDGOBJECT( a );
407
GObjectClass *gclass = G_OBJECT_GET_CLASS( gobject );
408
GValue value = { 0 };
411
if( !(p = action_proc_dot_tag( b, tag, 256 )) )
412
action_boperror( rc, compile,
413
_( "Bad right hand side of '.'." ),
415
if( !(pspec = g_object_class_find_property( gclass, p )) )
416
action_boperror( rc, compile,
417
_( "Property not found." ),
420
g_value_init( &value, G_PARAM_SPEC_VALUE_TYPE( pspec ) );
421
g_object_get_property( gobject, p, &value);
423
if( !heap_gvalue_to_ip( &value, out ) ) {
424
g_value_unset( &value );
428
g_value_unset( &value );
406
431
action_boperror( rc, compile, _( "Bad left hand side of '.'." ),
407
432
op, name, a, b );
419
444
else if( PEISCHAR( a ) && PEISCHAR( b ) ) {
420
445
PEPUTP( out, ELEMENT_BOOL, PEGETCHAR( a ) <= PEGETCHAR( b ) );
422
else if( PEISLIST( a ) && PEISLIST( b ) ) {
447
else if( PEISLIST( a ) && PEISLIST( b ) &&
448
reduce_is_string( rc, a ) && reduce_is_string( rc, b ) ) {
423
449
char a_string[MAX_STRSIZE];
424
450
char b_string[MAX_STRSIZE];
452
478
else if( PEISCHAR( a ) && PEISCHAR( b ) ) {
453
479
PEPUTP( out, ELEMENT_BOOL, PEGETCHAR( a ) < PEGETCHAR( b ) );
455
else if( PEISLIST( a ) && PEISLIST( b ) ) {
481
else if( PEISLIST( a ) && PEISLIST( b ) &&
482
reduce_is_string( rc, a ) && reduce_is_string( rc, b ) ) {
456
483
char a_string[MAX_STRSIZE];
457
484
char b_string[MAX_STRSIZE];
585
612
return( mn == 255 );
615
/* One of p1/p2 is a managedstring.
617
* This is pretty dumb. We could have a special loop down the list side which
618
* compared to the managedstring directly, but I doubt if this will ever be a
622
action_string_equal( Reduce *rc, PElement *p1, PElement *p2 )
624
char a_string[MAX_STRSIZE];
625
char b_string[MAX_STRSIZE];
627
reduce_get_string( rc, p1, a_string, MAX_STRSIZE );
628
reduce_get_string( rc, p2, b_string, MAX_STRSIZE );
630
return( strcmp( a_string, b_string ) == 0 );
588
633
/* Test two elements for equality. Force computation as required.
595
640
reduce_spine( rc, p1 );
596
641
reduce_spine( rc, p2 );
643
/* We can often test for eg. "fred" == "fred" by just checking
646
if( PEGETTYPE( p1 ) == PEGETTYPE( p2 ) ) {
647
switch( PEGETTYPE( p1 ) ) {
651
case ELEMENT_MANAGED:
652
if( PEGETVAL( p1 ) == PEGETVAL( p2 ) )
661
/* Special case if either is a managedstring.
663
if( PEISMANAGEDSTRING( p1 ) ||
664
PEISMANAGEDSTRING( p2 ) )
665
return( action_string_equal( rc, p1, p2 ) );
667
/* No other implicit conversions, so types must match.
600
669
if( PEGETTYPE( p1 ) != PEGETTYPE( p2 ) )
1552
1620
Compile *compile, HeapNode **arg, PElement *out )
1554
1622
if( trace_flags & TRACE_CLASS_NEW ) {
1555
BufInfo *buf = trace_push();
1623
VipsBuf *buf = trace_push();
1557
buf_appendf( buf, "constructor \"%s\" ",
1625
vips_buf_appendf( buf, "constructor \"%s\" ",
1558
1626
IOBJECT( compile->sym )->name );
1559
1627
trace_args( arg, compile->nparam + compile->nsecret );
1590
1658
heap_appl_init( &base, fn );
1591
1659
if( !heap_appl_add( rc->heap, &base, &rhs ) ||
1592
!heap_string_new( rc->heap, name, &rhs ) ||
1660
!heap_managedstring_new( rc->heap, name, &rhs ) ||
1593
1661
!heap_appl_add( rc->heap, &base, &rhs ) )
1611
1679
if( trace_flags & flags ) {
1612
BufInfo *buf = trace_push();
1680
VipsBuf *buf = trace_push();
1614
buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1615
buf_appends( buf, " " );
1682
vips_buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1683
vips_buf_appends( buf, " " );
1616
1684
trace_pelement( a );
1617
buf_appendf( buf, ".%s \"%s\" ", MEMBER_OO_BINARY, name );
1685
vips_buf_appendf( buf, ".%s \"%s\" ", MEMBER_OO_BINARY, name );
1618
1686
trace_pelement( b );
1619
buf_appends( buf, "\n" );
1687
vips_buf_appends( buf, "\n" );
1621
trace_text( flags, buf_all( buf ) );
1689
trace_text( flags, "%s", vips_buf_all( buf ) );
1647
1715
if( trace_flags & flags ) {
1648
BufInfo *buf = trace_push();
1716
VipsBuf *buf = trace_push();
1650
buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1651
buf_appends( buf, " " );
1718
vips_buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1719
vips_buf_appends( buf, " " );
1652
1720
trace_pelement( b );
1653
buf_appendf( buf, ".%s \"%s\" ", MEMBER_OO_BINARY2, name );
1721
vips_buf_appendf( buf, ".%s \"%s\" ", MEMBER_OO_BINARY2, name );
1654
1722
trace_pelement( a );
1655
buf_appends( buf, "\n" );
1723
vips_buf_appends( buf, "\n" );
1657
trace_text( flags, buf_all( buf ) );
1725
trace_text( flags, "%s", vips_buf_all( buf ) );
1773
1841
if( PEISBOOL( a ) ) {
1774
1842
if( trace_flags & TRACE_OPERATOR ) {
1775
BufInfo *buf = trace_push();
1843
VipsBuf *buf = trace_push();
1777
buf_appendf( buf, "if " );
1845
vips_buf_appendf( buf, "if " );
1778
1846
trace_pelement( a );
1779
buf_appendf( buf, " then " );
1847
vips_buf_appendf( buf, " then " );
1780
1848
trace_pelement( &t );
1781
buf_appendf( buf, " else " );
1849
vips_buf_appendf( buf, " else " );
1782
1850
trace_pelement( &e );
1783
buf_appendf( buf, " ->\n" );
1851
vips_buf_appendf( buf, " ->\n" );
1786
1854
if( PEGETBOOL( a ) ) {
1888
1956
heap_appl_init( &base, fn );
1889
1957
if( !heap_appl_add( rc->heap, &base, &rhs ) ||
1890
!heap_string_new( rc->heap, name, &rhs ) )
1958
!heap_managedstring_new( rc->heap, name, &rhs ) )
1893
1961
PEPUTPE( out, pe );
1905
1973
if( trace_flags & flags ) {
1906
BufInfo *buf = trace_push();
1974
VipsBuf *buf = trace_push();
1908
buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1909
buf_appends( buf, " " );
1976
vips_buf_appendf( buf, "%s\n", _( "invoking method:" ) );
1977
vips_buf_appends( buf, " " );
1910
1978
trace_pelement( a );
1911
buf_appendf( buf, ".%s \"%s\"\n", MEMBER_OO_UNARY, name );
1979
vips_buf_appendf( buf, ".%s \"%s\"\n", MEMBER_OO_UNARY, name );
1913
trace_text( flags, buf_all( buf ) );
1981
trace_text( flags, "%s", vips_buf_all( buf ) );
1918
1986
/* Look up a.dispatch_unary and build
1919
* (a.dispatch_unary "minus") application.
1987
* (a.oo_unary "minus") application.
1921
1989
if( !class_get_member( a, MEMBER_OO_UNARY, NULL, &fn ) )
1922
1990
action_uoperror( rc, compile, error_get_sub(), op, name, a );
1964
2036
PEPOINTRIGHT( arg[1], &a );
1966
2038
if( trace_flags & flags ) {
1967
BufInfo *buf = trace_push();
2039
VipsBuf *buf = trace_push();
1969
buf_appendf( buf, "\"%s\" ", name );
2041
vips_buf_appendf( buf, "\"%s\" ", name );
1970
2042
trace_args( arg, nargs );