Compiler Source Available

The source code to the SourcePawn compiler is now available. It retains the same license as its predecessor, zlib/libpng, and is not considered part of the SourceMod SDK.

Like everything else, it is available using ViewVC or SVN, both of which are synced nightly.

A quick rundown of what we’ve changed from the original compiler:

  • The output file format is completely different, which can be seen in The file is built in memory in the original AMX format and then converted to the new SourcePawn format. It is also GZ compressed.
  • There is a more advanced heap allocation tracker in place, in order to make certain features work.
  • There are new opcodes, such as OP.GENARRAY and OP.TRACKER.*, which are not yet documented.
  • Local arrays can have dynamic arguments.
  • Functions can be passed by index rather than by name. This was an aggressive modification.
  • Certain features are either disabled or explicitly not supported, such as “goto,” automatons, “struct enums,” sleeping, and all forms of packed or unpacked strings.
  • Strings are always encoded in native packed order and always use the built-in magic tag ‘String’. This was an aggressive modification.
  • There are new keywords:
    • functag (prototype tagging)
    • funcenum (prototype enumeration)
    • struct (simplistic structures)
    • cellsof (sizeof() returns bytes for Strings, so this returns cells)
    • decl (declares a variable that is not automatically zeroed)
  • There are a variety of bugs fixed which are either fixed differently or not fixed in the current Pawn distribution.

We will merge relevant changes from the ITB CompuPhase compiler with each of its releases.

While this won’t be terribly useful to most people, especially with automated nightly builds, it does show how the file format is generated. So, enjoy!

3 Responses to “Compiler Source Available”

  1. CyberMind says:

    Now Wraith has to parse another AMX file type.

  2. Zenith says:

    Is there a reason you compile it into the original AMX format then into the SourcePawn format (and not just straight to SourcePawn)?

  3. BAILOPAN says:

    Yes, it’s easier that way. Otherwise, we’d have to edit how the compiler builds and assembles everything. Taking the output and reformatting it ends up being simpler. This might not hold true for other scenarios but it is for this one.

    Cybermind: Indeed, though Wraith’s disassembler is pretty dated. It doesn’t support the newer symbol/debug section in AMX files. I think he’s working on a newer version. If it ever gets released I will probably write SourcePawn support in for him.

Leave a Reply

You must be logged in to post a comment.