Skip to content

[Feature]: InvocationExpression::evaluate — model-level expression evaluation engine #365

Description

@antoineatstariongroup

Description

InvocationExpressionExtensions.ComputeRedefinedEvaluateOperation(this IInvocationExpression, IElement target)
in SysML2.NET/Extend/InvocationExpressionExtensions.cs:83 is a NotSupportedException stub. It has
no OCL derivation — KerML 1.0 §8.4.4.9.8 delegates it to execution semantics:

An InvocationExpression evaluates to an application of its function to argument values
corresponding to the results of evaluating each of the argument Expressions of the
InvocationExpression.

What is required

A model-level expression evaluation engine, following the pilot implementation
(org.omg.sysml.expressionsModelLevelExpressionEvaluator).

  1. Library-function resolution. ComputeResolveGlobalOperation
    (SysML2.NET/Extend/NamespaceExtensions.cs:528) walks up owningNamespace only, so
    function.qualifiedName resolves only when the Kernel Functions Library sits in the same
    containment tree as the user model. Resources/sysml.library.kpar ships but is loaded nowhere
    outside SysML2.NET.Kpar.Tests. Decide: SDK-side library registry, or caller-supplied library.
  2. Dispatch registry + evaluation context. Evaluate(IElement target) carries no parameter
    binding; collect / select re-enter evaluation once per element with a bound body parameter.
  3. Literal factory + numeric coercion. evaluate constructs result elements (LiteralInteger,
    LiteralRational, LiteralBoolean, LiteralString, LiteralInfinity) and promotes
    Natural → Integer → Rational → Real.
  4. The 35 library function bodies, in four groups:
    • classification — istype, hastype, @, @@, as, meta, ==, !=, ===, !==
    • boolean / control — and, or, xor, not, implies, if, ?? (must not eagerly
      evaluate all arguments, so these cannot share the generic dispatch path)
    • numeric — +, -, *, /, %, ^, <, >, <=, >=, ..
    • sequence — ,, #, ., collect, select
  5. Fallback for a non-library function: evaluate the invoked type's result expression.

Blocked

meta and @@ need reflective metaclass features (KerML 1.0 §9.2.17) — i.e. the two remaining
Extend stubs MetadataAccessExpressionExtensions.ComputeMetaclassFeatureOperation
(SysML2.NET/Extend/MetadataAccessExpressionExtensions.cs:163) and
MetadataFeatureExtensions.ComputeSyntaxElementOperation
(SysML2.NET/Extend/MetadataFeatureExtensions.cs:208). Both require a MOF reflective registry that
does not exist in the SDK.

Depends on

#364 — dispatch keys on the same library-function set.

Checklist

  • Library-function resolution strategy
  • Dispatch registry + evaluation context
  • Literal factory + numeric coercion helpers
  • Classification functions
  • Boolean / control functions
  • Numeric functions
  • Sequence / collection functions
  • Non-library-function fallback
  • List<IElement> ComputeRedefinedEvaluateOperation(this IInvocationExpression, IElement)

System Configuration

  • SysML2.NET version: 0.19.0
  • Source file: SysML2.NET/Extend/InvocationExpressionExtensions.cs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions