| |
---|
| | Map.Entry<DataflowChannelGenerator, Set<ChannelMember>> ioChannelAndMembers = getIOChannelAndMembers(resource, model); |
---|
| | if (ioChannelAndMembers != null) { |
---|
| | Set<ChannelMember> outs = ioChannelAndMembers.getValue(); |
---|
| | for (ChannelMember out: outs) { |
---|
| | Term message = (Term) out.getStateTransition().getMessageExpression(); |
---|
| | MethodDeclaration input = getMethod(type, message.getSymbol().getName()); |
---|
| | MethodDeclaration input = getInputMethod(type, out); |
---|
| | if (input != null) { |
---|
| | String[] sideEffects = new String[] {""}; |
---|
| | Expression updateExp = ioChannelAndMembers.getKey().deriveUpdateExpressionOf(out, JavaCodeGenerator.pushAccessor); |
---|
| | String newState = updateExp.toImplementation(sideEffects); |
---|
| |
---|
| | MethodDeclaration mainInput = getMethod(mainType, input.getName()); |
---|
| | if (mainInput != null) { |
---|
| | String args = ""; |
---|
| | String delimitar = ""; |
---|
| | for (Variable var: message.getVariables().values()) { |
---|
| | args += delimitar + var.getName(); |
---|
| | delimitar = ", "; |
---|
| | if (out.getStateTransition().getMessageExpression() instanceof Term) { |
---|
| | Term message = (Term) out.getStateTransition().getMessageExpression(); |
---|
| | for (Variable var: message.getVariables().values()) { |
---|
| | args += delimitar + var.getName(); |
---|
| | delimitar = ", "; |
---|
| | } |
---|
| | } |
---|
| | mainInput.addStatement("this." + resourceName + "." + input.getName() + "(" + args + ");"); |
---|
| | } |
---|
| | } |
---|
| |
---|
| | DataflowChannelGenerator ch = (DataflowChannelGenerator) c; |
---|
| | // I/O channel |
---|
| | for (ChannelMember out: ch.getOutputChannelMembers()) { |
---|
| | if (out.getIdentifierTemplate().equals(resource.getIdentifierTemplate())) { |
---|
| | if (out.getStateTransition().getMessageExpression() instanceof Term) { |
---|
| | // not an identity element |
---|
| | if (out.getStateTransition().getMessageExpression() instanceof Term || out.getStateTransition().getMessageExpression() instanceof Variable) { |
---|
| | channel = ch; |
---|
| | channelMembers.add(out); |
---|
| | } |
---|
| | } |
---|
| |
---|
| | DataflowChannelGenerator channel = (DataflowChannelGenerator) c; |
---|
| | // I/O channel |
---|
| | for (ChannelMember out: channel.getOutputChannelMembers()) { |
---|
| | if (out.getIdentifierTemplate().equals(resource.getIdentifierTemplate())) { |
---|
| | if (out.getStateTransition().getMessageExpression() instanceof Term) { |
---|
| | // not an identity element |
---|
| | Term message = (Term) out.getStateTransition().getMessageExpression(); |
---|
| | MethodDeclaration input = getMethod(type, message.getSymbol().getName()); |
---|
| | return input; |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | return null; |
---|
| | MethodDeclaration input = getInputMethod(type, out); |
---|
| | if (input != null) return input; |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | private static MethodDeclaration getInputMethod(TypeDeclaration type, ChannelMember out) { |
---|
| | MethodDeclaration input = null; |
---|
| | if (out.getStateTransition().getMessageExpression() instanceof Term) { |
---|
| | Term message = (Term) out.getStateTransition().getMessageExpression(); |
---|
| | input = getMethod(type, message.getSymbol().getImplName()); |
---|
| | } else if (out.getStateTransition().getMessageExpression() instanceof Variable) { |
---|
| | Variable message = (Variable) out.getStateTransition().getMessageExpression(); |
---|
| | input = getMethod(type, message.getName()); |
---|
| | } |
---|
| | return input; |
---|
| | } |
---|
| | |
---|
| | private static MethodDeclaration getMethod(TypeDeclaration type, String methodName) { |
---|
| | for (MethodDeclaration m: type.getMethods()) { |
---|
| |
---|
| | |