diff src/pt-cmd.cc @ 2764:2c0f259cf83d

[project @ 1997-03-01 02:30:26 by jwe]
author jwe
date Sat, 01 Mar 1997 02:30:29 +0000
parents 5c773d4745d6
children 9aeba8e006a4
line wrap: on
line diff
--- a/src/pt-cmd.cc	Sat Mar 01 02:14:33 1997 +0000
+++ b/src/pt-cmd.cc	Sat Mar 01 02:30:29 1997 +0000
@@ -517,6 +517,50 @@
   tw.visit_if_command (*this);
 }
 
+// Switch.
+
+tree_switch_command::~tree_switch_command (void)
+{
+  delete expr;
+  delete list;
+}
+
+void
+tree_switch_command::eval (void)
+{
+  if (expr)
+    {
+      octave_value val = expr->eval (0);
+
+      if (! error_state)
+	{
+	  if (list)
+	    list->eval (val);
+
+	  if (error_state)
+	    eval_error ();
+	}
+      else
+	eval_error ();
+    }
+  else
+    ::error ("missing value in switch command near line %d, column %d",
+	     line (), column ());
+}
+
+void
+tree_switch_command::eval_error (void)
+{
+  ::error ("evaluating switch command near line %d, column %d",
+	   line (), column ());
+}
+
+void
+tree_switch_command::accept (tree_walker& tw)
+{
+  tw.visit_switch_command (*this);
+}
+
 // Simple exception handling.
 
 tree_try_catch_command::~tree_try_catch_command (void)