Mercurial > octave-nkf
annotate libinterp/octave-value/ov-usr-fcn.h @ 15869:5e5705b3e505 classdef
Implement some embryonic handle-classdef semantic.
* libinterp/octave-value/ov-classdef.h (cdef_object_rep::subsasgn,
handle_cdef_object::subsasgn, octave_classdef::subsasgn): New method
declarations.
(handle_cdef_object::~handle_cdef_object): New destructor declaration.
(cdef_class::cdef_class_rep::handle_class): New boolean field.
(cdef_class::cdef_class_rep::cdef_class_rep): Initialize it.
(cdef_class::cdef_class_rep::mark_as_handle_class,
cdef_class::cdef_class_rep::is_handle_class, cdef_class::mark_as_handle_class,
cdef_class::is_handle_class): Manipulate it.
(cdef_class::cdef_class_rep::get_name): New method.
(cdef_class::get_name): Use it.
(cdef_class::cdef_class_rep::initialize_object,
cdef_class::cdef_class_rep::subsref_meta,
cdef_class::cdef_class_rep::run_constructor,
cdef_class::cdef_class_rep::construct, cdef_class:initialize_object,
cdef_class::subsref_meta, cdef_class::run_constructor, cdef_class::construct):
New methods.
(cdef_class::cdef_class_rep::find_method, cdef_class::find_method):
Add "local" argument.
(cdef_class::cdef_class_rep::find_names, cdef_class::find_names): Change
signature to use std::set and a boolean flag.
(cdef_class::cdef_class_rep::find_methods, cdef_class::find_methods): Change
signature to use a boolean flag as second argument.
(cdef_class::make_meta_class): New static method.
(cdef_class::get_method_function, cdef_class::get_constructor_function): New
methods.
(cdef_property::cdef_property_rep::set_value, cdef_property::set_value):
Make cdef_object argument non const.
(cdef_property::cder_property_rep::is_relative_set): New method.
(cdef_property::get_get_access, cdef_property::get_set_access): Delete methods.
(cdef_property::check_get_access, cdef_property::check_set_access):
Remove string argument.
(cdef_method::get_access): Delete method.
(cdef_method::check_access): Remove string argument.
* libinterp/octave-value/ov-classdef.cc (gripe_method_access,
gripe_property_access): Support access specified as cell array of classes.
(make_function_of_class): New static function(s).
(check_access (std::string, std::string), superclass_access): Remove static
functions.
(lookup_class): Use symbol_table when class hasn't been loaded yet.
(lookup_classes): Returns std::list<cdef_class> instead of Cell.
(class_get_superclasses, class_get_inferiorclasses): Use it.
(to_ov (const std::list<cdef_class>&)): New static function.
(get_class_context, check_access (const cdef_class&, const octave_value&)):
Likewise.
(handle_cdef_object::subsref): Use new signature of access check methods.
(property_get_defaultvalue): New built-in property accessor.
(make_class): Change signature to support multiple inheritance. Set "Sealed" to
false by default. Determine value for HandleCompatible property and handle-class
representation.
(make_property): Take cdef_class as first argument. Add DefaultValue and
HasDefault properties. Call make_function_of_class for property accessors.
(make_attribute): Take cdef_class as first argument.
(make_method): Likewise. Call make_function_of_class.
(make_method (octave_builtin::fcn)): Do no construct a function handle object.
(octave_classdef::subsasgn, handle_cdef_object::subsasgn): New method.
(class octave_classdef_proxy): New class.
(cdef_class::get_method_function): Use it, new method.
(handle_cdef_object::~handle_cdef_object): New destructor.
(cdef_class_rep::find_method): New boolean "local" argument. When true, only
look into the current class, not in superclasses.
(cdef_class_rep::find_methods): New signature.
(cdef_class_rep::get_methods): Use it.
(cdef_class_rep::find_properties): New signature.
(cdef_class_rep::get_properties): Use it.
(cdef_class_rep::find_names): New signature.
(cdef_class_rep::get_names): Use it.
(cdef_class_rep::subsref_meta, cdef_class_rep::initialize_object,
cdef_class_rep::run_constructor, cdef_class_rep::construct): New methods.
(compute_attribute_value, attribute_to_string): New static functions.
(cdef_class::make_meta_class): Change signature, non const argument.
Implement it.
(cdef_property_rep::get_value): Do not check access here.
(cdef_property_rep::set_value, cdef_property_rep::is_recursive_set): New method.
(cdef_property_rep::check_get_access, cdef_property_rep::check_set_access,
cdef_method_rep::check_access): Use static check_access utility function.
(install_classdef): Adapt to change of signature of make_class. Mark meta
classes as sealed. Add HandleCompatible property to meta.class. Add
DefaultValue and HasDefault properties to meta.property.
* libinterp/parse-tree/pt-classdef.h (tree_classdef::make_meta_class):
Change return type to (octave_function *).
* libinterp/parse-tree/pt-classdef.cc (tree_classdef::make_meta_class):
Likewise. Call cdef_class::get_constructor_function.
* libinterp/parse-tree/oct-parse.yy (parse_fcn_file): Adapt to new
signature of tree_classdef::make_meta_class.
* libinterp/octave-value/ov-fcn.h (octave_function::is_classdef_constructor):
New virtual method.
* libinterp/octave-value/ov-usr-fcn.h
(octave_user_function::class_ctor_type): New private enum.
(octave_user_function::mark_as_class_constructor,
octave_user_function::is_class_constructor): Use it.
(octave_user_function::mark_as_classdef_constructor,
octave_user_function::is_classdef_constructor): New methods.
(octave_user_function::class_constructor): Turn into class_ctor_type.
* libinterp/octave-value/of-usr-fcn.cc
(octave_user_function::octave_user_function): Initialize class_constructor.
(octave_user_function::do_multi_index_op): When function is a classdef
constructor, extract the first argument and use it to populate the first
output argument.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Tue, 01 Jan 2013 19:42:17 -0500 |
parents | 6823ad7a25b1 |
children | 2ed5bc680c71 |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2974 | 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. | |
2974 | 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/>. | |
2974 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_user_function_h) | |
24 #define octave_user_function_h 1 | |
25 | |
26 #include <ctime> | |
27 | |
28 #include <string> | |
4214 | 29 #include <stack> |
2974 | 30 |
3665 | 31 #include "comment-list.h" |
2974 | 32 #include "oct-obj.h" |
33 #include "ov-fcn.h" | |
34 #include "ov-typeinfo.h" | |
7336 | 35 #include "symtab.h" |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
36 #include "unwind-prot.h" |
2974 | 37 |
38 class string_vector; | |
39 | |
40 class octave_value; | |
41 class tree_parameter_list; | |
42 class tree_statement_list; | |
43 class tree_va_return_list; | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
44 class tree_expression; |
2974 | 45 class tree_walker; |
46 | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
47 #ifdef HAVE_LLVM |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
48 class jit_function_info; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
49 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
50 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 class |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
52 octave_user_code : public octave_function |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
53 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
54 public: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
55 octave_user_code (void) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
56 : octave_function () { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
57 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
58 ~octave_user_code (void) { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
59 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
60 bool is_user_code (void) const { return true; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
61 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
62 virtual tree_statement_list *body (void) = 0; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
63 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
64 protected: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
65 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
66 octave_user_code (const std::string& nm, |
10313 | 67 const std::string& ds = std::string ()) |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
68 : octave_function (nm, ds) { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
69 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
70 private: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
71 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
72 // No copying! |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
73 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
74 octave_user_code (const octave_user_code& f); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
75 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
76 octave_user_code& operator = (const octave_user_code& f); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
77 }; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
78 |
5744 | 79 // Scripts. |
80 | |
81 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
82 octave_user_script : public octave_user_code |
5744 | 83 { |
84 public: | |
85 | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
86 octave_user_script (void); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
87 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
88 octave_user_script (const std::string& fnm, const std::string& nm, |
10313 | 89 tree_statement_list *cmds, |
90 const std::string& ds = std::string ()); | |
5744 | 91 |
92 octave_user_script (const std::string& fnm, const std::string& nm, | |
10313 | 93 const std::string& ds = std::string ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
94 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
95 ~octave_user_script (void); |
5744 | 96 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
97 octave_function *function_value (bool = false) { return this; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
98 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
99 octave_user_script *user_script_value (bool = false) { return this; } |
5744 | 100 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
101 octave_user_code *user_code_value (bool = false) { return this; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
102 |
5744 | 103 // Scripts and user functions are both considered "scripts" because |
104 // they are written in Octave's scripting language. | |
105 | |
106 bool is_user_script (void) const { return true; } | |
107 | |
108 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } | |
109 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
110 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
111 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
112 void stash_fcn_file_time (const octave_time& t) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
113 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
114 t_parsed = t; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
115 mark_fcn_file_up_to_date (t); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
116 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
117 |
5744 | 118 std::string fcn_file_name (void) const { return file_name; } |
119 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
120 octave_time time_parsed (void) const { return t_parsed; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
121 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
122 octave_time time_checked (void) const { return t_checked; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
123 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
124 octave_value subsref (const std::string& type, |
10313 | 125 const std::list<octave_value_list>& idx) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
126 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
127 octave_value_list tmp = subsref (type, idx, 1); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
128 return tmp.length () > 0 ? tmp(0) : octave_value (); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
129 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
130 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
131 octave_value_list subsref (const std::string& type, |
10313 | 132 const std::list<octave_value_list>& idx, |
133 int nargout); | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
134 |
7336 | 135 octave_value_list |
136 do_multi_index_op (int nargout, const octave_value_list& args); | |
137 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
138 tree_statement_list *body (void) { return cmd_list; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
139 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
140 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
141 |
5744 | 142 private: |
143 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
144 // The list of commands that make up the body of this function. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
145 tree_statement_list *cmd_list; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
146 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
147 // The name of the file we parsed. |
5744 | 148 std::string file_name; |
149 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
150 // The time the file was parsed. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
151 octave_time t_parsed; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
152 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
153 // The time the file was last checked to see if it needs to be |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
154 // parsed again. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
155 octave_time t_checked; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
156 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
157 // Used to keep track of recursion depth. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
158 int call_depth; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
159 |
5744 | 160 // No copying! |
161 | |
162 octave_user_script (const octave_user_script& f); | |
163 | |
164 octave_user_script& operator = (const octave_user_script& f); | |
165 | |
166 DECLARE_OCTAVE_ALLOCATOR | |
167 | |
168 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
169 }; | |
170 | |
171 // User-defined functions. | |
2974 | 172 |
173 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
174 octave_user_function : public octave_user_code |
2974 | 175 { |
176 public: | |
177 | |
7336 | 178 octave_user_function (symbol_table::scope_id sid = -1, |
10313 | 179 tree_parameter_list *pl = 0, |
180 tree_parameter_list *rl = 0, | |
181 tree_statement_list *cl = 0); | |
2974 | 182 |
183 ~octave_user_function (void); | |
184 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
185 symbol_table::context_id active_context () const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
186 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
187 return is_anonymous_function () |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
188 ? 0 : static_cast<symbol_table::context_id>(call_depth); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
189 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
190 |
4654 | 191 octave_function *function_value (bool = false) { return this; } |
2974 | 192 |
4700 | 193 octave_user_function *user_function_value (bool = false) { return this; } |
194 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
195 octave_user_code *user_code_value (bool = false) { return this; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
196 |
2974 | 197 octave_user_function *define_param_list (tree_parameter_list *t); |
198 | |
199 octave_user_function *define_ret_list (tree_parameter_list *t); | |
200 | |
4343 | 201 void stash_fcn_file_name (const std::string& nm); |
2974 | 202 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
203 void stash_fcn_location (int line, int col) |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
204 { |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
205 location_line = line; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
206 location_column = col; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
207 } |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
208 |
6323 | 209 void stash_parent_fcn_name (const std::string& p) { parent_name = p; } |
210 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
211 void stash_parent_fcn_scope (symbol_table::scope_id ps) { parent_scope = ps; } |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
212 |
3665 | 213 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } |
214 | |
215 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } | |
216 | |
3325 | 217 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
3165 | 218 |
3255 | 219 void stash_fcn_file_time (const octave_time& t) |
3165 | 220 { |
221 t_parsed = t; | |
222 mark_fcn_file_up_to_date (t); | |
223 } | |
2974 | 224 |
4346 | 225 std::string fcn_file_name (void) const { return file_name; } |
2974 | 226 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
227 std::string profiler_name (void) const; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
228 |
6323 | 229 std::string parent_fcn_name (void) const { return parent_name; } |
230 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
231 symbol_table::scope_id parent_fcn_scope (void) const { return parent_scope; } |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
232 |
7336 | 233 symbol_table::scope_id scope (void) { return local_scope; } |
234 | |
4346 | 235 octave_time time_parsed (void) const { return t_parsed; } |
2974 | 236 |
4346 | 237 octave_time time_checked (void) const { return t_checked; } |
3165 | 238 |
2974 | 239 void mark_as_system_fcn_file (void); |
240 | |
4346 | 241 bool is_system_fcn_file (void) const { return system_fcn_file; } |
2974 | 242 |
4748 | 243 bool is_user_function (void) const { return true; } |
244 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
245 void erase_subfunctions (void) |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
246 { |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
247 symbol_table::erase_subfunctions_in_scope (local_scope); |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
248 } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
249 |
2974 | 250 bool takes_varargs (void) const; |
251 | |
5848 | 252 bool takes_var_return (void) const; |
2974 | 253 |
11445
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
254 void mark_as_private_function (const std::string& cname = std::string ()) |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
255 { |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
256 symbol_table::mark_subfunctions_in_scope_as_private (local_scope, cname); |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
257 |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
258 octave_function::mark_as_private_function (cname); |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
259 } |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
260 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
261 void lock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
262 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
263 void unlock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
264 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
265 octave_value_list all_va_args (const octave_value_list& args); |
2974 | 266 |
4748 | 267 void stash_function_name (const std::string& s) { my_name = s; } |
2974 | 268 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
269 void mark_as_subfunction (void) { subfunction = true; } |
4238 | 270 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
271 bool is_subfunction (void) const { return subfunction; } |
4238 | 272 |
6149 | 273 void mark_as_inline_function (void) { inline_function = true; } |
274 | |
275 bool is_inline_function (void) const { return inline_function; } | |
276 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
277 void mark_as_anonymous_function (void) { anonymous_function = true; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
278 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
279 bool is_anonymous_function (void) const { return anonymous_function; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
280 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
281 bool is_anonymous_function_of_class |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
282 (const std::string& cname = std::string ()) const |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
283 { |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
284 return anonymous_function |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
285 ? (cname.empty () |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
286 ? (! dispatch_class ().empty ()) |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
287 : cname == dispatch_class ()) |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
288 : false; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
289 } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
290 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
291 // If we are a special expression, then the function body consists of exactly |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
292 // one expression. The expression's result is the return value of the |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
293 // function. |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
294 bool is_special_expr (void) const |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
295 { |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
296 return is_inline_function () || is_anonymous_function (); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
297 } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
298 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
299 bool is_nested_function (void) const { return nested_function; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
300 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
301 void mark_as_nested_function (void) { nested_function = true; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
302 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
303 void mark_as_class_constructor (void) { class_constructor = legacy; } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
304 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
305 void mark_as_classdef_constructor (void) { class_constructor = classdef; } |
7336 | 306 |
11220
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
307 bool is_class_constructor (const std::string& cname = std::string ()) const |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
308 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
309 return class_constructor == legacy |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
310 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
311 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
312 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
313 bool is_classdef_constructor (const std::string& cname = std::string ()) const |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
314 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
315 return class_constructor == classdef |
11220
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
316 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
317 } |
7336 | 318 |
319 void mark_as_class_method (void) { class_method = true; } | |
320 | |
11220
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
321 bool is_class_method (const std::string& cname = std::string ()) const |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
322 { |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
323 return class_method |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
324 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
325 } |
7336 | 326 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
327 octave_value subsref (const std::string& type, |
10313 | 328 const std::list<octave_value_list>& idx) |
4271 | 329 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
330 octave_value_list tmp = subsref (type, idx, 1); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
331 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4271 | 332 } |
333 | |
4247 | 334 octave_value_list subsref (const std::string& type, |
10313 | 335 const std::list<octave_value_list>& idx, |
336 int nargout); | |
3933 | 337 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
338 octave_value_list subsref (const std::string& type, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
339 const std::list<octave_value_list>& idx, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
340 int nargout, const std::list<octave_lvalue>* lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
341 |
3544 | 342 octave_value_list |
343 do_multi_index_op (int nargout, const octave_value_list& args); | |
2974 | 344 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
345 octave_value_list |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
346 do_multi_index_op (int nargout, const octave_value_list& args, |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
347 const std::list<octave_lvalue>* lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
348 |
2974 | 349 tree_parameter_list *parameter_list (void) { return param_list; } |
350 | |
351 tree_parameter_list *return_list (void) { return ret_list; } | |
352 | |
353 tree_statement_list *body (void) { return cmd_list; } | |
354 | |
3665 | 355 octave_comment_list *leading_comment (void) { return lead_comm; } |
356 | |
357 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
358 | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
359 // If is_special_expr is true, retrieve the sigular expression that forms the |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
360 // body. May be null (even if is_special_expr is true). |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
361 tree_expression *special_expr (void); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
362 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
363 bool subsasgn_optimization_ok (void); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
364 |
2974 | 365 void accept (tree_walker& tw); |
366 | |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
367 template <class T> |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
368 bool local_protect (T& variable) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
369 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
370 if (curr_unwind_protect_frame) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
371 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
372 curr_unwind_protect_frame->protect_var (variable); |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
373 return true; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
374 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
375 else |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
376 return false; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
377 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
378 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
379 #ifdef HAVE_LLVM |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
380 jit_function_info *get_info (void) { return jit_info; } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
381 |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
382 void stash_info (jit_function_info *info) { jit_info = info; } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
383 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
384 |
7336 | 385 #if 0 |
3933 | 386 void print_symtab_info (std::ostream& os) const; |
7336 | 387 #endif |
3933 | 388 |
2974 | 389 private: |
390 | |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
391 enum class_ctor_type |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
392 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
393 none, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
394 legacy, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
395 classdef |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
396 }; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
397 |
2974 | 398 // List of arguments for this function. These are local variables. |
399 tree_parameter_list *param_list; | |
400 | |
401 // List of parameters we return. These are also local variables in | |
402 // this function. | |
403 tree_parameter_list *ret_list; | |
404 | |
405 // The list of commands that make up the body of this function. | |
406 tree_statement_list *cmd_list; | |
407 | |
3665 | 408 // The comments preceding the FUNCTION token. |
409 octave_comment_list *lead_comm; | |
410 | |
411 // The comments preceding the ENDFUNCTION token. | |
412 octave_comment_list *trail_comm; | |
413 | |
6323 | 414 // The name of the file we parsed. |
3523 | 415 std::string file_name; |
2974 | 416 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
417 // Location where this function was defined. |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
418 int location_line; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
419 int location_column; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
420 |
6323 | 421 // The name of the parent function, if any. |
422 std::string parent_name; | |
423 | |
2974 | 424 // The time the file was parsed. |
3255 | 425 octave_time t_parsed; |
2974 | 426 |
3165 | 427 // The time the file was last checked to see if it needs to be |
428 // parsed again. | |
3255 | 429 octave_time t_checked; |
3165 | 430 |
2974 | 431 // True if this function came from a file that is considered to be a |
432 // system function. This affects whether we check the time stamp | |
433 // on the file to see if it has changed. | |
434 bool system_fcn_file; | |
435 | |
436 // Used to keep track of recursion depth. | |
437 int call_depth; | |
438 | |
439 // The number of arguments that have names. | |
440 int num_named_args; | |
441 | |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
442 // TRUE means this subfunction of a primary function. |
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
443 bool subfunction; |
4238 | 444 |
6149 | 445 // TRUE means this is an inline function. |
446 bool inline_function; | |
447 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
448 // TRUE means this is an anonymous function. |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
449 bool anonymous_function; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
450 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
451 // TRUE means this is a nested function. (either a child or parent) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
452 bool nested_function; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
453 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
454 // Enum describing whether this function is the constructor for class object. |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
455 class_ctor_type class_constructor; |
7336 | 456 |
457 // TRUE means this function is a method for a class. | |
458 bool class_method; | |
459 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
460 // The scope of the parent function, if any. |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
461 symbol_table::scope_id parent_scope; |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
462 |
7336 | 463 symbol_table::scope_id local_scope; |
2974 | 464 |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
465 // pointer to the current unwind_protect frame of this function. |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
466 unwind_protect *curr_unwind_protect_frame; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
467 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
468 #ifdef HAVE_LLVM |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
469 jit_function_info *jit_info; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
470 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
471 |
7336 | 472 #if 0 |
2974 | 473 // The symbol record for argn in the local symbol table. |
7336 | 474 octave_value& argn_varref; |
2974 | 475 |
476 // The symbol record for nargin in the local symbol table. | |
7336 | 477 octave_value& nargin_varref; |
2974 | 478 |
479 // The symbol record for nargout in the local symbol table. | |
7336 | 480 octave_value& nargout_varref; |
2974 | 481 |
3974 | 482 // The symbol record for varargin in the local symbol table. |
7336 | 483 octave_value& varargin_varref; |
484 #endif | |
3974 | 485 |
2974 | 486 void print_code_function_header (void); |
487 | |
488 void print_code_function_trailer (void); | |
489 | |
490 void bind_automatic_vars (const string_vector& arg_names, int nargin, | |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
491 int nargout, const octave_value_list& va_args, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
492 const std::list<octave_lvalue> *lvalue_list); |
3219 | 493 |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
494 void restore_warning_states (void); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
495 |
4645 | 496 // No copying! |
497 | |
498 octave_user_function (const octave_user_function& fn); | |
499 | |
500 octave_user_function& operator = (const octave_user_function& fn); | |
501 | |
4612 | 502 DECLARE_OCTAVE_ALLOCATOR |
3219 | 503 |
4612 | 504 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 505 }; |
506 | |
507 #endif |