changeset 2532:0e5eb97cb137

[project @ 1996-11-19 18:13:48 by jwe]
author jwe
date Tue, 19 Nov 1996 18:16:21 +0000
parents d21eb2d6e135
children 987e934bbb8c
files src/help.cc src/pt-const.cc src/pt-const.h src/pt-exp.h
diffstat 4 files changed, 49 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/help.cc	Tue Nov 19 18:13:18 1996 +0000
+++ b/src/help.cc	Tue Nov 19 18:16:21 1996 +0000
@@ -724,9 +724,6 @@
 
   begin_unwind_frame ("Ftype");
 
-  unwind_protect_str (Vps4);
-  Vps4 = "";
-
   int argc = args.length () + 1;
 
   string_vector argv = args.make_argv ("type");
@@ -738,12 +735,25 @@
     {
       // XXX FIXME XXX -- we should really use getopt ()
 
-      int quiet = 0;
-      int idx = 1;
-      if (argv[idx] == "-q")
+      bool quiet = false;
+      bool pr_orig_txt = true;
+
+      int idx;
+
+      for (idx = 1; idx < argc; idx++)
 	{
-	  quiet = 1;
-	  idx++;
+	  if (argv[idx] == "-q" || argv[idx] == "-quiet")
+	    quiet = true;
+	  else if (argv[idx] == "-t" || argv[idx] == "-transformed")
+	    pr_orig_txt = false;
+	  else
+	    break;
+	}
+
+      if (idx == argc)
+	{
+	  print_usage ("type");
+	  return retval;
 	}
 
       ostrstream output_buf;
@@ -775,7 +785,7 @@
 		  if (nargout == 0 && ! quiet)
 		    output_buf << argv[i] << " is a user-defined function\n";
 
-		  tree_print_code tpc (output_buf);
+		  tree_print_code tpc (output_buf, "", pr_orig_txt);
 
 		  defn->accept (tpc);
 		}
@@ -831,7 +841,7 @@
 		    }
 		  if (! tmp->is_map ())
 		    {
-		      tree_print_code tpc (output_buf);
+		      tree_print_code tpc (output_buf, "", pr_orig_txt);
 
 		      tmp->accept (tpc);
 
@@ -860,8 +870,6 @@
   else
     print_usage ("type");
 
-  run_unwind_frame ("Ftype");
-
   return retval;
 }
 
--- a/src/pt-const.cc	Tue Nov 19 18:13:18 1996 +0000
+++ b/src/pt-const.cc	Tue Nov 19 18:16:21 1996 +0000
@@ -76,6 +76,15 @@
 {
 }
 
+void
+tree_constant::print (ostream& os, bool pr_as_read_syntax, bool pr_orig_text)
+{
+  if (pr_orig_text && ! orig_text.empty ())
+    os << orig_text;
+  else
+    val.print (os, pr_as_read_syntax);
+}
+
 octave_value
 tree_constant::eval (bool print_result)
 {
@@ -115,6 +124,18 @@
 }
 
 void
+tree_constant::stash_original_text (const string& s)
+{
+  orig_text = s;
+}
+
+string
+tree_constant::original_text (void) const
+{
+  return orig_text;
+}
+
+void
 tree_constant::accept (tree_walker& tw)
 {
   tw.visit_constant (*this);
--- a/src/pt-const.h	Tue Nov 19 18:13:18 1996 +0000
+++ b/src/pt-const.h	Tue Nov 19 18:16:21 1996 +0000
@@ -281,12 +281,12 @@
   Octave_map map_value (void) const;
 
   octave_value lookup_map_element (const string& ref,
-				    bool insert = false,
-				    bool silent = false);
+				   bool insert = false,
+				   bool silent = false);
 
   octave_value lookup_map_element (SLList<string>& list,
-				    bool insert = false,
-				    bool silent = false);
+				   bool insert = false,
+				   bool silent = false);
 
   ColumnVector vector_value (bool /* frc_str_conv */ = false,
 			     bool /* frc_vec_conv */ = false) const 
@@ -325,8 +325,8 @@
   void decrement (void) { val.decrement (); }
 
   void print (void);
-  void print (ostream& os, bool pr_as_read_syntax = false)
-    { val.print (os, pr_as_read_syntax); }
+  void print (ostream& os, bool pr_as_read_syntax = false,
+	      bool pr_orig_txt = true);
 
   void print_with_name (const string& name, bool print_padding = true);
   void print_with_name (ostream& os, const string& name,
@@ -339,9 +339,9 @@
   // Store the original text corresponding to this constant for later
   // pretty printing.
 
-  void stash_original_text (const string& s) { orig_text = s; }
+  void stash_original_text (const string& s);
 
-  string original_text (void) { return orig_text; }
+  string original_text (void) const;
 
   void accept (tree_walker& tw);
 
--- a/src/pt-exp.h	Tue Nov 19 18:13:18 1996 +0000
+++ b/src/pt-exp.h	Tue Nov 19 18:16:21 1996 +0000
@@ -391,8 +391,6 @@
       delete op_increment;
     }
 
-  bool is_range_constant (void) const;
-
   tree_colon_expression *chain (tree_expression *t);
 
   octave_value eval (bool print);