Repository navigation
Conversation
54a87da to
be2acac
Compare
There was a problem hiding this comment.
Devin Review found 5 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| case ValueType::String: | ||
| return "\"" + escapeCppString(value.toString()) + "\""; | ||
|
|
||
| default: | ||
| throw std::runtime_error("unsupported constant type"); |
There was a problem hiding this comment.
🔴 Pointer arguments abort code generation
For blocks such as reset timer, toCppConstant rejects the pointer argument with “unsupported constant type.” compileResetTimer supplies its timer through addConstValue, so generation aborts.
Learn more
The compiler supports pointer constants as references to runtime objects. compileResetTimer records the engine's timer this way. castConstValue preserves that pointer, but createCall then sends it to this serializer, which throws.
Example: Compile a script containing only reset timer. Its sensing_resettimer call has a constant timer pointer and fails before finalization.
Recommended fix: Implement pointer-constant lowering using runtime object references appropriate for generated C++, rather than rejecting ValueType::Pointer. Avoid embedding process-specific addresses if the output must run in another process. Cover timer, target, variable, and list pointer arguments.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if (value->type() == targetType) | ||
| return source; | ||
|
|
||
| const CppNamedIdentifier *result = getNamedIdentifier(value, m_valueTypeMap.at(targetType), "castRawValue", false); |
There was a problem hiding this comment.
🔴 Conversion destinations alias their source values
For cross-type conversions, getNamedIdentifier returns the source identifier because m_identifiers keys only on the original value. castValue, castRawValue, and raw boxing reuse incompatible representations. Conversion assignments reject immutable sources or overwrite mutable sources.
Learn more
A compiler value can need several generated representations without changing its original value. getNamedIdentifier returns any existing identifier for the compiler value, regardless of the requested type. Consequently the conversion destination is the source itself. The generic-value conversion in castValue and raw boxing in createValue repeat this pattern. Allowing assignments alone does not resolve the aliasing.
Example: A numeric reporter value of 42 needs a boolean argument and later a numeric argument. The conversion destination resolves to the original numeric identifier, so enabling the assignment would replace 42 with 1 instead of preserving 42 and creating a separate boolean temporary.
Recommended fix: Allocate separate mutable conversion temporaries with createNamedIdentifier, or maintain distinct representations keyed by compiler value and destination type. Preserve the source mapping. Test repeated uses of one reporter across multiple argument types, including ValueData boxing.
Was this helpful? React with 👍 or 👎 to provide feedback.
Resolves: #664
Resolves: #665
Resolves: #666