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