devicescript
devicescript copied to clipboard
implicitly call `.toString()` (maybe)
The concatenation operator (+) as well as the indexing operator need to convert arguments to string. This may involve calling user-defined .toString() method.
The plan:
- add a flag to
devs_activationsaying it's an implicittoStringframe - when
.toString()needs to be called move backpcby one, copy any stack items, attach them to the activation frame fortoString(), reset stack to zero - upon return from toString frame - restore stack, in the calling opcode skip stuff based on the toString flag somehow
Alternative - STMT2_PLUS - stack is always empty
Alternative currently preferred - don't call .toString() implicitly and have the compiler warn about .toString()
I want to add the toString function to String.prototype, and the compiler shows the same infomation that this issue mentioned. I am curious about what is the plan of this issue?