Mercurial > octave-nkf
comparison src/ov-fcn-handle.cc @ 11060:54697b37d8bf
replace Octave_map->octave_scalar_map in oct-parse.yy and ov-fcn-handle.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 30 Sep 2010 09:13:37 +0200 |
parents | 4ab04ea74b08 |
children | 883b9308353c |
comparison
equal
deleted
inserted
replaced
11059:4ffa19147604 | 11060:54697b37d8bf |
---|---|
1599 { | 1599 { |
1600 octave_function *fcn = fh ? fh->function_value () : 0; | 1600 octave_function *fcn = fh ? fh->function_value () : 0; |
1601 | 1601 |
1602 if (fcn) | 1602 if (fcn) |
1603 { | 1603 { |
1604 Octave_map m; | 1604 octave_scalar_map m; |
1605 | 1605 |
1606 std::string fh_nm = fh->fcn_name (); | 1606 std::string fh_nm = fh->fcn_name (); |
1607 | 1607 |
1608 if (fh_nm == octave_fcn_handle::anonymous) | 1608 if (fh_nm == octave_fcn_handle::anonymous) |
1609 { | 1609 { |
1610 std::ostringstream buf; | 1610 std::ostringstream buf; |
1611 fh->print_raw (buf); | 1611 fh->print_raw (buf); |
1612 m.assign ("function", buf.str ()); | 1612 m.setfield ("function", buf.str ()); |
1613 | 1613 |
1614 m.assign ("type", "anonymous"); | 1614 m.setfield ("type", "anonymous"); |
1615 } | 1615 } |
1616 else | 1616 else |
1617 { | 1617 { |
1618 m.assign ("function", fh_nm); | 1618 m.setfield ("function", fh_nm); |
1619 | 1619 |
1620 if (fcn->is_nested_function ()) | 1620 if (fcn->is_nested_function ()) |
1621 { | 1621 { |
1622 m.assign ("type", "subfunction"); | 1622 m.setfield ("type", "subfunction"); |
1623 Cell parentage (dim_vector (1, 2)); | 1623 Cell parentage (dim_vector (1, 2)); |
1624 parentage.elem(0) = fh_nm; | 1624 parentage.elem(0) = fh_nm; |
1625 parentage.elem(1) = fcn->parent_fcn_name (); | 1625 parentage.elem(1) = fcn->parent_fcn_name (); |
1626 m.assign ("parentage", octave_value (parentage)); | 1626 m.setfield ("parentage", octave_value (parentage)); |
1627 } | 1627 } |
1628 else if (fcn->is_private_function ()) | 1628 else if (fcn->is_private_function ()) |
1629 m.assign ("type", "private"); | 1629 m.setfield ("type", "private"); |
1630 else if (fh->is_overloaded ()) | 1630 else if (fh->is_overloaded ()) |
1631 m.assign ("type", "overloaded"); | 1631 m.setfield ("type", "overloaded"); |
1632 else | 1632 else |
1633 m.assign ("type", "simple"); | 1633 m.setfield ("type", "simple"); |
1634 } | 1634 } |
1635 | 1635 |
1636 std::string nm = fcn->fcn_file_name (); | 1636 std::string nm = fcn->fcn_file_name (); |
1637 | 1637 |
1638 if (fh_nm == octave_fcn_handle::anonymous) | 1638 if (fh_nm == octave_fcn_handle::anonymous) |
1639 { | 1639 { |
1640 m.assign ("file", nm); | 1640 m.setfield ("file", nm); |
1641 | 1641 |
1642 octave_user_function *fu = fh->user_function_value (); | 1642 octave_user_function *fu = fh->user_function_value (); |
1643 | 1643 |
1644 std::list<symbol_table::symbol_record> vars | 1644 std::list<symbol_table::symbol_record> vars |
1645 = symbol_table::all_variables (fu->scope (), 0); | 1645 = symbol_table::all_variables (fu->scope (), 0); |
1646 | 1646 |
1647 size_t varlen = vars.size (); | 1647 size_t varlen = vars.size (); |
1648 | 1648 |
1649 if (varlen > 0) | 1649 if (varlen > 0) |
1650 { | 1650 { |
1651 Octave_map ws; | 1651 octave_scalar_map ws; |
1652 for (std::list<symbol_table::symbol_record>::const_iterator p = vars.begin (); | 1652 for (std::list<symbol_table::symbol_record>::const_iterator p = vars.begin (); |
1653 p != vars.end (); p++) | 1653 p != vars.end (); p++) |
1654 { | 1654 { |
1655 ws.assign (p->name (), p->varval (0)); | 1655 ws.assign (p->name (), p->varval (0)); |
1656 } | 1656 } |
1657 | 1657 |
1658 m.assign ("workspace", ws); | 1658 m.setfield ("workspace", ws); |
1659 } | 1659 } |
1660 } | 1660 } |
1661 else if (fcn->is_user_function () || fcn->is_user_script ()) | 1661 else if (fcn->is_user_function () || fcn->is_user_script ()) |
1662 { | 1662 { |
1663 octave_function *fu = fh->function_value (); | 1663 octave_function *fu = fh->function_value (); |
1664 m.assign ("file", fu->fcn_file_name ()); | 1664 m.setfield ("file", fu->fcn_file_name ()); |
1665 } | 1665 } |
1666 else | 1666 else |
1667 m.assign ("file", ""); | 1667 m.setfield ("file", ""); |
1668 | 1668 |
1669 retval = m; | 1669 retval = m; |
1670 } | 1670 } |
1671 else | 1671 else |
1672 error ("functions: invalid function handle object"); | 1672 error ("functions: invalid function handle object"); |