comparison src/ov-usr-fcn.h @ 7715:5b4d278ec828

parse scripts completely before executing
author John W. Eaton <jwe@octave.org>
date Wed, 16 Apr 2008 15:09:56 -0400
parents 443a8f5a50fd
children 87eda1f8faaa
comparison
equal deleted inserted replaced
7714:83ea845cda36 7715:5b4d278ec828
48 class 48 class
49 octave_user_script : public octave_function 49 octave_user_script : public octave_function
50 { 50 {
51 public: 51 public:
52 52
53 octave_user_script (void) { } 53 octave_user_script (void)
54 : octave_function (), cmd_list (0), file_name () { }
55
56 octave_user_script (const std::string& fnm, const std::string& nm,
57 tree_statement_list *cmds,
58 const std::string& ds = std::string ())
59 : octave_function (nm, ds), cmd_list (cmds), file_name (fnm) { }
54 60
55 octave_user_script (const std::string& fnm, const std::string& nm, 61 octave_user_script (const std::string& fnm, const std::string& nm,
56 const std::string& ds = std::string ()) 62 const std::string& ds = std::string ())
57 : octave_function (nm, ds), file_name (fnm) { } 63 : octave_function (nm, ds), cmd_list (0), file_name (fnm) { }
58 64
59 ~octave_user_script (void) { } 65 ~octave_user_script (void);
66
67 octave_function *function_value (bool = false) { return this; }
68
69 octave_user_script *user_script_value (bool = false) { return this; }
60 70
61 // Scripts and user functions are both considered "scripts" because 71 // Scripts and user functions are both considered "scripts" because
62 // they are written in Octave's scripting language. 72 // they are written in Octave's scripting language.
63 73
64 bool is_user_script (void) const { return true; } 74 bool is_user_script (void) const { return true; }
65 75
66 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } 76 void stash_fcn_file_name (const std::string& nm) { file_name = nm; }
67 77
78 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
79
80 void stash_fcn_file_time (const octave_time& t)
81 {
82 t_parsed = t;
83 mark_fcn_file_up_to_date (t);
84 }
85
68 std::string fcn_file_name (void) const { return file_name; } 86 std::string fcn_file_name (void) const { return file_name; }
87
88 octave_time time_parsed (void) const { return t_parsed; }
89
90 octave_time time_checked (void) const { return t_checked; }
91
92 octave_value subsref (const std::string& type,
93 const std::list<octave_value_list>& idx)
94 {
95 octave_value_list tmp = subsref (type, idx, 1);
96 return tmp.length () > 0 ? tmp(0) : octave_value ();
97 }
98
99 octave_value_list subsref (const std::string& type,
100 const std::list<octave_value_list>& idx,
101 int nargout);
69 102
70 octave_value_list 103 octave_value_list
71 do_multi_index_op (int nargout, const octave_value_list& args); 104 do_multi_index_op (int nargout, const octave_value_list& args);
72 105
106 tree_statement_list *body (void) { return cmd_list; }
107
108 void traceback_error (void) const;
109
110 void accept (tree_walker& tw);
111
73 private: 112 private:
74 113
75 // The name of the file to parse. 114 // The list of commands that make up the body of this function.
115 tree_statement_list *cmd_list;
116
117 // The name of the file we parsed.
76 std::string file_name; 118 std::string file_name;
119
120 // The time the file was parsed.
121 octave_time t_parsed;
122
123 // The time the file was last checked to see if it needs to be
124 // parsed again.
125 octave_time t_checked;
126
127 // Used to keep track of recursion depth.
128 int call_depth;
77 129
78 // No copying! 130 // No copying!
79 131
80 octave_user_script (const octave_user_script& f); 132 octave_user_script (const octave_user_script& f);
81 133