[GSoC] 'Replace Runtime Hooks with Templates' progress and update thread
Dan Printzell
xwildn00bx at gmail.com
Wed Jul 17 22:04:36 UTC 2019
On Wednesday, 17 July 2019 at 20:47:02 UTC, Olivier FAURE wrote:
> On Wednesday, 17 July 2019 at 17:04:45 UTC, Dan Printzell wrote:
>> It does this by getting getting the `FuncDeclaration` which in
>> this case
>> is `HookTraceImpl` function, goes to its parent the
>> `HookTraceImpl`
>> template, takes the second template parameters, and uses to
>> rewrite the
>> `CallExp` and replace the `FuncDeclaration` that is used to do
>> the CTFE
>> interception.
>
> Out of curiosity, what is CTFE interception?
Basically I rewrite the expression `arr.length = len;` into a
function
call to the templated runtime function `_d_arraysetlengthT(arr,
len);`. But because of this the CTFE can no longer recognize that
the
code is trying to change the size of `arr`, only that it is
calling a
function called `_d_arraysetlengthT`.
The CTFE intercept is basically intercepting all the function call
that the CTFE would run and checks if it is trying to call the
`_d_arraysetlengthT`, and if it is it will rewrite the expression
back
to `arr.length = len` and then interpret that expression instead
of
the function call.
This is needed as the CTFE way of resizing arrays is not the same
as
how regular code resizes arrays.
More information about the Digitalmars-d
mailing list