|
1 | 1 | /******************************************************************************* |
2 | 2 | * SysML 2 Pilot Implementation |
3 | | - * Copyright (c) 2022-2024 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 |
|
23 | 23 |
|
24 | 24 | import org.eclipse.emf.common.util.EList; |
25 | 25 | import org.omg.sysml.expressions.ModelLevelExpressionEvaluator; |
26 | | -import org.omg.sysml.expressions.util.EvaluationUtil; |
| 26 | +import org.omg.sysml.expressions.functions.LibraryFunction; |
27 | 27 | import org.omg.sysml.lang.sysml.Element; |
28 | 28 | import org.omg.sysml.lang.sysml.Expression; |
29 | 29 | import org.omg.sysml.lang.sysml.Feature; |
|
35 | 35 | import org.omg.sysml.lang.sysml.SysMLFactory; |
36 | 36 | import org.omg.sysml.lang.sysml.Type; |
37 | 37 | import org.omg.sysml.util.ElementUtil; |
38 | | -import org.omg.sysml.util.ExpressionUtil; |
| 38 | +import org.omg.sysml.util.EvaluationUtil; |
39 | 39 | import org.omg.sysml.util.FeatureUtil; |
40 | 40 | import org.omg.sysml.util.TypeUtil; |
41 | 41 |
|
42 | 42 | public class ExpressionEvaluator extends ModelLevelExpressionEvaluator { |
43 | 43 |
|
44 | 44 | public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator(); |
45 | 45 |
|
| 46 | + public ExpressionEvaluator() { |
| 47 | + super(); |
| 48 | + setLibraryFunctionFactory(new LibraryFunctionFactory()); |
| 49 | + } |
| 50 | + |
46 | 51 | @Override |
47 | 52 | public EList<Element> evaluateInvocation(InvocationExpression expression, Element target) { |
48 | 53 | Function function = expression.getFunction(); |
49 | | - if (function != null && function.isModelLevelEvaluable()) { |
50 | | - return super.evaluateInvocation(expression, target); |
| 54 | + LibraryFunction libraryFunction = libraryFunctionFactory.getLibraryFunction(function); |
| 55 | + if (libraryFunction != null) { |
| 56 | + return libraryFunction.invoke(expression, target, this); |
51 | 57 | } else { |
52 | 58 | Type type = expression.instantiatedType(); |
53 | | - Expression resultExpression = null; |
54 | | - if (type != null) { |
55 | | - resultExpression = ExpressionUtil.getResultExpressionOf(type); |
56 | | - if (resultExpression == null) { |
57 | | - Feature resultParameter = TypeUtil.getResultParameterOf(type); |
58 | | - if (resultParameter != null) { |
59 | | - resultExpression = FeatureUtil.getValueExpressionFor(resultParameter); |
60 | | - } |
61 | | - } |
62 | | - } |
| 59 | + Expression resultExpression = EvaluationUtil.getResultExpressionFor(type); |
63 | 60 | if (resultExpression == null) { |
64 | 61 | return EvaluationUtil.singletonList(expression); |
65 | 62 | } else { |
|
0 commit comments