|
Revision 18045, 1.4 kB
(checked in by fglock, 15 months ago)
|
|
[kp6] set svk eol, mime-type properties
|
-
Property svn:mime-type set to
text/plain; charset=UTF-8
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | ::If( |
|---|
| 2 | cond => |
|---|
| 3 | ::Apply( |
|---|
| 4 | arguments => [ ::Proto( name => $node.name ) ], |
|---|
| 5 | code => ::Var( name => 'VAR_defined', twigil => '', sigil => '&', ), |
|---|
| 6 | ), |
|---|
| 7 | body => '', |
|---|
| 8 | otherwise => |
|---|
| 9 | ::Lit::Code( |
|---|
| 10 | body => [ |
|---|
| 11 | ::Bind( |
|---|
| 12 | 'parameters' => ::Proto( name => $node.name ), |
|---|
| 13 | 'arguments' => ::Call( |
|---|
| 14 | 'invocant' => $metaobject, |
|---|
| 15 | 'method' => 'PROTOTYPE', |
|---|
| 16 | 'hyper' => '', |
|---|
| 17 | ), |
|---|
| 18 | ) |
|---|
| 19 | ], |
|---|
| 20 | sig => |
|---|
| 21 | ::Sig( named => {}, invocant => '', positional => [], ), |
|---|
| 22 | pad => ($node.body).pad, |
|---|
| 23 | state => { }, |
|---|
| 24 | ), |
|---|
| 25 | ); |
|---|
| 26 | |
|---|
| 27 | is written like that with quasi quotes |
|---|
| 28 | |
|---|
| 29 | q:code { |
|---|
| 30 | if (defined {{{::Proto( name => $node.name )}}}) { |
|---|
| 31 | } else { |
|---|
| 32 | {{{::Proto( name => $node.name )}}} := {{{$metaobject}}}.PROTOTYPE; |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | they compile to the same thing |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | Example of intended use in Token.pm |
|---|
| 40 | |
|---|
| 41 | return 'do { ' ~ |
|---|
| 42 | 'my $ret = self.'~$.closure ~ ';' ~ |
|---|
| 43 | 'if $ret {' ~ |
|---|
| 44 | '$MATCH.result = $ret; ' ~ |
|---|
| 45 | 'return $MATCH;' ~ |
|---|
| 46 | '};' ~ |
|---|
| 47 | '1' ~ |
|---|
| 48 | '}' |
|---|
| 49 | |
|---|
| 50 | return q:code { |
|---|
| 51 | do { |
|---|
| 52 | my $ret = sub { {{{$.closure}}} }; |
|---|
| 53 | if $ret { |
|---|
| 54 | $MATCH.result = $ret; |
|---|
| 55 | return $MATCH; |
|---|
| 56 | }; |
|---|
| 57 | 1; |
|---|
| 58 | } |
|---|
| 59 | } |
|---|