sfall-team / sslc Goto Github PK
View Code? Open in Web Editor NEWScript compiler/parser for Fallout 2/sfall scripts
Script compiler/parser for Fallout 2/sfall scripts
procedure stuff(variable stuff, variable in_recursion := 0)
begin
if not(in_recursion) then
stuff := stuff(stuff, 1);
else
begin
display_msg("doing critical stuff");
stuff++;
return stuff;
end
end
procedure start begin call stuff(0); end
According to int2sll it compiles to
procedure stuff(variable arg0, variable arg1);
procedure start;
procedure stuff(variable arg0, variable arg1)
begin
if (not(arg1)) then begin
arg0 := arg0(arg0, 1); // wait what...
end
else begin
display_msg("doing critical stuff");
arg0 := arg0 + 1;
return arg0;
end
end
procedure start
begin
call stuff(0, 0);
end
export variable wtf;
procedure start begin
variable k := "a";
wtf := temp_array(-1, 0);
wtf[k] := 1;
display_msg(wtf[k]);
end
This gives error "')' expected after args list". The same syntax with a normal variable works.
procedure start begin
variable k;
foreach k in list_as_array(0)
if (k) then arr2[k] := v;
end
This gives error:
:5:16: 'else' expected.
If you add parentheses around foreach header block, replace list_as_array with a symbol or remove if, the error is gone. This is wrong behavior.
procedure proc(variable &end)
begin&end++;
if&end>10then&end=-1; return &end;
end
All vars should follow same syntax rules; having a way to have very unique var name is real nice (for example when global scope variable is defined deep down in header), fact that it introduces own subset of syntax rules is not :/
Disallowing merging constants with keywords would be nice too~
With -O2 option, given code:
procedure my_proc begin
display_msg("my_proc called");
end
procedure start begin
variable n;
variable procName;
call my_proc;
n := dude_obj;
procName := "my_"+"proc"+n;
call procName;
end
Round-trips to this:
procedure my_proc;
procedure start;
procedure my_proc begin
display_msg("my_proc called");
end
procedure start begin
variable LVar0 := 0;
variable LVar1 := 0;
call my_proc();
LVar0 := dude_obj;
call LVar1();
end
It should correctly count calling a variable as usage and prevent it from removal. Since variable itself isn't removed, it looks like an error in constant expression optimizations. This doesn't happen if you pass this variable to an opcode, like debug_msg
.
export procedure testexport222(variable a, variable b);
procedure testexport222(variable a, variable b) begin
return a + b;
end
If SSL contains a procedure with a string literal in it and this procedures gets optimized out due to being unused, the string literal remains in the file, increasing it's size.
procedure test(variable a, variable b) begin
return b * 2;
end
procedure start begin
display_msg(test(1,2));
end
Round trips to:
procedure test(variable arg0, variable arg1);
procedure start;
procedure test(variable arg0, variable arg1) begin
return arg0 * 2;
end
procedure start begin
display_msg(test(1, 2));
end
The generated code uses arg0 instead of arg1, thus breaking the logic of the function. This only happens with "full" optimization.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.