Project

General

Profile

Revision 8

Added by Willibald K. over 8 years ago

adding initial version of the AstBuilder feature, contributed by Stefan T.

View differences:

ObjectConstructor.java
21 21
  *               Stephan Zimmerer (AIT)
22 22
  *               Markus Demetz (AIT)
23 23
  *               Christoph Czurda (AIT)
24
  *               Stefan Tiran (AIT)
24 25
  *
25 26
  */
26 27

  
......
32 33
import org.momut.ooas.ast.IAstVisitor;
33 34
import org.momut.ooas.ast.types.OoActionSystemInstance;
34 35
import org.momut.ooas.ast.types.OpaqueType;
36
import org.momut.ooas.ast.types.UlyssesType;
35 37

  
36 38
public final class ObjectConstructor extends TypeConstructionExpression
37 39
{
......
39 41
	private int m_currentInstance;
40 42
	private String m_fixedObjectName;
41 43

  
44
	private final String cleanup(String name) {
45
		if (name.startsWith("\"")) {
46
			name = name.substring(1, name.length()-1);
47
		}
48
		return name;
49
	}
50

  
42 51
	public int currentInstance() { return m_currentInstance; }
43 52
	public ArrayList<OoActionSystemInstance> instances() { return m_instances; }
44 53
	public String givenObjectName() { return m_fixedObjectName; }
......
59 68
		SetType(aType);
60 69
		m_instances = new ArrayList<OoActionSystemInstance>();
61 70
		m_currentInstance = 0;
62
		m_fixedObjectName = aName;
71
		m_fixedObjectName = cleanup(aName);
63 72
	}
64 73

  
74
	public ObjectConstructor(UlyssesType aType, String aName, int line, int pos)
75
	{
76
		super (ExpressionKind.ObjectConstr, line, pos);
77
		SetType(aType);
78
		m_instances = new ArrayList<OoActionSystemInstance>();
79
		m_currentInstance = 0;
80
		m_fixedObjectName = cleanup(aName);
81
	}
65 82

  
66 83
	public ObjectConstructor(ObjectConstructor toCopy)
67 84
	{
......
72 89
	}
73 90

  
74 91
	@Override
75
	public /*override*/ Expression Clone()
92
	public Expression Clone()
76 93
	{
77 94
		return new ObjectConstructor(this);
78 95
	}
79 96

  
80
	public /*override*/ void Accept(IAstVisitor visitor)
97
	@Override
98
	public void Accept(IAstVisitor visitor)
81 99
	{
82 100
		visitor.visit(this);
83 101
	}
......
89 107

  
90 108
	public OoActionSystemInstance GetNextInstance()
91 109
	{
92
		OoActionSystemInstance result = m_instances.get(m_currentInstance);
110
		final OoActionSystemInstance result = m_instances.get(m_currentInstance);
93 111
		m_currentInstance++;
94 112
		return result;
95 113
	}

Also available in: Unified diff