Menu

#1 Variable propagation for base types

v0.4.2
open-postponed
5
2003-05-19
2002-08-22
No

Variable propagation along traversals does not work for
base types (see result of example APExample.ijp,
transformed file Car.java):

[...]

public void count(int c) {
c = 0;
this.chassis.count(c);
System.out.println("Number of axes: " + c);
}
[...]

Variable c is passed by value rather than by reference.
The System.out will always print '0'.

Possible solution:
Use wrapper objects (Integer etc.) for passing
variables of base types along traversals.

Discussion

  • Thomas Genssler

    Thomas Genssler - 2002-08-26

    Logged In: YES
    user_id=466738

    Workaround: Use path-global variables, such as:
    traverse 'car' do
    {
    add method 'void count()' {
    Integer c;
    [...]

    However, this also brings a problem: The generated code for
    count() contains the following stmnt sequence:
    java.util.Hashtable transport = new
    java.util.Hashtable();
    Integer c = null;
    transport.put("c", c);
    count(transport);

    One is not allowed to put null values into a hashtable. The
    generated code should rather look like:
    java.util.Hashtable transport = new
    java.util.Hashtable();
    Integer c = new Integer(0);
    transport.put("c", c);
    count(transport);

    This is another bug.

     
  • Benedikt Schulz

    Benedikt Schulz - 2003-01-19

    Logged In: YES
    user_id=672918

    Base-types like int, boolean, ... are transformed into
    Class-types before they can be put into the container for
    transportation.

    However the necessary code for e.g. transforming an int into
    an Integer (like described in the diploma thesis) is not
    generated. The base-types are put into into the container
    for transportation without this explicit type conversion.

     
  • Tobias Gutzmann

    Tobias Gutzmann - 2003-05-19
    • status: open --> open-postponed
     

Log in to post a comment.