Package: FreeVariablesChecker

FreeVariablesChecker

nameinstructionbranchcomplexitylinemethod
FreeVariablesChecker(ITypeCheckerAssistantFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAlwaysStm(AAlwaysStm, FreeVarInfo)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAAnnotatedStm(AAnnotatedStm, FreeVarInfo)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAApplyExp(AApplyExp, FreeVarInfo)
M: 0 C: 59
100%
M: 1 C: 9
90%
M: 1 C: 5
83%
M: 0 C: 10
100%
M: 0 C: 1
100%
caseAAssignmentStm(AAssignmentStm, FreeVarInfo)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAtomicStm(AAtomicStm, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseABlockSimpleBlockStm(ABlockSimpleBlockStm, FreeVarInfo)
M: 0 C: 30
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseABracketType(ABracketType, FreeVarInfo)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseACallObjectStm(ACallObjectStm, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseACallStm(ACallStm, FreeVarInfo)
M: 0 C: 30
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseACasesExp(ACasesExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseACasesStm(ACasesStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAClassInvariantDefinition(AClassInvariantDefinition, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseACyclesStm(ACyclesStm, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseADefExp(ADefExp, FreeVarInfo)
M: 1 C: 51
98%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseADurationStm(ADurationStm, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAEqualsDefinition(AEqualsDefinition, FreeVarInfo)
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseAExists1Exp(AExists1Exp, FreeVarInfo)
M: 0 C: 41
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseAExistsExp(AExistsExp, FreeVarInfo)
M: 0 C: 55
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseAExitStm(AExitStm, FreeVarInfo)
M: 4 C: 14
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
caseAExplicitFunctionDefinition(AExplicitFunctionDefinition, FreeVarInfo)
M: 0 C: 75
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
caseAExplicitOperationDefinition(AExplicitOperationDefinition, FreeVarInfo)
M: 0 C: 56
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 10
100%
M: 0 C: 1
100%
caseAFieldExp(AFieldExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAForAllExp(AForAllExp, FreeVarInfo)
M: 0 C: 55
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseAForAllStm(AForAllStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAForIndexStm(AForIndexStm, FreeVarInfo)
M: 0 C: 30
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAForPatternBindStm(AForPatternBindStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAFuncInstatiationExp(AFuncInstatiationExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAFunctionType(AFunctionType, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAIfExp(AIfExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAIfStm(AIfStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAImplicitFunctionDefinition(AImplicitFunctionDefinition, FreeVarInfo)
M: 0 C: 76
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
caseAImplicitOperationDefinition(AImplicitOperationDefinition, FreeVarInfo)
M: 0 C: 76
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
caseAInstanceVariableDefinition(AInstanceVariableDefinition, FreeVarInfo)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAIotaExp(AIotaExp, FreeVarInfo)
M: 0 C: 48
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseAIsExp(AIsExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseALambdaExp(ALambdaExp, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseALetBeStExp(ALetBeStExp, FreeVarInfo)
M: 0 C: 51
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseALetBeStStm(ALetBeStStm, FreeVarInfo)
M: 0 C: 51
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseALetDefExp(ALetDefExp, FreeVarInfo)
M: 0 C: 52
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseALetStm(ALetStm, FreeVarInfo)
M: 0 C: 52
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseALocalDefinition(ALocalDefinition, FreeVarInfo)
M: 21 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAMapCompMapExp(AMapCompMapExp, FreeVarInfo)
M: 0 C: 52
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseAMapEnumMapExp(AMapEnumMapExp, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAMapMapType(AMapMapType, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAMapletExp(AMapletExp, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAMkBasicExp(AMkBasicExp, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAMkTypeExp(AMkTypeExp, FreeVarInfo)
M: 0 C: 28
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAMuExp(AMuExp, FreeVarInfo)
M: 0 C: 30
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseANamedInvariantType(ANamedInvariantType, FreeVarInfo)
M: 4 C: 17
81%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
caseANarrowExp(ANarrowExp, FreeVarInfo)
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAOptionalType(AOptionalType, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAPeriodicStm(APeriodicStm, FreeVarInfo)
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAProductType(AProductType, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseARecordInvariantType(ARecordInvariantType, FreeVarInfo)
M: 4 C: 17
81%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
caseAReturnStm(AReturnStm, FreeVarInfo)
M: 0 C: 22
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseASeq1SeqType(ASeq1SeqType, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqBind(ASeqBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqCompSeqExp(ASeqCompSeqExp, FreeVarInfo)
M: 0 C: 51
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseASeqEnumSeqExp(ASeqEnumSeqExp, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseASeqMultipleBind(ASeqMultipleBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqSeqType(ASeqSeqType, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASet1SetType(ASet1SetType, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASetBind(ASetBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASetCompSetExp(ASetCompSetExp, FreeVarInfo)
M: 0 C: 55
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseASetEnumSetExp(ASetEnumSetExp, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseASetMultipleBind(ASetMultipleBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASetRangeSetExp(ASetRangeSetExp, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseASetSetType(ASetSetType, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASporadicStm(ASporadicStm, FreeVarInfo)
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAStartStm(AStartStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAStateDefinition(AStateDefinition, FreeVarInfo)
M: 0 C: 43
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseAStopStm(AStopStm, FreeVarInfo)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseASubseqExp(ASubseqExp, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseATixeStm(ATixeStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseATrapStm(ATrapStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseATupleExp(ATupleExp, FreeVarInfo)
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseATypeBind(ATypeBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseATypeDefinition(ATypeDefinition, FreeVarInfo)
M: 0 C: 35
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseATypeMultipleBind(ATypeMultipleBind, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAValueDefinition(AValueDefinition, FreeVarInfo)
M: 0 C: 27
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAVariableExp(AVariableExp, FreeVarInfo)
M: 0 C: 57
100%
M: 1 C: 9
90%
M: 1 C: 5
83%
M: 0 C: 10
100%
M: 0 C: 1
100%
caseAWhileStm(AWhileStm, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createNewReturnValue(INode, FreeVarInfo)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createNewReturnValue(Object, FreeVarInfo)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultSBinaryExp(SBinaryExp, FreeVarInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
defaultSBooleanBinaryExp(SBooleanBinaryExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultSSimpleBlockStm(SSimpleBlockStm, FreeVarInfo)
M: 0 C: 30
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
defaultSUnaryExp(SUnaryExp, FreeVarInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getDefinitions(APatternListTypePair, NameScope)
M: 0 C: 30
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2017 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.typechecker.utilities;
25:
26: import java.util.List;
27: import java.util.Vector;
28:
29: import org.overture.ast.analysis.AnalysisException;
30: import org.overture.ast.analysis.QuestionAnswerAdaptor;
31: import org.overture.ast.definitions.AAssignmentDefinition;
32: import org.overture.ast.definitions.AClassInvariantDefinition;
33: import org.overture.ast.definitions.AEqualsDefinition;
34: import org.overture.ast.definitions.AExplicitFunctionDefinition;
35: import org.overture.ast.definitions.AExplicitOperationDefinition;
36: import org.overture.ast.definitions.AImplicitFunctionDefinition;
37: import org.overture.ast.definitions.AImplicitOperationDefinition;
38: import org.overture.ast.definitions.AInstanceVariableDefinition;
39: import org.overture.ast.definitions.ALocalDefinition;
40: import org.overture.ast.definitions.ARenamedDefinition;
41: import org.overture.ast.definitions.AStateDefinition;
42: import org.overture.ast.definitions.ATypeDefinition;
43: import org.overture.ast.definitions.AValueDefinition;
44: import org.overture.ast.definitions.PDefinition;
45: import org.overture.ast.expressions.AApplyExp;
46: import org.overture.ast.expressions.ACasesExp;
47: import org.overture.ast.expressions.ADefExp;
48: import org.overture.ast.expressions.AExists1Exp;
49: import org.overture.ast.expressions.AExistsExp;
50: import org.overture.ast.expressions.AFieldExp;
51: import org.overture.ast.expressions.AForAllExp;
52: import org.overture.ast.expressions.AFuncInstatiationExp;
53: import org.overture.ast.expressions.AIfExp;
54: import org.overture.ast.expressions.AIotaExp;
55: import org.overture.ast.expressions.AIsExp;
56: import org.overture.ast.expressions.ALambdaExp;
57: import org.overture.ast.expressions.ALetBeStExp;
58: import org.overture.ast.expressions.ALetDefExp;
59: import org.overture.ast.expressions.AMapCompMapExp;
60: import org.overture.ast.expressions.AMapEnumMapExp;
61: import org.overture.ast.expressions.AMapletExp;
62: import org.overture.ast.expressions.AMkBasicExp;
63: import org.overture.ast.expressions.AMkTypeExp;
64: import org.overture.ast.expressions.AMuExp;
65: import org.overture.ast.expressions.ANarrowExp;
66: import org.overture.ast.expressions.ARecordModifier;
67: import org.overture.ast.expressions.ASeqCompSeqExp;
68: import org.overture.ast.expressions.ASeqEnumSeqExp;
69: import org.overture.ast.expressions.ASetCompSetExp;
70: import org.overture.ast.expressions.ASetEnumSetExp;
71: import org.overture.ast.expressions.ASetRangeSetExp;
72: import org.overture.ast.expressions.ASubseqExp;
73: import org.overture.ast.expressions.ATupleExp;
74: import org.overture.ast.expressions.AVariableExp;
75: import org.overture.ast.expressions.PExp;
76: import org.overture.ast.expressions.SBinaryExp;
77: import org.overture.ast.expressions.SBooleanBinaryExp;
78: import org.overture.ast.expressions.SUnaryExp;
79: import org.overture.ast.factory.AstFactory;
80: import org.overture.ast.lex.LexNameSet;
81: import org.overture.ast.node.INode;
82: import org.overture.ast.patterns.APatternListTypePair;
83: import org.overture.ast.patterns.ASeqBind;
84: import org.overture.ast.patterns.ASeqMultipleBind;
85: import org.overture.ast.patterns.ASetBind;
86: import org.overture.ast.patterns.ASetMultipleBind;
87: import org.overture.ast.patterns.ATypeBind;
88: import org.overture.ast.patterns.ATypeMultipleBind;
89: import org.overture.ast.patterns.PMultipleBind;
90: import org.overture.ast.patterns.PPattern;
91: import org.overture.ast.statements.AAlwaysStm;
92: import org.overture.ast.statements.AAnnotatedStm;
93: import org.overture.ast.statements.AAssignmentStm;
94: import org.overture.ast.statements.AAtomicStm;
95: import org.overture.ast.statements.ABlockSimpleBlockStm;
96: import org.overture.ast.statements.ACallObjectStm;
97: import org.overture.ast.statements.ACallStm;
98: import org.overture.ast.statements.ACasesStm;
99: import org.overture.ast.statements.ACyclesStm;
100: import org.overture.ast.statements.ADurationStm;
101: import org.overture.ast.statements.AExitStm;
102: import org.overture.ast.statements.AForAllStm;
103: import org.overture.ast.statements.AForIndexStm;
104: import org.overture.ast.statements.AForPatternBindStm;
105: import org.overture.ast.statements.AIfStm;
106: import org.overture.ast.statements.ALetBeStStm;
107: import org.overture.ast.statements.ALetStm;
108: import org.overture.ast.statements.APeriodicStm;
109: import org.overture.ast.statements.AReturnStm;
110: import org.overture.ast.statements.ASporadicStm;
111: import org.overture.ast.statements.AStartStm;
112: import org.overture.ast.statements.AStopStm;
113: import org.overture.ast.statements.ATixeStm;
114: import org.overture.ast.statements.ATrapStm;
115: import org.overture.ast.statements.AWhileStm;
116: import org.overture.ast.statements.PStm;
117: import org.overture.ast.statements.SSimpleBlockStm;
118: import org.overture.ast.typechecker.NameScope;
119: import org.overture.ast.types.ABracketType;
120: import org.overture.ast.types.AFunctionType;
121: import org.overture.ast.types.AMapMapType;
122: import org.overture.ast.types.ANamedInvariantType;
123: import org.overture.ast.types.AOptionalType;
124: import org.overture.ast.types.AProductType;
125: import org.overture.ast.types.ARecordInvariantType;
126: import org.overture.ast.types.ASeq1SeqType;
127: import org.overture.ast.types.ASeqSeqType;
128: import org.overture.ast.types.ASet1SetType;
129: import org.overture.ast.types.ASetSetType;
130: import org.overture.ast.types.PType;
131: import org.overture.typechecker.FlatEnvironment;
132: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
133:
134: /**
135: * Used to find the free variables in a definition, type or expression.
136: */
137: public class FreeVariablesChecker extends QuestionAnswerAdaptor<FreeVarInfo, LexNameSet>
138: {
139:         protected ITypeCheckerAssistantFactory af;
140:
141:         public FreeVariablesChecker(ITypeCheckerAssistantFactory af)
142:         {
143:                 this.af = af;
144:         }
145:
146:         /************************* Definitions ***************************/
147:
148:         @Override
149:         public LexNameSet caseAClassInvariantDefinition(AClassInvariantDefinition node, FreeVarInfo info)
150:                 throws AnalysisException
151:         {
152:                 return node.getExpression().apply(this, info);
153:         }
154:         
155:         @Override
156:         public LexNameSet caseAEqualsDefinition(AEqualsDefinition node,        FreeVarInfo info)
157:                 throws AnalysisException
158:         {
159:                 FreeVarInfo local = info.set(new FlatEnvironment(af, node.getDefs(), info.env));
160:                 return node.getTest().apply(this, local);
161:         }
162:         
163:         @Override
164:         public LexNameSet caseAValueDefinition(AValueDefinition node,
165:                 FreeVarInfo info) throws AnalysisException
166:         {
167:                 LexNameSet names = new LexNameSet();
168:                 
169:•                if (node.getType() != null)
170:                 {
171:                         names.addAll(node.getType().apply(this, info));
172:                 }
173:                 
174:                 names.addAll(node.getExpression().apply(this, info));
175:                 return names;
176:         }
177:
178:         @Override
179:         public LexNameSet caseAExplicitFunctionDefinition(AExplicitFunctionDefinition node, FreeVarInfo info)
180:                 throws AnalysisException
181:         {
182:                 List<PDefinition> defs = new Vector<PDefinition>();
183:                 List<List<PDefinition>> paramDefinitionList = af.createSFunctionDefinitionAssistant().
184:                         getParamDefinitions(node, (AFunctionType) node.getType(), node.getParamPatternList(), node.getLocation());
185:                 
186:•                for (List<PDefinition> list: paramDefinitionList)
187:                 {
188:                         defs.addAll(list);
189:                 }
190:
191:                 FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env));
192:                 LexNameSet names = node.getBody().apply(this, local);
193:                 
194:•                if (node.getPredef() != null)
195:                 {
196:                         names.addAll(node.getPredef().apply(this, local));
197:                 }
198:                 
199:•                if (node.getPostdef() != null)
200:                 {
201:                         names.addAll(node.getPostdef().apply(this, local));
202:                 }
203:
204:                 return names;
205:         }
206:
207:         @Override
208:         public LexNameSet caseAImplicitFunctionDefinition(AImplicitFunctionDefinition node, FreeVarInfo info)
209:                 throws AnalysisException
210:         {
211:                 List<PDefinition> defs = new Vector<PDefinition>();
212:                 
213:•                for (APatternListTypePair pltp : node.getParamPatterns())
214:                 {
215:                         defs.addAll(getDefinitions(pltp, NameScope.LOCAL));
216:                 }
217:                 
218:                 FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env));
219:                 LexNameSet names = new LexNameSet();
220:                 
221:•                if (node.getBody() != null)
222:                 {
223:                         names.addAll(node.getBody().apply(this, local));
224:                 }
225:                 
226:•                if (node.getPredef() != null)
227:                 {
228:                         names.addAll(node.getPredef().apply(this, local));
229:                 }
230:                 
231:•                if (node.getPostdef() != null)
232:                 {
233:                         names.addAll(node.getPostdef().apply(this, local));
234:                 }
235:
236:                 return names;
237:         }
238:         
239:         @Override
240:         public LexNameSet caseATypeDefinition(ATypeDefinition node,        FreeVarInfo info)
241:                 throws AnalysisException
242:         {
243:                 LexNameSet names = new LexNameSet();
244:                 
245:•                if (node.getType() instanceof ANamedInvariantType)
246:                 {
247:                         ANamedInvariantType nt = (ANamedInvariantType)node.getType();
248:                         names.addAll(nt.getType().apply(this, info));
249:                 }
250:                 
251:•                if (node.getInvdef() != null)
252:                 {
253:                         names.addAll(node.getInvdef().apply(this, info));
254:                 }
255:                 
256:                 return names;
257:         }
258:         
259:         @Override
260:         public LexNameSet caseAInstanceVariableDefinition(AInstanceVariableDefinition node, FreeVarInfo info)
261:                 throws AnalysisException
262:         {
263:                 LexNameSet names = new LexNameSet();
264:                 names.addAll(node.getType().apply(this, info));
265:                 names.addAll(node.getExpression().apply(this, info));
266:                 return names;
267:         }
268:         
269:         @Override
270:         public LexNameSet caseALocalDefinition(ALocalDefinition node, FreeVarInfo info)
271:                 throws AnalysisException
272:         {
273:                 LexNameSet names = node.getType().apply(this, info);
274:                 
275:•                if (node.getValueDefinition() != null)
276:                 {
277:                         names.addAll(node.getValueDefinition().apply(this, info));
278:                 }
279:                 
280:                 return names;
281:         }
282:         
283:         @Override
284:         public LexNameSet caseAStateDefinition(AStateDefinition node, FreeVarInfo info)
285:                 throws AnalysisException
286:         {
287:                 FreeVarInfo local = info.set(new FlatEnvironment(af, new Vector<PDefinition>(), info.env));
288:                 LexNameSet names = new LexNameSet();
289:                 
290:•                if (node.getInvdef() != null)
291:                 {
292:                         names.addAll(node.getInvdef().apply(this, local));
293:                 }
294:                 
295:•                if (node.getInitdef() != null)
296:                 {
297:                         names.addAll(node.getInitdef().apply(this, local));
298:                 }
299:                 
300:                 return names;
301:         }
302:         
303:         @Override
304:         public LexNameSet caseAExplicitOperationDefinition(AExplicitOperationDefinition node, FreeVarInfo info)
305:                 throws AnalysisException
306:         {
307:                 List<PDefinition> defs = new Vector<PDefinition>();
308:
309:•                if (node.getParamDefinitions() != null)
310:                 {
311:                         defs.addAll(node.getParamDefinitions());
312:                 }
313:
314:                 FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env));
315:                 LexNameSet names = node.getBody().apply(this, local);
316:
317:•                if (node.getPredef() != null)
318:                 {
319:                         names.addAll(node.getPredef().apply(this, local));
320:                 }
321:
322:•                if (node.getPostdef() != null)
323:                 {
324:                         names.addAll(node.getPostdef().apply(this, local));
325:                 }
326:
327:                 return names;
328:         }
329:         
330:         @Override
331:         public LexNameSet caseAImplicitOperationDefinition(AImplicitOperationDefinition node, FreeVarInfo info)
332:                 throws AnalysisException
333:         {
334:                 List<PDefinition> defs = new Vector<PDefinition>();
335:
336:•                for (APatternListTypePair pltp : node.getParameterPatterns())
337:                 {
338:                         defs.addAll(getDefinitions(pltp, NameScope.LOCAL));
339:                 }
340:
341:                 FreeVarInfo local = info.set(new FlatEnvironment(af, defs, info.env));
342:                 LexNameSet names = new LexNameSet();
343:
344:•                if (node.getBody() != null)
345:                 {
346:                         names.addAll(node.getBody().apply(this, local));
347:                 }
348:
349:•                if (node.getPredef() != null)
350:                 {
351:                         names.addAll(node.getPredef().apply(this, local));
352:                 }
353:
354:•                if (node.getPostdef() != null)
355:                 {
356:                         names.addAll(node.getPostdef().apply(this, local));
357:                 }
358:
359:                 return names;
360:         }
361:         
362:         /************************* Expressions ***************************/
363:         
364:         @Override
365:         public LexNameSet caseAVariableExp(AVariableExp node, FreeVarInfo info) throws AnalysisException
366:         {
367:                 PDefinition d = info.globals.findName(node.getName(), NameScope.NAMESANDSTATE);
368:                 
369:•                if (d != null && af.createPDefinitionAssistant().isFunction(d))
370:                 {
371:                         return new LexNameSet();
372:                 }
373:
374:•                if (d instanceof ARenamedDefinition)
375:                 {
376:                         ARenamedDefinition rd = (ARenamedDefinition)d;
377:                         
378:•                        if (rd.getDef().getName() != null)
379:                         {
380:                                 return new LexNameSet(rd.getDef().getName().getExplicit(true));
381:                         }
382:                 }
383:                 
384:•                if (info.env.findName(node.getName(), NameScope.NAMESANDSTATE) == null)
385:                 {
386:                         return new LexNameSet(node.getName().getExplicit(true));
387:                 }
388:                 else
389:                 {
390:                         return new LexNameSet();        // Already in local info.env, so not free
391:                 }
392:         }
393:         
394:         @Override
395:         public LexNameSet caseAApplyExp(AApplyExp node, FreeVarInfo info) throws AnalysisException
396:         {
397:                 LexNameSet names = new LexNameSet();
398:                 
399:•                if (node.getRoot() instanceof AVariableExp && node.getRoot().getType() != null &&
400:•                        af.createPTypeAssistant().isFunction(node.getRoot().getType(), null))
401:                 {
402:                         // If this is a global call, then we depend on the function
403:                         AVariableExp v = (AVariableExp)node.getRoot();
404:                         
405:•                        if (info.globals.findName(v.getName(), NameScope.NAMESANDSTATE) != null)
406:                         {
407:                                 names.add(v.getName());
408:                         }
409:                 }
410:                 
411:•                for (PExp exp: node.getArgs())
412:                 {
413:                         names.addAll(exp.apply(this, info));
414:                 }
415:                 
416:                 return names;
417:         }
418:         
419:         @Override
420:         public LexNameSet caseACasesExp(ACasesExp node, FreeVarInfo info) throws AnalysisException
421:         {
422:                 return node.getExpression().apply(this, info);
423:         }
424:         
425:         @Override
426:         public LexNameSet caseAExistsExp(AExistsExp node, FreeVarInfo info)        throws AnalysisException
427:         {
428:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), node.getBindList());
429:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
430:                 LexNameSet names = new LexNameSet();
431:                 
432:•                if (node.getPredicate() != null)
433:                 {
434:                         names.addAll(node.getPredicate().apply(this, local));
435:                 }
436:                 
437:•                for (PMultipleBind mb: node.getBindList())
438:                 {
439:                         names.addAll(mb.apply(this, local));
440:                 }
441:                 
442:                 return names;
443:         }
444:         
445:         @Override
446:         public LexNameSet caseAExists1Exp(AExists1Exp node, FreeVarInfo info) throws AnalysisException
447:         {
448:                 PDefinition def = node.getDef();
449:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
450:                 LexNameSet names = new LexNameSet();
451:                 
452:•                if (node.getPredicate() != null)
453:                 {
454:                         names.addAll(node.getPredicate().apply(this, local));
455:                 }
456:
457:                 names.addAll(node.getBind().apply(this, local));
458:                 return names;
459:         }
460:         
461:         @Override
462:         public LexNameSet caseAFieldExp(AFieldExp node, FreeVarInfo info) throws AnalysisException
463:         {
464:                 return node.getObject().apply(this, info);
465:         }
466:         
467:         @Override
468:         public LexNameSet caseAForAllExp(AForAllExp node, FreeVarInfo info) throws AnalysisException
469:         {
470:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), node.getBindList());
471:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
472:                 LexNameSet names = new LexNameSet();
473:                 
474:•                if (node.getPredicate() != null)
475:                 {
476:                         names.addAll(node.getPredicate().apply(this, local));
477:                 }
478:                 
479:•                for (PMultipleBind mb: node.getBindList())
480:                 {
481:                         names.addAll(mb.apply(this, local));
482:                 }
483:                 
484:                 return names;
485:         }
486:         
487:         @Override
488:         public LexNameSet caseAFuncInstatiationExp(AFuncInstatiationExp node, FreeVarInfo info)
489:                 throws AnalysisException
490:         {
491:                 return node.getFunction().apply(this, info);
492:         }
493:         
494:         @Override
495:         public LexNameSet caseAIfExp(AIfExp node, FreeVarInfo info)        throws AnalysisException
496:         {
497:                 return node.getTest().apply(this, info);
498:         }
499:         
500:         @Override
501:         public LexNameSet caseAIotaExp(AIotaExp node, FreeVarInfo info)        throws AnalysisException
502:         {
503:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), af.createPBindAssistant().getMultipleBindList(node.getBind()));
504:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
505:                 LexNameSet names = new LexNameSet();
506:                 
507:•                if (node.getPredicate() != null)
508:                 {
509:                         names.addAll(node.getPredicate().apply(this, local));
510:                 }
511:
512:                 names.addAll(node.getBind().apply(this, local));
513:                 return names;
514:         }
515:         
516:         @Override
517:         public LexNameSet caseAIsExp(AIsExp node, FreeVarInfo info)        throws AnalysisException
518:         {
519:                 return node.getTest().apply(this, info);
520:         }
521:         
522:         @Override
523:         public LexNameSet caseALambdaExp(ALambdaExp node, FreeVarInfo info) throws AnalysisException
524:         {
525:                 LexNameSet names = new LexNameSet();
526:                 
527:•                for (ATypeBind mb: node.getBindList())
528:                 {
529:                         names.addAll(mb.apply(this, info));
530:                 }
531:                 
532:                 return names;
533:         }
534:         
535:         @Override
536:         public LexNameSet caseALetBeStExp(ALetBeStExp node, FreeVarInfo info) throws AnalysisException
537:         {
538:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), af.createPMultipleBindAssistant().getMultipleBindList(node.getBind()));
539:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
540:                 LexNameSet names = node.getBind().apply(this, local);
541:                 
542:•                if (node.getSuchThat() != null)
543:                 {
544:                         names.addAll(node.getSuchThat().apply(this, local));
545:                 }
546:                 
547:                 names.addAll(node.getValue().apply(this, local));
548:                 return names;
549:         }
550:         
551:         @Override
552:         public LexNameSet caseALetDefExp(ALetDefExp node, FreeVarInfo info) throws AnalysisException
553:         {
554:                 FreeVarInfo local = info;
555:                 LexNameSet names = new LexNameSet();
556:
557:•                for (PDefinition d : node.getLocalDefs())
558:                 {
559:•                        if (d instanceof AExplicitFunctionDefinition)
560:                         {
561:                                 // ignore
562:                         }
563:                         else
564:                         {
565:                                 local = info.set(new FlatEnvironment(af, d, local.env));
566:                                 names.addAll(d.apply(this, local));
567:                         }
568:                 }
569:
570:                 names.addAll(node.getExpression().apply(this, local));
571:                 return names;
572:         }
573:         
574:         @Override
575:         public LexNameSet caseADefExp(ADefExp node, FreeVarInfo info) throws AnalysisException
576:         {
577:                 FreeVarInfo local = info;
578:                 LexNameSet names = new LexNameSet();
579:
580:•                for (PDefinition d : node.getLocalDefs())
581:                 {
582:•                        if (d instanceof AExplicitFunctionDefinition)
583:                         {
584:                                 // ignore
585:                         }
586:                         else
587:                         {
588:                                 local = info.set(new FlatEnvironment(af, d, local.env));
589:                                 names.addAll(d.apply(this, local));
590:                         }
591:                 }
592:
593:                 names.addAll(node.getExpression().apply(this, local));
594:                 return names;
595:         }
596:         
597:         @Override
598:         public LexNameSet caseAMapCompMapExp(AMapCompMapExp node, FreeVarInfo info) throws AnalysisException
599:         {
600:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), node.getBindings());
601:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
602:                 LexNameSet names = new LexNameSet();        // Note "first" is conditional
603:                 
604:•                if (node.getPredicate() != null)
605:                 {
606:                         node.getPredicate().apply(this, local);
607:                 }
608:                 
609:•                for (PMultipleBind mb: node.getBindings())
610:                 {
611:                         names.addAll(mb.apply(this, local));
612:                 }
613:                 
614:                 return names;
615:         }
616:         
617:         @Override
618:         public LexNameSet caseAMapEnumMapExp(AMapEnumMapExp node, FreeVarInfo info) throws AnalysisException
619:         {
620:                 LexNameSet names = new LexNameSet();
621:                 
622:•                for (AMapletExp maplet: node.getMembers())
623:                 {
624:                         names.addAll(maplet.apply(this, info));
625:                 }
626:                 
627:                 return names;
628:         }
629:         
630:         @Override
631:         public LexNameSet caseAMapletExp(AMapletExp node, FreeVarInfo info) throws AnalysisException
632:         {
633:                 LexNameSet names = node.getLeft().apply(this, info);
634:                 names.addAll(node.getRight().apply(this, info));
635:                 return names;
636:         }
637:         
638:         @Override
639:         public LexNameSet caseAMkBasicExp(AMkBasicExp node, FreeVarInfo info) throws AnalysisException
640:         {
641:                 LexNameSet names = node.getType().apply(this, info);
642:                 names.addAll(node.getArg().apply(this, info));
643:                 return names;
644:         }
645:         
646:         @Override
647:         public LexNameSet caseAMkTypeExp(AMkTypeExp node, FreeVarInfo info) throws AnalysisException
648:         {
649:                 LexNameSet names = new LexNameSet(node.getTypeName());
650:                 
651:•                for (PExp arg: node.getArgs())
652:                 {
653:                         names.addAll(arg.apply(this, info));
654:                 }
655:                 
656:                 return names;
657:         }
658:         
659:         @Override
660:         public LexNameSet caseAMuExp(AMuExp node, FreeVarInfo info) throws AnalysisException
661:         {
662:                 LexNameSet names = node.getRecord().apply(this, info);
663:                 
664:•                for (ARecordModifier rm: node.getModifiers())
665:                 {
666:                         names.addAll(rm.getValue().apply(this, info));
667:                 }
668:                 
669:                 return names;
670:         }
671:         
672:         @Override
673:         public LexNameSet caseANarrowExp(ANarrowExp node, FreeVarInfo info) throws AnalysisException
674:         {
675:                 LexNameSet names = node.getTest().apply(this, info);
676:                 
677:•                if (node.getTypeName() != null)
678:                 {
679:                         names.add(node.getTypeName());
680:                 }
681:                 
682:                 return names;
683:         }
684:         
685:         @Override
686:         public LexNameSet caseASeqCompSeqExp(ASeqCompSeqExp node, FreeVarInfo info) throws AnalysisException
687:         {
688:                 FreeVarInfo local = null;
689:                 LexNameSet names = new LexNameSet();        // Note "first" is conditional
690:                 
691:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), af.createPBindAssistant().getMultipleBindList(node.getBind()));
692:                 def.parent(node.getBind());
693:                 local = info.set(new FlatEnvironment(af, def, info.env));
694:                 names.addAll(node.getBind().apply(this, local));
695:                 
696:•                if (node.getPredicate() != null)
697:                 {
698:                         node.getPredicate().apply(this, local);
699:                 }
700:                 
701:                 return names;
702:         }
703:         
704:         @Override
705:         public LexNameSet caseASeqEnumSeqExp(ASeqEnumSeqExp node, FreeVarInfo info) throws AnalysisException
706:         {
707:                 LexNameSet names = new LexNameSet();
708:                 
709:•                for (PExp exp: node.getMembers())
710:                 {
711:                         names.addAll(exp.apply(this, info));
712:                 }
713:                 
714:                 return names;
715:         }
716:
717:         @Override
718:         public LexNameSet caseASetCompSetExp(ASetCompSetExp node, FreeVarInfo info) throws AnalysisException
719:         {
720:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), node.getBindings());
721:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
722:                 LexNameSet names = new LexNameSet();
723:                 
724:•                if (node.getPredicate() != null)
725:                 {
726:                         names.addAll(node.getPredicate().apply(this, local));
727:                 }
728:                 
729:•                for (PMultipleBind mb: node.getBindings())
730:                 {
731:                         names.addAll(mb.apply(this, local));
732:                 }
733:                 
734:                 return names;
735:         }
736:         
737:         @Override
738:         public LexNameSet caseASetEnumSetExp(ASetEnumSetExp node, FreeVarInfo info) throws AnalysisException
739:         {
740:                 LexNameSet names = new LexNameSet();
741:                 
742:•                for (PExp exp: node.getMembers())
743:                 {
744:                         names.addAll(exp.apply(this, info));
745:                 }
746:                 
747:                 return names;
748:         }
749:
750:         @Override
751:         public LexNameSet caseASetRangeSetExp(ASetRangeSetExp node,        FreeVarInfo info) throws AnalysisException
752:         {
753:                 LexNameSet names = node.getFirst().apply(this, info);
754:                 names.addAll(node.getLast().apply(this, info));
755:                 return names;
756:         }
757:         
758:         @Override
759:         public LexNameSet caseASubseqExp(ASubseqExp node, FreeVarInfo info) throws AnalysisException
760:         {
761:                 LexNameSet names = node.getFrom().apply(this, info);
762:                 names.addAll(node.getTo().apply(this, info));
763:                 return names;
764:         }
765:         
766:         @Override
767:         public LexNameSet caseATupleExp(ATupleExp node, FreeVarInfo info) throws AnalysisException
768:         {
769:                 LexNameSet names = new LexNameSet();
770:                 
771:•                for (PExp exp: node.getArgs())
772:                 {
773:                         names.addAll(exp.apply(this, info));
774:                 }
775:                 
776:                 return names;
777:         }
778:         
779:         /************************* Binds ***************************/
780:         
781:         @Override
782:         public LexNameSet caseASeqMultipleBind(ASeqMultipleBind node, FreeVarInfo info) throws AnalysisException
783:         {
784:                 return node.getSeq().apply(this, info);
785:         }
786:         
787:         @Override
788:         public LexNameSet caseASetMultipleBind(ASetMultipleBind node, FreeVarInfo info) throws AnalysisException
789:         {
790:                 return node.getSet().apply(this, info);
791:         }
792:         
793:         @Override
794:         public LexNameSet caseATypeMultipleBind(ATypeMultipleBind node, FreeVarInfo info) throws AnalysisException
795:         {
796:                 return node.getType().apply(this, info);
797:         }
798:         
799:         @Override
800:         public LexNameSet caseASeqBind(ASeqBind node, FreeVarInfo info) throws AnalysisException
801:         {
802:                 return node.getSeq().apply(this, info);
803:         }
804:         
805:         @Override
806:         public LexNameSet caseASetBind(ASetBind node, FreeVarInfo info) throws AnalysisException
807:         {
808:                 return node.getSet().apply(this, info);
809:         }
810:         
811:         @Override
812:         public LexNameSet caseATypeBind(ATypeBind node, FreeVarInfo info) throws AnalysisException
813:         {
814:                 return node.getType().apply(this, info);
815:         }
816:         
817:         /************************* Types ***************************/
818:         
819:         @Override
820:         public LexNameSet caseABracketType(ABracketType node, FreeVarInfo info) throws AnalysisException
821:         {
822:                 return node.getType().apply(this, info);
823:         }
824:         
825:         @Override
826:         public LexNameSet caseAFunctionType(AFunctionType node, FreeVarInfo info) throws AnalysisException
827:         {
828:                 LexNameSet names = new LexNameSet();
829:                 
830:•                for (PType p: node.getParameters())
831:                 {
832:                         names.addAll(p.apply(this, info));
833:                 }
834:                 
835:                 return names;
836:         }
837:         
838:         @Override
839:         public LexNameSet caseAMapMapType(AMapMapType node, FreeVarInfo info) throws AnalysisException
840:         {
841:                 LexNameSet names = node.getFrom().apply(this, info);
842:                 names.addAll(node.getTo().apply(this, info));
843:                 return names;
844:         }
845:         
846:         @Override
847:         public LexNameSet caseANamedInvariantType(ANamedInvariantType node, FreeVarInfo info)
848:                 throws AnalysisException
849:         {
850:•                if (info.env.findType(node.getName(), node.getLocation().getModule()) == null)
851:                 {
852:                         // Invariant values covered in TCTypeDefinition
853:                         return new LexNameSet(node.getName().getExplicit(true));
854:                 }
855:                 else
856:                 {
857:                         return new LexNameSet();
858:                 }
859:         }
860:         
861:         @Override
862:         public LexNameSet caseAOptionalType(AOptionalType node, FreeVarInfo info) throws AnalysisException
863:         {
864:                 return node.getType().apply(this, info);
865:         }
866:         
867:         @Override
868:         public LexNameSet caseAProductType(AProductType node, FreeVarInfo info) throws AnalysisException
869:         {
870:                 LexNameSet names = new LexNameSet();
871:                 
872:•                for (PType p: node.getTypes())
873:                 {
874:                         names.addAll(p.apply(this, info));
875:                 }
876:                 
877:                 return names;
878:         }
879:         
880:         @Override
881:         public LexNameSet caseARecordInvariantType(ARecordInvariantType node, FreeVarInfo info) throws AnalysisException
882:         {
883:•                if (info.env.findType(node.getName(), node.getLocation().getModule()) == null)
884:                 {
885:                         // Invariant values covered in TCTypeDefinition
886:                         return new LexNameSet(node.getName().getExplicit(true));
887:                 }
888:                 else
889:                 {
890:                         return new LexNameSet();
891:                 }
892:         }
893:         
894:         @Override
895:         public LexNameSet caseASeqSeqType(ASeqSeqType node, FreeVarInfo info) throws AnalysisException
896:         {
897:                 return node.getSeqof().apply(this, info);
898:         }
899:
900:         @Override
901:         public LexNameSet caseASeq1SeqType(ASeq1SeqType node, FreeVarInfo info) throws AnalysisException
902:         {
903:                 return node.getSeqof().apply(this, info);
904:         }
905:         
906:         @Override
907:         public LexNameSet caseASetSetType(ASetSetType node, FreeVarInfo info) throws AnalysisException
908:         {
909:                 return node.getSetof().apply(this, info);
910:         }
911:         
912:         @Override
913:         public LexNameSet caseASet1SetType(ASet1SetType node, FreeVarInfo info) throws AnalysisException
914:         {
915:                 return node.getSetof().apply(this, info);
916:         }
917:         
918:         /************************* Statements ***************************/
919:         
920:         @Override
921:         public LexNameSet caseAAlwaysStm(AAlwaysStm node, FreeVarInfo info)        throws AnalysisException
922:         {
923:                 LexNameSet names = new LexNameSet();
924:                 names.addAll(node.getAlways().apply(this, info));
925:                 names.addAll(node.getBody().apply(this, info));
926:                 return names;
927:         }
928:         
929:         @Override
930:         public LexNameSet caseAAssignmentStm(AAssignmentStm node, FreeVarInfo info) throws AnalysisException
931:         {
932:                 LexNameSet names = new LexNameSet();
933:                 names.addAll(node.getExp().apply(this, info));
934:                 return names;
935:         }
936:         
937:         @Override
938:         public LexNameSet caseAAtomicStm(AAtomicStm node, FreeVarInfo info)        throws AnalysisException
939:         {
940:                 LexNameSet names = new LexNameSet();
941:                                 
942:•                for (AAssignmentStm stmt: node.getAssignments())
943:                 {
944:                         names.addAll(stmt.apply(this, info));
945:                 }
946:                 
947:                 return names;
948:         }
949:
950:         @Override
951:         public LexNameSet caseABlockSimpleBlockStm(ABlockSimpleBlockStm node, FreeVarInfo info)
952:                 throws AnalysisException
953:         {
954:                 FreeVarInfo local = info;
955:                 
956:•                for (AAssignmentDefinition d: node.getAssignmentDefs())
957:                 {
958:                         local = local.set(new FlatEnvironment(af, d, local.env));        // cumulative
959:                 }
960:                 
961:                 return defaultSSimpleBlockStm(node, local);
962:         }
963:         
964:         @Override
965:         public LexNameSet caseACallObjectStm(ACallObjectStm node, FreeVarInfo info)
966:                 throws AnalysisException
967:         {
968:                 LexNameSet names = new LexNameSet();
969:                 
970:•                for (PExp arg: node.getArgs())
971:                 {
972:                         names.addAll(arg.apply(this, info));
973:                 }
974:                 
975:                 return names;
976:         }
977:         
978:         @Override
979:         public LexNameSet caseACallStm(ACallStm node, FreeVarInfo info)        throws AnalysisException
980:         {
981:                 LexNameSet names = new LexNameSet(node.getName().getExplicit(true));
982:                 
983:•                for (PExp arg: node.getArgs())
984:                 {
985:                         names.addAll(arg.apply(this, info));
986:                 }
987:                 
988:                 return names;
989:         }
990:         
991:         @Override
992:         public LexNameSet caseACasesStm(ACasesStm node, FreeVarInfo info) throws AnalysisException
993:         {
994:                 return node.getExp().apply(this, info);
995:         }
996:         
997:         @Override
998:         public LexNameSet caseACyclesStm(ACyclesStm node, FreeVarInfo info) throws AnalysisException
999:         {
1000:                 LexNameSet names = node.getCycles().apply(this, info);
1001:                 names.addAll(node.getStatement().apply(this, info));
1002:                 return names;
1003:         }
1004:         
1005:         @Override
1006:         public LexNameSet caseADurationStm(ADurationStm node, FreeVarInfo info) throws AnalysisException
1007:         {
1008:                 LexNameSet names = node.getDuration().apply(this, info);
1009:                 names.addAll(node.getStatement().apply(this, info));
1010:                 return names;
1011:         }
1012:         
1013:         @Override
1014:         public LexNameSet caseAExitStm(AExitStm node, FreeVarInfo info) throws AnalysisException
1015:         {
1016:•                if (node.getExpression() == null)
1017:                 {
1018:                         return new LexNameSet();
1019:                 }
1020:                 
1021:                 info.returns.set(true);
1022:                 return node.getExpression().apply(this, info);
1023:         }
1024:         
1025:         @Override
1026:         public LexNameSet caseAForAllStm(AForAllStm node, FreeVarInfo info)        throws AnalysisException
1027:         {
1028:                 return node.getSet().apply(this, info);
1029:         }
1030:         
1031:         @Override
1032:         public LexNameSet caseAForIndexStm(AForIndexStm node, FreeVarInfo info)        throws AnalysisException
1033:         {
1034:                 LexNameSet names = node.getFrom().apply(this, info);
1035:                 names.addAll(node.getTo().apply(this, info));
1036:                 
1037:•                if (node.getBy() != null)
1038:                 {
1039:                         names.addAll(node.getBy().apply(this, info));
1040:                 }
1041:                 
1042:                 return names;
1043:         }
1044:         
1045:         @Override
1046:         public LexNameSet caseAForPatternBindStm(AForPatternBindStm node, FreeVarInfo info)
1047:                 throws AnalysisException
1048:         {
1049:                 return node.getExp().apply(this, info);
1050:         }
1051:         
1052:         @Override
1053:         public LexNameSet caseAIfStm(AIfStm node, FreeVarInfo info)        throws AnalysisException
1054:         {
1055:                 return node.getIfExp().apply(this, info);
1056:         }
1057:         
1058:         @Override
1059:         public LexNameSet caseALetBeStStm(ALetBeStStm node, FreeVarInfo info) throws AnalysisException
1060:         {
1061:                 PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), af.createPMultipleBindAssistant().getMultipleBindList(node.getBind()));
1062:                 FreeVarInfo local = info.set(new FlatEnvironment(af, def, info.env));
1063:                 LexNameSet names = node.getBind().apply(this, local);
1064:                 
1065:•                if (node.getSuchThat() != null)
1066:                 {
1067:                         names.addAll(node.getSuchThat().apply(this, local));
1068:                 }
1069:                 
1070:                 names.addAll(node.getStatement().apply(this, local));
1071:                 return names;
1072:         }
1073:         
1074:         @Override
1075:         public LexNameSet caseALetStm(ALetStm node, FreeVarInfo info) throws AnalysisException
1076:         {
1077:                 FreeVarInfo local = info;
1078:                 LexNameSet names = new LexNameSet();
1079:
1080:•                for (PDefinition d : node.getLocalDefs())
1081:                 {
1082:•                        if (d instanceof AExplicitFunctionDefinition)
1083:                         {
1084:                                 // ignore
1085:                         }
1086:                         else
1087:                         {
1088:                                 local = info.set(new FlatEnvironment(af, d, local.env));
1089:                                 names.addAll(d.apply(this, local));
1090:                         }
1091:                 }
1092:
1093:                 names.addAll(node.getStatement().apply(this, local));
1094:                 return names;
1095:         }
1096:         
1097:         @Override
1098:         public LexNameSet caseAPeriodicStm(APeriodicStm node, FreeVarInfo info) throws AnalysisException
1099:         {
1100:                 LexNameSet names = new LexNameSet();
1101:                 
1102:•                for (PExp arg: node.getArgs())
1103:                 {
1104:                         names.addAll(arg.apply(this, info));
1105:                 }
1106:                 
1107:                 return names;
1108:         }
1109:         
1110:         @Override
1111:         public LexNameSet caseASporadicStm(ASporadicStm node, FreeVarInfo info) throws AnalysisException
1112:         {
1113:                 LexNameSet names = new LexNameSet();
1114:                 
1115:•                for (PExp arg: node.getArgs())
1116:                 {
1117:                         names.addAll(arg.apply(this, info));
1118:                 }
1119:                 
1120:                 return names;
1121:         }
1122:         
1123:         @Override
1124:         public LexNameSet caseAReturnStm(AReturnStm node, FreeVarInfo info) throws AnalysisException
1125:         {
1126:                 LexNameSet names = new LexNameSet();
1127:                 
1128:•                if (node.getExpression() != null)
1129:                 {
1130:                         names.addAll(node.getExpression().apply(this, info));
1131:                 }
1132:                 
1133:                 info.returns.set(true);
1134:                 return names;
1135:         }
1136:         
1137:         @Override
1138:         public LexNameSet caseAStartStm(AStartStm node, FreeVarInfo info) throws AnalysisException
1139:         {
1140:                 return node.getObj().apply(this, info);
1141:         }
1142:         
1143:         @Override
1144:         public LexNameSet caseAStopStm(AStopStm node, FreeVarInfo info)        throws AnalysisException
1145:         {
1146:                 return node.getObj().apply(this, info);
1147:         }
1148:         
1149:         @Override
1150:         public LexNameSet caseATixeStm(ATixeStm node, FreeVarInfo info) throws AnalysisException
1151:         {
1152:                 return node.getBody().apply(this, info);
1153:         }
1154:         
1155:         @Override
1156:         public LexNameSet caseATrapStm(ATrapStm node, FreeVarInfo info) throws AnalysisException
1157:         {
1158:                 return node.getBody().apply(this, info);
1159:         }
1160:         
1161:         @Override
1162:         public LexNameSet caseAWhileStm(AWhileStm node, FreeVarInfo info) throws AnalysisException
1163:         {
1164:                 return node.getExp().apply(this, info);
1165:         }
1166:         
1167:         @Override
1168:         public LexNameSet caseAAnnotatedStm(AAnnotatedStm node, FreeVarInfo question)
1169:                         throws AnalysisException
1170:         {
1171:                 return node.getStmt().apply(this, question);
1172:         }
1173:         
1174:         /************************* Defaults ***************************/
1175:         
1176:         @Override
1177:         public LexNameSet defaultSBinaryExp(SBinaryExp exp, FreeVarInfo info) throws AnalysisException
1178:         {
1179:                 LexNameSet names = exp.getLeft().apply(this, info);
1180:                 names.addAll(exp.getRight().apply(this, info));
1181:                 return names;
1182:         }
1183:         
1184:         public LexNameSet defaultSBooleanBinaryExp(SBooleanBinaryExp exp, FreeVarInfo info) throws AnalysisException
1185:         {
1186:                 return exp.getLeft().apply(this, info);                // Only left is unconditional
1187:         }
1188:
1189:         @Override
1190:         public LexNameSet defaultSUnaryExp(SUnaryExp exp, FreeVarInfo info) throws AnalysisException
1191:         {
1192:                 return exp.getExp().apply(this, info);
1193:         }
1194:         
1195:         @Override
1196:         public LexNameSet defaultSSimpleBlockStm(SSimpleBlockStm node, FreeVarInfo info)
1197:                 throws AnalysisException
1198:         {
1199:                 LexNameSet names = new LexNameSet();
1200:                 
1201:•                for (PStm stmt: node.getStatements())
1202:                 {
1203:•                        if (!info.returns.get())
1204:                         {
1205:                                 names.addAll(stmt.apply(this, info));
1206:                         }
1207:                 }
1208:                 
1209:                 return names;
1210:         }
1211:         
1212:         
1213:
1214:         /************************* New values etc ***************************/
1215:
1216:         @Override
1217:         public LexNameSet createNewReturnValue(INode node, FreeVarInfo info) throws AnalysisException
1218:         {
1219:                 return new LexNameSet();        // None
1220:         }
1221:
1222:         @Override
1223:         public LexNameSet createNewReturnValue(Object node, FreeVarInfo info) throws AnalysisException
1224:         {
1225:                 return new LexNameSet();        // None
1226:         }
1227:         
1228:         private List<PDefinition> getDefinitions(APatternListTypePair pltp, NameScope scope)
1229:         {
1230:                 List<PDefinition> list = new Vector<PDefinition>();
1231:
1232:•                for (PPattern p : pltp.getPatterns())
1233:                 {
1234:                         list.addAll(af.createPPatternAssistant(null).getDefinitions(p, pltp.getType(), scope));
1235:                 }
1236:
1237:                 return list;
1238:         }
1239: }