Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Resolving correct inferred variable
Resolving correct inferred variable [message #1163852] Thu, 31 October 2013 09:02 Go to next message
Matthias Spiller is currently offline Matthias SpillerFriend
Messages: 13
Registered: September 2013
Junior Member
In my language I can write
flow(a=1) {
  handle calls ClassA(a = a)
}


The topmost a is inferred to a field of type int and value 1.
handle is inferred to a field of type ClassA with name handle
ClassA has a method void setA(...)

In the typecomputer for the "calls" statement, I pass the inferred field "handle" to a call to
state.addExtensionToCurrentScope(handle)


The above code shall be translated to
handle.setA(this.a);
a.execute();


However I want it is translated to
this.a = this.a;
handle.execute();


Where would I have to plug in to make it inferred correctly?
Is this a scoping issue? Or does it have to be done during type computation?

Thanks for any hint.
Matthias
Re: Resolving correct inferred variable [message #1169744 is a reply to message #1163852] Mon, 04 November 2013 06:49 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You would need to define a separate scope for the left-hand side and the
right-hand side of the assignment (a=a) as otherwise the symbol 'a' will
refer to the same element on both sides.

I'd say that's a bit confusing for the user so better force him to call
ClassA(setA(a))

Sven

Am 10/31/13 10:02 AM, schrieb Matthias Spiller:
> In my language I can write
>
> flow(a=1) {
> handle calls ClassA(a = a)
> }
>
>
> The topmost a is inferred to a field of type int and value 1.
> handle is inferred to a field of type ClassA with name handle
> ClassA has a method void setA(...)
>
> In the typecomputer for the "calls" statement, I pass the inferred field
> "handle" to a call to state.addExtensionToCurrentScope(handle)
>
> The above code shall be translated to
>
> handle.setA(this.a);
> a.execute();
>
>
> However I want it is translated to
>
> this.a = this.a;
> handle.execute();
>
>
> Where would I have to plug in to make it inferred correctly?
> Is this a scoping issue? Or does it have to be done during type
> computation?
>
> Thanks for any hint.
> Matthias


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: Resolving correct inferred variable [message #1170273 is a reply to message #1169744] Mon, 04 November 2013 14:24 Go to previous messageGo to next message
Matthias Spiller is currently offline Matthias SpillerFriend
Messages: 13
Registered: September 2013
Junior Member
Sven Efftinge wrote on Mon, 04 November 2013 01:49


I'd say that's a bit confusing for the user so better force him to call
ClassA(setA(a))


There is also a this.setA(...)

Where do I need to plug in for defining the scopes for the lhs and rhs of the assignment?

The grammar looks like:
Call:
  handle = ValidID
  "calls"
  callee = [JvmType|QualifiedName]
  "("
    (parameters += XAssignment (parameters += XAssignment)*)?
  ")"
;


I think I need to subclass XbaseWithAnnotationsBatchScopeProvider? But I currenlty have no idea what to override and what to change.

Could you give me a hint?

Thanks,
Matthias
Re: Resolving correct inferred variable [message #1171407 is a reply to message #1170273] Tue, 05 November 2013 07:59 Go to previous message
Matthias Spiller is currently offline Matthias SpillerFriend
Messages: 13
Registered: September 2013
Junior Member
Found a solution myself.
I have subclassed FeatureScopes and have provided my own implementation of createFeatureCallScope.
Previous Topic:Single project for Xtext
Next Topic:Split model
Goto Forum:
  


Current Time: Sat Dec 05 01:04:19 GMT 2020

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

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

Back to the top