Permalink
Browse files

Minor enum fixes, two new passing test files

  • Loading branch information...
1 parent 58de2de commit ea8474432b1a612368b0c93a94c9a9c13e831b33 @sorear committed Jun 6, 2011
Showing with 15 additions and 5 deletions.
  1. +2 −2 lib/CORE.setting
  2. +11 −3 src/niecza
  3. +2 −0 t/spectest.data
View
@@ -359,7 +359,7 @@ my class CommonEnum {
method pred() {
my $index = defined(self) ?? $!index !! 0;
- $!index ?? self.from-index($!index - 1) !! self;
+ $index ?? self.from-index($index - 1) !! self;
}
method from-index($ix) { self._create($ix,self.enums._index_to_value($ix)) }
@@ -906,7 +906,7 @@ my class EnumMap {
my ($k, $v);
if $p ~~ Pair {
$k ::= $p.key;
- $v ::= $v.value;
+ $v ::= $p.value;
} else {
$k ::= $p;
$v ::= $last.succ;
View
@@ -125,8 +125,16 @@ method trivial_eval($/, $ast) {
$ast.text;
} elsif $ast.^isa(::Op::Paren) {
self.trivial_eval($/, $ast.inside);
+ } elsif $ast.^isa(::Op::StatementList) {
+ my @l = @( $ast.children ); pop @l;
+ self.trivial_eval($/, $_) for @l;
+ $ast.children ?? self.trivial_eval($/, $ast.children[*-1]) !! Nil;
+ } elsif $ast.^isa(::Op::Num) && $ast.value !~~ Array {
+ $ast.value.Num
+ } elsif $ast.^isa(::Op::Num) && $ast.value ~~ Array && $ast.value[0] == 10 {
+ (+$ast.value[1]).Int # well not quite
} else {
- $/.CURSOR.sorry("Compile time expression is insufficiently trivial");
+ $/.CURSOR.sorry("Compile time expression is insufficiently trivial {$ast.WHAT.perl}");
"XXX"
}
}
@@ -184,7 +192,7 @@ method type_declarator:constant ($/) {
if $*MULTINESS {
$/.CURSOR.sorry("Multi variables NYI");
}
- my $scope = $*SCOPE // 'my';
+ my $scope = $*SCOPE || 'our';
my $slot = ~($<identifier> // $<variable> // self.gensym);
make ::Op::ConstantDecl.new(|node($/), name => $slot,
@@ -230,7 +238,7 @@ method type_declarator:enum ($/) {
my $basetype = $*OFTYPE ?? self.simple_longname($*OFTYPE<longname>) !!
[ 'MY', $has_strs ?? 'Str' !! 'Int' ];
- if $<name> && $<name>.reduced eq 'longname' && ($scope ||= 'my') ne 'anon' {
+ if $<name> && $<name>.reduced eq 'longname'&& ($scope ||= 'our') ne 'anon' {
# Longnamed enum is a kind of type definition
my $ourpath = Array;
View
@@ -90,6 +90,8 @@ S12-class/extending-arrays.t
S12-class/inheritance-class-methods.t
S12-class/lexical.t
S12-class/stubs.t
+S12-enums/anonymous.t
+S12-enums/basic.t
S12-methods/calling_syntax.t
S12-methods/chaining.t
S12-methods/class-and-instance.t

0 comments on commit ea84744

Please sign in to comment.