Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Cursor.pmc] fake up a YOU_ARE_HERE for .pm files to dump .yml

[Cursor.pmc] don't add & names for enums or exported constants
[Cursor.pmc] .yml doesn't include its setting, and hides GLOBAL as UNIT::GLOBALish
[DEBUG.pm] typo
[CORE.setting] change some classes to roles and subsets now that those work
[CORE.setting] fake up DEBUG module as enum for now
[STD.pm] fix SETTING and UNIT semantics
[STD.pm] don't add & names in constant context
[STD.pm] reconstruct CORE and GLOBAL correctly from SETTING that maybe isn't CORE
[STD.pm] don't localize $*CORE, $*GLOBAL, and $*UNIT since they're used outside .parsefile
[STD.pm] don't create new pad for role's signature before you know there is one
[Makefile] don't fail snapshot on unimportant transients


git-svn-id: http://svn.pugscode.org/pugs@27272 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 6ebf958bd35ffa5b028858770b84b28d2bc05447 1 parent ab3b9d8
lwall authored
Showing with 61 additions and 36 deletions.
  1. +28 −18 CORE.setting
  2. +12 −3 Cursor.pmc
  3. +1 −1  DEBUG.pm
  4. +2 −2 Makefile
  5. +18 −12 STD.pm
View
46 CORE.setting
@@ -112,7 +112,7 @@ my class uint16 { }
my class uint32 { }
my class uint64 { }
-my class Buf { }
+my role Buf { }
my class buf { }
my class buf1 { }
my class buf2 { }
@@ -130,18 +130,17 @@ my class Bit { }
my class bit { }
my class bool { }
-my class Increasing { }
-my class Decreasing { }
-my class Ordered { }
-my class Callable { }
-my class Positional { }
-my class Associative { }
-my class Abstraction { }
-my class Integral { }
-my class Ordering { }
-my class KeyExtractor { }
-my class Comparator { }
-my class OrderingPair { }
+my role Ordered { }
+my role Callable { }
+my role Positional { }
+my role Associative { }
+my role Abstraction { }
+my role Integral { }
+
+my subset Comparator of Code where { .signature === :(Any, Any --> Int ) };
+my subset KeyExtractor of Code where { .signature === :(Any --> Any) };
+my subset OrderingPair of Pair where { .left ~~ KeyExtractor && .right ~~ Comparator };
+my subset Ordering of Object where Signature | KeyExtractor | Comparator | OrderingPair | Whatever;
my class Instant { }
my class Duration { }
@@ -367,10 +366,21 @@ class Test {
proto version_lt is export { }
}
-# XXX constants don't work yet
-module DEBUG {
- class EXPR {}
- class trace_call {}
-}
+enum DEBUG <
+ :autolexer(1)
+ :lexer(2)
+ :fixed_length(4)
+ :fates(8)
+ :longest_token_pattern_generation(16)
+ :EXPR(32)
+ :matchers(64)
+ :trace_call(128)
+ :cursors(256)
+ :try_processing(1024)
+ :mixins(2048)
+ :callm_show_subnames(16384)
+ :use_color(32768)
+>;
+
YOU_ARE_HERE;
View
15 Cursor.pmc
@@ -192,6 +192,10 @@ sub parsefile {
if ($::YOU_WERE_HERE) {
$result->you_were_here;
}
+ elsif ($file =~ /\.pm$/) {
+ $::YOU_WERE_HERE = $::UNIT;
+ $result->you_were_here;
+ }
$result;
}
@@ -262,7 +266,7 @@ sub gettrait {
my $name = $::DECLARING->{name};
$::CURPKG->{EXPORT}{stash}{$text}{stash}{$name} = $::DECLARING;
$::CURPKG->{EXPORT}{stash}{$text}{stash}{'&'.$name} = $::DECLARING
- if $name =~ /^\w/;
+ if $name =~ /^\w/ and $::SCOPE ne 'constant';
$text;
}
elsif (defined $text) {
@@ -282,8 +286,12 @@ sub you_are_here {
sub you_were_here {
my $self = shift;
my $file = $::COMPILING::FILE->{name};
- $file =~ s/\.setting$/.yml/ or die "Can't dump setting for non-setting file";
- delete $::YOU_WERE_HERE->{OUTER} if $file eq 'CORE.yml';
+ $file =~ s/\.(setting|pm)$/.yml/ or die "Can't dump setting for non-module file";
+ $::UNIT //= $::YOU_WERE_HERE;
+ $::UNIT->{SETTINGNAME} = $::UNIT->{OUTER}{longname};
+ $::UNIT->{GLOBALish} = $::GLOBAL;
+ delete $::UNIT->{OUTER};
+ delete $::UNIT->{GLOBALish}{stash}{PARENT}; # don't want to slurp in CORE
open(SETTING, ">$file") or die "Can't open new setting file $file: $!";
print SETTING Dump({ file => $COMPILING::FILE, line => $self->line, stash => $::YOU_WERE_HERE });
close SETTING;
@@ -1093,6 +1101,7 @@ sub add_enum { my $self = shift;
my $type = shift;
my $expr = shift;
return unless $expr;
+ local $::SCOPE = 'constant';
# XXX complete kludge, really need to eval EXPR
for ($expr =~ m/([a-zA-Z_]\w*)/g) {
$self->add_name($type . "::$_");
View
2  DEBUG.pm
@@ -6,7 +6,7 @@ constant fates is export = 8;
constant longest_token_pattern_generation is export = 16;
constant EXPR is export = 32;
constant matchers is export = 64;
-constant trace_callis export = 128;
+constant trace_call is export = 128;
constant cursors is export = 256;
constant try_processing is export = 1024;
constant mixins is export = 2048;
View
4 Makefile
@@ -11,8 +11,8 @@ snap: $(FIXINS) check lex/STD/termish
mkdir snap.new
svn info |grep ^Revision|cut -d' ' -f2 > snap.new/revision
cp $(FIXINS) CORE.yml tryfile STD.pmc CORE.*.store snap.new
- mv lex snap.new
- rm -rf snap.old
+ -mv lex snap.new
+ -rm -rf snap.old
-mv snap snap.old
mv snap.new snap
View
30 STD.pm
@@ -27,6 +27,7 @@ my $BORG is context;
my $MULTINESS is context = '';
my $CORE is context;
+my $SETTING is context;
my $CORESETTING is context = "CORE";
my $GLOBAL is context;
my $CURPKG is context;
@@ -198,6 +199,9 @@ method find_top_pkg ($name) {
elsif $name eq 'CORE' {
return $*CORE<stash>;
}
+ elsif $name eq 'SETTING' {
+ return $*SETTING<stash>;
+ }
elsif $name eq 'UNIT' {
return $*UNIT<stash>;
}
@@ -289,7 +293,7 @@ method add_my_name ($n, $d) {
}
else {
$*DECLARING = $curstash.{$name} = $declaring;
- if $name ~~ /^\w/ {
+ if $name ~~ /^\w/ and $*SCOPE ne 'constant' {
$curstash.{"&$name"} //= $curstash.{$name};
$curstash.{$name}<stash> //= { 'PARENT' => $curstash };
}
@@ -389,15 +393,18 @@ method add_mystery ($name,$pos) {
method load_setting ($setting) {
@PKGS = ();
- $*CORE = self.load_pad($setting);
- $*CURPAD = $*CORE<stash>;
- $*CURPAD<MY> = $*CORE unless $setting eq 'NULL.setting';
- $*GLOBAL = $*CORE<stash><GLOBAL> // {};
- $*GLOBAL<stash><CORE> = $*GLOBAL<stash><SETTING> = $*CORE;
- $*CURPAD<GLOBAL> = $*GLOBAL;
+ $*SETTING = self.load_pad($setting);
+ $*CURPAD = $*SETTING<stash>;
+ $*CORE = $*SETTING;
+ $*CORE = $*SETTING<stash><OUTER> while $*SETTING<stash><OUTER>;
+ $*GLOBAL = $*CORE<stash><GLOBAL> //= {
+ file => $COMPILING::FILE, line => 1,
+ longname => 'GLOBAL',
+ stash => {},
+ };
+ $GLOBAL<stash><$?STAB> = $GLOBAL;
$*CURPKG = $*GLOBAL<stash>;
$*CURPKG<$?STAB> = $*GLOBAL;
- $*CURPKG<PARENT> = $*CURPAD;
}
method is_known ($n, $curpad = $*CURPAD) {
@@ -977,10 +984,7 @@ rule comp_unit {
:my $REALLYADD is context<rw> = 0;
:my $MULTINESS is context = '';
- :my $CORE is context;
- :my $GLOBAL is context;
:my $CURPKG is context;
- :my $UNIT is context;
{{
%*LANG<MAIN> = ::STD ;
@@ -992,7 +996,8 @@ rule comp_unit {
@COMPILING::WORRIES = ();
self.load_setting($*CORESETTING);
- $*UNIT = self.newpad;
+ self.newpad;
+ $*UNIT = $*CURPAD;
self.finishpad(1);
}}
<statementlist>
@@ -1421,6 +1426,7 @@ rule statement_mod_loop:given {<sym> <modifier_expr> }
token def_module_name {
<longname>
[ :dba('generic role')
+ <?before '['>
<?{ ($*PKGDECL//'') eq 'role' }>
<.newpad>
'[' ~ ']' <signature>
Please sign in to comment.
Something went wrong with that request. Please try again.