Skip to content

Commit

Permalink
Various tweaks and fixes to get us able to run all of the sanity test…
Browse files Browse the repository at this point in the history
…s now and pass a lot of the spectests. Now it's down to triage of what's left.
  • Loading branch information
jnthn committed Oct 8, 2009
1 parent 2c09561 commit d7f854a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/classes/Junction.pir
Expand Up @@ -132,7 +132,6 @@ Smart-matching for junctions, short-circuiting.
type = self.'!type'()
if type == JUNCTION_TYPE_NONE goto none
if type == JUNCTION_TYPE_ALL goto all

any_one:
unless it goto false
state = shift it
Expand Down
1 change: 1 addition & 0 deletions src/classes/Signature.pir
Expand Up @@ -45,6 +45,7 @@ Gets a perl representation of the signature.
# Grab low level signature we're wrapping.
.local pmc signature
signature = getattribute self, '$!ll_sig'
signature = descalarref signature

# Loop over parameters.
.local int cur_param, count
Expand Down
6 changes: 5 additions & 1 deletion src/ops/perl6.ops
Expand Up @@ -471,7 +471,11 @@ inline op set_signature_elem(in PMC, in INT, in STR, in INT, inout PMC, inout PM
struct llsig_element *element = elements[$2];
element->variable_name = $3;
element->flags = $4;
element->nominal_type = $5;
if (!PMC_IS_NULL($5))
element->nominal_type = $5;
else
element->nominal_type = Parrot_find_global_n(interp, Parrot_get_ctx_HLL_namespace(interp),
string_from_literal(interp, "Object"));
element->post_constraints = $6;
element->named_names = $7;
element->type_captures = $8;
Expand Down
26 changes: 17 additions & 9 deletions src/parser/signature.pm
Expand Up @@ -117,17 +117,20 @@ method ast($high_level?) {
for @entries {
# First, compute flags.
my $flags := 0;
if $_<optional> { $flags := $flags + $SIG_ELEM_IS_OPTIONAL; }
if $_<invocant> { $flags := $flags + $SIG_ELEM_INVOCANT; }
if $_<multi_invocant> ne "0" { $flags := $flags + $SIG_ELEM_MULTI_INVOCANT; }
if $_<slurpy> && !$_<names> { $flags := $flags + $SIG_ELEM_SLURPY_POS; }
if $_<slurpy> && $_<names> { $flags := $flags + $SIG_ELEM_SLURPY_NAMED; }
if $_<read_type> eq 'rw' { $flags := $flags + $SIG_ELEM_IS_RW; }
if $_<read_type> eq 'copy' { $flags := $flags + $SIG_ELEM_IS_COPY; }
if $_<optional> { $flags := $flags + $SIG_ELEM_IS_OPTIONAL; }
if $_<invocant> { $flags := $flags + $SIG_ELEM_INVOCANT; }
if $_<multi_invocant> ne "0" { $flags := $flags + $SIG_ELEM_MULTI_INVOCANT; }
if $_<slurpy> && !+@($_<names>) { $flags := $flags + $SIG_ELEM_SLURPY_POS; }
if $_<slurpy> && +@($_<names>) { $flags := $flags + $SIG_ELEM_SLURPY_NAMED; }
if $_<read_type> eq 'rw' { $flags := $flags + $SIG_ELEM_IS_RW; }
if $_<read_type> eq 'copy' { $flags := $flags + $SIG_ELEM_IS_COPY; }

# Fix up nominal type.
my $sigil := substr($_<var_name>, 0, 1);
if $sigil eq "$" {
if $_<slurpy> {
$_<nom_type> := PAST::Var.new( :name('Object'), :scope('package') );
}
elsif $sigil eq "$" {
if !$_<nom_type> {
$_<nom_type> := PAST::Var.new(
:name(self.get_default_parameter_type()),
Expand Down Expand Up @@ -157,12 +160,17 @@ method ast($high_level?) {
}
}

# If we have only one constraint type, don't bother emitting a junction.
if $_<cons_type> && +@($_<cons_type>) == 1 {
$_<cons_type> := $_<cons_type>[0];
}

# Emit op to build signature element.
# XXX Fix nameds to handle multiple names for an argument.
$ast.push(PAST::Op.new(
:inline(' set_signature_elem signature, ' ~ $i ~ ', "' ~
$_<var_name> ~ '", ' ~ $flags ~ ', %0, %1, %2, %3'),
($_<nom_type> && !$_<slurpy> ?? $_<nom_type> !! $null_reg),
$_<nom_type>,
($_<cons_type> ?? $_<cons_type> !! $null_reg),
(+@($_<names>) && !$_<slurpy> ?? $_<names>[0] !! $null_reg),
$null_reg
Expand Down
2 changes: 1 addition & 1 deletion src/setting/traits.pm
Expand Up @@ -122,7 +122,7 @@ multi trait_mod:<does>(ContainerDeclarand $c, Object $role) {
$c.container does $role;
}

multi trait_mod:<of>(Code $block is rw where { .defined }, Object $type is rw) {
multi trait_mod:<of>(Code $block is rw, Object $type is rw) {
$block does Callable[$type];
}

Expand Down

0 comments on commit d7f854a

Please sign in to comment.