LSL-PyOptimizer/unit_tests/coverage.suite/inline-1.lsl
Sei Lisa bf72d2c3bf Allow //pragma inline or /*pragma inline*/ for inlining a function
They are transformed by the scanner to the identifier `inline`, which is how the parser identifies it. This solves the comment problem, but it results in a funny side effect. Now, in inline mode, /*pragma inline*/ will always be the identifier `inline`, therefore this is valid:

    integer /*pragma inline*/ = 5;
    llOwnerSay((string)inline); // will say 5

Not overly elegant, but better than making up a specific token or declaring comments as tokens or the like.
2021-10-17 20:29:22 +02:00

61 lines
872 B
Text

#pragma OPT inline
f1() inline
{
llOwnerSay("f1");
}
f2(integer f2param) /*pragma inline*/
{
llOwnerSay("f2:" + (string)f2param);
}
vector f3(integer f3p1, string f3p2) //pragma inline
{
f2(f3p1);
integer f3p1; // test shading the parameter
{
jump x;
llOwnerSay("f3:" + (string)f3p1 + f3p2);
}
@x;
if (f3p2 != "") return <1,1,1>;
do ; while (f4());
while (f4()) ;
for (f3p1=0; f4(); f3p1++, llDie())
{
integer f3p1 = llGetNumberOfPrims();
llOwnerSay((string)f3p1);
}
return <0,0,0>;
}
integer f4() inline
{
return llGetLinkNumber();
}
say(string s) inline
{
llOwnerSay(s);
}
default
{
state_entry()
{
f1();
if (1) f1();
f2(3);
if (f3(4, "x") == ZERO_VECTOR) llOwnerSay("ok");
}
timer()
{
say("hi");
}
}