diff src/pt-cmd.h @ 578:d169be9237fb

[project @ 1994-08-03 20:06:54 by jwe]
author jwe
date Wed, 03 Aug 1994 20:07:26 +0000
parents 7ea224e713cd
children bc813f5eb025
line wrap: on
line diff
--- a/src/pt-cmd.h	Wed Aug 03 20:06:54 1994 +0000
+++ b/src/pt-cmd.h	Wed Aug 03 20:07:26 1994 +0000
@@ -28,13 +28,15 @@
 #pragma interface
 #endif
 
+class tree_statement_list;
+class tree_global_init_list;
+class tree_if_command_list;
 class tree_expression;
 class tree_index_expression;
 class tree_constant;
 class symbol_record;
 
 class tree_command;
-class tree_command_list;
 class tree_global_command;
 class tree_while_command;
 class tree_for_command;
@@ -43,183 +45,172 @@
 class tree_continue_command;
 class tree_return_command;
 
-/*
- * A base class for commands.
- */
+#include "tree-base.h"
+
+// A base class for commands.
+
 class
 tree_command : public tree
 {
+public:
+  tree_command (int l = -1, int c = -1) : tree (l, c) { }
+
+  virtual void eval (void) = 0;
 };
 
-/*
- * A command or two to be executed.
- */
-class
-tree_command_list : public tree_command
-{
- public:
-  tree_command_list (void);
-  tree_command_list (tree *t);
-
-  ~tree_command_list (void);
-
-  tree_command_list *chain (tree *t);
-  tree_command_list *reverse (void);
-
-  void set_print_flag (int print);
-
-  tree_constant eval (int print);
-
- private:
-  tree *command;		// Command to execute.
-  int print_flag;		// Print result of eval for this command?
-  tree_command_list *next;	// Next command in list.
-};
-
-/*
- * Global.
- */
 class
 tree_global_command : public tree_command
 {
  public:
-  tree_global_command (int l = -1, int c = -1);
-  tree_global_command (symbol_record *s, int l = -1, int c = -1);
-  tree_global_command (symbol_record *s, tree_expression *e,
-		       int l = -1, int c = -1); 
+  tree_global_command (int l = -1, int c = -1) : tree_command (l, c)
+    { init_list = 0; }
+
+  tree_global_command (tree_global_init_list *t, int l = -1, int c = -1)
+    : tree_command (l, c)
+      { init_list = t; }
 
   ~tree_global_command (void);
 
-  tree_global_command *chain (symbol_record *s, int l = -1, int c = -1);
-  tree_global_command *chain (symbol_record *s, tree_expression *e,
-			      int l = -1, int c = -1);
-  tree_global_command *reverse (void);
-
-  tree_constant eval (int print);
+  void eval (void);
 
-  void eval_error (void);
-
- private:
-  symbol_record *sr;		// Symbol record from local symbol table.
-  tree_expression *rhs;		// RHS of assignment.
-  tree_global_command *next;	// Next global command.
+private:
+  tree_global_init_list *init_list;
 };
 
-/*
- * While.
- */
+// While.
+
 class
 tree_while_command : public tree_command
 {
  public:
-  tree_while_command (int l = -1, int c = -1);
-  tree_while_command (tree_expression *e, int l = -1, int c = -1);
-  tree_while_command (tree_expression *e, tree *lst, int l = -1, int c = -1);
+  tree_while_command (int l = -1, int c = -1) : tree_command (l, c)
+    {
+      expr = 0;
+      list = 0;
+    }
+
+  tree_while_command (tree_expression *e, int l = -1, int c = -1)
+    : tree_command (l, c)
+      {
+	expr = e;
+	list = 0;
+      }
+
+  tree_while_command (tree_expression *e, tree_statement_list *lst,
+		      int l = -1, int c = -1)
+    : tree_command (l, c)
+      {
+	expr = e;
+	list = lst;
+      }
 
   ~tree_while_command (void);
 
-  tree_constant eval (int print);
+  void eval (void);
 
   void eval_error (void);
 
  private:
   tree_expression *expr;	// Expression to test.
-  tree *list;			// List of commands to execute.
+  tree_statement_list *list;	// List of commands to execute.
 };
 
-/*
- * For.
- */
+// For.
+
 class
 tree_for_command : public tree_command
 {
  public:
-  tree_for_command (int l = -1, int c = -1);
-  tree_for_command (tree_index_expression *id, tree_expression *e, tree *lst,
-		    int l = -1, int c = -1);
+  tree_for_command (int l = -1, int c = -1) : tree_command (l, c)
+    {
+      id = 0;
+      expr = 0;
+      list = 0;
+    }
+
+  tree_for_command (tree_index_expression *ident, tree_expression *e,
+		    tree_statement_list *lst, int l = -1, int c = -1)
+    : tree_command (l, c)
+      {
+	id = ident;
+	expr = e;
+	list = lst;
+      }
 
   ~tree_for_command (void);
 
-  tree_constant eval (int print);
+  void eval (void);
 
   void eval_error (void);
 
  private:
-  tree_constant do_for_loop_once (tree_constant *rhs, int& quit);
+  void do_for_loop_once (tree_constant *rhs, int& quit);
 
   tree_index_expression *id;	// Identifier to modify.
   tree_expression *expr;	// Expression to evaluate.
-  tree *list;			// List of commands to execute.
+  tree_statement_list *list;	// List of commands to execute.
 };
 
-/*
- * Simple if.
- */
+// If.
+
 class
 tree_if_command : public tree_command
 {
  public:
-  tree_if_command (int l = -1, int c = -1);
-  tree_if_command (tree *lst, int l = -1, int c = -1);
-  tree_if_command (tree_expression *e, tree *lst, int l = -1, int c = -1);
+  tree_if_command (int l = -1, int c = -1) : tree_command (l, c)
+    { list = 0; }
+
+  tree_if_command (tree_if_command_list *lst, int l = -1, int c = -1)
+    : tree_command (l, c)
+      { list = lst; }
 
   ~tree_if_command (void);
 
-  tree_if_command *chain (tree *lst, int l = -1, int c = -1);
-  tree_if_command *chain (tree_expression *e, tree *lst, int l = -1,
-			  int c = -1);
-  tree_if_command *reverse (void);
-
-  tree_constant eval (int print);
+  void eval (void);
 
   void eval_error (void);
 
  private:
-  tree_expression *expr;	// Expression to test.
-  tree *list;			// Commands to execute.
-  tree_if_command *next;	// Next if command.
+  tree_if_command_list *list;
 };
 
-/*
- * Break.
- */
+// Break.
+
 class
 tree_break_command : public tree_command
 {
  public:
-  tree_break_command (int l = -1, int c = -1);
+  tree_break_command (int l = -1, int c = -1) : tree_command (l, c) { }
 
-  ~tree_break_command (void);
+  ~tree_break_command (void) { }
 
-  tree_constant eval (int print);
+  void eval (void);
 };
 
-/*
- * Continue.
- */
+// Continue.
+
 class
 tree_continue_command : public tree_command
 {
  public:
-  tree_continue_command (int l = -1, int c = -1);
+  tree_continue_command (int l = -1, int c = -1) : tree_command (l, c) { }
 
-  ~tree_continue_command (void);
+  ~tree_continue_command (void) { }
 
-  tree_constant eval (int print);
+  void eval (void);
 };
 
-/*
- * Return.
- */
+// Return.
+
 class
 tree_return_command : public tree_command
 {
- public:
-  tree_return_command (int l = -1, int c = -1);
+public:
+  tree_return_command (int l = -1, int c = -1) : tree_command (l, c) { }
 
-  ~tree_return_command (void);
+  ~tree_return_command (void) { }
 
-  tree_constant eval (int print);
+  void eval (void);
 };
 
 #endif