diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-19 11:26:40 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-19 11:26:40 -0500 |
commit | 481b04ace765135c4b990e90a0b872fa23f286f0 (patch) | |
tree | 2959aa676ed9419c0a780526820f209ae872275d /lib/Text/Handlebars/Compiler.pm | |
parent | 47fc628b0553c6b1bf7597f29bd2b6b5ce238cbf (diff) | |
download | text-handlebars-481b04ace765135c4b990e90a0b872fa23f286f0.tar.gz text-handlebars-481b04ace765135c4b990e90a0b872fa23f286f0.zip |
find_file and suffix are now opcodes
Diffstat (limited to 'lib/Text/Handlebars/Compiler.pm')
-rw-r--r-- | lib/Text/Handlebars/Compiler.pm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Text/Handlebars/Compiler.pm b/lib/Text/Handlebars/Compiler.pm index 356baeb..de7b0c4 100644 --- a/lib/Text/Handlebars/Compiler.pm +++ b/lib/Text/Handlebars/Compiler.pm @@ -83,7 +83,7 @@ sub _generate_partial { arity => 'binary', id => '~', first => $file->[0], - second => $self->call($node, '(suffix)'), + second => $node->clone(arity => 'suffix'), ); } @@ -102,11 +102,24 @@ sub _generate_partial { ); } +sub _generate_suffix { + my $self = shift; + my ($node) = @_; + + return ( + $self->opcode('suffix'), + ); +} + sub find_file { my $self = shift; my ($filename) = @_; - return $self->call($filename, '(find_file)', $filename); + return $filename->clone( + arity => 'unary', + id => 'find_file', + first => $filename, + ); } sub _generate_for { @@ -207,7 +220,7 @@ sub _generate_unary { ); # render_string can't be constant folded, because it depends on the # current vars - if ($Text::Xslate::Compiler::OPTIMIZE and $self->_code_is_literal(@code) && $node->id ne 'render_string') { + if ($Text::Xslate::Compiler::OPTIMIZE and $self->_code_is_literal(@code) && $node->id ne 'render_string' && $node->id ne 'find_file') { $self->_fold_constants(\@code); } return @code; @@ -223,7 +236,7 @@ sub is_unary { my %unary = ( map { $_ => 1 } qw(builtin_is_array_ref builtin_is_hash_ref is_code_ref - render_string) + find_file render_string) ); return $unary{$id}; |