diff src/pt-decl.cc @ 8658:73c4516fae10

New evaluator and debugger derived from tree-walker class
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 00:47:53 -0500
parents 3100283874d7
children 35cd375d4bb3
line wrap: on
line diff
--- a/src/pt-decl.cc	Tue Feb 03 12:47:38 2009 +0100
+++ b/src/pt-decl.cc	Wed Feb 04 00:47:53 2009 -0500
@@ -55,7 +55,7 @@
     {
       octave_lvalue ult = id->lvalue ();
 
-      octave_value init_val = expr->rvalue ();
+      octave_value init_val = expr->rvalue1 ();
 
       if (! error_state)
 	{
@@ -84,20 +84,6 @@
 
 // Initializer lists for declaration statements.
 
-void
-tree_decl_init_list::eval (tree_decl_elt::eval_fcn f)
-{
-  for (iterator p = begin (); p != end (); p++)
-    {
-      tree_decl_elt *elt = *p;
-
-      f (*elt);
-
-      if (error_state)
-	break;
-    }
-}
-
 tree_decl_init_list *
 tree_decl_init_list::dup (symbol_table::scope_id scope,
 			  symbol_table::context_id context)
@@ -127,53 +113,8 @@
   delete init_list;
 }
 
-void
-tree_decl_command::accept (tree_walker& tw)
-{
-  tw.visit_decl_command (*this);
-}
-
 // Global.
 
-void
-tree_global_command::do_init (tree_decl_elt& elt)
-{
-  tree_identifier *id = elt.ident ();
-
-  if (id)
-    {
-      id->mark_global ();
-
-      if (! error_state)
-	{
-	  octave_lvalue ult = id->lvalue ();
-
-	  if (ult.is_undefined ())
-	    {
-	      tree_expression *expr = elt.expression ();
-
-	      octave_value init_val;
-
-	      if (expr)
-		init_val = expr->rvalue ();
-	      else
-		init_val = Matrix ();
-
-	      ult.assign (octave_value::op_asn_eq, init_val);
-	    }
-	}
-    }
-}
-
-void
-tree_global_command::eval (void)
-{
-  MAYBE_DO_BREAKPOINT;
-
-  if (init_list)
-    init_list->eval (do_init);
-}
-
 tree_command *
 tree_global_command::dup (symbol_table::scope_id scope,
 			  symbol_table::context_id context)
@@ -183,45 +124,13 @@
 			     line (), column ());
 }
 
-// Static.
-
 void
-tree_static_command::do_init (tree_decl_elt& elt)
+tree_global_command::accept (tree_walker& tw)
 {
-  tree_identifier *id = elt.ident ();
-
-  if (id)
-    {
-      id->mark_as_static ();
-
-      octave_lvalue ult = id->lvalue ();
-
-      if (ult.is_undefined ())
-	{
-	  tree_expression *expr = elt.expression ();
-
-	  octave_value init_val;
-
-	  if (expr)
-	    init_val = expr->rvalue ();
-	  else
-	    init_val = Matrix ();
-
-	  ult.assign (octave_value::op_asn_eq, init_val);
-	}
-    }
+  tw.visit_global_command (*this);
 }
 
-void
-tree_static_command::eval (void)
-{
-  MAYBE_DO_BREAKPOINT;
-
-  // Static variables only need to be marked and initialized once.
-
-  if (init_list)
-    init_list->eval (do_init);
-}
+// Static.
 
 tree_command *
 tree_static_command::dup (symbol_table::scope_id scope,
@@ -232,6 +141,12 @@
 			     line (), column ());
 }
 
+void
+tree_static_command::accept (tree_walker& tw)
+{
+  tw.visit_static_command (*this);
+}
+
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***