Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/pt-id.cc @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/parse-tree/pt-id.cc@46b19589b593 |
children | 44d6ffdf9479 |
rev | line source |
---|---|
2887 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2887 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2887 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2887 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "error.h" | |
28 #include "oct-obj.h" | |
2979 | 29 #include "oct-lvalue.h" |
2900 | 30 #include "pager.h" |
3770 | 31 #include "pt-bp.h" |
2887 | 32 #include "pt-const.h" |
33 #include "pt-id.h" | |
34 #include "pt-walk.h" | |
2900 | 35 #include "symtab.h" |
2887 | 36 #include "utils.h" |
2956 | 37 #include "variables.h" |
2887 | 38 |
39 // Symbols from the symbol table. | |
40 | |
41 void | |
42 tree_identifier::eval_undefined_error (void) | |
43 { | |
44 int l = line (); | |
45 int c = column (); | |
46 | |
10443
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
47 maybe_missing_function_hook (name ()); |
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
48 if (error_state) |
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
49 return; |
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
50 |
2887 | 51 if (l == -1 && c == -1) |
14871
26c4ca9782b0
Give message id to undefined function error
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14846
diff
changeset
|
52 ::error_with_id ("Octave:undefined-function", |
26c4ca9782b0
Give message id to undefined function error
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14846
diff
changeset
|
53 "`%s' undefined", name ().c_str ()); |
2887 | 54 else |
14871
26c4ca9782b0
Give message id to undefined function error
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14846
diff
changeset
|
55 ::error_with_id ("Octave:undefined-function", |
26c4ca9782b0
Give message id to undefined function error
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14846
diff
changeset
|
56 "`%s' undefined near line %d column %d", |
26c4ca9782b0
Give message id to undefined function error
Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
parents:
14846
diff
changeset
|
57 name ().c_str (), l, c); |
2887 | 58 } |
59 | |
60 octave_value_list | |
2971 | 61 tree_identifier::rvalue (int nargout) |
2887 | 62 { |
63 octave_value_list retval; | |
64 | |
65 if (error_state) | |
66 return retval; | |
67 | |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
68 octave_value val = sym->find (); |
2887 | 69 |
7336 | 70 if (val.is_defined ()) |
2887 | 71 { |
7336 | 72 // GAGME -- this would be cleaner if we required |
73 // parens to indicate function calls. | |
74 // | |
75 // If this identifier refers to a function, we need to know | |
76 // whether it is indexed so that we can do the same thing | |
77 // for `f' and `f()'. If the index is present, return the | |
78 // function object and let tree_index_expression::rvalue | |
79 // handle indexing. Otherwise, arrange to call the function | |
80 // here, so that we don't return the function definition as | |
81 // a value. | |
82 | |
83 if (val.is_function () && ! is_postfix_indexed ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
84 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
85 octave_value_list tmp_args; |
2887 | 86 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
87 retval = val.do_multi_index_op (nargout, tmp_args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
88 } |
2887 | 89 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
90 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
91 if (print_result () && nargout == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
92 val.print_with_name (octave_stdout, name ()); |
7336 | 93 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
94 retval = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
95 } |
2887 | 96 } |
7336 | 97 else |
98 eval_undefined_error (); | |
2887 | 99 |
100 return retval; | |
101 } | |
102 | |
2971 | 103 octave_value |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
104 tree_identifier::rvalue1 (int nargout) |
2971 | 105 { |
106 octave_value retval; | |
107 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
108 octave_value_list tmp = rvalue (nargout); |
2971 | 109 |
110 if (! tmp.empty ()) | |
111 retval = tmp(0); | |
112 | |
113 return retval; | |
114 } | |
115 | |
2979 | 116 octave_lvalue |
2971 | 117 tree_identifier::lvalue (void) |
118 { | |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
119 return octave_lvalue (&(sym->varref ())); |
2971 | 120 } |
121 | |
5861 | 122 tree_identifier * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
123 tree_identifier::dup (symbol_table::scope_id sc, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
124 symbol_table::context_id) const |
5861 | 125 { |
7336 | 126 // The new tree_identifier object contains a symbol_record |
127 // entry from the duplicated scope. | |
5861 | 128 |
7336 | 129 // FIXME -- is this the best way? |
130 symbol_table::symbol_record new_sym | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
131 = symbol_table::find_symbol (name (), sc); |
7336 | 132 |
133 tree_identifier *new_id | |
134 = new tree_identifier (new_sym, line (), column ()); | |
5861 | 135 |
136 new_id->copy_base (*this); | |
137 | |
138 return new_id; | |
139 } | |
140 | |
2887 | 141 void |
142 tree_identifier::accept (tree_walker& tw) | |
143 { | |
144 tw.visit_identifier (*this); | |
145 } |