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
37 lines
1 KiB
Text
37 lines
1 KiB
Text
var original := struct{ foo := "FOO", bar := array{ 1, 2, 3 } };
|
|
// Serialize the original, and check at end nothing has changed.
|
|
var original_serialized := Pack( original );
|
|
|
|
// Calls copy. Globals
|
|
var { foo } := original;
|
|
foo := "BLUB";
|
|
print( $"original.foo={original.foo} foo={foo}" );
|
|
// Locals
|
|
if ( 1 )
|
|
var { foo } := original;
|
|
foo := "BLUB";
|
|
print( $"original.foo={original.foo} foo={foo}" );
|
|
endif
|
|
print( "----" );
|
|
|
|
// Also calls copy
|
|
var { bar: [ a, b, c ], bar } := original;
|
|
print( $"bar={bar} a={a} b={b} c={c}" );
|
|
bar[1] := "one";
|
|
print( $"bar={bar} original={original}" );
|
|
bar := "BAR";
|
|
print( $"bar={bar} original={original}" );
|
|
|
|
print( "----" );
|
|
print( $"original unchanged: {original_serialized == Pack( original )}" );
|
|
|
|
print( "----" );
|
|
// Does not call copy. Globals
|
|
// Can't really test this via script, since there will be no other reference to the binding initializer,
|
|
var [ d, e, f ] := array{ 1, 2, 3 };
|
|
print( $"d={d} e={e} f={f}" );
|
|
// Locals
|
|
if ( 1 )
|
|
var [ d, e, f ] := array{ 1, 2, 3 };
|
|
print( $"d={d} e={e} f={f}" );
|
|
endif
|