node<>Module> and SModule difference

I am trying to find the module of a node during generation. I first tried:

Ibml.logBehavior(this, "getExtensions", "Module " + this.model.module); 
And this prints a null value for the module.  I was not expecting this, the module in the MPS model is not empty at all. Then I tried to cast the node<...> to SModel from the openapi and then get the SModule (also from the openapi) from that.

SModel sModel = ((SModel) this.model); 
SModule sModule = sModel.getModule(); 
Ibml.logBehavior(this, "getExtensions", "Module " + sModel.getModule()); 
Ibml.logBehavior(this, "getExtensions", "Module " + sModel.getModule().getClass().getName());
And found that this prints the correct module (sModel.getModule() is not empty and correct. I would have expected the same result, but it seems that there is some subtle distinction between openapi types and node<...> types.

I cast from node<Module> to SModule, but I cannot find a way to get an node<Module> again from an SModule.

I don't quite understand how the node<..> types and the S* types in the openapi interact. Is this described anywhere? Or can someone explain?

The print of the classname shows that the model in question is actually a TransientModelsInModule instance.  Would this mean that the first piece of code gets the module of a transient Model, while the second piece of code gets the module of the original model?
1 comment
Comment actions Permalink
Yep, this is a bad moment. The problem is that the ".module" operation is not from smodel language, but still it's very hard to notice.
For now, module can't be acessed through the SModel language, you can only access it using OpenAPI (cast to SModel or "model/" operation, which is "cast to lower semantic level" and means exactly the same).
The .module operation gives you a descriptor of a module, which is contained in a special model. This descriptor has nothing in common with module in MPS.
I think, it would be better to give the .module operation a better name and not to show it by default. I'll fix this for next major release, which is not so far.

Please sign in to leave a comment.