1 | # |
1 | # |
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | # |
3 | # |
4 | # Copyright (©) 2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | # Copyright (©) 2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | # |
5 | # |
6 | # Deliantra is free software: you can redistribute it and/or modify it under |
6 | # Deliantra is free software: you can redistribute it and/or modify it under |
7 | # the terms of the Affero GNU General Public License as published by the |
7 | # the terms of the Affero GNU General Public License as published by the |
8 | # Free Software Foundation, either version 3 of the License, or (at your |
8 | # Free Software Foundation, either version 3 of the License, or (at your |
9 | # option) any later version. |
9 | # option) any later version. |
… | |
… | |
229 | Starts with the default object - this is the object passed to the match to |
229 | Starts with the default object - this is the object passed to the match to |
230 | match against by default. Matches have an explicit C<of object> appended, |
230 | match against by default. Matches have an explicit C<of object> appended, |
231 | but submatches start at the current object, and in this case C<of object> |
231 | but submatches start at the current object, and in this case C<of object> |
232 | can be used to start at the original object once more. |
232 | can be used to start at the original object once more. |
233 | |
233 | |
|
|
234 | =item of self |
|
|
235 | |
|
|
236 | Starts with the object initiating/asking for the match - this is basically |
|
|
237 | always the object that the match expression is attached to. |
|
|
238 | |
234 | =item of source |
239 | =item of source |
235 | |
240 | |
236 | Starts with the I<source> object - this object is sometimes passed to |
241 | Starts with the I<source> object - this object is sometimes passed to |
237 | matches and represents the object that is the source of the action, such |
242 | matches and represents the object that is the source of the action, such |
238 | as a rod or a potion when it is applied. Often, the I<source> is the same |
243 | as a rod or a potion when it is applied. Often, the I<source> is the same |
… | |
… | |
244 | I<source>, the I<originator> is sometimes passed to matches and represents |
249 | I<source>, the I<originator> is sometimes passed to matches and represents |
245 | the original initiator of an action, most commonly a player or monster. |
250 | the original initiator of an action, most commonly a player or monster. |
246 | |
251 | |
247 | This object is often identical to the I<source> (e.g. when a player casts |
252 | This object is often identical to the I<source> (e.g. when a player casts |
248 | a spell, the player is both source and originator). |
253 | a spell, the player is both source and originator). |
249 | |
|
|
250 | =item of self |
|
|
251 | |
|
|
252 | Starts with the object initiating/asking for the match - this is basically |
|
|
253 | always the object that the match expression is attached to. |
|
|
254 | |
254 | |
255 | =back |
255 | =back |
256 | |
256 | |
257 | =head2 EXPRESSIONS |
257 | =head2 EXPRESSIONS |
258 | |
258 | |
… | |
… | |
475 | die "number, string or uppercase constant name expected\n"; |
475 | die "number, string or uppercase constant name expected\n"; |
476 | } |
476 | } |
477 | |
477 | |
478 | our $flag = $cf::REFLECT{object}{flags}; |
478 | our $flag = $cf::REFLECT{object}{flags}; |
479 | our $sattr = $cf::REFLECT{object}{scalars}; |
479 | our $sattr = $cf::REFLECT{object}{scalars}; |
|
|
480 | # quick hack to support archname, untested |
|
|
481 | $sattr->{archname} = "W"; |
480 | our $aattr = $cf::REFLECT{object}{arrays}; |
482 | our $aattr = $cf::REFLECT{object}{arrays}; |
481 | our $lattr = $cf::REFLECT{living}{scalars}; |
483 | our $lattr = $cf::REFLECT{living}{scalars}; |
482 | |
484 | |
483 | sub expr { |
485 | sub expr { |
484 | # ws done by factor |
486 | # ws done by factor |
… | |
… | |
723 | our %CACHE; |
725 | our %CACHE; |
724 | |
726 | |
725 | sub compile($$) { |
727 | sub compile($$) { |
726 | my ($wantarray, $match) = @_; |
728 | my ($wantarray, $match) = @_; |
727 | my $expr = parse $wantarray, $match; |
729 | my $expr = parse $wantarray, $match; |
728 | warn "MATCH DEBUG $match,$wantarray => $expr\n";#d# |
730 | # warn "MATCH DEBUG $match,$wantarray => $expr\n";#d# |
729 | $expr = eval " |
731 | $expr = eval " |
730 | package cf::match::exec; |
732 | package cf::match::exec; |
731 | sub { |
733 | sub { |
732 | my (\$object, \$self, \$source, \$originator) = \@_; |
734 | my (\$object, \$self, \$source, \$originator) = \@_; |
733 | $expr |
735 | $expr |