comparison src/pt-exp-base.cc @ 636:fae2bd91c027

[project @ 1994-08-23 18:39:50 by jwe]
author jwe
date Tue, 23 Aug 1994 18:39:50 +0000
parents 8e4e7e5f307e
children 95c7e27b2df7
comparison
equal deleted inserted replaced
635:5338832d2cf6 636:fae2bd91c027
312 { 312 {
313 retval = tree_constant (Matrix ()); 313 retval = tree_constant (Matrix ());
314 goto done; 314 goto done;
315 } 315 }
316 316
317 Octave_object otmp = elem->eval (0); 317 tree_constant tmp = elem->eval (0);
318 tree_constant tmp = otmp(0);
319 if (error_state || tmp.is_undefined ()) 318 if (error_state || tmp.is_undefined ())
320 { 319 {
321 retval = tree_constant (); 320 retval = tree_constant ();
322 goto done; 321 goto done;
323 } 322 }
494 { 493 {
495 memcpy (str_ptr, tmp.string_value (), nc); 494 memcpy (str_ptr, tmp.string_value (), nc);
496 str_ptr += nc; 495 str_ptr += nc;
497 } 496 }
498 } 497 }
499 else if (tmp.is_range ()) 498 else if (tmp.is_real_matrix () || tmp.is_range ())
500 {
501 tmp.force_numeric (1);
502 if (tmp.is_real_scalar ())
503 m (put_row, put_col) = tmp.double_value ();
504 else if (tmp.is_real_matrix ())
505 m.insert (tmp.matrix_value (), put_row, put_col);
506 else
507 panic_impossible ();
508 }
509 else if (tmp.is_real_matrix ())
510 { 499 {
511 cm.insert (tmp.matrix_value (), put_row, put_col); 500 cm.insert (tmp.matrix_value (), put_row, put_col);
512 } 501 }
513 else if (tmp.is_complex_scalar ()) 502 else if (tmp.is_complex_scalar ())
514 { 503 {
535 { 524 {
536 memcpy (str_ptr, tmp.string_value (), nc); 525 memcpy (str_ptr, tmp.string_value (), nc);
537 str_ptr += nc; 526 str_ptr += nc;
538 } 527 }
539 } 528 }
540 else if (tmp.is_range ()) 529 else if (tmp.is_real_matrix () || tmp.is_range ())
541 {
542 tmp.force_numeric (1);
543 if (tmp.is_real_scalar ())
544 m (put_row, put_col) = tmp.double_value ();
545 else if (tmp.is_real_matrix ())
546 m.insert (tmp.matrix_value (), put_row, put_col);
547 else
548 panic_impossible ();
549 }
550 else if (tmp.is_real_matrix ())
551 { 530 {
552 m.insert (tmp.matrix_value (), put_row, put_col); 531 m.insert (tmp.matrix_value (), put_row, put_col);
553 } 532 }
554 else 533 else
555 { 534 {
1232 case tree_expression::uminus: 1211 case tree_expression::uminus:
1233 case tree_expression::hermitian: 1212 case tree_expression::hermitian:
1234 case tree_expression::transpose: 1213 case tree_expression::transpose:
1235 if (op) 1214 if (op)
1236 { 1215 {
1237 Octave_object tmp = op->eval (0); 1216 tree_constant u = op->eval (0);
1238 tree_constant u = tmp(0);
1239 if (error_state) 1217 if (error_state)
1240 eval_error (); 1218 eval_error ();
1241 else if (u.is_defined ()) 1219 else if (u.is_defined ())
1242 { 1220 {
1243 ans = do_unary_op (u, etype); 1221 ans = do_unary_op (u, etype);
1345 case tree_expression::cmp_ne: 1323 case tree_expression::cmp_ne:
1346 case tree_expression::and: 1324 case tree_expression::and:
1347 case tree_expression::or: 1325 case tree_expression::or:
1348 if (op1) 1326 if (op1)
1349 { 1327 {
1350 Octave_object tmp = op1->eval (0); 1328 tree_constant a = op1->eval (0);
1351 tree_constant a = tmp(0);
1352 if (error_state) 1329 if (error_state)
1353 eval_error (); 1330 eval_error ();
1354 else if (a.is_defined () && op2) 1331 else if (a.is_defined () && op2)
1355 { 1332 {
1356 tmp = op2->eval (0); 1333 tree_constant b = op2->eval (0);
1357 tree_constant b = tmp (0);
1358 if (error_state) 1334 if (error_state)
1359 eval_error (); 1335 eval_error ();
1360 else if (b.is_defined ()) 1336 else if (b.is_defined ())
1361 { 1337 {
1362 ans = do_binary_op (a, b, etype); 1338 ans = do_binary_op (a, b, etype);
1374 case tree_expression::or_or: 1350 case tree_expression::or_or:
1375 { 1351 {
1376 int result = 0; 1352 int result = 0;
1377 if (op1) 1353 if (op1)
1378 { 1354 {
1379 Octave_object tmp = op1->eval (0); 1355 tree_constant a = op1->eval (0);
1380 tree_constant a = tmp(0);
1381 if (error_state) 1356 if (error_state)
1382 { 1357 {
1383 eval_error (); 1358 eval_error ();
1384 break; 1359 break;
1385 } 1360 }
1408 } 1383 }
1409 } 1384 }
1410 1385
1411 if (op2) 1386 if (op2)
1412 { 1387 {
1413 tmp = op2->eval (0); 1388 tree_constant b = op2->eval (0);
1414 tree_constant b = tmp(0);
1415 if (error_state) 1389 if (error_state)
1416 { 1390 {
1417 eval_error (); 1391 eval_error ();
1418 break; 1392 break;
1419 } 1393 }
1533 if (error_state) 1507 if (error_state)
1534 return retval; 1508 return retval;
1535 1509
1536 if (rhs) 1510 if (rhs)
1537 { 1511 {
1538 Octave_object tmp = rhs->eval (0); 1512 tree_constant rhs_val = rhs->eval (0);
1539 tree_constant rhs_val = tmp(0);
1540 if (error_state) 1513 if (error_state)
1541 { 1514 {
1542 if (error_state) 1515 if (error_state)
1543 eval_error (); 1516 eval_error ();
1544 } 1517 }
1842 tree_constant retval; 1815 tree_constant retval;
1843 1816
1844 if (error_state || ! op1 || ! op2) 1817 if (error_state || ! op1 || ! op2)
1845 return retval; 1818 return retval;
1846 1819
1847 Octave_object otmp = op1->eval (0); 1820 tree_constant tmp = op1->eval (0);
1848 tree_constant tmp = otmp(0);
1849 1821
1850 if (tmp.is_undefined ()) 1822 if (tmp.is_undefined ())
1851 { 1823 {
1852 eval_error ("invalid null value in colon expression"); 1824 eval_error ("invalid null value in colon expression");
1853 return retval; 1825 return retval;
1854 } 1826 }
1855 1827
1856 tmp = tmp.make_numeric (); 1828 double base = tmp.double_value ();
1857 if (! tmp.is_scalar_type ()) 1829
1858 { 1830 if (error_state)
1859 eval_error ("base for colon expression must be a scalar"); 1831 {
1832 eval_error ("evaluating colon expression");
1860 return retval; 1833 return retval;
1861 } 1834 }
1862 double base = tmp.double_value (); 1835
1863 1836 tmp = op2->eval (0);
1864 otmp = op2->eval (0);
1865 tmp = otmp(0);
1866 1837
1867 if (tmp.is_undefined ()) 1838 if (tmp.is_undefined ())
1868 { 1839 {
1869 eval_error ("invalid null value in colon expression"); 1840 eval_error ("invalid null value in colon expression");
1870 return retval; 1841 return retval;
1871 } 1842 }
1872 1843
1873 tmp = tmp.make_numeric (); 1844 double limit = tmp.double_value ();
1874 if (! tmp.is_scalar_type ()) 1845
1875 { 1846 if (error_state)
1876 eval_error ("limit for colon expression must be a scalar"); 1847 {
1848 eval_error ("evaluating colon expression");
1877 return retval; 1849 return retval;
1878 } 1850 }
1879 double limit = tmp.double_value ();
1880 1851
1881 double inc = 1.0; 1852 double inc = 1.0;
1882 if (op3) 1853 if (op3)
1883 { 1854 {
1884 otmp = op3->eval (0); 1855 tmp = op3->eval (0);
1885 tmp = otmp(0);
1886 1856
1887 if (tmp.is_undefined ()) 1857 if (tmp.is_undefined ())
1888 { 1858 {
1889 eval_error ("invalid null value in colon expression"); 1859 eval_error ("invalid null value in colon expression");
1890 return retval; 1860 return retval;
1891 } 1861 }
1892 1862
1893 tmp = tmp.make_numeric (); 1863 inc = tmp.double_value ();
1894 if (! tmp.is_scalar_type ()) 1864
1895 { 1865 if (error_state)
1896 eval_error ("increment for colon expression must be a scalar"); 1866 {
1867 eval_error ("evaluating colon expression");
1897 return retval; 1868 return retval;
1898 } 1869 }
1899 else
1900 inc = tmp.double_value ();
1901 } 1870 }
1902 1871
1903 retval = tree_constant (base, limit, inc); 1872 retval = tree_constant (base, limit, inc);
1904 1873
1905 if (error_state) 1874 if (error_state)