|
1 | 1 | /******************************************************************************* |
2 | 2 | * SysML 2 Pilot Implementation |
3 | | - * Copyright (c) 2022 Model Driven Solutions, Inc. |
| 3 | + * Copyright (c) 2022, 2025 Model Driven Solutions, Inc. |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU Lesser General Public License as published by |
|
30 | 30 | import org.omg.sysml.expressions.functions.LibraryFunction; |
31 | 31 | import org.omg.sysml.expressions.util.EvaluationUtil; |
32 | 32 | import org.omg.sysml.lang.sysml.AnnotatingElement; |
| 33 | +import org.omg.sysml.lang.sysml.ConstructorExpression; |
33 | 34 | import org.omg.sysml.lang.sysml.Element; |
34 | 35 | import org.omg.sysml.lang.sysml.Expression; |
35 | 36 | import org.omg.sysml.lang.sysml.Feature; |
@@ -74,6 +75,8 @@ public EList<Element> evaluate(Expression expression, Element target) { |
74 | 75 | return evaluateMetadataAccess((MetadataAccessExpression)expression, target); |
75 | 76 | } else if (expression instanceof InvocationExpression) { |
76 | 77 | return evaluateInvocation((InvocationExpression)expression, target); |
| 78 | + } else if (expression instanceof ConstructorExpression) { |
| 79 | + return evaluateConstructor((ConstructorExpression)expression, target); |
77 | 80 | } else { |
78 | 81 | return new BasicEList<>(); |
79 | 82 | } |
@@ -109,6 +112,11 @@ public EList<Element> evaluateInvocation(InvocationExpression expression, Elemen |
109 | 112 | return function == null? EvaluationUtil.singletonList(expression): function.invoke(expression, target, this); |
110 | 113 | } |
111 | 114 |
|
| 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 | + |
112 | 120 | public EList<Element> evaluateFeature(Feature feature, Type type) { |
113 | 121 | if (type != null && TypeUtil.specializes(feature, ExpressionUtil.getSelfReferenceFeature(feature))) { |
114 | 122 | // Evaluate "self" feature. (Note: Must be checked before test for feature chain because "self" has chaining features.) |
|
0 commit comments