Skip to main content
summaryrefslogtreecommitdiffstats
blob: dec9e1e6cb4ea6d6112c5d1488637667ff573826 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import 'QVTimperative.ecore'

--package ocl
--context Element
--def: joinNames(names : Set(String)) : String = '{' + names->sortedBy(n | n)->iterate(n; s : String = '' | if s = '' then n else s + ';' + n endif) + '}'
--endpackage

package qvtimperative

context AddStatement
inv CompatibleTypeForValue: ownedExpression.type.conformsTo(targetVariable.type)

context BufferStatement
inv CompatibleTypeForValue: ownedExpression <> null implies ownedExpression.type.oclAsType(ocl::CollectionType).elementType.conformsTo(type)

context CheckStatement
inv TypeIsBoolean: ownedExpression.type = Boolean

context DeclareStatement
inv CompatibleTypeForCheckedValue: isCheck implies type.conformsTo(ownedExpression.type)
inv CompatibleTypeForUncheckedValue: not isCheck implies ownedExpression.type.conformsTo(type)

--context GuardParameter
--FIXME completeType inv TypedModelContainsType: referredTypedModel.allUsedPackages->includes(type.oclContainer())

context ImperativeTransformation
inv allRulesAreMappings: rule->forAll(oclIsKindOf(Mapping))

context ImperativeTypedModel
def: allUsedPackages : Set(ocl::Package) = usedPackage
inv NameIsNotNull : name <> null
inv NotBothCheckedAndEnforced: not (isChecked and isEnforced)

context Mapping
inv NameIsNotNull : name <> null
inv MappingParameterNamesAreUnique: ownedMappingParameters->isUnique(name)
inv LocalVariabelNamesAreUnique: ownedMappingParameters->union(ownedStatements->selectByKind(VariableStatement))->isUnique(name)
-- FIXME statment ordering

context MappingCall
def: referredNames : OrderedSet(String) = referredMapping.ownedMappingParameters.name->asSet()->sortedBy(n | n)
def: referringNames : OrderedSet(String) = ownedMappingParameterBindings.boundVariable.name->asSet()->sortedBy(n | n)
inv MatchingCallBindings('Mismatched bindings ' + referredMapping.name + joinNames(referredNames) + ' <= ' + joinNames(referringNames)): referredNames = referringNames
inv NotBothInstallAndInvoke: not (isInstall and isInvoke)
inv UniqueCallBindings: ownedMappingParameterBindings->isUnique(boundVariable)

context MappingParameterBinding
inv ParameterIsMappingParameter: owningMappingCall.referredMapping.ownedMappingParameters->includes(boundVariable)

context NewStatement
inv CompatibleTypeForValue: ownedExpression <> null implies ownedExpression.type.conformsTo(type)
inv NonDataTypeForType: not type.oclIsKindOf(ocl::DataType)
--FIXME completeType inv TypedModelContainsType: referredTypedModel.allUsedPackages->includes(type.oclContainer())

context SetStatement
def:resolvedProperty : ocl::Property[1] = if isOpposite then targetProperty.opposite else targetProperty endif
inv CompatibleClassForProperty(targetVariable.type?.name + ' must conform to ' + resolvedProperty.owningClass?.name):
targetVariable.type.conformsTo(resolvedProperty.owningClass)
inv CompatibleTypeForValue(ownedExpression.type?.name + ' must conform to ' + resolvedProperty.type?.name):
ownedExpression.type.conformsTo(resolvedProperty.type)
inv ValueDoesNotNavigateFromRealizedVariables:
ownedExpression->closure(e : ocl::OclElement | e.oclContents())->selectByKind(ocl::VariableExp)->select(referredVariable.oclIsKindOf(NewStatement))->select(s | s.oclContainer().oclIsKindOf(ocl::CallExp) and s.oclContainer().oclAsType(ocl::CallExp).ownedSource = s)->isEmpty()
inv TargetPropertyIsNotReadOnly:
not resolvedProperty.isReadOnly

context SimpleParameterBinding
inv CompatibleTypeForCheckedValue: isCheck implies boundVariable.type.conformsTo(value.type)
inv CompatibleTypeForUncheckedValue: not isCheck implies value.type.conformsTo(boundVariable.type)

context Statement
def: joinNames(names : OrderedSet(String)) : String = '{' + names/*->sortedBy(n | n)*/->iterate(n; s : String = '' | if s = '' then n else s + ';' + n endif) + '}'


endpackage

Back to the top