Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2t-dev] [backend] bugs and thoughts

Arno,

First of all, let me apologize, this will be a lengthy mail :D.

Playing with the backend, I stumbled upon several issues and wanted to give you feedback on these, mainly to ask you if these are indeed problems or if you simply haven't had enough time to implement them as yet. I will go through either bugs, missing features and random questions I had regarding the implementation so forgive me about the (inexistant) construction of this mail :). And without further ado :

1) I found the IfExpression you have defined in the backend for the control flow. But there isn't any cases such as "an if with no else" (I think such use cases could be handled by creating an "if" with an LiteralExpression containing an empty String as the else, but it would be better to have the backend perform this transparently) or "if - else if - else". What is the expected way to implement this last use case? An "if" with another "if" as the statement when false? Or simply using a SwitchExpression that seems to present the right behavior?

2) This might be the most annoying one I have faced since so hard to track down : When using a CompositeTypeSystem, getting functions from a java file through MiddleEnd#getFunctions() fails in NPE with the root being the first line of JavaBeansType#init() : - _superTypes = Collections.singleton (ts.getRootTypesystem().findType (_javaClass.getSuperclass())); It so happens that one of the java class as no superClasses, thus _javaClass.getSuperclass() returning null and the execution failing later on. I have had to completely comment out all of the lines of CompositeTypeSystem that references the field _javaBeansTypesystem in order to get rid of the error (I do not need the java beans types for my use case ... why didn't you create a typeSystem for java beans as you did for EMF, one that can be registered if needed and that isn't used otherwise).

3) You have defined a SequenceExpression that is described on the wiki ( http://wiki.eclipse.org/M2TBackend ) as being "the subsequent execution of several expressions"... yet I am puzzled by its implementation :
   protected Object evaluateInternal(ExecutionContext ctx) {
           Object result = null;
           for (ExpressionBase e: _inner)
               result = e.evaluate(ctx);
           return result;
   }
The only result we'll get ... is the result of the very last statement's evaluation since "result" is overriden by each new evaluation. Is that how it is intended? If yes, is there an expression that has been defined to allow us to have the backend execute a sequence of expressions (let's say two LiteralExpression) and get the result of both evaluations? The use case I have is similar to (forgive the errors, I've never used xpand :D) :
   «DEFINE function FOR uml::Element-»
       «IF name != null-»
           Element : «name»
           Element type : «eClass»
       «ENDIF»
And I would like to define the backend expressions needed : an IfExpression with a condition, but what can I use as the "then part" of this IF if not a SequenceExpression?

4) On to the Type System. You have provided us the way of defining new BackendTypeSystem through the CompositeTypeSystem#register() method. In the same fashion, you provided us with a way of defining new BackendType and to tell that such or such BackendType is assignment compatible with another through BackendType#isAssignableFrom(). This is perfect ... but what if I tell that RandomType is assignment-compatible with String? The backend will fail to invoke functions defined with parameter of type "RandomType" with a String parameter since it doesn't know how to convert from String to Random. We then need a way to provide our own converters, the same way you did with the JavaBuiltinConverterFactory. What I did for now is "hack" my way through by adding a method "addConverter" to the JavaBuiltinConverterFactory and providing it with as key the Class on which the converter applies, and as value the converter itself (extending JavaBuiltinConverter). This doesn't seem like a solution that could be applied since all types that need conversion are not mandatory java. I think type conversion should be handled by the BackendTypeSystem itself when we provide it. Maybe we could discuss this a little further? This truly is a blocking issue if we decide to use the backend for our project (hence the "hack" I implemented to carry on my tests). Except if I deeply misunderstood something (which can be the case :p).

5) Each of the Expressions provided by the backend need a "SourcePos" object which seems to hold information on the source template and the line number where we are located. Is this intended for debugguing purposes? I couldn't find documentation on these.

6) Last but not least, some languages define functions with varargs. This can happen in M2T languages (Acceleo comes in mind) as well as in programming languages (Java 5 and function defined as "public void varargs(Object... args)"). How are these dealed with by the backend? Or if they are not, is there even plans to support such feature?

That's all there is for this mail, hope you are not sleeping or in need of an aspirin by now ;).

Cheers.
Laurent Goubet
Obeo
begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr/";>Obeo</a>
email;internet:laurent.goubet@xxxxxxx
url:http://www.obeo.fr
version:2.1
end:vcard


Back to the top