5. Fanp


The fanp command line tool is used to dissemble compiled fcode. If you have a burning desire to hack the compiler or the runtime emit code, then you will find fanp indispensable. Like many of the other command line tools you can pass a pod name, a type qname, or a slot qname:

fanp fansh
fanp fansh::Main
fanp fansh::Main.main

By default only high level signatures and facets are printed. Print the usage via "-?" to see various options.

Dissembling Code

The "-c" option will dump the opcodes:

// fansh::Main.main
static Void main() { Shell.make.run }

// disassemble it
C:\>fanp -c fansh::Main.main

main () -> sys::Void [const public static]
    0: CallNew             fansh::Shell.make() -> sys::Void
    3: CallVirtual         fansh::Shell.run() -> sys::Void
    6: Return
  [LineNumber] size=2

Dissembling Scripts

You can print the dissembled code of a script file after it is compiled but before it is executed using the "-fcodeDump" argument after the script filename:

fan script.fan -fcodeDump
script.fan -fcodeDump        // if script.fan is directly executable