| | 237 | During this phase, avoid storing "sharp" values such `someType.sharpRef`. While C# is Cobra's current backend, there will likely be other backends in the future including CIL, JVM, Objective-C, etc. Instead store a reference to the type or other object and then access its "sharp" properties during C# code gen (typically in a .writeSharpDef method implementation). |
| | 238 | |
| | 239 | |
| | 240 | .h2 @ Code generation phase |
| | 241 | |
| | 242 | TODO |
| | 243 | |
| | 244 | The code generation is currently C#. |
| | 245 | |
| | 246 | When a statement needs to create a private local variable to help with its implementation, there are some conventions to follow which prevent problems. First, start them with an underscore (_) which will eliminate any possibility of collision with explicit locals (Cobra does not allow locals to start with an undescore). Also, use "_lh_" for local helper which reduces chance collisions with object variables. Also, add the serial number of the current node to further prevent collisions including with other local helper variables. For example: |
| | 247 | |
| | 248 | .code |
| | 249 | def writeSharpDef(sw as SharpWriter) |
| | 250 | # ... |
| | 251 | localName = '_lh_event_[.serialNum]' |
| | 252 | |