Permalink
Browse files

[CORE,Stash] catch up with recent name changes

[STD] add anon, sink


git-svn-id: http://svn.pugscode.org/pugs@29177 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 72eddc2 commit 379e2c068870ab1225a7120681db0808f3905f96 lwall committed Nov 23, 2009
Showing with 47 additions and 34 deletions.
  1. +6 −6 CORE.pad
  2. +13 −6 CORE.setting
  3. +5 −5 Cursor.pmc
  4. +1 −1 Makefile
  5. +2 −2 NULL.pad
  6. +17 −12 STD.pm
  7. +1 −1 STASH.pmc → Stash.pmc
  8. +0 −1 lib/STASH.pm
  9. +1 −0 lib/Stash.pm
  10. +1 −0 lib/Test.pm
View
@@ -1,28 +1,28 @@
my $id = 'MY:file<CORE.pad>:line(1):pos(0)';
use strict;
-use STASH;
+use Stash;
use NAME;
my $file = { name => 'CORE.pad' };
-my $core = STASH::->new( _file => $file, _line => __LINE__,
+my $core = Stash::->new( _file => $file, _line => __LINE__,
'!id' => [$id],
Bool => NAME::->new( name => 'Bool', file => $file, line => __LINE__ ),
- 'Bool::' => STASH::->new( _file => $file, _line => __LINE__,
+ 'Bool::' => Stash::->new( _file => $file, _line => __LINE__,
True => NAME::->new( name => 'True', file => $file, line => __LINE__ ),
False => NAME::->new( name => 'False', file => $file, line => __LINE__ ),
),
Num => NAME::->new( name => 'Num', file => $file, line => __LINE__),
- 'Num::' => STASH::->new( _file => $file, _line => __LINE__,
+ 'Num::' => Stash::->new( _file => $file, _line => __LINE__,
pi => NAME::->new( name => 'pi', value => atan2(1,1)*4, file => $file, line => __LINE__ ),
e => NAME::->new( name => 'e', value => exp(1), file => $file, line => __LINE__ ),
),
Order => NAME::->new( name => 'Order', file => $file, line => __LINE__),
- 'Order::' => STASH::->new( _file => $file, _line => __LINE__,
+ 'Order::' => Stash::->new( _file => $file, _line => __LINE__,
Increase => NAME::->new( name => 'Increase', file => $file, line => __LINE__ ),
Same => NAME::->new( name => 'Same', file => $file, line => __LINE__ ),
Decrease => NAME::->new( name => 'Decrease', file => $file, line => __LINE__ ),
),
DEBUG => NAME::->new( name => 'DEBUG', file => $file, line => __LINE__),
- 'DEBUG::' => STASH::->new( _file => $file, _line => __LINE__,
+ 'DEBUG::' => Stash::->new( _file => $file, _line => __LINE__,
EXPR => NAME::->new( name => 'Increase', file => $file, line => __LINE__, export => 'DEFAULT' ),
trace_call => NAME::->new( name => 'Increase', file => $file, line => __LINE__, export => 'DEFAULT' ),
),
View
@@ -6,6 +6,13 @@ my enum Bool <False True>;
my enum Order < Increase Same Decrease >;
+my role Stash { }
+my role Role does Stash { }
+my role Package does Stash { }
+my role Module does Stash { }
+my role Class does Module { }
+my role Grammar does Class { }
+
my class P6opaque { }
my class Object { }
my class Any { }
@@ -21,11 +28,6 @@ my class Signature { }
my class Parameter { }
my class Proxy { }
my class Matcher { }
-my class Package { }
-my class Module { }
-my class Class { }
-my class Role { }
-my class Grammar { }
my class Scalar { }
my class Array { }
my class Hash { }
@@ -39,7 +41,7 @@ my class Range { }
my class Set { }
my class Bag { }
my class Mapping { }
-my class Void { }
+my class Sink { }
my class Undef { }
my class Failure { }
my class Exception { }
@@ -53,6 +55,7 @@ my class Submethod { }
my class Regex { }
my class Multi { }
+my role Stringy { }
my class Str { }
my class Cat { }
my class Blob { }
@@ -66,7 +69,9 @@ my class StrPos { }
my class StrLen { }
my class Version { }
+my role Numeric { }
my class Num {
+ # XXX, would these generate FatRats, and is that bad?
constant pi is export = 3.14159_26535_89793_23846_26433_83279_50288;
constant e is export = 2.71828_18284_59045_23536_02874_71352_66249;
constant i is export = 1i;
@@ -88,6 +93,7 @@ my class complex32 { }
my class complex64 { }
my class complex128 { }
+my role Integral { }
my class Int { }
my class int { }
@@ -99,6 +105,7 @@ my class int16 { }
my class int32 { }
my class int64 { }
+my role Rational { }
my class Rat { }
my class rat { }
my class rat8 { }
View
@@ -4,7 +4,7 @@ use warnings;
no warnings 'recursion';
use utf8;
use NAME;
-use STASH;
+use Stash;
my $TRIE = 1;
my $STORABLE = 1;
@@ -220,10 +220,10 @@ sub load_pad {
my $setting = shift;
my $file = "$setting.syml";
if (-e $file) {
- bless($self->load_yaml_pad($setting),'STASH');
+ bless($self->load_yaml_pad($setting),'Stash');
}
else {
- bless($self->load_perl_pad($setting),'STASH');
+ bless($self->load_perl_pad($setting),'Stash');
}
}
@@ -2402,8 +2402,8 @@ sub set_export {
my $xpad = $STD::ALL->{ (delete $::DECLARAND->{xpad})->[0] };
$::DECLARAND->{export} = $text;
my $sid = $::CURPAD->idref;
- my $x = $xpad->{'EXPORT::'} //= STASH::->new( 'PARENT::' => $sid, '!id' => [$sid->[0] . '::EXPORT'] );
- $x->{$textpkg} //= STASH::->new( 'PARENT::' => $x->idref, '!id' => [$sid->[0] . '::EXPORT::' . $text] );
+ my $x = $xpad->{'EXPORT::'} //= Stash::->new( 'PARENT::' => $sid, '!id' => [$sid->[0] . '::EXPORT'] );
+ $x->{$textpkg} //= Stash::->new( 'PARENT::' => $x->idref, '!id' => [$sid->[0] . '::EXPORT::' . $text] );
$x->{$textpkg}->{$name} = $::DECLARAND;
$x->{$textpkg}->{'&'.$name} = $::DECLARAND
if $name =~ /^\w/ and $::IN_DECL ne 'constant';
View
@@ -1,7 +1,7 @@
.PHONY: check try cat clean distclean purge test
FIXINS=Cursor.pmc LazyMap.pm lib/DEBUG.pm DEBUG.pmc lib/Test.pm CORE.setting NULL.pad \
-std mangle.pl CORE.pad lib/NAME.pm NAME.pmc lib/STASH.pm STASH.pmc sprixel.pl ToJS.pm \
+std mangle.pl CORE.pad lib/NAME.pm NAME.pmc lib/Stash.pm Stash.pmc sprixel.pl ToJS.pm \
viv sprixelCORE.setting
all: $(FIXINS) check lex/STD/termish
View
@@ -1,8 +1,8 @@
use 5.010;
use strict;
-use STASH;
+use Stash;
my $id = "MY:file<NULL.pad>:line(1):pos(0)";
-my $core = STASH::->new(
+my $core = Stash::->new(
'!id' => [$id],
'!file' => 'NULL.pad', '!line' => __LINE__ ,
);
View
@@ -2,7 +2,7 @@ grammar STD:ver<6.0.0.alpha>:auth<http://perl.org>;
use DEBUG;
use NAME;
-use STASH;
+use Stash;
our $ALL;
@@ -1255,7 +1255,7 @@ grammar P6 is STD {
self.load_setting($*SETTINGNAME);
my $oid = $*SETTING.id;
my $id = 'MY:file<' ~ $*FILE<name> ~ '>';
- $*CURPAD = STASH.new(
+ $*CURPAD = Stash.new(
'OUTER::' => [$oid],
'!file' => $*FILE, '!line' => 0,
'!id' => [$id],
@@ -1750,6 +1750,7 @@ grammar P6 is STD {
token scope_declarator:my { <sym> <scoped('my')> }
token scope_declarator:our { <sym> <scoped('our')> }
+ token scope_declarator:anon { <sym> <scoped('anon')> }
token scope_declarator:state { <sym> <scoped('state')> }
token scope_declarator:has { <sym> <scoped('has')> }
token scope_declarator:augment { <sym> <scoped('augment')> }
@@ -2988,6 +2989,7 @@ grammar P6 is STD {
'=' <EXPR(item %item_assignment)>
}
+ token statement_prefix:sink { <sym> <blast> }
token statement_prefix:try { <sym> <blast> }
token statement_prefix:quietly { <sym> <blast> }
token statement_prefix:gather { <sym> <blast> }
@@ -4811,7 +4813,7 @@ grammar Regex is STD {
token mod_arg { :dba('modifier argument') '(' ~ ')' [:lang($¢.cursor_fresh(%*LANG<MAIN>)) <semilist> ] }
- token mod_internal:sym<:my> { ':' <?before ['my'|'state'|'our'|'constant'|'temp'|'let'] \s > [:lang($¢.cursor_fresh(%*LANG<MAIN>)) <statement> <eat_terminator> ] }
+ token mod_internal:sym<:my> { ':' <?before ['my'|'state'|'our'|'anon'|'constant'|'temp'|'let'] \s > [:lang($¢.cursor_fresh(%*LANG<MAIN>)) <statement> <eat_terminator> ] }
# XXX needs some generalization
@@ -4892,7 +4894,7 @@ method newpad ($needsig = 0) {
}
else {
$id = 'MY:file<' ~ $*FILE<name> ~ '>:line(' ~ $line ~ '):pos(' ~ self.pos ~ ')';
- $*CURPAD = STASH.new(
+ $*CURPAD = Stash.new(
'OUTER::' => [$oid],
'!file' => $*FILE, '!line' => $line,
'!id' => [$id],
@@ -5054,6 +5056,7 @@ method find_top_pkg ($name) {
method add_name ($name) {
my $scope = $*SCOPE || 'my';
+ return self if $scope eq 'anon';
say "Adding $scope $name" if $*DEBUG +& DEBUG::symtab;
if $scope eq 'augment' or $scope eq 'supersede' {
self.is_name($name) or self.worry("Can't $scope something that doesn't exist");
@@ -5079,7 +5082,7 @@ method add_my_name ($n, $d, $p) {
while @components > 1 {
my $pkg = shift @components;
$sid ~= "::$pkg";
- my $newstash = $curstash.{$pkg} //= STASH.new(
+ my $newstash = $curstash.{$pkg} //= Stash.new(
'PARENT::' => $curstash.idref,
'!stub' => 1,
'!id' => [$sid] );
@@ -5145,7 +5148,7 @@ method add_my_name ($n, $d, $p) {
if !$*DECLARAND<const> and $name ~~ /^\w+$/ {
$curstash.{"&$name"} //= $curstash.{$name};
$sid ~= "::$name";
- $*NEWPAD = $curstash.{$name ~ '::'} //= ($p // STASH.new(
+ $*NEWPAD = $curstash.{$name ~ '::'} //= ($p // Stash.new(
'PARENT::' => $curstash.idref,
'!file' => $*FILE, '!line' => self.line,
'!id' => [$sid] ));
@@ -5174,7 +5177,7 @@ method add_our_name ($n) {
while @components > 1 {
my $pkg = shift @components;
$sid ~= "::$pkg";
- my $newstash = $curstash.{$pkg} //= STASH.new(
+ my $newstash = $curstash.{$pkg} //= Stash.new(
'PARENT::' => $curstash.idref,
'!stub' => 1,
'!id' => [$sid] );
@@ -5229,7 +5232,7 @@ method add_our_name ($n) {
if $name ~~ /^\w+$/ and $*IN_DECL ne 'constant' {
$curstash.{"&$name"} //= $declaring;
$sid ~= "::$name";
- $*NEWPAD = $curstash.{$name ~ '::'} //= STASH.new(
+ $*NEWPAD = $curstash.{$name ~ '::'} //= Stash.new(
'PARENT::' => $curstash.idref,
'!file' => $*FILE, '!line' => self.line,
'!id' => [$sid] );
@@ -5310,7 +5313,7 @@ method load_setting ($setting) {
$*SETTING = $ALL<SETTING>;
$*CURPAD = $*SETTING;
- $*GLOBAL = $*CORE.<GLOBAL::> = STASH.new(
+ $*GLOBAL = $*CORE.<GLOBAL::> = Stash.new(
'!file' => $*FILE, '!line' => 1,
'!id' => ['GLOBAL'],
);
@@ -5389,7 +5392,9 @@ method add_routine ($name) {
}
method add_variable ($name) {
- if ($*SCOPE||'') eq 'our' {
+ my $scope = $*SCOPE || 'our';
+ return self if $scope eq 'anon';
+ if $scope eq 'our' {
self.add_our_variable($name);
}
else {
@@ -5500,9 +5505,9 @@ method lookup_compiler_var($name) {
when '$?LINE' { return self.lineof(self.pos); }
when '$?POSITION' { return self.pos; }
- when '$?LANG' { return item %*LANG; }
+ when '$?LANG' { return item %*LANG; }
- when '$?STASH' { return $*CURPAD; }
+ when '$?LEXPAD' { return $*CURPAD; }
when '$?PACKAGE' { return $*CURPKG; }
when '$?MODULE' { return $*CURPKG; } # XXX should scan
@@ -1,5 +1,5 @@
use 5.010;
-package STASH;
+package Stash;
sub new {
my $class = shift;
my %attrs = @_;
View
@@ -1 +0,0 @@
-my class STASH;
View
@@ -0,0 +1 @@
+my class Stash;
View
@@ -3,6 +3,7 @@ proto plan is export { }
proto done_testing is export { }
proto is is export { }
proto ok is export { }
+proto nok is export { }
proto dies_ok is export { }
proto lives_ok is export { }
proto skip is export { }

0 comments on commit 379e2c0

Please sign in to comment.