Skip to content

Commit a405a74

Browse files
committed
ST6RI-840 Updated ModelLevelEvaluator for constructor expressions.
1 parent b1d5b81 commit a405a74

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

org.omg.sysml/src/org/omg/sysml/expressions/ModelLevelExpressionEvaluator.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2022 Model Driven Solutions, Inc.
3+
* Copyright (c) 2022, 2025 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -30,6 +30,7 @@
3030
import org.omg.sysml.expressions.functions.LibraryFunction;
3131
import org.omg.sysml.expressions.util.EvaluationUtil;
3232
import org.omg.sysml.lang.sysml.AnnotatingElement;
33+
import org.omg.sysml.lang.sysml.ConstructorExpression;
3334
import org.omg.sysml.lang.sysml.Element;
3435
import org.omg.sysml.lang.sysml.Expression;
3536
import org.omg.sysml.lang.sysml.Feature;
@@ -74,6 +75,8 @@ public EList<Element> evaluate(Expression expression, Element target) {
7475
return evaluateMetadataAccess((MetadataAccessExpression)expression, target);
7576
} else if (expression instanceof InvocationExpression) {
7677
return evaluateInvocation((InvocationExpression)expression, target);
78+
} else if (expression instanceof ConstructorExpression) {
79+
return evaluateConstructor((ConstructorExpression)expression, target);
7780
} else {
7881
return new BasicEList<>();
7982
}
@@ -109,6 +112,11 @@ public EList<Element> evaluateInvocation(InvocationExpression expression, Elemen
109112
return function == null? EvaluationUtil.singletonList(expression): function.invoke(expression, target, this);
110113
}
111114

115+
public EList<Element> evaluateConstructor(ConstructorExpression expression, Element target) {
116+
Feature resultParameter = TypeUtil.getResultParameterOf(expression);
117+
return resultParameter == null? null: EvaluationUtil.singletonList(resultParameter);
118+
}
119+
112120
public EList<Element> evaluateFeature(Feature feature, Type type) {
113121
if (type != null && TypeUtil.specializes(feature, ExpressionUtil.getSelfReferenceFeature(feature))) {
114122
// Evaluate "self" feature. (Note: Must be checked before test for feature chain because "self" has chaining features.)

0 commit comments

Comments
 (0)