Skip to content

Instantly share code, notes, and snippets.

@Whiteknight
Created February 5, 2012 17:14
Show Gist options
  • Save Whiteknight/1746639 to your computer and use it in GitHub Desktop.
Save Whiteknight/1746639 to your computer and use it in GitHub Desktop.
Optional Args in Winxed
<winxed git:optional_args> ./winxed test.winxed
foo
4
5
6
bar
foo
7
8
9
test
foo
1
2
3
test
# THIS IS A GENERATED FILE! DO NOT EDIT!
# Begin generated code
.namespace [ ]
.sub 'foo' :subid('WSubId_1')
.param pmc __ARG_1 :optional
.param int __opt_flag___ARG_1 :opt_flag
.param string __ARG_2 :optional
.param int __opt_flag___ARG_2 :opt_flag
if __opt_flag___ARG_1 goto __have_value___ARG_1
.annotate 'file', 'test.winxed'
.annotate 'line', 1
root_new $P1, ['parrot';'ResizablePMCArray']
assign $P1, 3
$P1[0] = 1
$P1[1] = 2
$P1[2] = 3
__ARG_1 = $P1
__have_value___ARG_1:
if __opt_flag___ARG_2 goto __have_value___ARG_2
__ARG_2 = "test"
__have_value___ARG_2:
.annotate 'line', 3
say "\nfoo"
.annotate 'line', 4
$P1 = __ARG_1[0]
say $P1
.annotate 'line', 5
$P1 = __ARG_1[1]
say $P1
.annotate 'line', 6
$P1 = __ARG_1[2]
say $P1
.annotate 'line', 7
say __ARG_2
.annotate 'line', 8
.end # foo
.sub 'main' :main
.param pmc __ARG_1
.const 'Sub' WSubId_1 = "WSubId_1"
.annotate 'line', 12
root_new $P1, ['parrot';'ResizablePMCArray']
assign $P1, 3
$P1[0] = 4
$P1[1] = 5
$P1[2] = 6
WSubId_1($P1, "bar")
.annotate 'line', 13
root_new $P1, ['parrot';'ResizablePMCArray']
assign $P1, 3
$P1[0] = 7
$P1[1] = 8
$P1[2] = 9
WSubId_1($P1)
.annotate 'line', 14
WSubId_1()
.annotate 'line', 15
.end # main
# End generated code
function foo(var x = [1, 2, 3], string y = "test")
{
say("\nfoo");
say(x[0]);
say(x[1]);
say(x[2]);
say(y);
}
function main[main](var args)
{
foo([4, 5, 6], "bar");
foo([7, 8, 9]);
foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment