This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional script functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer.
Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive.
If you use Fallout Script Editor, you can extract `compile.exe` and `dos4gw.exe` to its `\binary` folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn't seem to be able to tell when errors occur when using this compiler though, so I'd recommend either using sfall's script editor instead or compiling by hand if possible.
When compiling global or hook scripts for sfall 3.4 or below, you _must_ include the line `procedure start;` before any `#include` files that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5)
This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don't use any of the arrays syntax and any sfall script functions.
- Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.
- new:
```
procedure test(variable x, variable y := 0, variable z := -1) begin
...
end
...
call test("value");
```
- old:
```
procedure test(variable x, variable y, variable z) begin
...
end
...
call test("value", 0, -1);
```
- New logical operators `AndAlso`, `OrElse` for short-circuit evaluation of logical expressions.
Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.
Example: `if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...`
If `obj` is `null`, the second condition will not be checked and your script won't fail with "obj is null" error in debug.log
This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always `false` (0) or `true` (1):
- Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.
- Hexadecimal numerical constants: Simply prefix a number with `0x` to create a hexadecimal. The numbers 0 to 9 and letters A to F are allowed in the number. The number may not have a decimal point.
- Increment/decrement operators: `++` and `--` can be used as shorthand for `+= 1` and `-= 1` respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where `+= 1` would normally be allowed.
- `break` & `continue` statements: They work just like in most high-level languages. `break` jumps out of the loop. `continue` jumps right to the beginning of the next iteration (see `for` and `foreach` sections for additional details).
- `for` loops: Another piece of syntactic shorthand, to shorten `while` loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement).
__NOTE:__ `continue` statement in a `for` loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.
- Empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the Fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it's always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition:
- Procedure stringify operator `@`: Designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by `@` by a string constant.
Not many people know that since vanilla Fallout you can call procedures by "calling a variable" containing it's name as a string value. There was a couple of problems using this:
- optimizer wasn't aware that you are referencing a procedure, and could remove it, if you don't call it explicitly (can be solved by adding making procedure `critical`)
- you couldn't see all references of a procedure from a Script Editor
- it was completely not obvious that you could do such a thing, it was a confusing syntax
- (*) **Arrays**: In vanilla Fallout, arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in `[]`` to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it's not required, see "Arrays" page for more information)
- (*) **Array expressions**: Sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible:
__NOTE:__ When using incremental operators like `+=`, `*=`, `++`, `--` compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of `get_array` calls twice.
If you want to add additional condition for continuing the loop, use syntax: `foreach (<symbol> in <expression> while <expression>)`. In this case loop will iterate over elements of an array until last element or until "while" expression is true (whatever comes first).
- `playmoviealpharect` was using the token for `playmoviealpha`, breaking both functions in the process.
- `addbuttonflag` had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.
- The function `tokenize` was missing an entry in the token table, and so would not be recognised by the compiler.
- Fixed the check for the `call "foo"` syntax so that non-string constants will no longer be accepted.
## Backward compatibility
There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option `-b` is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:
- Since `for`, `foreach`, `break`, `continue`, `in` and `tokenize` are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.
- Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)
- The function `addbuttonflag` used to be recognised by the compiler, but would not emit any code into the int file.
- The function `playmoviealpharect` compiled as `playmoviealpha`.
**int2ssl** by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.