mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* update grammar * add ast nodes; ast building * Rename to unpacking * semantic analysis * executor work part 1, unpacking indices * renamings; implement index binding * small cleanup * use multi_index; more tests * use multi_index only for rest, otherwise list * initial formatting * add missing token decoding * address self-review comments * formatting tweaks * add test for var binding in classes * add StringIterator * fix spread tests * add cfgfile iterator; add cfgelem opersubscript; tests * add iterator for SQLResultSet and SQLRow; tests * Copy value in take global/local * Allow any iterable can index rest unpacking Always use dictionary as rest object in index unpacking * add docs, core-changes, doc tests * formatting changes... * address self-review comments * update formatter, format all binding test srcs * address review comments - unset var scope * add cfgfile/cfgelem docs * reformat objref svg
90 lines
2.2 KiB
Text
90 lines
2.2 KiB
Text
// Test varargs with base class?
|
|
|
|
// Something that does not have an iterator
|
|
var unspreadable := error{};
|
|
|
|
class BaseClass1()
|
|
function BaseClass1( this, arg0, args ... )
|
|
print( $"BaseClass1::BaseClass1 this={this} arg0={arg0} args={args}" );
|
|
// print( $"BaseClass1::BaseClass1 this={this} arg0={arg0}" );
|
|
endfunction
|
|
endclass
|
|
|
|
class BaseClass2()
|
|
function BaseClass2( this, arg0, args ... )
|
|
print( $"BaseClass2::BaseClass2 this={this} arg0={arg0} args={args}" );
|
|
endfunction
|
|
endclass
|
|
|
|
class BaseClass3()
|
|
function BaseClass3( this, args ... )
|
|
print( $"BaseClass3::BaseClass3 this={this} args={args}" );
|
|
endfunction
|
|
endclass
|
|
|
|
function GetSomeValues()
|
|
return array{ 4, 5, 6 };
|
|
endfunction
|
|
|
|
///////////
|
|
|
|
class Foo1( BaseClass1, BaseClass2, BaseClass3 )
|
|
function Foo1( this )
|
|
super( "arg0", BaseClass1::args:= { 1, 2, 3 },
|
|
BaseClass2::arg0:= "arg2", BaseClass2::args:= { 4,
|
|
5,
|
|
6 },
|
|
BaseClass3::args:= struct{ "struct values get spreaded" := "struct value" } );
|
|
endfunction
|
|
endclass
|
|
|
|
Foo1();
|
|
|
|
print( "----" );
|
|
|
|
class Foo2( BaseClass1, BaseClass2, BaseClass3 )
|
|
function Foo2( this )
|
|
super( "c1", array{ 1, 2, 3 }, "c2", GetSomeValues(), unspreadable );
|
|
endfunction
|
|
endclass
|
|
|
|
Foo2();
|
|
|
|
print( "----" );
|
|
|
|
class Foo3( BaseClass1, BaseClass2, BaseClass3 )
|
|
function Foo3( this )
|
|
super( "c1", unspreadable /* baseclass1::args, not spreadable, goes as empty array */, "c2!", {
|
|
"c2 args" }, BaseClass3::args:= unspreadable );
|
|
endfunction
|
|
endclass
|
|
|
|
Foo3();
|
|
|
|
print( "----" );
|
|
|
|
class BaseClassNotVariadic()
|
|
function BaseClassNotVariadic( this, arg0, arg1 )
|
|
print( $"BaseClassNotVariadic::BaseClassNotVariadic this={this} arg0={arg0} arg1={arg1}" );
|
|
endfunction
|
|
endclass
|
|
|
|
// A class where _only_ the last base class has varadic ctor can have a variadic super()
|
|
class Foo4( BaseClassNotVariadic, BaseClass1 )
|
|
function Foo4( this )
|
|
super( "nv0", "nv1", "bc.0", "bc1.0", "bc1.1" );
|
|
endfunction
|
|
endclass
|
|
|
|
Foo4();
|
|
|
|
print( "----" );
|
|
|
|
// A string is spreadable...
|
|
class Foo5( BaseClass1 )
|
|
function Foo5( this )
|
|
super( "arg0", "string" ... );
|
|
endfunction
|
|
endclass
|
|
|
|
Foo5();
|