00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_tree_const_h)
00025 #define octave_tree_const_h 1
00026
00027 #include <iosfwd>
00028 #include <string>
00029
00030 #include "oct-alloc.h"
00031
00032 class octave_value_list;
00033 class tree_walker;
00034
00035 #include "ov.h"
00036 #include "pt-bp.h"
00037 #include "pt-exp.h"
00038 #include "symtab.h"
00039
00040 class
00041 tree_constant : public tree_expression
00042 {
00043 public:
00044
00045 tree_constant (int l = -1, int c = -1)
00046 : tree_expression (l, c), val (), orig_text () { }
00047
00048 tree_constant (const octave_value& v, int l = -1, int c = -1)
00049 : tree_expression (l, c), val (v), orig_text () { }
00050
00051 tree_constant (const octave_value& v, const std::string& ot,
00052 int l = -1, int c = -1)
00053 : tree_expression (l, c), val (v), orig_text (ot) { }
00054
00055 ~tree_constant (void) { }
00056
00057 bool has_magic_end (void) const { return false; }
00058
00059 void *operator new (size_t size) { return allocator.alloc (size); }
00060
00061 void operator delete (void *p, size_t size) { allocator.free (p, size); }
00062
00063
00064
00065 bool is_constant (void) const { return true; }
00066
00067 void maybe_mutate (void) { val.maybe_mutate (); }
00068
00069 void print (std::ostream& os, bool pr_as_read_syntax = false,
00070 bool pr_orig_txt = true);
00071
00072 void print_raw (std::ostream& os, bool pr_as_read_syntax = false,
00073 bool pr_orig_txt = true);
00074
00075 bool rvalue_ok (void) const { return true; }
00076
00077 octave_value rvalue1 (int = 1) { return val; }
00078
00079 octave_value_list rvalue (int nargout);
00080
00081 tree_expression *dup (symbol_table::scope_id scope,
00082 symbol_table::context_id context) const;
00083
00084 void accept (tree_walker& tw);
00085
00086
00087
00088
00089 void stash_original_text (const std::string& s) { orig_text = s; }
00090
00091 std::string original_text (void) const { return orig_text; }
00092
00093 private:
00094
00095
00096 static octave_allocator allocator;
00097
00098
00099 octave_value val;
00100
00101
00102 std::string orig_text;
00103
00104
00105
00106 tree_constant (const tree_constant&);
00107
00108 tree_constant& operator = (const tree_constant&);
00109 };
00110
00111 #endif
00112
00113
00114
00115
00116
00117