#106 Fan compiler milestone

brian Mon 21 Aug 2006

I reached a big milestone tonight - I can compile a Fan program end-to-end using the compiler written in Fan. The frontend (parser) and backend (assembler) are pretty much done. That just leaves the very challenging analysis steps.

One of the big problems I ran into is how to boot a script compiled in Fan code into the Java (or .NET runtime). In the Java compiler I compile into a FPod memory data structure, then use that to load the Pod - skipping the file system. However in the Fan compiler I don't have the Java version of the FPod data structures so the only way to communicate is to serialize into a zip file. Right now I'm actually doing this serialization to a temporary zip file on the disk. But this requires File.deleteOnExit which will eat up memory in a very long running server process. Another option would be to serialize into a big byte array and then use that to pass the load the pod. Tough problem.

brian Wed 23 Aug 2006

After some though I changed the key method Sys.loadPod(File) to be Sys.loadPod(InStream). That means I create the pod zip in memory to pass to Sys. It saves us from creating a bunch of temporary files and seems like a better design for loading scripts and stuff compiled in memory. You just can't have resource files for the pod, but in general this should only be used when compiling a script from an in-memory string.

Login or Signup to reply.