Package: BindAssistantIR

BindAssistantIR

nameinstructionbranchcomplexitylinemethod
BindAssistantIR(AssistantManager)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
convertToMultipleBind(SBindIR)
M: 26 C: 65
71%
M: 4 C: 4
50%
M: 3 C: 2
40%
M: 6 C: 19
76%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.assistant;
23:
24: import org.overture.codegen.ir.SBindIR;
25: import org.overture.codegen.ir.SMultipleBindIR;
26: import org.overture.codegen.ir.patterns.ASeqBindIR;
27: import org.overture.codegen.ir.patterns.ASeqMultipleBindIR;
28: import org.overture.codegen.ir.patterns.ASetBindIR;
29: import org.overture.codegen.ir.patterns.ASetMultipleBindIR;
30: import org.overture.codegen.ir.patterns.ATypeBindIR;
31: import org.overture.codegen.ir.patterns.ATypeMultipleBindIR;
32:
33: public class BindAssistantIR extends AssistantBase
34: {
35:         public BindAssistantIR(AssistantManager assistantManager)
36:         {
37:                 super(assistantManager);
38:         }
39:
40:         public SMultipleBindIR convertToMultipleBind(SBindIR bind)
41:         {
42:                 SMultipleBindIR result = null;
43:
44:•                if (bind instanceof ASetBindIR)
45:                 {
46:                         ASetBindIR setBind = (ASetBindIR) bind;
47:
48:                         ASetMultipleBindIR multipleSetBind = new ASetMultipleBindIR();
49:
50:                         multipleSetBind.getPatterns().add(bind.getPattern());
51:                         multipleSetBind.setSet(setBind.getSet());
52:
53:                         result = multipleSetBind;
54:•                } else if (bind instanceof ASeqBindIR)
55:                 {
56:                         ASeqBindIR seqBind = (ASeqBindIR) bind;
57:
58:                         ASeqMultipleBindIR multipleSeqBind = new ASeqMultipleBindIR();
59:
60:                         multipleSeqBind.getPatterns().add(bind.getPattern());
61:                         multipleSeqBind.setSeq(seqBind.getSeq());
62:
63:                         result = multipleSeqBind;
64:•                } else if (bind instanceof ATypeBindIR)
65:                 {
66:                         ATypeBindIR typeBind = (ATypeBindIR) bind;
67:
68:                         ATypeMultipleBindIR multipleTypeBind = new ATypeMultipleBindIR();
69:
70:                         multipleTypeBind.getPatterns().add(bind.getPattern());
71:                         multipleTypeBind.setType(typeBind.getType());
72:
73:                         result = multipleTypeBind;
74:                 }
75:
76:•                if (result != null)
77:                 {
78:                         result.setTag(bind.getTag());
79:                         result.setSourceNode(bind.getSourceNode());
80:                         result.setMetaData(bind.getMetaData());
81:                 } else
82:                 {
83:                         log.error("Expected set or type bind");
84:                 }
85:
86:                 return result;
87:         }
88: }