Commit 0772743d authored by Philip Makedonski's avatar Philip Makedonski
Browse files

* workaround for multiple guards on the same component, &27

parent de2e9c78
Loading
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ public class TTCN3Renderer {
		return output;
	}

	//TODO: handle true, false, pass, fail
	String render(SimpleDataInstance e, String indent) {
		String output = "";
		output+=indent+"template "+ttcnName(e.getDataType())+" "+ttcnName(e)+" := \""+ttcnName(e)+"\";"+LF;
@@ -561,13 +562,19 @@ public class TTCN3Renderer {
	String render(CompoundBehaviour e, String indent, ComponentInstance c) {
		String output = "";
		String guard = "";
		//TODO: multiple guards on the same component -> check specification and update
		if (!e.getBlock().getGuard().isEmpty()) {
			String block = "";
			if (e.getBlock().getGuard().stream().anyMatch(g -> g.getComponentInstance() == c)) {
				block = render(e.getBlock(), indent+this.indent, c);
			}
			for (var g : e.getBlock().getGuard()) {
				if (g.getComponentInstance() == c) {
					guard+="if ("+render(g.getExpression(), "")+") ";
					output+=indent+guard+"{"+LF;
					output+=render(e.getBlock(), indent+this.indent, c);
					output+=block;
					output+=indent+"}"+LF;
					break;//TODO: Handle multiple?
				}
			}
		} else {