eclipse / mita

mita
Eclipse Public License 2.0
56 stars 20 forks source link

enum in struct #358

Open boaks opened 5 years ago

boaks commented 5 years ago
enum Feature {
    Temperature,
    Pressure,
    Humidity,
    Illuminance,
    Accelerometer,
    Gyroscope,
    Magnetometer
}

struct Sensor {
    var current : float;
    var min : float;
    var max : float;
    var init : bool;
    var feature : Feature;
}

Results in

typedef struct {
    float current;
    float min;
    float max;
    bool init;
    Feature feature;
} Sensor;

typedef enum {
    Temperature,
    Pressure,
    Humidity,
    Illuminance,
    Accelerometer,
    Gyroscope,
    Magnetometer
} Feature;

and error: "unknown type name 'Feature'"

wegendt-bosch commented 5 years ago

This chould already be fixed in master since some point after the new type system. Are you using master or the XDK Workbench 3.*? Nope, not fixed.

wegendt-bosch commented 5 years ago

We might have to do something similar to how we handle system resource initialization and create a graph of dependencies, then do a topological sort.

Since structs may reference one another via references, those have to be excluded when collecting dependencies, and forward declared when translating.