Skip to content

Commit

Permalink
Fixes reference bugs (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
arminzavada authored Nov 7, 2024
2 parents 6c9074c + 0e4fc86 commit cf286ec
Show file tree
Hide file tree
Showing 23 changed files with 780 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ fragment TransitionBody returns Transition:
(
'('
(
parameters+=Parameter
(',' parameters+=Parameter)*
arguments+=Argument
(',' arguments+=Argument)*
(',')?
)?
')'
Expand All @@ -125,8 +125,9 @@ fragment TransitionBody returns Transition:
)*
;

Parameter:
name=ID ':' type=[Type|FQN]

Argument:
name=ID ':' typing=Typing
;


Expand Down Expand Up @@ -194,13 +195,13 @@ InlineSeq:
InlineCall:
'inline' reference=ReferenceExpression '('
(
parameterBindings+=ParameterBinding
(',' parameterBindings+=ParameterBinding)* (',')?
argumentBindings+=ArgumentBinding
(',' argumentBindings+=ArgumentBinding)* (',')?
)?
')'
;

ParameterBinding:
ArgumentBinding:
expression=Expression
;

Expand Down Expand Up @@ -343,6 +344,10 @@ Pattern:
('or' patternBodies += PatternBody)*
;

Parameter:
name=ID ':' type=[Type|FQN]
;

PatternBody:
'{'
(constraints += Constraint)*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ protected List<Element> getAccessibleElements(EObject element) {
elements.addAll(getInheritedElements(feature.getTyping()));
} else if (element instanceof Parameter parameter) {
elements.addAll(getInheritedElements(parameter.getType()));
} else if (element instanceof Argument argument) {
elements.addAll(getInheritedElements(argument.getTyping()));
}

elements.addAll(getAccessibleElements(parent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ public void checkFeatureRedefinition(Feature feature) {

@Check
public void checkTransitionInlining(InlineCall operation) {
var bindings = operation.getParameterBindings();
var bindings = operation.getArgumentBindings();
var transition = (Transition) getReference(operation.getReference());

if (transition == null) return;

if (bindings.size() < transition.getParameters().size()) {
if (bindings.size() < transition.getArguments().size()) {
error("Transition inlining defines too few parameter bindings",
OxstsPackage.Literals.INLINE_CALL__PARAMETER_BINDINGS,
OxstsPackage.Literals.INLINE_CALL__ARGUMENT_BINDINGS,
INVALID_INLINING);
} else if (bindings.size() > transition.getParameters().size()) {
} else if (bindings.size() > transition.getArguments().size()) {
error("Transition inlining defines too much parameter bindings",
OxstsPackage.Literals.INLINE_CALL__PARAMETER_BINDINGS,
OxstsPackage.Literals.INLINE_CALL__ARGUMENT_BINDINGS,
INVALID_INLINING);
}
}
Expand Down
469 changes: 208 additions & 261 deletions subprojects/oxsts.model/model/oxsts.aird

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions subprojects/oxsts.model/model/oxsts.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Boolean"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="override" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//Boolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parameters" upperBound="-1"
eType="#//Parameter" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="arguments" upperBound="-1"
eType="#//Argument" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SequenceOperation" eSuperTypes="#//CompositeOperation"/>
<eClassifiers xsi:type="ecore:EClass" name="Operation" abstract="true" eSuperTypes="#//Element"/>
Expand Down Expand Up @@ -64,8 +64,8 @@
<eClassifiers xsi:type="ecore:EClass" name="InlineCall" eSuperTypes="#//InlineOperation">
<eStructuralFeatures xsi:type="ecore:EReference" name="reference" eType="#//ReferenceExpression"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parameterBindings" upperBound="-1"
eType="#//ParameterBinding" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="argumentBindings" upperBound="-1"
eType="#//ArgumentBinding" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Expression" abstract="true" eSuperTypes="#//Element"/>
<eClassifiers xsi:type="ecore:EClass" name="LiteralExpression" abstract="true" eSuperTypes="#//Expression"/>
Expand Down Expand Up @@ -167,7 +167,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="variables" upperBound="-1"
eType="#//Variable" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ParameterBinding">
<eClassifiers xsi:type="ecore:EClass" name="ArgumentBinding">
<eStructuralFeatures xsi:type="ecore:EReference" name="expression" lowerBound="1"
eType="#//Expression" containment="true"/>
</eClassifiers>
Expand Down Expand Up @@ -273,4 +273,8 @@
eType="#//Feature"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="type" lowerBound="1" eType="#//Type"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Argument" eSuperTypes="#//Element">
<eStructuralFeatures xsi:type="ecore:EReference" name="typing" lowerBound="1"
eType="#//Typing" containment="true"/>
</eClassifiers>
</ecore:EPackage>
11 changes: 7 additions & 4 deletions subprojects/oxsts.model/model/oxsts.genmodel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//Transition/operation"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute oxsts.ecore#//Transition/virtual"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute oxsts.ecore#//Transition/override"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//Transition/parameters"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//Transition/arguments"/>
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//SequenceOperation"/>
<genClasses ecoreClass="oxsts.ecore#//Operation"/>
Expand Down Expand Up @@ -58,7 +58,7 @@
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//InlineCall">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//InlineCall/reference"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//InlineCall/parameterBindings"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//InlineCall/argumentBindings"/>
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//Expression"/>
<genClasses ecoreClass="oxsts.ecore#//LiteralExpression"/>
Expand Down Expand Up @@ -136,8 +136,8 @@
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//XSTS/property"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//XSTS/variables"/>
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//ParameterBinding">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//ParameterBinding/expression"/>
<genClasses ecoreClass="oxsts.ecore#//ArgumentBinding">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//ArgumentBinding/expression"/>
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//ContextDependentReference"/>
<genClasses ecoreClass="oxsts.ecore#//LessThanOperator"/>
Expand Down Expand Up @@ -210,5 +210,8 @@
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference oxsts.ecore#//FeatureConstraint/feature"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference oxsts.ecore#//FeatureConstraint/type"/>
</genClasses>
<genClasses ecoreClass="oxsts.ecore#//Argument">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference oxsts.ecore#//Argument/typing"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/


var __Mission__a__x : boolean

trans {
__Mission__a__x := true;
}

init {
__Mission__a__x := false;
}

env {}

prop {
(__Mission__a__x != true)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package Test

type Simple {
var x : Boolean

init {
x := false
}

tran set(y: Boolean) {
x := y
}
}

target Mission {
containment a : Simple

init {
inline a.init()
}

tran {
inline a.set(true)
}

prop {
a.x != true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/


var __Mission__a__x : integer

trans {
__Mission__a__x := 10;
}

init {
__Mission__a__x := 0;
}

env {}

prop {
(__Mission__a__x != 10)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package Test

type Simple {
var x : Integer

init {
x := 0
}

tran set(y: Integer) {
x := y
}
}

target Mission {
containment a : Simple

init {
inline a.init()
}

tran {
inline a.set(10)
}

prop {
a.x != 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/


var __Mission__a__x : boolean = true

trans {
}

init {
}

env {}

prop {
(__Mission__a__x != true)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package Test

type Simple {
reference defaultX : Boolean = false
var x : Boolean = defaultX
}

target Mission {
containment a : Simple {
reference ::> defaultX : Boolean = true
}

init {}
tran {}

prop {
a.x != true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/


var __Mission__a__x : integer = 10

trans {
}

init {
}

env {}

prop {
(__Mission__a__x != 10)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package Test

type Simple {
reference defaultX : Integer = 0
var x : Integer = defaultX
}

target Mission {
containment a : Simple {
reference ::> defaultX : Integer = 10
}

init {}
tran {}

prop {
a.x != 10
}
}

Loading

0 comments on commit cf286ec

Please sign in to comment.