Permalink
Browse files

switch Attribute, Enumeration, Hash, LoL and Order to sigilless params

  • Loading branch information...
1 parent 0d98c32 commit 504e994257560e2db5ce66fe460172e5df18e4e1 @moritz moritz committed Aug 14, 2012
Showing with 47 additions and 47 deletions.
  1. +5 −5 src/core/Attribute.pm
  2. +1 −1 src/core/Enumeration.pm
  3. +25 −25 src/core/Hash.pm
  4. +7 −7 src/core/LoL.pm
  5. +9 −9 src/core/Order.pm
View
@@ -86,13 +86,13 @@ my class Attribute {
}
}
- method set_value(Mu $obj, Mu \$value) {
+ method set_value(Mu $obj, Mu \value) {
my $decont := nqp::p6decont($obj);
given nqp::p6box_i(pir::repr_get_primitive_type_spec__IP($!type)) {
- when 0 { nqp::bindattr($decont, $!package, $!name, $value) }
- when 1 { nqp::p6box_i(nqp::bindattr_i($decont, $!package, $!name, $value)) }
- when 2 { nqp::p6box_n(nqp::bindattr_n($decont, $!package, $!name, $value)) }
- when 3 { nqp::p6box_s(nqp::bindattr_s($decont, $!package, $!name, $value)) }
+ when 0 { nqp::bindattr($decont, $!package, $!name, value) }
+ when 1 { nqp::p6box_i(nqp::bindattr_i($decont, $!package, $!name, value)) }
+ when 2 { nqp::p6box_n(nqp::bindattr_n($decont, $!package, $!name, value)) }
+ when 3 { nqp::p6box_s(nqp::bindattr_s($decont, $!package, $!name, value)) }
}
}
View
@@ -80,7 +80,7 @@ Metamodel::EnumHOW.set_composalizer(-> $type, $name, %enum_values {
$r.HOW.add_method($r, $key, $meth);
}
$r.HOW.set_body_block($r,
- -> |$c { nqp::list($r, nqp::hash('$?CLASS', $c<$?CLASS>)) });
+ -> |c { nqp::list($r, nqp::hash('$?CLASS', c<$?CLASS>)) });
$r.HOW.compose($r);
$r
});
View
@@ -16,27 +16,27 @@ my class Hash {
-> { nqp::bindkey($storage, nqp::unbox_s($key), $v) } )
}
- method bind_key($key, \$bindval) is rw {
+ method bind_key($key, \bindval) is rw {
nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ||
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
nqp::bindkey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key.Str),
- $bindval)
+ bindval)
}
- multi method perl(Hash:D \$self:) {
- nqp::iscont($self)
+ multi method perl(Hash:D \SELF:) {
+ nqp::iscont(SELF)
?? '{' ~ self.pairs.map({.perl}).join(', ') ~ '}'
!! '(' ~ self.pairs.map({.perl}).join(', ') ~ ').hash'
}
- method STORE_AT_KEY(\$key, Mu $x is copy) is rw {
- nqp::findmethod(EnumMap, 'STORE_AT_KEY')(self, $key, $x);
+ method STORE_AT_KEY(\key, Mu $x is copy) is rw {
+ nqp::findmethod(EnumMap, 'STORE_AT_KEY')(self, key, $x);
}
- method STORE(\$to_store) is hidden_from_backtrace {
- my $items = ($to_store,).flat.eager;
+ method STORE(\to_store) is hidden_from_backtrace {
+ my $items = (to_store,).flat.eager;
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
while $items {
my Mu $x := $items.shift;
@@ -110,22 +110,22 @@ my class Hash {
!! pir::setattribute__0PPsP($v, Scalar, '$!whence',
-> { nqp::findmethod(EnumMap, 'STORE_AT_KEY')(self, $key, $v) } )
}
- method STORE_AT_KEY(Str \$key, TValue $x is copy) is rw {
- nqp::findmethod(EnumMap, 'STORE_AT_KEY')(self, $key, $x);
+ method STORE_AT_KEY(Str \key, TValue $x is copy) is rw {
+ nqp::findmethod(EnumMap, 'STORE_AT_KEY')(self, key, $x);
}
- method bind_key($key, TValue \$bindval) is rw {
+ method bind_key($key, TValue \bindval) is rw {
nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ||
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
nqp::bindkey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key.Str),
- $bindval)
+ bindval)
}
}
my role TypedHash[::TValue, ::TKey] does Associative[TValue] {
has $!keys;
- method at_key(TKey \$key, TValue $v? is copy) is rw {
- my $key_which = $key.WHICH;
+ method at_key(TKey \key, TValue $v? is copy) is rw {
+ my $key_which = key.WHICH;
self.exists($key_which)
?? nqp::findmethod(EnumMap, 'at_key')(self, $key_which)
!! pir::setattribute__0PPsP($v, Scalar, '$!whence',
@@ -137,42 +137,42 @@ my class Hash {
nqp::bindkey(
nqp::getattr(self, $?CLASS, '$!keys'),
nqp::unbox_s($key_which),
- $key);
+ key);
nqp::bindkey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key_which),
$v);
})
}
- method STORE_AT_KEY(TKey \$key, TValue $x is copy) is rw {
- my $key_which = $key.WHICH;
+ method STORE_AT_KEY(TKey \key, TValue $x is copy) is rw {
+ my $key_which = key.WHICH;
nqp::defined(nqp::getattr(self, $?CLASS, '$!keys')) ||
nqp::bindattr(self, $?CLASS, '$!keys', nqp::hash());
nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ||
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
nqp::bindkey(
nqp::getattr(self, $?CLASS, '$!keys'),
nqp::unbox_s($key_which),
- $key);
+ key);
nqp::bindkey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key_which),
$x);
}
- method bind_key(TKey $key, TValue \$bindval) is rw {
- my $key_which = $key.WHICH;
+ method bind_key(TKey \key, TValue \bindval) is rw {
+ my $key_which = key.WHICH;
nqp::defined(nqp::getattr(self, $?CLASS, '$!keys')) ||
nqp::bindattr(self, $?CLASS, '$!keys', nqp::hash());
nqp::defined(nqp::getattr(self, EnumMap, '$!storage')) ||
nqp::bindattr(self, EnumMap, '$!storage', nqp::hash());
nqp::bindkey(
nqp::getattr(self, $?CLASS, '$!keys'),
nqp::unbox_s($key_which),
- $key);
+ key);
nqp::bindkey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key_which),
- $bindval)
+ bindval)
}
method pairs() {
return unless nqp::defined(nqp::getattr(self, EnumMap, '$!storage'));
@@ -189,9 +189,9 @@ my class Hash {
}
}
}
- method PARAMETERIZE_TYPE(Mu $t, |$c) {
- $c.elems ??
- self but TypedHash[$t.WHAT, $c[0]] !!
+ method PARAMETERIZE_TYPE(Mu $t, |c) {
+ c.elems ??
+ self but TypedHash[$t.WHAT, c[0]] !!
self but TypedHash[$t.WHAT]
}
}
View
@@ -16,24 +16,24 @@ class LoL {
-> { nqp::findmethod(List, 'STORE_AT_POS')(self, $pos, $v) } )
}
- multi method perl(LoL:D \$self:) {
+ multi method perl(LoL:D \SELF:) {
self.WHAT.perl ~ '.new(' ~ self.map({.perl}).join(', ') ~ ')'
- ~ ('.item' if nqp::iscont($self));
+ ~ ('.item' if nqp::iscont(SELF));
}
- method REIFY(Parcel \$parcel, Mu \$nextiter) {
- my Mu $rpa := nqp::getattr($parcel, Parcel, '$!storage');
+ method REIFY(Parcel \parcel, Mu \nextiter) {
+ my Mu $rpa := nqp::getattr(parcel, Parcel, '$!storage');
my Mu $iter := nqp::iterator($rpa);
my int $i = 0;
while $iter {
nqp::bindpos($rpa, $i, my $v = nqp::shift($iter));
$i = $i + 1;
}
- nqp::findmethod(List, 'REIFY')(self, $parcel, $nextiter)
+ nqp::findmethod(List, 'REIFY')(self, parcel, nextiter)
}
- method STORE_AT_POS(\$pos, Mu $v is copy) {
- nqp::findmethod(List, 'STORE_AT_POS')(self, $pos, $v);
+ method STORE_AT_POS(\pos, Mu $v is copy) {
+ nqp::findmethod(List, 'STORE_AT_POS')(self, pos, $v);
}
}
View
@@ -2,21 +2,21 @@
my enum Order (:Increase(-1), :Same(0), :Decrease(1));
proto infix:<cmp>($, $) { * }
-multi infix:<cmp>(\$a, \$b) {
- return Order::Increase if $a === -$Inf || $b === $Inf;
- return Order::Decrease if $a === $Inf || $b === -$Inf;
- $a.Stringy cmp $b.Stringy
+multi infix:<cmp>(\a, \b) {
+ return Order::Increase if a === -$Inf || b === $Inf;
+ return Order::Decrease if a === $Inf || b === -$Inf;
+ a.Stringy cmp b.Stringy
}
-multi infix:<cmp>(Real \$a, Real \$b) { $a.Bridge cmp $b.Bridge }
-multi infix:<cmp>(Int:D \$a, Int:D \$b) {
- Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
+multi infix:<cmp>(Real \a, Real \b) { a.Bridge cmp b.Bridge }
+multi infix:<cmp>(Int:D \a, Int:D \b) {
+ Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont(a), nqp::p6decont(b))))
}
multi infix:<cmp>(int $a, int $b) {
Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))
}
-multi infix:«<=>»(Int:D \$a, Int:D \$b) {
- Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont($a), nqp::p6decont($b))))
+multi infix:«<=>»(Int:D \a, Int:D \b) {
+ Order.(nqp::p6box_i(nqp::cmp_I(nqp::p6decont(a), nqp::p6decont(b))))
}
multi infix:«<=>»(int $a, int $b) {
Order.(nqp::p6box_i(nqp::cmp_i($a, $b)))

0 comments on commit 504e994

Please sign in to comment.