Method: caseAExplicitOperationDefinition(AExplicitOperationDefinition)

1: /*
2: * #%~
3: * The VDM Type Checker
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.typechecker.utilities;
23:
24: import org.overture.ast.analysis.AnalysisException;
25: import org.overture.ast.analysis.AnswerAdaptor;
26: import org.overture.ast.definitions.AExplicitOperationDefinition;
27: import org.overture.ast.definitions.AImplicitOperationDefinition;
28: import org.overture.ast.definitions.AImportedDefinition;
29: import org.overture.ast.definitions.AInheritedDefinition;
30: import org.overture.ast.definitions.ANamedTraceDefinition;
31: import org.overture.ast.definitions.ARenamedDefinition;
32: import org.overture.ast.definitions.AThreadDefinition;
33: import org.overture.ast.definitions.PDefinition;
34: import org.overture.ast.node.INode;
35: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
36:
37: /**
38: * This class implements a way to check operation from a node in the AST
39: *
40: * @author kel
41: */
42: public class OperationChecker extends AnswerAdaptor<Boolean>
43: {
44:
45:         protected ITypeCheckerAssistantFactory af;
46:
47:         public OperationChecker(ITypeCheckerAssistantFactory af)
48:         {
49:                 this.af = af;
50:         }
51:
52:         @Override
53:         public Boolean caseAExplicitOperationDefinition(
54:                         AExplicitOperationDefinition node) throws AnalysisException
55:         {
56:                 return true;
57:         }
58:
59:         @Override
60:         public Boolean caseAImplicitOperationDefinition(
61:                         AImplicitOperationDefinition node) throws AnalysisException
62:         {
63:                 return true;
64:         }
65:
66:         @Override
67:         public Boolean caseANamedTraceDefinition(ANamedTraceDefinition node)
68:                         throws AnalysisException
69:         {
70:                 return true;
71:         }
72:
73:         @Override
74:         public Boolean caseAThreadDefinition(AThreadDefinition node)
75:                         throws AnalysisException
76:         {
77:                 return true;
78:         }
79:
80:         @Override
81:         public Boolean caseAImportedDefinition(AImportedDefinition node)
82:                         throws AnalysisException
83:         {
84:                 return node.getDef().apply(THIS);
85:         }
86:
87:         @Override
88:         public Boolean caseAInheritedDefinition(AInheritedDefinition node)
89:                         throws AnalysisException
90:         {
91:                 return node.getSuperdef().apply(THIS);
92:         }
93:
94:         @Override
95:         public Boolean caseARenamedDefinition(ARenamedDefinition node)
96:                         throws AnalysisException
97:         {
98:                 return node.getDef().apply(THIS);
99:         }
100:
101:         @Override
102:         public Boolean defaultPDefinition(PDefinition node)
103:                         throws AnalysisException
104:         {
105:                 return false;
106:         }
107:
108:         @Override
109:         public Boolean createNewReturnValue(INode node)
110:         {
111:                 assert false : "should not happen";
112:                 return null;
113:         }
114:
115:         @Override
116:         public Boolean createNewReturnValue(Object node)
117:         {
118:                 assert false : "should not happen";
119:                 return null;
120:         }
121:
122: }