Skip to content

Commit

Permalink
Fix "\r\n".perl
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jan 24, 2012
1 parent b2c1062 commit 566fb13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 87 deletions.
2 changes: 1 addition & 1 deletion lib/CORE.setting
Expand Up @@ -901,7 +901,7 @@ my class Str is Cool {
'\\' => '\\\\' };
method perl() {
self // nextsame;
'"' ~ self.subst(/ <[$@%&{\b\n\r\t\"\\]> /, { $esc{$/} }, :g)\
'"' ~ self.subst(/ <[$@%&{\b\cJ\cM\t\"\\]> /, { $esc{$/} }, :g)\
.subst(/ <-print> /, { ord($/).fmt('\x[%x]') }, :g) ~ '"'
}
}
Expand Down
97 changes: 11 additions & 86 deletions main.pl
Expand Up @@ -8,7 +8,8 @@
# * Allow exact Perl 6 forms, quoted away from shell
# * Fix remaining XXXX

# TODO (sorear): add True, False to val(); (eval) becomes -e
# TODO (sorear): add True, False to val(); (eval) becomes -e; change param
# names to be name-of-var or ""; Str.perl escaping

use MONKEY_TYPING;
augment class Code {
Expand Down Expand Up @@ -73,95 +74,19 @@
method named_names() { !!! }
method type() { !!! }
method optional() { !!! }
method positional() { !!! }
method value_constraint_list() { !!! }
method name() { !!! }
method slurpy() { !!! }

method name() {
$!variable_name
}

method constraint_list() {
pir::isnull($!post_constraints) ?? () !!
pir::perl6ize_type__PP($!post_constraints)
}

method constraints() {
all(pir::isnull($!post_constraints) ?? () !!
pir::perl6ize_type__PP($!post_constraints))
}

method type() {
$!nominal_type
}

method named() {
!nqp::p6bool(nqp::isnull($!named_names)) ||
nqp::p6bool($!flags +& $SIG_ELEM_SLURPY_NAMED)
}

method named_names() {
if !pir::isnull($!named_names) {
my Int $count = nqp::p6box_i(nqp::elems($!named_names));
my Int $i = 0;
my @res;
while $i < $count {
@res.push: nqp::p6box_s(nqp::atpos($!named_names, nqp::unbox_i($i)));
$i++;
}
@res;
} else {
().list
}
}

method positional() {
nqp::p6bool(
($!flags +& ($SIG_ELEM_SLURPY_POS +| $SIG_ELEM_SLURPY_NAMED)) == 0 &&
nqp::isnull($!named_names)
)
}

method slurpy() {
nqp::p6bool(
$!flags +& ($SIG_ELEM_SLURPY_POS
+| $SIG_ELEM_SLURPY_NAMED
+| $SIG_ELEM_SLURPY_BLOCK)
)
}

method optional() {
?($!flags +& $SIG_ELEM_IS_OPTIONAL)
}

method parcel() {
?($!flags +& $SIG_ELEM_IS_PARCEL)
}

method capture() {
?($!flags +& $SIG_ELEM_IS_CAPTURE)
}

method rw() {
?($!flags +& $SIG_ELEM_IS_RW)
}

method copy() {
?($!flags +& $SIG_ELEM_IS_COPY)
}

method readonly() {
!($.rw || $.copy || $.parcel)
}

method invocant() {
?($!flags +& $SIG_ELEM_INVOCANT)
}

method default() {
nqp::isnull($!default_value) ?? Any !!
$!default_value ~~ Code ?? $!default_value !! { $!default_value }
}
# no constraint_list! niecza's SubInfo constraints don't reflect well :|
method parcel() { !!! }
method capture() { !!! }
method rw() { !!! }
method copy() { !!! }
method readonly() { !!! }
method invocant() { !!! }
method default() { !!! }

# XXX TODO: A few more bits :-)
multi method perl(Parameter:D:) {
Expand Down

0 comments on commit 566fb13

Please sign in to comment.