<commit_before>#
# File.pm
#
# Copyright (C) 2003 <NAME>. All rights reserved.
# This program is free software. It is subject to the same license
# as the Parrot interpreter.
#
# $Id$
#

use strict;
eval "use warnings";

package Jako::Construct::Block::File;

use Carp;

use Jako::Compiler;

use base qw(Jako::Construct::Block);


#
# compile()
#

sub compile
{
  my $self     = shift; # Required:
  my $compiler = shift; # Required

#  my $namespace = "FILE"; # TODO: Don't we need to do better than this?

  return 1 unless $self->content;

  my $inline = 0;
  my $last_seen = 'sub';

  $compiler->emit(".sub ___MAIN");
  $compiler->indent;
  $compiler->emit("bsr __INLINE_0");
  $compiler->emit("end");
  $compiler->outdent;
  $compiler->emit(".end");

  foreach my $construct ($self->content) {
    if (
         $construct->isa("Jako::Construct::Block::Sub")
      or $construct->isa("Jako::Construct::Block::Module")
      or $construct->isa("Jako::Construct::Declaration::Sub")
    ) {
      if ($last_seen ne 'sub') {
        $compiler->emit("goto __INLINE_" . $inline); # $inline is already the next one.
        $compiler->outdent;
        $compiler->emit(".end");

        $last_seen = 'sub';
      }
    }
    else {<commit_msg>Use bsr & ret instead of goto to move among inline code sequences<commit_after>#
# File.pm
#
# Copyright (C) 2003 <NAME>. All rights reserved.
# This program is free software. It is subject to the same license
# as the Parrot interpreter.
#
# $Id$
#

use strict;
eval "use warnings";

package Jako::Construct::Block::File;

use Carp;

use Jako::Compiler;

use base qw(Jako::Construct::Block);


#
# compile()
#

sub compile
{
  my $self     = shift; # Required:
  my $compiler = shift; # Required

#  my $namespace = "FILE"; # TODO: Don't we need to do better than this?

  return 1 unless $self->content;

  my $inline = 0;
  my $last_seen = 'sub';

  $compiler->emit(".sub ___MAIN");
  $compiler->indent;
  $compiler->emit("bsr __INLINE_0");
  $compiler->emit("end");
  $compiler->outdent;
  $compiler->emit(".end");

  foreach my $construct ($self->content) {
    if (
         $construct->isa("Jako::Construct::Block::Sub")
      or $construct->isa("Jako::Construct::Block::Module")
      or $construct->isa("Jako::Construct::Declaration::Sub")
    ) {
      if ($last_seen ne 'sub') {
        $compiler->emit("bsr __INLINE_" . $inline); # $inline is already the next one.
        $compiler->emit("ret"); # Return to the previous inline chunk.
        $compiler->outdent;
        $compiler->emit(".end");

        $last_seen = 'sub';
      }
    }
    else {
{'fraction_non_alphanumeric': 0.1679477325134512, 'fraction_numerical': 0.005380476556495004, 'mean_word_length': 3.2883031301482704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452718', 'n_tokens_mistral': 878, 'n_tokens_neox': 837, 'n_words': 236}