1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
* Copyright (C) 2001 Gerwin Klein <lsf@jflex.de> *
3
* Copyright (C) 2001 Bernhard Rumpe <rumpe@in.tum.de> *
4
* All rights reserved. *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License. See the file *
8
* COPYRIGHT for more information. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License along *
16
* with this program; if not, write to the Free Software Foundation, Inc., *
17
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
23
* AST node for if-then-else expressions
25
class Tifthenelse extends Texp implements AST {
26
Tboolexp boolexp; // condition
27
Texp exp1, exp2; // then and else branch
29
public Tifthenelse(Tboolexp b, Texp e1, Texp e2) {
35
public String toString() {
36
return "if "+boolexp+" then "+exp1+" else "+exp2+" fi";
39
public void checkcontext(SymTab st) {
40
boolexp.checkcontext(st);
41
exp1.checkcontext(st);
42
exp2.checkcontext(st);
45
public void prepInterp(SymTab st) {
46
boolexp.prepInterp(st);
51
public int interpret(int[] in, int[] par) {
52
boolean b = boolexp.interpret(in,par);
54
return exp1.interpret(in,par);
56
return exp2.interpret(in,par);