<commit_before># Copyright (C) 2007-2008, The Perl Foundation.
# $Id$

=head1 NAME

lib/luaperl.pir

=head1 DESCRIPTION

Encapsulation of the compiler written in Perl as a Parrot registered compiler.

This encapsulation is used to implement some Lua functions :

=over 4

=item dofile

=item loadfile

=item loadstring

=back

It's a temporary work. Waiting for the real PIR compiler/interpreter.

=head2 Methods

=over 4

=cut

.namespace []

.sub '__onload' :anon :load :init
    $P0 = newclass [ 'Lua::PerlCompiler' ]
    new $P1, $P0
    compreg 'Lua', $P1
.end

.namespace [ 'Lua::PerlCompiler' ]

.sub 'unlink' :anon
    .param string filename
    new $P0, 'OS'
    push_eh _handler
    $P0.'rm'(filename)
  _handler:
    .return ()
.end

.sub 'save_lua' :anon
    .param string code
    .param string filename
    .local pmc fh
    fh = open filename, '>'
    if fh goto L1
    $S0 = err
    print "Can't open '"
    print filename
    print "' ("
    print $S0
    print ")\n"
    goto L2
  L1:
    print fh, code
    close fh
  L2:<commit_msg>[Lua] - refactor namespace : Perl Compiler<commit_after># Copyright (C) 2007-2008, The Perl Foundation.
# $Id$

=head1 NAME

lib/luaperl.pir

=head1 DESCRIPTION

Encapsulation of the compiler written in Perl as a Parrot registered compiler.

This encapsulation is used to implement some Lua functions :

=over 4

=item dofile

=item loadfile

=item loadstring

=back

It's a temporary work. Waiting for the real PIR compiler/interpreter.

=head2 Methods

=over 4

=cut

.namespace []

.sub '__onload' :anon :load :init
    $P0 = newclass [ 'Lua'; 'PerlCompiler' ]
    new $P1, $P0
    compreg 'Lua', $P1
.end

.namespace [ 'Lua'; 'PerlCompiler' ]

.sub 'unlink' :anon
    .param string filename
    new $P0, 'OS'
    push_eh _handler
    $P0.'rm'(filename)
  _handler:
    .return ()
.end

.sub 'save_lua' :anon
    .param string code
    .param string filename
    .local pmc fh
    fh = open filename, '>'
    if fh goto L1
    $S0 = err
    print "Can't open '"
    print filename
    print "' ("
    print $S0
    print ")\n"
    goto L2
  L1:
    print fh, code
    close fh
  L2:
{'fraction_non_alphanumeric': 0.10762751520823584, 'fraction_numerical': 0.02339728591483388, 'mean_word_length': 2.7508771929824563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3810018', 'n_tokens_mistral': 827, 'n_tokens_neox': 784, 'n_words': 267}