openroberta-lab icon indicating copy to clipboard operation
openroberta-lab copied to clipboard

small enhancements for C (and Python) code generator

Open rbudde opened this issue 7 years ago • 2 comments

  • [x] 1. #define a constant for the sleep-time (wait blocks, ...).
  • [x] 2. #define a constant for 255.0/9.0, which is used at many places for calculating the brightness
  • [ ] 3. replace the pattern if (... == true) by if(...) and if(... == false) by if(! ...). Actually the patterns are mixed (I see both (... == true) and (...)
  • [x] 4. replace while(true) by while(1) or vice versa. Actually we have a mix.
  • [ ] 5. the layout of a label used in a generated goto (from a "break out from loop") is broken
  • [ ] 6. we generate dead code after a generated goto (from a "break out from loop")
  • [ ] 7. if a programmer chooses as function name a name used by the mbit runtime, e.g. "release_fiber", the compiler bails out. We should decide whether we ignore that or have a server side checker detecting this (will be a lot of names) or use prefixing to decrease probability of clashes or ...

These are small enhancement. May be done if there is time :-)

rbudde avatar Feb 09 '18 16:02 rbudde

The current implementation of #define ... will cause errors, if one declare a variable. image Please remove this part off your last commit

bjost2s avatar Feb 25 '18 21:02 bjost2s

The following should be implemented:

  • create a file "NEPODefs.h" and make it accessible for the code generator
  • put the 3 #defines into that file. The names should start with _
  • the variable uBit should be renamed to _uBit . The code generator has to be adjusted (at many places)
  • the variable initTime should be renamed to _initTime and only be generated if the timer is used in the program to be compiled.

rbudde avatar Mar 12 '18 11:03 rbudde

unclear status

bjost2s avatar Oct 23 '24 10:10 bjost2s