-
Notifications
You must be signed in to change notification settings - Fork 8
/
BVarStatement.java
65 lines (52 loc) · 1.54 KB
/
BVarStatement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.Vector;
/* Package: B AMN */
/******************************
* Copyright (c) 2003,2019 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
* *****************************/
public class BVarStatement extends BStatement
{ private String var;
private BStatement code;
public BVarStatement(String v, BStatement body)
{ var = v;
code = body;
}
public String getVar()
{ return var; }
public BStatement getCode()
{ return code; }
public Vector wr()
{ return code.wr(); }
public Vector rd()
{ Vector res = code.rd();
res.remove(var);
return res;
}
public String toString()
{ String res = "VAR " + var + " IN\n";
res = res + code + " END";
return res;
}
public BStatement substituteEq(String oldE, BExpression newE)
{ if (var.equals(oldE)) { return this; }
BStatement ncode = code.substituteEq(oldE,newE);
return new BVarStatement(var,ncode);
}
public BStatement simplify()
{ BStatement ncode = code.simplify();
return new BVarStatement(var,ncode);
}
public BStatement seq2parallel()
{ BStatement ncode = code.seq2parallel();
return new BVarStatement(var,ncode);
}
public BStatement normalise()
{ BStatement stat = code.normalise();
BStatement res = new BVarStatement(var,stat);
return res;
}
}