diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2553347..0452b1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: uses: actions/cache@v4 with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1005 - name: Download RPU scripts & modderspack if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') @@ -97,7 +97,7 @@ jobs: uses: actions/cache@v4 with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1005 - name: Download RPU scripts & modderspack if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') shell: bash @@ -234,7 +234,7 @@ jobs: if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1005 fail-on-cache-miss: true - name: Test on Fallout RPU if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') @@ -283,7 +283,7 @@ jobs: if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1005 fail-on-cache-miss: true - name: Test on Fallout RPU if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') diff --git a/docs/sslc_readme.md b/docs/sslc_readme.md index 4be48e7..b87149d 100644 --- a/docs/sslc_readme.md +++ b/docs/sslc_readme.md @@ -322,6 +322,8 @@ Syntax which requires sfall for compiled scripts to be interpreted is marked by If you want to add additional condition for continuing the loop, use syntax: `foreach ( in while )`. In this case loop will iterate over elements of an array until last element or until "while" expression is true (whatever comes first). __NOTE:__ Just like `for` loop, `continue` statement will respect increments of a hidden counter variable, so you can safely use it inside `foreach`. + +- `#pragma sce` directive. If present anywhere in the compiled script, will enable short-circuit evaluation of logical `and` and `or` operators, even if `-s` command line argument is not used. --- @@ -348,6 +350,9 @@ There are several changes in this version of sslc which may result in problems f ### Changelog +**sfall 4.4.10:** +- added #pragma sce + **sfall 4.4.7:** - fixed leftover stack data caused by the `break` statement - added Linux & WebAssembly builds diff --git a/lex.c b/lex.c index 1a1527e..c2cf038 100644 --- a/lex.c +++ b/lex.c @@ -37,6 +37,7 @@ static void AppendToAssignCache() { } extern int backwardcompat; +extern int shortCircuit; static int ungotToken = -1; static int lastToken = -1; @@ -637,6 +638,38 @@ int lex_internal(void) { ungetChar(); } } + else if (_stricmp(buf[which], "pragma") == 0) { // pragma directives + do { + c = getChar(); + } while(c != EOF && c != '\n' && !validSymbolChar(c)); + + if (c == EOF) { + ungetChar(); + } + else if (validSymbolChar(c)) { + + buf[which][0] = c; + + i = 0; + while(1) { + c = getChar(); + + if (!validSymbolChar(c) && c != '-') + break; + + buf[which][i+1] = c; + i++; + } + + buf[which][i+1] = 0; + + if (_stricmp(buf[which], "sce") == 0 && !shortCircuit) { + shortCircuit = 1; + } + if (c == EOF) + ungetChar(); + } + } else if (c == EOF) { ungetChar(); } diff --git a/parse.c b/parse.c index 967f0ea..bd046d9 100644 --- a/parse.c +++ b/parse.c @@ -28,7 +28,7 @@ extern int warnings; extern int optimize; extern int debug; extern int dumpTree; -extern int shortCircuit; + void optimizeTree(Program *program); /*