Blame view

circus/src/jcircus/complementaryenvs/ChanComplexCommEnv.java 1.14 KB
8d0dc533f   Madiel de Souza Conserva Filho   first
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
  package jcircus.complementaryenvs;
  
  import java.util.HashMap;
  import java.util.LinkedHashMap;
  
  import net.sourceforge.czt.circus.ast.CircusFieldList;
  import net.sourceforge.czt.circus.ast.Communication;
  import net.sourceforge.czt.circus.ast.Field;
  import net.sourceforge.czt.circus.ast.InputField;
  
  public class ChanComplexCommEnv {
  	private HashMap <String, Boolean> _map;
  	public ChanComplexCommEnv () {
  		this._map = new LinkedHashMap <String, Boolean> ();
  	}
  	public void update (String channelName, boolean b) {
  		if (_map.containsKey (channelName)) {
  			_map.remove (channelName);
  		}
  		this._map.put (channelName, b);
  	}
  	public boolean get (String channelName) {
  		if (_map.containsKey (channelName))
  			return this._map.get (channelName);
  		else {
  			return false;
  		}
  	}
  	public static boolean isComplexComm (Communication c) {
  		CircusFieldList cfl = c.getCircusFieldList();
  		int size = cfl.size();
  		if (size > 1) {
  			for (int i = 0; i < size - 1; i++) {
  				Field field = cfl.get(i);
  				if (field instanceof InputField) {
  					return true;
  				}
  			}
  			return false;
  		}
  		else {
  			return false;
  		}
  	}
  }