Skip to content

Commit

Permalink
Fix issues with using Rats in the setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 17, 2011
1 parent ebe121d commit 30e9bc4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -4029,7 +4029,8 @@ class Perl6::Actions is HLL::Actions {
if $seen_dot {
return $*ST.add_constant('Rat', 'type_new',
$*ST.add_numeric_constant('Int', $iresult)<compile_time_value>,
$*ST.add_numeric_constant('Int', $fdivide)<compile_time_value>
$*ST.add_numeric_constant('Int', $fdivide)<compile_time_value>,
:nocache(1)
);
} else {
return $*ST.add_numeric_constant('Int', $iresult);
Expand Down
36 changes: 26 additions & 10 deletions src/Perl6/SymbolTable.pm
Expand Up @@ -1043,16 +1043,32 @@ class Perl6::SymbolTable is HLL::Compiler::SerializationContextBuilder {
}
elsif $primitive eq 'type_new' {
$constant := $type_obj.new(|@value, |%named);
$des := PAST::Op.new(
:pasttype('callmethod'), :name('new'),
$type_obj_lookup
);
$des.push(self.get_object_sc_ref_past(nqp::shift(@value)))
while @value;
for %named {
my $x := self.get_object_sc_ref_past($_.value);
$x.named($_.key);
$des.push($x);
if $type eq 'Rat' {
my $int_lookup := self.get_object_sc_ref_past(self.find_symbol(['Int']));
my $nu := nqp::unbox_i(nqp::getattr($constant, $type_obj, '$!numerator'));
my $de := nqp::unbox_i(nqp::getattr($constant, $type_obj, '$!denominator'));
$des := PAST::Op.new(
:pirop('repr_bind_attr_obj 0PPsP'),
PAST::Op.new(
:pirop('repr_bind_attr_obj 0PPsP'),
PAST::Op.new( :pirop('repr_instance_of PP'), $type_obj_lookup ),
$type_obj_lookup, '$!numerator',
PAST::Op.new( :pirop('repr_box_int PiP'), $nu, $int_lookup )),
$type_obj_lookup, '$!denominator',
PAST::Op.new( :pirop('repr_box_int PiP'), $de, $int_lookup ));
}
else {
$des := PAST::Op.new(
:pasttype('callmethod'), :name('new'),
$type_obj_lookup
);
$des.push(self.get_object_sc_ref_past(nqp::shift(@value)))
while @value;
for %named {
my $x := self.get_object_sc_ref_past($_.value);
$x.named($_.key);
$des.push($x);
}
}
}
else {
Expand Down

0 comments on commit 30e9bc4

Please sign in to comment.