OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / a60 / stmt.c
1 /*
2  * Copyright (C) 1991,1992 Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de)
3  *
4  * This file is part of NASE A60.
5  * 
6  * NASE A60 is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * NASE A60 is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with NASE A60; see the file COPYING.  If not, write to the Free
18  * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * stmt.c:                                      aug '90
21  *
22  * Erik Schoenfelder (schoenfr@ibr.cs.tu-bs.de)
23  */
24
25 #include "comm.h"
26 #include "util.h"
27 #include "tree.h"
28 #include "run.h"
29
30
31 /*
32  * conacatenate the two stmts; if is_cont is set, mark the next
33  * element as continuation (used in if-then-else);
34  */
35
36 void
37 append_stmt (t1, t2, is_cont)
38 TREE **t1, *t2;
39 int is_cont;
40 {
41         TREE *last = (TREE *) 0;
42
43         while (*t1) {
44                 last = *t1;
45                 t1 = &(*t1)->next;
46         }
47
48         *t1 = t2;
49
50         if (is_cont) {
51                 if (! last)
52                         xabort ("INTERNAL: append_stmt: no last");
53                 last->is_cont = 1;
54         }
55 }
56
57
58 /*
59  * return new stmts. if-stmt, assign-stmt, goto-stmt.
60  */
61
62 TREE *
63 new_if_stmt (expr)
64 EXPR *expr;
65 {
66         TREE *new = new_tree (t_if_stmt);
67         new->runme = run_ifstmt;
68         new->u.ifstmt = TALLOC (IFSTMT);
69         new->u.ifstmt->cond = expr;
70         new->u.ifstmt->tthen = new->u.ifstmt->telse = (TREE *) 0;
71
72         /* better to get the expr, than the 'then' clause... */
73         new->lineno = expr->lineno;
74         new->source = expr->source;
75
76         return new;
77 }
78
79
80 TREE *
81 new_assign_stmt (lhelm, expr)
82 LHELM *lhelm;
83 EXPR *expr;
84 {
85         TREE *new = new_tree (t_assign_stmt);
86         new->runme = run_assign;
87         new->u.ass = TALLOC (ASSIGN);
88         new->u.ass->lhelm = lhelm;
89         new->u.ass->expr = expr;
90
91         return new;
92 }
93
94
95 TREE *
96 new_goto_stmt (expr)
97 EXPR *expr;
98 {
99         TREE *new = new_tree (t_goto_stmt);
100         new->runme = run_goto;
101         new->u.dexpr = expr;
102         return new;
103 }
104
105 /* end of stmt.c */