Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Linking XCastExpression to a "toX" function
Linking XCastExpression to a "toX" function [message #1774571] Tue, 17 October 2017 08:54 Go to next message
Eclipse UserFriend
Dear all.

In my DSL, I would like to enable operator overriding for the cast expressions.
My idea is:

Let the following code:
var x = ...
var y = x as String
var z = x as Y


"x as String" should be map to the Java code "x.toString()".

"x as Y" should be be map to the Java code:
* "x.toY()" if this instance function is defined and accessible,
* "toY(x)" if this class function is defined and accessible,
* "(Y) x" otherwise

My question is: what are the typical classes within Xbase to be extended for enabling this behavior?

I think about:
* XbaseCompiler for generating the Java code,
* DSLValidator for changing the validation test.

What else?

Thank in advance.
Stéphane.
Re: Linking XCastExpression to a "toX" function [message #1774572 is a reply to message #1774571] Tue, 17 October 2017 08:56 Go to previous messageGo to next message
Eclipse UserFriend
XbaseCompiler. Possibly Validator. Possibly FeatureScopes
Xbase Type Computer. Maybe XExpressionHelper
Re: Linking XCastExpression to a "toX" function [message #1774574 is a reply to message #1774572] Tue, 17 October 2017 09:02 Go to previous message
Eclipse UserFriend
Thank you, I will start to work based on this list of classes.

Stéphane.
Previous Topic:Expression Language: Using ".*" in combination with Decimal Numbers
Next Topic:Xtext Standalone: Add/Remove/Modify resources
Goto Forum:
  


Current Time: Wed Jul 23 22:46:50 EDT 2025

Powered by FUDForum. Page generated in 0.04021 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top