Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ import org.omg.sysml.lang.sysml.VisibilityKind
import org.omg.sysml.lang.sysml.Structure
import org.omg.sysml.lang.sysml.CrossSubsetting
import org.omg.sysml.lang.sysml.Annotation
import org.omg.sysml.lang.sysml.InstantiationExpression
import org.omg.sysml.lang.sysml.ConstructorExpression

import org.omg.sysml.util.TypeUtil
import org.omg.sysml.util.ElementUtil
import org.omg.sysml.util.EvaluationUtil
import org.omg.sysml.util.ExpressionUtil
import org.omg.sysml.util.FeatureUtil
import org.omg.sysml.util.NamespaceUtil
import org.omg.sysml.util.ImplicitGeneralizationMap

import org.omg.sysml.expressions.util.EvaluationUtil
import java.util.Collections
import java.util.HashMap
import java.util.Set
import java.util.Map
import org.omg.sysml.lang.sysml.InstantiationExpression
import org.omg.sysml.lang.sysml.ConstructorExpression

/**
* This class contains custom validation rules.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2022-2024 Model Driven Solutions, Inc.
* Copyright (c) 2022-2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -23,7 +23,7 @@

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.expressions.functions.LibraryFunction;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.Expression;
import org.omg.sysml.lang.sysml.Feature;
Expand All @@ -35,31 +35,28 @@
import org.omg.sysml.lang.sysml.SysMLFactory;
import org.omg.sysml.lang.sysml.Type;
import org.omg.sysml.util.ElementUtil;
import org.omg.sysml.util.ExpressionUtil;
import org.omg.sysml.util.EvaluationUtil;
import org.omg.sysml.util.FeatureUtil;
import org.omg.sysml.util.TypeUtil;

public class ExpressionEvaluator extends ModelLevelExpressionEvaluator {

public static final ExpressionEvaluator INSTANCE = new ExpressionEvaluator();

public ExpressionEvaluator() {
super();
setLibraryFunctionFactory(new LibraryFunctionFactory());
}

@Override
public EList<Element> evaluateInvocation(InvocationExpression expression, Element target) {
Function function = expression.getFunction();
if (function != null && function.isModelLevelEvaluable()) {
return super.evaluateInvocation(expression, target);
LibraryFunction libraryFunction = libraryFunctionFactory.getLibraryFunction(function);
if (libraryFunction != null) {
return libraryFunction.invoke(expression, target, this);
} else {
Type type = expression.instantiatedType();
Expression resultExpression = null;
if (type != null) {
resultExpression = ExpressionUtil.getResultExpressionOf(type);
if (resultExpression == null) {
Feature resultParameter = TypeUtil.getResultParameterOf(type);
if (resultParameter != null) {
resultExpression = FeatureUtil.getValueExpressionFor(resultParameter);
}
}
}
Expression resultExpression = EvaluationUtil.getResultExpressionFor(type);
if (resultExpression == null) {
return EvaluationUtil.singletonList(expression);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/

package org.omg.sysml.execution.expressions;

import org.omg.sysml.execution.expressions.functions.*;

public class LibraryFunctionFactory extends org.omg.sysml.expressions.ModelLevelLibraryFunctionFactory {

public static final LibraryFunctionFactory INSTANCE = new LibraryFunctionFactory();

@Override
protected void initializeFunctionMap() {
super.initializeFunctionMap();

put(new SizeFunction());
put(new IsEmptyFunction());
put(new NotEmptyFunction());
put(new IncludesFunction());
put(new ExcludesFunction());

put(new SumFunction());
put(new ProdFunction());

put(new StringLengthFunction());
put(new StringSubstringFunction());
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2024 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,13 +18,13 @@
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.util.EvaluationUtil;

public class ExcludesFunction extends SequenceFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,13 +18,13 @@
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.util.EvaluationUtil;

public class IncludesFunction extends SequenceFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,13 +18,13 @@
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.util.EvaluationUtil;

public class IsEmptyFunction extends SequenceFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,13 +18,13 @@
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.util.EvaluationUtil;

public class NotEmptyFunction extends SequenceFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of theGNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/

package org.omg.sysml.execution.expressions.functions;

import org.omg.sysml.expressions.functions.LibraryFunction;

public abstract class NumericalFunction implements LibraryFunction {

@Override
public String getPackageName() {
return "NumericalFunctions";
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2022 Model Driven Solutions, Inc.
* Copyright (c) 2022, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -19,23 +19,18 @@
*
*******************************************************************************/

package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.lang.sysml.LiteralInteger;
import org.omg.sysml.lang.sysml.LiteralRational;
import org.omg.sysml.util.EvaluationUtil;

public class ProdFunction implements LibraryFunction {
public class ProdFunction extends NumericalFunction {

@Override
public String getPackageName() {
return "NumericalFunctions";
}

@Override
public String getOperatorName() {
return "product";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -19,7 +19,9 @@
*
*******************************************************************************/

package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.omg.sysml.expressions.functions.LibraryFunction;

public abstract class SequenceFunction implements LibraryFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -18,13 +18,13 @@
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/
package org.omg.sysml.expressions.functions;
package org.omg.sysml.execution.expressions.functions;

import org.eclipse.emf.common.util.EList;
import org.omg.sysml.expressions.ModelLevelExpressionEvaluator;
import org.omg.sysml.expressions.util.EvaluationUtil;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.lang.sysml.InvocationExpression;
import org.omg.sysml.util.EvaluationUtil;

public class SizeFunction extends SequenceFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of theGNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
*
*******************************************************************************/

package org.omg.sysml.execution.expressions.functions;

import org.omg.sysml.expressions.functions.LibraryFunction;

public abstract class StringFunction implements LibraryFunction {

@Override
public String getPackageName() {
return "StringFunctions";
}

}
Loading