Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
start to make enums less int centric
  • Loading branch information
moritz committed May 11, 2012
1 parent 6a660de commit 417d760
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Perl6/Actions.pm
Expand Up @@ -2308,23 +2308,22 @@ class Perl6::Actions is HLL::Actions {
# for each of the keys, unless they have them supplied.
# XXX Should not assume integers, and should use lexically
# scoped &postfix:<++> or so.
my $cur_value := 0;
my $cur_value := nqp::box_i(-1, $*W.find_symbol(['Int']));
for @values {
# If it's a pair, take that as the value; also find
# key.
my $cur_key;
if $_.returns() eq 'Pair' {
$cur_key := $_[1]<compile_time_value>;
if $_[2]<has_compile_time_value> {
$cur_value := nqp::unbox_i($_[2]<compile_time_value>);
$cur_value := $_[2]<compile_time_value>;
}
else {
my $ok;
try {
$cur_value := nqp::unbox_i(
Perl6::ConstantFolder.fold(
$_[2], $*W.cur_lexpad(), $*W
)<compile_time_value>);
$cur_value := Perl6::ConstantFolder.fold(
$_[2], $*W.cur_lexpad(), $*W
)<compile_time_value>;
$ok := 1;
}
unless $ok {
Expand All @@ -2334,6 +2333,7 @@ class Perl6::Actions is HLL::Actions {
}
else {
$cur_key := $_<compile_time_value>;
$cur_value := $cur_value.succ();
}

# Create and install value.
Expand All @@ -2345,9 +2345,6 @@ class Perl6::Actions is HLL::Actions {
if $*SCOPE eq '' || $*SCOPE eq 'our' {
$*W.install_package_symbol($*PACKAGE, nqp::unbox_s($cur_key), $val_obj);
}

# Increment for next value.
$cur_value := $cur_value + 1;
}

# We evaluate to the enum type object.
Expand Down

0 comments on commit 417d760

Please sign in to comment.