Skip to content

Commit

Permalink
Merge branch 'nom' into podparser
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadeusz Sośnierz committed Jul 7, 2011
2 parents c26b9d5 + 3279598 commit 9cd2db4
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 32 deletions.
12 changes: 1 addition & 11 deletions NOMMAP.markdown
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Roadmap for "nom" Branch

Last Updated 4 July 2011
Last Updated 7 July 2011

Note that this isn't strictly in order, though things nearer to the top
are likely to get focus sooner.

Current fails that people are likely to encounter (no particular order):
* core constants (e.g., Inf, Order::Decrease)
* True constant doesn't work in setting (try "say *.ACCEPTS(1)")
* regexes missing
* is export on methods
- should work outside the setting; note here if not
* my ($a, $, $b) = 1,2,3; (S03-operators/assign.t)
* multi dispatch to .Bool seems to be borked - for example 0i.Bool does not
call the multi in Complex.

Things that aren't blockers but might be worth knowing about:
* attribute := doesn't work in CORE.setting (works outside of setting, though)
Expand All @@ -30,9 +26,6 @@ Things that aren't blockers but might be worth knowing about:
## Lexical Multi-Part names
For my X::Base { ... }, my Foo::Bar { ... } etc. The our-scoped ones work.

## Object construction
Defaults should only be used if attribute never accessed.

## Magicals
Methods should get automatic %_.

Expand All @@ -44,9 +37,6 @@ While much binding works again now, there's some stuff to "put back":
* |$c
* Sub-signatures

## Rat and Complex literals
Depends on working out how to unify parsing of numeric strings.

## Fix up binding some more
Get ::= correcter, and a bit more stuff on := also.

Expand Down
8 changes: 5 additions & 3 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ INIT {
p6parcel => 'perl6_parcel_from_rpa__PPP',
p6listiter => 'perl6_iter_from_rpa__PPP',
p6list => 'perl6_list_from_rpa__PPPP',
attrinited => 'repr_is_attr_initialized__IPPs',

istype => 'type_check__IPP',
lcm_i => 'lcm__Iii',
Expand Down Expand Up @@ -1021,9 +1022,10 @@ class Perl6::Actions is HLL::Actions {
$_<twigil>, $_<desigilname>, []));
}
else {
$list.push(PAST::Op.new(
:pirop('repr_instance_of PP'),
$*ST.symbol_lookup([sigiltype($_<sigil> || '$')], $/)));
$list.push($*ST.build_container_past(
sigiltype($_<sigil> || '$'),
$*ST.create_container_descriptor(
$*ST.find_symbol(['Mu']), 1, 'anon')));
}
}
make $list;
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Code.HOW.add_method(Code, 'add_dispatchee', sub ($self, $dispatchee) {
my $disp_list := pir::getattribute__PPPsP($self, Code, '$!dispatchees');
if pir::defined($disp_list) {
$disp_list.push($dispatchee);
pir::setattribute__0PPsP($self, Code, '$!dispatcher_cache', pir::null__P());
}
else {
pir::die("Cannot add a dispatchee to a non-dispatcher code object");
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Metamodel/ClassHOW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Perl6::Metamodel::ClassHOW
method isa($obj, $type) {
my $decont := pir::nqp_decontainerize__PP($type);
for self.mro($obj) {
if $_ =:= $decont { return 1 }
if pir::nqp_decontainerize__PP($_) =:= $decont { return 1 }
}
0
}
Expand Down
23 changes: 18 additions & 5 deletions src/binder/sixmodelobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ typedef struct {
* attributes, as well as how it boxes/unboxes to the three primitive types
* INTVAL, FLOATVAL and STRING * (if it can).
*
* All representations will either use this struct directly or have it as
* the first element in their own struct followed by any data they want to
* keep for representation instance. Essentially, it defines the set of
* functions that a representation should implement to fulfil the
* representation API. */
* This struct defines the set of operations that a representation
* should implement to fulfil the representation API. Note that a
* representation may also store some per-type data in the repr_data
* slot of the s-table. That aside, representations are singletons,
* and code being compiled with a known representation could even
* inline the lookups. */
typedef struct {
/* Creates a new type object of this representation, and
* associates it with the given HOW. Also sets up a new
Expand Down Expand Up @@ -194,6 +195,18 @@ typedef struct {

/* Gets the storage specification for this representation. */
storage_spec (*get_storage_spec) (PARROT_INTERP, STable *st);

/* Checks if an attribute has been initialized. */
INTVAL (*is_attribute_initialized) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name, INTVAL Hint);

/* Handles an object changing its type. The representation is responsible
* for doing any changes to the underlying data structure, and may reject
* changes that it's not willing to do (for example, a representation may
* choose to only handle switching to a subclass). It is also left to update
* the S-Table pointer as needed; while in theory this could be factored
* out, the representation probably knows more about timing issues and
* thread safety requirements. */
void (*change_type) (PARROT_INTERP, PMC *Object, PMC *NewType);
} REPRCommonalities;

/* Hint value to indicate the absence of an attribute lookup or method
Expand Down
6 changes: 6 additions & 0 deletions src/core/Any.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ my class Any {
method hash() { my %h = self }
method list() { nqp::p6list(nqp::list(self), List, Mu) }
method pick($n = 1) { self.list.pick($n) }
method roll($n = 1) { self.list.roll($n) }
method reverse() { self.list.reverse }
method sort($by = &infix:<cmp>) { self.list.sort($by) }

Expand Down Expand Up @@ -142,6 +143,11 @@ multi map(&code, *@values) { @values.map(&code) }
proto grep(|$) {*}
multi grep(Mu $test, *@values) { @values.grep($test) }

proto join(|$) { * }
multi join($sep = '', *@values) { @values.join($sep) }

proto pick(|$) { * }
multi pick($n, *@values) { @values.pick($n) }

proto roll(|$) { * }
multi roll($n, *@values) { @values.roll($n) }
11 changes: 11 additions & 0 deletions src/core/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ class List does Positional {
self.STORE_AT_POS($pos++, @values.shift) while @values;
}

method roll($n is copy = 1) {
my $elems = self.elems;
fail ".roll from infinite list NYI" if $!nextiter.defined;
$n = +$Inf if nqp::istype($n, Whatever);
return self.at_pos($elems.rand.floor) if $n == 1;
gather while $n > 0 {
take nqp::atpos($!items, nqp::unbox_i($elems.rand.floor.Int));
$n--;
}
}

method reverse() {
self.gimme(*);
fail 'Cannot reverse and infinite list' if self.infinite;
Expand Down
12 changes: 8 additions & 4 deletions src/core/Mu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ my class Mu {
}
}
elsif nqp::iseq_i(nqp::atpos($task, 0), 2) {
# XXX Need check if slot has already been initialized
# or not.
my $attr := nqp::getattr(self, nqp::atpos($task, 1), nqp::atpos($task, 2));
$attr = nqp::atpos($task, 3)(self, $attr);
unless nqp::attrinited(self, nqp::atpos($task, 1), nqp::atpos($task, 2)) {
my $attr := nqp::getattr(self, nqp::atpos($task, 1), nqp::atpos($task, 2));
$attr = nqp::atpos($task, 3)(self, $attr);
}
}
else {
die "Invalid BUILDPLAN";
Expand Down Expand Up @@ -200,6 +200,10 @@ multi sub infix:<~~>(Mu \$topic, Mu \$matcher) {
$matcher.ACCEPTS($topic).Bool;
}

sub infix:<=:=>(Mu \$x, Mu \$y) {
nqp::p6bool(nqp::iseq_i(nqp::where($x), nqp::where($y)));
}


sub DUMP(|$) {
my Mu $args := pir::perl6_current_args_rpa__P();
Expand Down
3 changes: 2 additions & 1 deletion src/core/Parcel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ my class Parcel does Positional {

multi method Str(Parcel:D:) { self.flat.Str }
method Numeric() { self.flat.elems }
method Capture() { self } # XXX CHEAT CHEAT CHEAT

method flat() {
nqp::p6list(nqp::clone($!storage), List, Bool::True)
Expand All @@ -22,7 +23,7 @@ my class Parcel does Positional {

method at_pos(Parcel:D: \$x) { self.flat.at_pos($x); }

multi method postcircumfix:<[ ]>(Parcel:D: \$x) { self.flat.[$x] }
method postcircumfix:<[ ]>(Parcel:D: \$x) { self.flat.[$x] }

multi method gist(Parcel:D:) {
my Mu $gist := nqp::list();
Expand Down
2 changes: 1 addition & 1 deletion src/core/Range.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Range is Iterable does Positional {
unless count > 0 goto done
$I0 = cmp value, max
unless $I0 < cmpstop goto done
$P0 = perl6_box_num value
$P0 = perl6_box_bigint value
push rpa, $P0
inc value
dec count
Expand Down
22 changes: 22 additions & 0 deletions src/ops/perl6.ops
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,28 @@ inline op perl6_box_num(out PMC, in NUM) :base_core {
}


/*

=item perl6_box_bigint(out PMC, in NUM)

Return a Perl 6 Int if $2 will fit, otherwise return a Perl 6 Num.

=cut

*/
inline op perl6_box_bigint(out PMC, in NUM) :base_core {
if ((INTVAL)$2 == $2) {
PMC *type = Rakudo_types_int_get();
$1 = REPR(type)->instance_of(interp, type);
REPR($1)->set_int(interp, $1, $2);
}
else {
PMC *type = Rakudo_types_num_get();
$1 = REPR(type)->instance_of(interp, type);
REPR($1)->set_num(interp, $1, $2);
}
}

/*

=item perl6ize_type(out PMC, in PMC)
Expand Down
10 changes: 5 additions & 5 deletions t/spectest.data
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

S02-builtin_data_types/anon_block.t
S02-builtin_data_types/array_extending.t
# S02-builtin_data_types/array_ref.t
S02-builtin_data_types/array_ref.t
S02-builtin_data_types/array.t
# S02-builtin_data_types/assigning-refs.t
# S02-builtin_data_types/autovivification.t
Expand All @@ -46,7 +46,7 @@ S02-builtin_data_types/num.t
# S02-builtin_data_types/pair.t # pair := bindings
S02-builtin_data_types/parcel.t
S02-builtin_data_types/parsing-bool.t
# S02-builtin_data_types/range.t
S02-builtin_data_types/range.t
# S02-builtin_data_types/set.t
S02-builtin_data_types/sigils-and-types.t
S02-builtin_data_types/subscripts_and_context.t
Expand Down Expand Up @@ -486,7 +486,7 @@ S32-array/shift.t
# S32-array/unshift.t
# S32-basics/warn.t
# S32-container/zip.t
# S32-hash/exists.t # needs hash() composer
S32-hash/exists.t
# S32-hash/delete.t
# S32-hash/invert.t
# S32-hash/keys_values.t
Expand All @@ -507,7 +507,7 @@ S32-list/create.t
# S32-list/map_function_return_values.t
# S32-list/map.t
# S32-list/minmax.t
# S32-list/pick.t
# S32-list/pick.t # needs junctions
# S32-list/reduce.t
# S32-list/reverse.t
# S32-list/roll.t
Expand Down Expand Up @@ -593,7 +593,7 @@ S32-trig/simple.t
# integration/advent2009-day01.t
# integration/advent2009-day02.t
# integration/advent2009-day03.t
# integration/advent2009-day04.t
integration/advent2009-day04.t
# integration/advent2009-day05.t
# integration/advent2009-day06.t
# integration/advent2009-day07.t
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2011.06-21-g26dd00c
2011.06-33-g5c9cd12

0 comments on commit 9cd2db4

Please sign in to comment.