Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xbase and logical containers
Xbase and logical containers [message #1021872] Wed, 20 March 2013 20:46
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 672
Registered: July 2009
Location: Trondheim, Norway
Senior Member

I trying to understand how logical containers for expressions work. I've
used it with success so far, but recent problems have tested my
understanding of them...

In my DSL I can declare variable-like elements that provide a scope for
some expressions. The following is not the DSL, but illustrates the point:

val int x = 1 // declare variable
process x+1 // expression x+1 is evaluated in the scope of x

To make the framework handle the scoping for me, I infer (and generate)
two methods as follows:

void process() {
processExpressions(1); // <-- the init expression for x

void processExpressions(int x) {
int _x = x+1; // <- expression has processExpression is its logical
container, but is serialized "by hand" during generation

processExpressions is assigned as the logical container for the
expression x+1, to make it scoped to parameter x

This examples works, but when introducing type parameters, the
serialization of the expressions gives an exception. E.g.

val T x = ... // T is a type parameter of enclosing "class"
process x

Should generate:

void process() { processExpressions(...); }

void processExpressions(T x) {
T _x = <<Exception when serializing x as an expression>>;

By stepping through the serialization process in the debugger, I get the
impression that xbase tries to infer more specific type info, since the
type is a type argument. It looks at the expected type and ends up with
void as the type, which makes the serialization (as an expression)
break, since a void expression doesn't have value. What I believe xbase
has done, is look at the return type of the expression's logical
container, which is processExpression (to get the scoping right), and
infer that as the expected type, in practice assigning void to the type

Am I using the logical container for the wrong reason (to get the
scoping right)? What can I do to avoid the faulty inference that void is
the expected type of the expression?

Previous Topic:Using data rule Id instead of ID terminal
Next Topic:document flyout missing on imports
Goto Forum:

Current Time: Sat Jan 16 07:00:54 GMT 2021

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

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

Back to the top