Where can we obtain the code written for a generated method?
When a class containing a method generator is compiled, the code that implements the method at runtime is written according to the instructions in the method definition.
Suppose I want to obtain the generated code in order to parse and analyze it (e.g. in our Yuzinji tool). The method generator code is available in the Implementation stream of %Dictionary.MethodDefinition, but I want the code that this code generates. I tried looking in %Dictionary.CompiledMethod but was disappointed to find that its Implementation stream also contains the generator code, not the generated code. See below for an example using a method of a class that exists in the SAMPLES namespace:
SAMPLES>s m1=##class(%Dictionary.MethodDefinition).%OpenId("Sample.Installer||setup") SAMPLES>d m1.Implementation.OutputToDevice() #; Let our XGL document generate code for this method. Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "MyApp") SAMPLES> SAMPLES>s m2=##class(%Dictionary.CompiledMethod).%OpenId("Sample.Installer||setup") SAMPLES>d m2.Implementation.OutputToDevice() #; Let our XGL document generate code for this method. Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "MyApp") SAMPLES>w $zv Cache for Windows (x86-64) 2017.2 (Build 744U) Fri Sep 29 2017 10:58:27 EDT SAMPLES>
Does anyone know of a way to get the generated code, other than forcing the compilation to retain INT code and then digging into the INT routine for the relevant procedure?